41 std::map<std::string,int> Use;
51 Use[
"Likelihood"] = 1;
52 Use[
"LikelihoodD"] = 0;
53 Use[
"LikelihoodPCA"] = 1;
54 Use[
"LikelihoodKDE"] = 0;
55 Use[
"LikelihoodMIX"] = 0;
62 Use[
"PDEFoamBoost"] = 0;
69 Use[
"BoostedFisher"] = 0;
104 Use[
"SVM_Gauss"] = 0;
108 std::cout << std::endl;
109 std::cout <<
"==> Start TMVAClassificationApplication" << std::endl;
113 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;
121 <<
"\" not known in TMVA under this name. Choose among the following:" << std::endl;
122 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
123 std::cout << it->first <<
" ";
125 std::cout << std::endl;
142 reader->AddVariable(
"myvar1 := var1+var2", &
var1 );
143 reader->AddVariable(
"myvar2 := var1-var2", &
var2 );
153 if (Use[
"Category"]){
162 TString dir =
"dataset/weights/";
163 TString prefix =
"TMVAClassification";
166 for (std::map<std::string,int>::iterator it = Use.begin(); it != Use.end(); it++) {
214 if (Use[
"Likelihood"])
histLk =
new TH1F(
"MVA_Likelihood",
"MVA_Likelihood",
nbin, -1, 1 );
215 if (Use[
"LikelihoodD"])
histLkD =
new TH1F(
"MVA_LikelihoodD",
"MVA_LikelihoodD",
nbin, -1, 0.9999 );
216 if (Use[
"LikelihoodPCA"])
histLkPCA =
new TH1F(
"MVA_LikelihoodPCA",
"MVA_LikelihoodPCA",
nbin, -1, 1 );
217 if (Use[
"LikelihoodKDE"])
histLkKDE =
new TH1F(
"MVA_LikelihoodKDE",
"MVA_LikelihoodKDE",
nbin, -0.00001, 0.99999 );
218 if (Use[
"LikelihoodMIX"])
histLkMIX =
new TH1F(
"MVA_LikelihoodMIX",
"MVA_LikelihoodMIX",
nbin, 0, 1 );
219 if (Use[
"PDERS"])
histPD =
new TH1F(
"MVA_PDERS",
"MVA_PDERS",
nbin, 0, 1 );
220 if (Use[
"PDERSD"])
histPDD =
new TH1F(
"MVA_PDERSD",
"MVA_PDERSD",
nbin, 0, 1 );
221 if (Use[
"PDERSPCA"])
histPDPCA =
new TH1F(
"MVA_PDERSPCA",
"MVA_PDERSPCA",
nbin, 0, 1 );
222 if (Use[
"KNN"])
histKNN =
new TH1F(
"MVA_KNN",
"MVA_KNN",
nbin, 0, 1 );
223 if (Use[
"HMatrix"])
histHm =
new TH1F(
"MVA_HMatrix",
"MVA_HMatrix",
nbin, -0.95, 1.55 );
224 if (Use[
"Fisher"])
histFi =
new TH1F(
"MVA_Fisher",
"MVA_Fisher",
nbin, -4, 4 );
225 if (Use[
"FisherG"])
histFiG =
new TH1F(
"MVA_FisherG",
"MVA_FisherG",
nbin, -1, 1 );
226 if (Use[
"BoostedFisher"])
histFiB =
new TH1F(
"MVA_BoostedFisher",
"MVA_BoostedFisher",
nbin, -2, 2 );
227 if (Use[
"LD"])
histLD =
new TH1F(
"MVA_LD",
"MVA_LD",
nbin, -2, 2 );
228 if (Use[
"MLP"])
histNn =
new TH1F(
"MVA_MLP",
"MVA_MLP",
nbin, -1.25, 1.5 );
229 if (Use[
"MLPBFGS"])
histNnbfgs =
new TH1F(
"MVA_MLPBFGS",
"MVA_MLPBFGS",
nbin, -1.25, 1.5 );
230 if (Use[
"MLPBNN"])
histNnbnn =
new TH1F(
"MVA_MLPBNN",
"MVA_MLPBNN",
nbin, -1.25, 1.5 );
231 if (Use[
"CFMlpANN"])
histNnC =
new TH1F(
"MVA_CFMlpANN",
"MVA_CFMlpANN",
nbin, 0, 1 );
232 if (Use[
"TMlpANN"])
histNnT =
new TH1F(
"MVA_TMlpANN",
"MVA_TMlpANN",
nbin, -1.3, 1.3 );
233 if (Use[
"DNN_GPU"])
histDnnGpu =
new TH1F(
"MVA_DNN_GPU",
"MVA_DNN_GPU",
nbin, -0.1, 1.1);
234 if (Use[
"DNN_CPU"])
histDnnCpu =
new TH1F(
"MVA_DNN_CPU",
"MVA_DNN_CPU",
nbin, -0.1, 1.1);
235 if (Use[
"BDT"])
histBdt =
new TH1F(
"MVA_BDT",
"MVA_BDT",
nbin, -0.8, 0.8 );
236 if (Use[
"BDTG"])
histBdtG =
new TH1F(
"MVA_BDTG",
"MVA_BDTG",
nbin, -1.0, 1.0 );
237 if (Use[
"BDTB"])
histBdtB =
new TH1F(
"MVA_BDTB",
"MVA_BDTB",
nbin, -1.0, 1.0 );
238 if (Use[
"BDTD"])
histBdtD =
new TH1F(
"MVA_BDTD",
"MVA_BDTD",
nbin, -0.8, 0.8 );
239 if (Use[
"BDTF"])
histBdtF =
new TH1F(
"MVA_BDTF",
"MVA_BDTF",
nbin, -1.0, 1.0 );
240 if (Use[
"RuleFit"])
histRf =
new TH1F(
"MVA_RuleFit",
"MVA_RuleFit",
nbin, -2.0, 2.0 );
241 if (Use[
"SVM_Gauss"])
histSVMG =
new TH1F(
"MVA_SVM_Gauss",
"MVA_SVM_Gauss",
nbin, 0.0, 1.0 );
242 if (Use[
"SVM_Poly"])
histSVMP =
new TH1F(
"MVA_SVM_Poly",
"MVA_SVM_Poly",
nbin, 0.0, 1.0 );
243 if (Use[
"SVM_Lin"])
histSVML =
new TH1F(
"MVA_SVM_Lin",
"MVA_SVM_Lin",
nbin, 0.0, 1.0 );
244 if (Use[
"FDA_MT"])
histFDAMT =
new TH1F(
"MVA_FDA_MT",
"MVA_FDA_MT",
nbin, -2.0, 3.0 );
245 if (Use[
"FDA_GA"])
histFDAGA =
new TH1F(
"MVA_FDA_GA",
"MVA_FDA_GA",
nbin, -2.0, 3.0 );
246 if (Use[
"Category"])
histCat =
new TH1F(
"MVA_Category",
"MVA_Category",
nbin, -2., 2. );
247 if (Use[
"Plugin"])
histPBdt =
new TH1F(
"MVA_PBDT",
"MVA_BDT",
nbin, -0.8, 0.8 );
250 if (Use[
"PDEFoam"]) {
268 TString fname =
gROOT->GetTutorialDir() +
"/machine_learning/data/tmva_class_example.root";
273 std::cout <<
"ERROR: could not open data file" << std::endl;
276 std::cout <<
"--- TMVAClassificationApp : Using input file: " <<
input->GetName() << std::endl;
285 std::cout <<
"--- Select signal sample" << std::endl;
297 std::vector<Float_t>
vecVar(4);
299 std::cout <<
"--- Processing: " <<
theTree->GetEntries() <<
" events" << std::endl;
304 if (
ievt%1000 == 0) std::cout <<
"--- ... Processing event: " <<
ievt << std::endl;
319 if (Use[
"Likelihood" ])
histLk ->Fill(
reader->EvaluateMVA(
"Likelihood method" ) );
320 if (Use[
"LikelihoodD" ])
histLkD ->Fill(
reader->EvaluateMVA(
"LikelihoodD method" ) );
321 if (Use[
"LikelihoodPCA"])
histLkPCA ->Fill(
reader->EvaluateMVA(
"LikelihoodPCA method" ) );
322 if (Use[
"LikelihoodKDE"])
histLkKDE ->Fill(
reader->EvaluateMVA(
"LikelihoodKDE method" ) );
323 if (Use[
"LikelihoodMIX"])
histLkMIX ->Fill(
reader->EvaluateMVA(
"LikelihoodMIX method" ) );
324 if (Use[
"PDERS" ])
histPD ->Fill(
reader->EvaluateMVA(
"PDERS method" ) );
325 if (Use[
"PDERSD" ])
histPDD ->Fill(
reader->EvaluateMVA(
"PDERSD method" ) );
326 if (Use[
"PDERSPCA" ])
histPDPCA ->Fill(
reader->EvaluateMVA(
"PDERSPCA method" ) );
327 if (Use[
"KNN" ])
histKNN ->Fill(
reader->EvaluateMVA(
"KNN method" ) );
328 if (Use[
"HMatrix" ])
histHm ->Fill(
reader->EvaluateMVA(
"HMatrix method" ) );
329 if (Use[
"Fisher" ])
histFi ->Fill(
reader->EvaluateMVA(
"Fisher method" ) );
330 if (Use[
"FisherG" ])
histFiG ->Fill(
reader->EvaluateMVA(
"FisherG method" ) );
331 if (Use[
"BoostedFisher"])
histFiB ->Fill(
reader->EvaluateMVA(
"BoostedFisher method" ) );
332 if (Use[
"LD" ])
histLD ->Fill(
reader->EvaluateMVA(
"LD method" ) );
333 if (Use[
"MLP" ])
histNn ->Fill(
reader->EvaluateMVA(
"MLP method" ) );
334 if (Use[
"MLPBFGS" ])
histNnbfgs ->Fill(
reader->EvaluateMVA(
"MLPBFGS method" ) );
335 if (Use[
"MLPBNN" ])
histNnbnn ->Fill(
reader->EvaluateMVA(
"MLPBNN method" ) );
336 if (Use[
"CFMlpANN" ])
histNnC ->Fill(
reader->EvaluateMVA(
"CFMlpANN method" ) );
337 if (Use[
"TMlpANN" ])
histNnT ->Fill(
reader->EvaluateMVA(
"TMlpANN method" ) );
338 if (Use[
"DNN_GPU"])
histDnnGpu->Fill(
reader->EvaluateMVA(
"DNN_GPU method"));
339 if (Use[
"DNN_CPU"])
histDnnCpu->Fill(
reader->EvaluateMVA(
"DNN_CPU method"));
340 if (Use[
"BDT" ])
histBdt ->Fill(
reader->EvaluateMVA(
"BDT method" ) );
341 if (Use[
"BDTG" ])
histBdtG ->Fill(
reader->EvaluateMVA(
"BDTG method" ) );
342 if (Use[
"BDTB" ])
histBdtB ->Fill(
reader->EvaluateMVA(
"BDTB method" ) );
343 if (Use[
"BDTD" ])
histBdtD ->Fill(
reader->EvaluateMVA(
"BDTD method" ) );
344 if (Use[
"BDTF" ])
histBdtF ->Fill(
reader->EvaluateMVA(
"BDTF method" ) );
345 if (Use[
"RuleFit" ])
histRf ->Fill(
reader->EvaluateMVA(
"RuleFit method" ) );
346 if (Use[
"SVM_Gauss" ])
histSVMG ->Fill(
reader->EvaluateMVA(
"SVM_Gauss method" ) );
347 if (Use[
"SVM_Poly" ])
histSVMP ->Fill(
reader->EvaluateMVA(
"SVM_Poly method" ) );
348 if (Use[
"SVM_Lin" ])
histSVML ->Fill(
reader->EvaluateMVA(
"SVM_Lin method" ) );
349 if (Use[
"FDA_MT" ])
histFDAMT ->Fill(
reader->EvaluateMVA(
"FDA_MT method" ) );
350 if (Use[
"FDA_GA" ])
histFDAGA ->Fill(
reader->EvaluateMVA(
"FDA_GA method" ) );
351 if (Use[
"Category" ])
histCat ->Fill(
reader->EvaluateMVA(
"Category method" ) );
352 if (Use[
"Plugin" ])
histPBdt ->Fill(
reader->EvaluateMVA(
"P_BDT method" ) );
355 if (Use[
"PDEFoam"]) {
372 std::cout <<
"--- End of event loop: ";
sw.Print();
375 if (Use[
"CutsGA"]) std::cout <<
"--- Efficiency for CutsGA method: " <<
double(
nSelCutsGA)/
theTree->GetEntries()
376 <<
" (for a required signal efficiency of " <<
effS <<
")" << std::endl;
387 std::cout <<
"--- -------------------------------------------------------------" << std::endl;
388 std::cout <<
"--- Retrieve cut values for signal efficiency of 0.7 from Reader" << std::endl;
390 std::cout <<
"... Cut: "
397 std::cout <<
"--- -------------------------------------------------------------" << std::endl;
404 if (Use[
"Likelihood" ])
histLk ->Write();
405 if (Use[
"LikelihoodD" ])
histLkD ->Write();
406 if (Use[
"LikelihoodPCA"])
histLkPCA ->Write();
407 if (Use[
"LikelihoodKDE"])
histLkKDE ->Write();
408 if (Use[
"LikelihoodMIX"])
histLkMIX ->Write();
409 if (Use[
"PDERS" ])
histPD ->Write();
410 if (Use[
"PDERSD" ])
histPDD ->Write();
411 if (Use[
"PDERSPCA" ])
histPDPCA ->Write();
412 if (Use[
"KNN" ])
histKNN ->Write();
413 if (Use[
"HMatrix" ])
histHm ->Write();
414 if (Use[
"Fisher" ])
histFi ->Write();
415 if (Use[
"FisherG" ])
histFiG ->Write();
416 if (Use[
"BoostedFisher"])
histFiB ->Write();
417 if (Use[
"LD" ])
histLD ->Write();
418 if (Use[
"MLP" ])
histNn ->Write();
421 if (Use[
"CFMlpANN" ])
histNnC ->Write();
422 if (Use[
"TMlpANN" ])
histNnT ->Write();
425 if (Use[
"BDT" ])
histBdt ->Write();
426 if (Use[
"BDTG" ])
histBdtG ->Write();
427 if (Use[
"BDTB" ])
histBdtB ->Write();
428 if (Use[
"BDTD" ])
histBdtD ->Write();
429 if (Use[
"BDTF" ])
histBdtF ->Write();
430 if (Use[
"RuleFit" ])
histRf ->Write();
431 if (Use[
"SVM_Gauss" ])
histSVMG ->Write();
432 if (Use[
"SVM_Poly" ])
histSVMP ->Write();
433 if (Use[
"SVM_Lin" ])
histSVML ->Write();
436 if (Use[
"Category" ])
histCat ->Write();
437 if (Use[
"Plugin" ])
histPBdt ->Write();
446 std::cout <<
"--- Created root file: \"TMVApp.root\" containing the MVA output histograms" << std::endl;
450 std::cout <<
"==> TMVAClassificationApplication is done!" << std::endl << std::endl;
456 for (
int i=1; i<
argc; i++) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
R__EXTERN TSystem * gSystem
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a float per channel (see TH1 documentation)
Multivariate optimisation of signal efficiency for given background efficiency, applying rectangular ...
The Reader class serves to use the MVAs in a specific analysis context.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
A TTree represents a columnar dataset.
create variable transformations