Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:11

0001 // @(#)root/tmva $Id$
0002 // Author: Andreas Hoecker, Joerg Stelzer, Helge Voss
0003 
0004 /**********************************************************************************
0005  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis       *
0006  * Package: TMVA                                                                  *
0007  * Class  : Option                                                                *
0008  *                                             *
0009  *                                                                                *
0010  * Description:                                                                   *
0011  *      Variable type info                                                        *
0012  *                                                                                *
0013  * Authors (alphabetical):                                                        *
0014  *      Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland              *
0015  *      Joerg Stelzer   <Joerg.Stelzer@cern.ch>  - CERN, Switzerland              *
0016  *      Helge Voss      <Helge.Voss@cern.ch>     - MPI-K Heidelberg, Germany      *
0017  *                                                                                *
0018  * Copyright (c) 2006:                                                            *
0019  *      CERN, Switzerland                                                         *
0020  *      U. of Victoria, Canada                                                    *
0021  *      MPI-K Heidelberg, Germany                                                 *
0022  *      LAPP, Annecy, France                                                      *
0023  *                                                                                *
0024  * Redistribution and use in source and binary forms, with or without             *
0025  * modification, are permitted according to the terms listed in LICENSE           *
0026  * (http://mva.sourceforge.net/license.txt)                                       *
0027  **********************************************************************************/
0028 
0029 #ifndef ROOT_TMVA_VariableInfo
0030 #define ROOT_TMVA_VariableInfo
0031 
0032 //////////////////////////////////////////////////////////////////////////
0033 //                                                                      //
0034 // VariableInfo                                                         //
0035 //                                                                      //
0036 // Class for type info of MVA input variable                            //
0037 //                                                                      //
0038 //////////////////////////////////////////////////////////////////////////
0039 
0040 #include "Rtypes.h"
0041 #include "TString.h"
0042 #include "TMVA/Types.h"
0043 #include "TNamed.h"
0044 
0045 namespace TMVA {
0046 
0047    class VariableInfo:public TNamed {
0048 
0049    public:
0050 
0051       VariableInfo( const TString& expression, const TString& title, const TString& unit,
0052                     Int_t varCounter, char varType = 'F', void* external = nullptr,
0053                     Double_t min = 0, Double_t max = 0, Bool_t normalized=kTRUE );
0054       VariableInfo();
0055       VariableInfo( const VariableInfo& other );
0056       ~VariableInfo() {}
0057       const TString& GetExpression()       const { return fExpression; }
0058       const TString& GetInternalName()     const { return fInternalName; }
0059       const TString& GetLabel()            const { return fLabel; }
0060       const TString& GetUnit()             const { return fUnit; }
0061       char           GetVarType()          const { return fVarType; }
0062 
0063       Double_t       GetMin ()     const { return fXminNorm; }
0064       Double_t       GetMax ()     const { return fXmaxNorm; }
0065       Double_t       GetMean()     const { return fXmeanNorm; }
0066       Double_t       GetRMS ()     const { return fXrmsNorm; }
0067       Double_t       GetVariance() const { return fXvarianceNorm; }
0068 
0069       void           SetInternalName(const char *name) { fInternalName = name; }
0070 
0071       void           SetMin         ( Double_t v ) { fXminNorm     = v; }
0072       void           SetMax         ( Double_t v ) { fXmaxNorm     = v; }
0073       void           SetMean        ( Double_t v ) { fXmeanNorm    = v; }
0074       void           SetRMS         ( Double_t v ) { fXrmsNorm     = v; }
0075       void           SetExternalLink( void* p    ) { fExternalData = (char*)p; }
0076       void           SetVariance    ( Double_t v ) { fXvarianceNorm= v; }
0077       void           ResetMinMax() { fXminNorm = 1e30; fXmaxNorm = -1e30; }
0078 
0079       void           WriteToStream ( std::ostream& o ) const;
0080       void           ReadFromStream( std::istream& istr );
0081       void           ReadFromXML   ( void* varnode );
0082       void           AddToXML      ( void* varnode );
0083       void*          GetExternalLink() const { return (void*)fExternalData; }
0084 
0085       // assignment operator (does not copy external link)
0086       VariableInfo&  operator=(const TMVA::VariableInfo& rhs);
0087 
0088    private:
0089 
0090       // should not be set from outside this class
0091       void           SetExpression     ( const TString& s ) { fExpression = s; }
0092       void           SetLabel          ( const TString& s ) { fLabel = s; }
0093       void           SetUnit           ( const TString& s ) { fUnit  = s; }
0094       void           SetInternalVarName( const TString& s ) { fInternalName = s; }
0095       void           SetVarType        ( char c )           { fVarType = c; }
0096 
0097       TString  fExpression;      ///< original variable expression (can be a formula)
0098       TString  fInternalName;    ///< internal variable name (needs to be regular expression)
0099       TString  fLabel;           ///< variable label, set by "mylabel := var1 + var2", this is a shortcut
0100       //TString  fTitle;         ///<! title for axis labels in plots; set by second string in AddVariable
0101       TString  fUnit;            ///< unit for axis labels in plots; set by third string in AddVariable
0102       Char_t   fVarType;         ///< the variable type to be used internally ('F'-default or 'I')
0103       Double_t fXminNorm;        ///< minimum value for correlated/decorrelated/PCA variable
0104       Double_t fXmaxNorm;        ///< maximum value for correlated/decorrelated/PCA variable
0105       Double_t fXmeanNorm;       ///< mean value for correlated/decorrelated/PCA variable
0106       Double_t fXrmsNorm;        ///< rms value for correlated/decorrelated/PCA variable
0107       Double_t fXvarianceNorm;   ///< variance value for correlated/decorrelated/PCA variable
0108       Bool_t   fNormalized;      ///< variable gets normalized
0109       void*    fExternalData;    ///<! if the variable content is linked to an external pointer
0110       TString  fExternalDataType;///< type of external variable (int, long, double, float) - to be done JS
0111       Int_t    fVarCounter;      ///< dummy variable
0112    public:
0113 
0114        ClassDef(VariableInfo,1);
0115    };
0116 
0117 }
0118 
0119 #endif