00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef ROOT_TMVA_Reader
00032 #define ROOT_TMVA_Reader
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef ROOT_TMVA_Configurable
00044 #include "TMVA/Configurable.h"
00045 #endif
00046 #ifndef ROOT_TMVA_Types
00047 #include "TMVA/Types.h"
00048 #endif
00049 #ifndef ROOT_TMVA_DataSetInfo
00050 #include "TMVA/DataSetInfo.h"
00051 #endif
00052 #ifndef ROOT_TMVA_DataInputHandler
00053 #include "TMVA/DataInputHandler.h"
00054 #endif
00055 #ifndef ROOT_TMVA_DataSetManager
00056 #include "TMVA/DataSetManager.h"
00057 #endif
00058
00059 #include <vector>
00060 #include <map>
00061 #include <stdexcept>
00062
00063 namespace TMVA {
00064
00065 class IMethod;
00066 class MethodBase;
00067 class DataSetInfo;
00068 class MethodCuts;
00069
00070 class Reader : public Configurable {
00071
00072 public:
00073
00074
00075 Reader( const TString& theOption="", Bool_t verbose = 0 );
00076
00077
00078 Reader( std::vector<std::string>& varNames, const TString& theOption = "", Bool_t verbose = 0 );
00079 Reader( const std::string& varNames, const TString& theOption, Bool_t verbose = 0 );
00080
00081
00082 Reader( std::vector<TString>& varNames, const TString& theOption = "", Bool_t verbose = 0 );
00083 Reader( const TString& varNames, const TString& theOption, Bool_t verbose = 0 );
00084
00085 virtual ~Reader( void );
00086
00087
00088 IMethod* BookMVA( const TString& methodTag, const TString& weightfile );
00089 IMethod* BookMVA( TMVA::Types::EMVA methodType, const char* xmlstr );
00090 IMethod* FindMVA( const TString& methodTag );
00091
00092
00093 MethodCuts* FindCutsMVA( const TString& methodTag );
00094
00095
00096
00097 Double_t EvaluateMVA( const std::vector<Float_t> &, const TString& methodTag, Double_t aux = 0 );
00098 Double_t EvaluateMVA( const std::vector<Double_t>&, const TString& methodTag, Double_t aux = 0 );
00099 Double_t EvaluateMVA( MethodBase* method, Double_t aux = 0 );
00100 Double_t EvaluateMVA( const TString& methodTag, Double_t aux = 0 );
00101
00102
00103
00104 Double_t GetMVAError() const { return fMvaEventError; }
00105 Double_t GetMVAErrorLower() const { return fMvaEventError; }
00106 Double_t GetMVAErrorUpper() const { return fMvaEventErrorUpper; }
00107
00108
00109 const std::vector< Float_t >& EvaluateRegression( const TString& methodTag, Double_t aux = 0 );
00110 const std::vector< Float_t >& EvaluateRegression( MethodBase* method, Double_t aux = 0 );
00111 Float_t EvaluateRegression( UInt_t tgtNumber, const TString& methodTag, Double_t aux = 0 );
00112
00113
00114 const std::vector< Float_t >& EvaluateMulticlass( const TString& methodTag, Double_t aux = 0 );
00115 const std::vector< Float_t >& EvaluateMulticlass( MethodBase* method, Double_t aux = 0 );
00116 Float_t EvaluateMulticlass( UInt_t clsNumber, const TString& methodTag, Double_t aux = 0 );
00117
00118
00119 Double_t GetProba ( const TString& methodTag, Double_t ap_sig=0.5, Double_t mvaVal=-9999999 );
00120 Double_t GetRarity( const TString& methodTag, Double_t mvaVal=-9999999 );
00121
00122
00123 virtual const char* GetName() const { return "Reader"; }
00124 Bool_t Verbose( void ) const { return fVerbose; }
00125 void SetVerbose( Bool_t v ) { fVerbose = v; }
00126
00127 const DataSetInfo& DataInfo() const { return fDataSetInfo; }
00128 DataSetInfo& DataInfo() { return fDataSetInfo; }
00129
00130 void AddVariable( const TString& expression, Float_t* );
00131 void AddVariable( const TString& expression, Int_t* );
00132
00133 void AddSpectator( const TString& expression, Float_t* );
00134 void AddSpectator( const TString& expression, Int_t* );
00135
00136 private:
00137
00138 DataSetManager* fDataSetManager;
00139
00140
00141 TString GetMethodTypeFromFile( const TString& filename );
00142
00143
00144 IMethod* BookMVA( Types::EMVA method, const TString& weightfile );
00145
00146 DataSetInfo fDataSetInfo;
00147
00148 DataInputHandler fDataInputHandler;
00149
00150
00151 void Init( void );
00152
00153
00154 void DecodeVarNames( const std::string& varNames );
00155 void DecodeVarNames( const TString& varNames );
00156
00157 void DeclareOptions();
00158
00159 Bool_t fVerbose;
00160 Bool_t fSilent;
00161 Bool_t fColor;
00162 Bool_t fCalculateError;
00163
00164 Double_t fMvaEventError;
00165 Double_t fMvaEventErrorUpper;
00166
00167 std::map<TString, IMethod*> fMethodMap;
00168
00169 std::vector<Float_t> fTmpEvalVec;
00170
00171 mutable MsgLogger* fLogger;
00172 MsgLogger& Log() const { return *fLogger; }
00173
00174 ClassDef(Reader,0)
00175 };
00176
00177 }
00178
00179 #endif