14 std::cout <<
"Get test data..." << std::endl;
15 TString fname =
"./tmva_class_example.root";
17 gSystem->
Exec(
"curl -O http://root.cern.ch/files/tmva_class_example.root");
21 std::cout <<
"Setup TMVA..." << std::endl;
23 TFile* outputFile =
TFile::Open(
"ResultsTestPyAdaBoostClassification.root",
"RECREATE");
25 "!V:Silent:Color:!DrawProgressBar:AnalysisType=Classification");
41 "SplitMode=Random:NormMode=NumEvents:!V");
45 "H:V:NEstimators=50");
46 std::cout <<
"Train classifier..." << std::endl;
56 std::cout <<
"Run reader and classify " << numEvents <<
" events..." << std::endl;
63 reader->
BookMVA(
"PyAdaBoost",
"datasetTestPyAdaBoostClassification/weights/testPyAdaBoostClassification_PyAdaBoost.weights.xml");
78 for(
UInt_t i=0; i<numEvents; i++){
82 meanMvaBackground += reader->
EvaluateMVA(
"PyAdaBoost");
84 meanMvaSignal = meanMvaSignal/float(numEvents);
85 meanMvaBackground = meanMvaBackground/float(numEvents);
95 std::cout <<
"Mean MVA response on signal: " << meanMvaSignal << std::endl;
96 if(meanMvaSignal < 0.5){
97 std::cout <<
"[ERROR] Mean response on signal is " << meanMvaSignal <<
" (<0.5)" << std::endl;
100 std::cout <<
"Mean MVA response on background: " << meanMvaBackground << std::endl;
101 if(meanMvaBackground > 0.5){
102 std::cout <<
"[ERROR] Mean response on background is " << meanMvaBackground <<
" (>0.5)" << std::endl;
void AddBackgroundTree(TTree *background, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
MethodBase * BookMethod(DataLoader *loader, TString theMethodName, TString methodTitle, TString theOption="")
Book a classifier or regression method.
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
void TrainAllMethods()
Iterates through all booked methods and calls training.
int testPyAdaBoostClassification()
void AddVariable(const TString &expression, const TString &title, const TString &unit, char type='F', Double_t min=0, Double_t max=0)
user inserts discriminating variable in data set info
static void PyInitialize()
Initialize Python interpreter.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
R__EXTERN TSystem * gSystem
virtual Int_t Exec(const char *shellcmd)
Execute a command.
This is the main MVA steering class.
void PrepareTrainingAndTestTree(const TCut &cut, const TString &splitOpt)
prepare the training and test trees -> same cuts for signal and background
Double_t EvaluateMVA(const std::vector< Float_t > &, const TString &methodTag, Double_t aux=0)
Evaluate a std::vector<float> of input data for a given method The parameter aux is obligatory for th...
The Reader class serves to use the MVAs in a specific analysis context.
A TTree object has a header with a name and a title.
void AddSignalTree(TTree *signal, Double_t weight=1.0, Types::ETreeType treetype=Types::kMaxTreeType)
number of signal events (used to compute significance)