Logo ROOT   6.07/09
Reference Guide
TMVAClassificationApplication.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tmva
3 /// \notebook -nodraw
4 /// This macro provides a simple example on how to use the trained classifiers
5 /// within an analysis module
6 /// - Project : TMVA - a Root-integrated toolkit for multivariate data analysis
7 /// - Package : TMVA
8 /// - Exectuable: TMVAClassificationApplication
9 ///
10 /// \macro_output
11 /// \macro_code
12 /// \author Andreas Hoecker
13 
14 #include <cstdlib>
15 #include <vector>
16 #include <iostream>
17 #include <map>
18 #include <string>
19 
20 #include "TFile.h"
21 #include "TTree.h"
22 #include "TString.h"
23 #include "TSystem.h"
24 #include "TROOT.h"
25 #include "TStopwatch.h"
26 
27 #include "TMVA/Tools.h"
28 #include "TMVA/Reader.h"
29 #include "TMVA/MethodCuts.h"
30 
31 using namespace TMVA;
32 
33 void TMVAClassificationApplication( TString myMethodList = "" )
34 {
35 
36  //---------------------------------------------------------------
37  // This loads the library
39 
40  // Default MVA methods to be trained + tested
41  std::map<std::string,int> Use;
42 
43  // Cut optimisation
44  Use["Cuts"] = 1;
45  Use["CutsD"] = 1;
46  Use["CutsPCA"] = 0;
47  Use["CutsGA"] = 0;
48  Use["CutsSA"] = 0;
49  //
50  // 1-dimensional likelihood ("naive Bayes estimator")
51  Use["Likelihood"] = 1;
52  Use["LikelihoodD"] = 0; // the "D" extension indicates decorrelated input variables (see option strings)
53  Use["LikelihoodPCA"] = 1; // the "PCA" extension indicates PCA-transformed input variables (see option strings)
54  Use["LikelihoodKDE"] = 0;
55  Use["LikelihoodMIX"] = 0;
56  //
57  // Mutidimensional likelihood and Nearest-Neighbour methods
58  Use["PDERS"] = 1;
59  Use["PDERSD"] = 0;
60  Use["PDERSPCA"] = 0;
61  Use["PDEFoam"] = 1;
62  Use["PDEFoamBoost"] = 0; // uses generalised MVA method boosting
63  Use["KNN"] = 1; // k-nearest neighbour method
64  //
65  // Linear Discriminant Analysis
66  Use["LD"] = 1; // Linear Discriminant identical to Fisher
67  Use["Fisher"] = 0;
68  Use["FisherG"] = 0;
69  Use["BoostedFisher"] = 0; // uses generalised MVA method boosting
70  Use["HMatrix"] = 0;
71  //
72  // Function Discriminant analysis
73  Use["FDA_GA"] = 1; // minimisation of user-defined function using Genetics Algorithm
74  Use["FDA_SA"] = 0;
75  Use["FDA_MC"] = 0;
76  Use["FDA_MT"] = 0;
77  Use["FDA_GAMT"] = 0;
78  Use["FDA_MCMT"] = 0;
79  //
80  // Neural Networks (all are feed-forward Multilayer Perceptrons)
81  Use["MLP"] = 0; // Recommended ANN
82  Use["MLPBFGS"] = 0; // Recommended ANN with optional training method
83  Use["MLPBNN"] = 1; // Recommended ANN with BFGS training method and bayesian regulator
84  Use["CFMlpANN"] = 0; // Depreciated ANN from ALEPH
85  Use["TMlpANN"] = 0; // ROOT's own ANN
86  //
87  // Support Vector Machine
88  Use["SVM"] = 1;
89  //
90  // Boosted Decision Trees
91  Use["BDT"] = 1; // uses Adaptive Boost
92  Use["BDTG"] = 0; // uses Gradient Boost
93  Use["BDTB"] = 0; // uses Bagging
94  Use["BDTD"] = 0; // decorrelation + Adaptive Boost
95  //
96  // Friedman's RuleFit method, ie, an optimised series of cuts ("rules")
97  Use["RuleFit"] = 1;
98  // ---------------------------------------------------------------
99  Use["Plugin"] = 0;
100  Use["Category"] = 0;
101  Use["SVM_Gauss"] = 0;
102  Use["SVM_Poly"] = 0;
103  Use["SVM_Lin"] = 0;
104 
105  std::cout << std::endl;
106  std::cout << "==> Start TMVAClassificationApplication" << std::endl;
107 
108  // Select methods (don't look at this code - not of interest)
109  if (myMethodList != "") {
110  for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
111 
112  std::vector<TString> mlist = gTools().SplitString( myMethodList, ',' );
113  for (UInt_t i=0; i<mlist.size(); i++) {
114  std::string regMethod(mlist[i]);
115 
116  if (Use.find(regMethod) == Use.end()) {
117  std::cout << "Method \"" << regMethod
118  << "\" not known in TMVA under this name. Choose among the following:" << std::endl;
119  for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
120  std::cout << it->first << " ";
121  }
122  std::cout << std::endl;
123  return;
124  }
125  Use[regMethod] = 1;
126  }
127  }
128 
129  // --------------------------------------------------------------------------------------------------
130 
131  // Create the Reader object
132 
133  TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
134 
135  // Create a set of variables and declare them to the reader
136  // - the variable names MUST corresponds in name and type to those given in the weight file(s) used
137  Float_t var1, var2;
138  Float_t var3, var4;
139  reader->AddVariable( "myvar1 := var1+var2", &var1 );
140  reader->AddVariable( "myvar2 := var1-var2", &var2 );
141  reader->AddVariable( "var3", &var3 );
142  reader->AddVariable( "var4", &var4 );
143 
144  // Spectator variables declared in the training have to be added to the reader, too
145  Float_t spec1,spec2;
146  reader->AddSpectator( "spec1 := var1*2", &spec1 );
147  reader->AddSpectator( "spec2 := var1*3", &spec2 );
148 
149  Float_t Category_cat1, Category_cat2, Category_cat3;
150  if (Use["Category"]){
151  // Add artificial spectators for distinguishing categories
152  reader->AddSpectator( "Category_cat1 := var3<=0", &Category_cat1 );
153  reader->AddSpectator( "Category_cat2 := (var3>0)&&(var4<0)", &Category_cat2 );
154  reader->AddSpectator( "Category_cat3 := (var3>0)&&(var4>=0)", &Category_cat3 );
155  }
156 
157  // Book the MVA methods
158 
159  TString dir = "dataset/weights/";
160  TString prefix = "TMVAClassification";
161 
162  // Book method(s)
163  for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
164  if (it->second) {
165  TString methodName = TString(it->first) + TString(" method");
166  TString weightfile = dir + prefix + TString("_") + TString(it->first) + TString(".weights.xml");
167  reader->BookMVA( methodName, weightfile );
168  }
169  }
170 
171  // Book output histograms
172  UInt_t nbin = 100;
173  TH1F *histLk(0), *histLkD(0), *histLkPCA(0), *histLkKDE(0), *histLkMIX(0), *histPD(0), *histPDD(0);
174  TH1F *histPDPCA(0), *histPDEFoam(0), *histPDEFoamErr(0), *histPDEFoamSig(0), *histKNN(0), *histHm(0);
175  TH1F *histFi(0), *histFiG(0), *histFiB(0), *histLD(0), *histNn(0),*histNnbfgs(0),*histNnbnn(0);
176  TH1F *histNnC(0), *histNnT(0), *histBdt(0), *histBdtG(0), *histBdtD(0), *histRf(0), *histSVMG(0);
177  TH1F *histSVMP(0), *histSVML(0), *histFDAMT(0), *histFDAGA(0), *histCat(0), *histPBdt(0);
178 
179  if (Use["Likelihood"]) histLk = new TH1F( "MVA_Likelihood", "MVA_Likelihood", nbin, -1, 1 );
180  if (Use["LikelihoodD"]) histLkD = new TH1F( "MVA_LikelihoodD", "MVA_LikelihoodD", nbin, -1, 0.9999 );
181  if (Use["LikelihoodPCA"]) histLkPCA = new TH1F( "MVA_LikelihoodPCA", "MVA_LikelihoodPCA", nbin, -1, 1 );
182  if (Use["LikelihoodKDE"]) histLkKDE = new TH1F( "MVA_LikelihoodKDE", "MVA_LikelihoodKDE", nbin, -0.00001, 0.99999 );
183  if (Use["LikelihoodMIX"]) histLkMIX = new TH1F( "MVA_LikelihoodMIX", "MVA_LikelihoodMIX", nbin, 0, 1 );
184  if (Use["PDERS"]) histPD = new TH1F( "MVA_PDERS", "MVA_PDERS", nbin, 0, 1 );
185  if (Use["PDERSD"]) histPDD = new TH1F( "MVA_PDERSD", "MVA_PDERSD", nbin, 0, 1 );
186  if (Use["PDERSPCA"]) histPDPCA = new TH1F( "MVA_PDERSPCA", "MVA_PDERSPCA", nbin, 0, 1 );
187  if (Use["KNN"]) histKNN = new TH1F( "MVA_KNN", "MVA_KNN", nbin, 0, 1 );
188  if (Use["HMatrix"]) histHm = new TH1F( "MVA_HMatrix", "MVA_HMatrix", nbin, -0.95, 1.55 );
189  if (Use["Fisher"]) histFi = new TH1F( "MVA_Fisher", "MVA_Fisher", nbin, -4, 4 );
190  if (Use["FisherG"]) histFiG = new TH1F( "MVA_FisherG", "MVA_FisherG", nbin, -1, 1 );
191  if (Use["BoostedFisher"]) histFiB = new TH1F( "MVA_BoostedFisher", "MVA_BoostedFisher", nbin, -2, 2 );
192  if (Use["LD"]) histLD = new TH1F( "MVA_LD", "MVA_LD", nbin, -2, 2 );
193  if (Use["MLP"]) histNn = new TH1F( "MVA_MLP", "MVA_MLP", nbin, -1.25, 1.5 );
194  if (Use["MLPBFGS"]) histNnbfgs = new TH1F( "MVA_MLPBFGS", "MVA_MLPBFGS", nbin, -1.25, 1.5 );
195  if (Use["MLPBNN"]) histNnbnn = new TH1F( "MVA_MLPBNN", "MVA_MLPBNN", nbin, -1.25, 1.5 );
196  if (Use["CFMlpANN"]) histNnC = new TH1F( "MVA_CFMlpANN", "MVA_CFMlpANN", nbin, 0, 1 );
197  if (Use["TMlpANN"]) histNnT = new TH1F( "MVA_TMlpANN", "MVA_TMlpANN", nbin, -1.3, 1.3 );
198  if (Use["BDT"]) histBdt = new TH1F( "MVA_BDT", "MVA_BDT", nbin, -0.8, 0.8 );
199  if (Use["BDTD"]) histBdtD = new TH1F( "MVA_BDTD", "MVA_BDTD", nbin, -0.8, 0.8 );
200  if (Use["BDTG"]) histBdtG = new TH1F( "MVA_BDTG", "MVA_BDTG", nbin, -1.0, 1.0 );
201  if (Use["RuleFit"]) histRf = new TH1F( "MVA_RuleFit", "MVA_RuleFit", nbin, -2.0, 2.0 );
202  if (Use["SVM_Gauss"]) histSVMG = new TH1F( "MVA_SVM_Gauss", "MVA_SVM_Gauss", nbin, 0.0, 1.0 );
203  if (Use["SVM_Poly"]) histSVMP = new TH1F( "MVA_SVM_Poly", "MVA_SVM_Poly", nbin, 0.0, 1.0 );
204  if (Use["SVM_Lin"]) histSVML = new TH1F( "MVA_SVM_Lin", "MVA_SVM_Lin", nbin, 0.0, 1.0 );
205  if (Use["FDA_MT"]) histFDAMT = new TH1F( "MVA_FDA_MT", "MVA_FDA_MT", nbin, -2.0, 3.0 );
206  if (Use["FDA_GA"]) histFDAGA = new TH1F( "MVA_FDA_GA", "MVA_FDA_GA", nbin, -2.0, 3.0 );
207  if (Use["Category"]) histCat = new TH1F( "MVA_Category", "MVA_Category", nbin, -2., 2. );
208  if (Use["Plugin"]) histPBdt = new TH1F( "MVA_PBDT", "MVA_BDT", nbin, -0.8, 0.8 );
209 
210  // PDEFoam also returns per-event error, fill in histogram, and also fill significance
211  if (Use["PDEFoam"]) {
212  histPDEFoam = new TH1F( "MVA_PDEFoam", "MVA_PDEFoam", nbin, 0, 1 );
213  histPDEFoamErr = new TH1F( "MVA_PDEFoamErr", "MVA_PDEFoam error", nbin, 0, 1 );
214  histPDEFoamSig = new TH1F( "MVA_PDEFoamSig", "MVA_PDEFoam significance", nbin, 0, 10 );
215  }
216 
217  // Book example histogram for probability (the other methods are done similarly)
218  TH1F *probHistFi(0), *rarityHistFi(0);
219  if (Use["Fisher"]) {
220  probHistFi = new TH1F( "MVA_Fisher_Proba", "MVA_Fisher_Proba", nbin, 0, 1 );
221  rarityHistFi = new TH1F( "MVA_Fisher_Rarity", "MVA_Fisher_Rarity", nbin, 0, 1 );
222  }
223 
224  // Prepare input tree (this must be replaced by your data source)
225  // in this example, there is a toy tree with signal and one with background events
226  // we'll later on use only the "signal" events for the test in this example.
227  //
228  TFile *input(0);
229  TString fname = "./tmva_example.root";
230  if (!gSystem->AccessPathName( fname ))
231  input = TFile::Open( fname ); // check if file in local directory exists
232  else
233  input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server
234 
235  if (!input) {
236  std::cout << "ERROR: could not open data file" << std::endl;
237  exit(1);
238  }
239  std::cout << "--- TMVAClassificationApp : Using input file: " << input->GetName() << std::endl;
240 
241  // Event loop
242 
243  // Prepare the event tree
244  // - Here the variable names have to corresponds to your tree
245  // - You can use the same variables as above which is slightly faster,
246  // but of course you can use different ones and copy the values inside the event loop
247  //
248  std::cout << "--- Select signal sample" << std::endl;
249  TTree* theTree = (TTree*)input->Get("TreeS");
250  Float_t userVar1, userVar2;
251  theTree->SetBranchAddress( "var1", &userVar1 );
252  theTree->SetBranchAddress( "var2", &userVar2 );
253  theTree->SetBranchAddress( "var3", &var3 );
254  theTree->SetBranchAddress( "var4", &var4 );
255 
256  // Efficiency calculator for cut method
257  Int_t nSelCutsGA = 0;
258  Double_t effS = 0.7;
259 
260  std::vector<Float_t> vecVar(4); // vector for EvaluateMVA tests
261 
262  std::cout << "--- Processing: " << theTree->GetEntries() << " events" << std::endl;
263  TStopwatch sw;
264  sw.Start();
265  for (Long64_t ievt=0; ievt<theTree->GetEntries();ievt++) {
266 
267  if (ievt%1000 == 0) std::cout << "--- ... Processing event: " << ievt << std::endl;
268 
269  theTree->GetEntry(ievt);
270 
271  var1 = userVar1 + userVar2;
272  var2 = userVar1 - userVar2;
273 
274  // Return the MVA outputs and fill into histograms
275 
276  if (Use["CutsGA"]) {
277  // Cuts is a special case: give the desired signal efficienciy
278  Bool_t passed = reader->EvaluateMVA( "CutsGA method", effS );
279  if (passed) nSelCutsGA++;
280  }
281 
282  if (Use["Likelihood" ]) histLk ->Fill( reader->EvaluateMVA( "Likelihood method" ) );
283  if (Use["LikelihoodD" ]) histLkD ->Fill( reader->EvaluateMVA( "LikelihoodD method" ) );
284  if (Use["LikelihoodPCA"]) histLkPCA ->Fill( reader->EvaluateMVA( "LikelihoodPCA method" ) );
285  if (Use["LikelihoodKDE"]) histLkKDE ->Fill( reader->EvaluateMVA( "LikelihoodKDE method" ) );
286  if (Use["LikelihoodMIX"]) histLkMIX ->Fill( reader->EvaluateMVA( "LikelihoodMIX method" ) );
287  if (Use["PDERS" ]) histPD ->Fill( reader->EvaluateMVA( "PDERS method" ) );
288  if (Use["PDERSD" ]) histPDD ->Fill( reader->EvaluateMVA( "PDERSD method" ) );
289  if (Use["PDERSPCA" ]) histPDPCA ->Fill( reader->EvaluateMVA( "PDERSPCA method" ) );
290  if (Use["KNN" ]) histKNN ->Fill( reader->EvaluateMVA( "KNN method" ) );
291  if (Use["HMatrix" ]) histHm ->Fill( reader->EvaluateMVA( "HMatrix method" ) );
292  if (Use["Fisher" ]) histFi ->Fill( reader->EvaluateMVA( "Fisher method" ) );
293  if (Use["FisherG" ]) histFiG ->Fill( reader->EvaluateMVA( "FisherG method" ) );
294  if (Use["BoostedFisher"]) histFiB ->Fill( reader->EvaluateMVA( "BoostedFisher method" ) );
295  if (Use["LD" ]) histLD ->Fill( reader->EvaluateMVA( "LD method" ) );
296  if (Use["MLP" ]) histNn ->Fill( reader->EvaluateMVA( "MLP method" ) );
297  if (Use["MLPBFGS" ]) histNnbfgs ->Fill( reader->EvaluateMVA( "MLPBFGS method" ) );
298  if (Use["MLPBNN" ]) histNnbnn ->Fill( reader->EvaluateMVA( "MLPBNN method" ) );
299  if (Use["CFMlpANN" ]) histNnC ->Fill( reader->EvaluateMVA( "CFMlpANN method" ) );
300  if (Use["TMlpANN" ]) histNnT ->Fill( reader->EvaluateMVA( "TMlpANN method" ) );
301  if (Use["BDT" ]) histBdt ->Fill( reader->EvaluateMVA( "BDT method" ) );
302  if (Use["BDTD" ]) histBdtD ->Fill( reader->EvaluateMVA( "BDTD method" ) );
303  if (Use["BDTG" ]) histBdtG ->Fill( reader->EvaluateMVA( "BDTG method" ) );
304  if (Use["RuleFit" ]) histRf ->Fill( reader->EvaluateMVA( "RuleFit method" ) );
305  if (Use["SVM_Gauss" ]) histSVMG ->Fill( reader->EvaluateMVA( "SVM_Gauss method" ) );
306  if (Use["SVM_Poly" ]) histSVMP ->Fill( reader->EvaluateMVA( "SVM_Poly method" ) );
307  if (Use["SVM_Lin" ]) histSVML ->Fill( reader->EvaluateMVA( "SVM_Lin method" ) );
308  if (Use["FDA_MT" ]) histFDAMT ->Fill( reader->EvaluateMVA( "FDA_MT method" ) );
309  if (Use["FDA_GA" ]) histFDAGA ->Fill( reader->EvaluateMVA( "FDA_GA method" ) );
310  if (Use["Category" ]) histCat ->Fill( reader->EvaluateMVA( "Category method" ) );
311  if (Use["Plugin" ]) histPBdt ->Fill( reader->EvaluateMVA( "P_BDT method" ) );
312 
313  // Retrieve also per-event error
314  if (Use["PDEFoam"]) {
315  Double_t val = reader->EvaluateMVA( "PDEFoam method" );
316  Double_t err = reader->GetMVAError();
317  histPDEFoam ->Fill( val );
318  histPDEFoamErr->Fill( err );
319  if (err>1.e-50) histPDEFoamSig->Fill( val/err );
320  }
321 
322  // Retrieve probability instead of MVA output
323  if (Use["Fisher"]) {
324  probHistFi ->Fill( reader->GetProba ( "Fisher method" ) );
325  rarityHistFi->Fill( reader->GetRarity( "Fisher method" ) );
326  }
327  }
328 
329  // Get elapsed time
330  sw.Stop();
331  std::cout << "--- End of event loop: "; sw.Print();
332 
333  // Get efficiency for cuts classifier
334  if (Use["CutsGA"]) std::cout << "--- Efficiency for CutsGA method: " << double(nSelCutsGA)/theTree->GetEntries()
335  << " (for a required signal efficiency of " << effS << ")" << std::endl;
336 
337  if (Use["CutsGA"]) {
338 
339  // test: retrieve cuts for particular signal efficiency
340  // CINT ignores dynamic_casts so we have to use a cuts-secific Reader function to acces the pointer
341  TMVA::MethodCuts* mcuts = reader->FindCutsMVA( "CutsGA method" ) ;
342 
343  if (mcuts) {
344  std::vector<Double_t> cutsMin;
345  std::vector<Double_t> cutsMax;
346  mcuts->GetCuts( 0.7, cutsMin, cutsMax );
347  std::cout << "--- -------------------------------------------------------------" << std::endl;
348  std::cout << "--- Retrieve cut values for signal efficiency of 0.7 from Reader" << std::endl;
349  for (UInt_t ivar=0; ivar<cutsMin.size(); ivar++) {
350  std::cout << "... Cut: "
351  << cutsMin[ivar]
352  << " < \""
353  << mcuts->GetInputVar(ivar)
354  << "\" <= "
355  << cutsMax[ivar] << std::endl;
356  }
357  std::cout << "--- -------------------------------------------------------------" << std::endl;
358  }
359  }
360 
361  // Write histograms
362 
363  TFile *target = new TFile( "TMVApp.root","RECREATE" );
364  if (Use["Likelihood" ]) histLk ->Write();
365  if (Use["LikelihoodD" ]) histLkD ->Write();
366  if (Use["LikelihoodPCA"]) histLkPCA ->Write();
367  if (Use["LikelihoodKDE"]) histLkKDE ->Write();
368  if (Use["LikelihoodMIX"]) histLkMIX ->Write();
369  if (Use["PDERS" ]) histPD ->Write();
370  if (Use["PDERSD" ]) histPDD ->Write();
371  if (Use["PDERSPCA" ]) histPDPCA ->Write();
372  if (Use["KNN" ]) histKNN ->Write();
373  if (Use["HMatrix" ]) histHm ->Write();
374  if (Use["Fisher" ]) histFi ->Write();
375  if (Use["FisherG" ]) histFiG ->Write();
376  if (Use["BoostedFisher"]) histFiB ->Write();
377  if (Use["LD" ]) histLD ->Write();
378  if (Use["MLP" ]) histNn ->Write();
379  if (Use["MLPBFGS" ]) histNnbfgs ->Write();
380  if (Use["MLPBNN" ]) histNnbnn ->Write();
381  if (Use["CFMlpANN" ]) histNnC ->Write();
382  if (Use["TMlpANN" ]) histNnT ->Write();
383  if (Use["BDT" ]) histBdt ->Write();
384  if (Use["BDTD" ]) histBdtD ->Write();
385  if (Use["BDTG" ]) histBdtG ->Write();
386  if (Use["RuleFit" ]) histRf ->Write();
387  if (Use["SVM_Gauss" ]) histSVMG ->Write();
388  if (Use["SVM_Poly" ]) histSVMP ->Write();
389  if (Use["SVM_Lin" ]) histSVML ->Write();
390  if (Use["FDA_MT" ]) histFDAMT ->Write();
391  if (Use["FDA_GA" ]) histFDAGA ->Write();
392  if (Use["Category" ]) histCat ->Write();
393  if (Use["Plugin" ]) histPBdt ->Write();
394 
395  // Write also error and significance histos
396  if (Use["PDEFoam"]) { histPDEFoam->Write(); histPDEFoamErr->Write(); histPDEFoamSig->Write(); }
397 
398  // Write also probability hists
399  if (Use["Fisher"]) { if (probHistFi != 0) probHistFi->Write(); if (rarityHistFi != 0) rarityHistFi->Write(); }
400  target->Close();
401 
402  std::cout << "--- Created root file: \"TMVApp.root\" containing the MVA output histograms" << std::endl;
403 
404  delete reader;
405 
406  std::cout << "==> TMVAClassificationApplication is done!" << std::endl << std::endl;
407 }
408 
409 int main( int argc, char** argv )
410 {
411  TString methodList;
412  for (int i=1; i<argc; i++) {
413  TString regMethod(argv[i]);
414  if(regMethod=="-b" || regMethod=="--batch") continue;
415  if (!methodList.IsNull()) methodList += TString(",");
416  methodList += regMethod;
417  }
418  TMVAClassificationApplication(methodList);
419  return 0;
420 }
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition: TSystem.cxx:1265
static Tools & Instance()
Definition: Tools.cxx:80
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
Definition: TStopwatch.cxx:219
long long Long64_t
Definition: RtypesCore.h:69
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Definition: TStopwatch.cxx:58
float Float_t
Definition: RtypesCore.h:53
void AddVariable(const TString &expression, Float_t *)
Add a float variable or expression to the reader.
Definition: Reader.cxx:309
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:50
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
Definition: TTree.cxx:5210
Double_t GetRarity(const TString &methodTag, Double_t mvaVal=-9999999)
evaluates the MVA&#39;s rarity
Definition: Reader.cxx:764
Basic string class.
Definition: TString.h:137
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const TString & GetInputVar(Int_t i) const
Definition: MethodBase.h:345
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3871
Tools & gTools()
Definition: Tools.cxx:79
void Stop()
Stop the stopwatch.
Definition: TStopwatch.cxx:77
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
Definition: TTree.cxx:7719
Double_t GetCuts(Double_t effS, std::vector< Double_t > &cutMin, std::vector< Double_t > &cutMax) const
retrieve cut values for given signal efficiency
Definition: MethodCuts.cxx:563
Double_t GetMVAError() const
Definition: Reader.h:107
IMethod * BookMVA(const TString &methodTag, const TString &weightfile)
read method name from weight file
Definition: Reader.cxx:378
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
unsigned int UInt_t
Definition: RtypesCore.h:42
Bool_t IsNull() const
Definition: TString.h:387
void AddSpectator(const TString &expression, Float_t *)
Add a float spectator or expression to the reader.
Definition: Reader.cxx:327
double Double_t
Definition: RtypesCore.h:55
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
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...
Definition: Reader.cxx:486
Abstract ClassifierFactory template that handles arbitrary types.
virtual Long64_t GetEntries() const
Definition: TTree.h:392
A TTree object has a header with a name and a title.
Definition: TTree.h:98
std::vector< TString > SplitString(const TString &theOpt, const char separator) const
splits the option string at &#39;separator&#39; and fills the list &#39;splitV&#39; with the primitive strings ...
Definition: Tools.cxx:1207
int main(int argc, char **argv)
Double_t GetProba(const TString &methodTag, Double_t ap_sig=0.5, Double_t mvaVal=-9999999)
evaluates probability of MVA for given set of input variables
Definition: Reader.cxx:733
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:904
MethodCuts * FindCutsMVA(const TString &methodTag)
special function for Cuts to avoid dynamic_casts in ROOT macros, which are not properly handled by CI...
Definition: Reader.cxx:725
Stopwatch class.
Definition: TStopwatch.h:30