本文整理汇总了C++中tmva::Factory::AddBackgroundTree方法的典型用法代码示例。如果您正苦于以下问题:C++ Factory::AddBackgroundTree方法的具体用法?C++ Factory::AddBackgroundTree怎么用?C++ Factory::AddBackgroundTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmva::Factory
的用法示例。
在下文中一共展示了Factory::AddBackgroundTree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TMVAClassification
void TMVAClassification(char* trainFile, char* tree,
char* mycuts, char* mycutb, char* inputVars[], int size)
{
// this loads the library
TMVA::Tools::Instance();
// Create a new root output file.
TFile* outputFile = TFile::Open( "TMVA.root", "RECREATE" );
// Create the factory object.
TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", outputFile,
"!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D" );
// ---------- input variables
for (int ivar = 0; ivar < size; ++ivar) {
factory->AddVariable(inputVars[ivar], 'F');
}
// read training and test data
TFile *input = TFile::Open( trainFile);
TTree *signal = (TTree*)input->Get(tree);
TTree *background = (TTree*)input->Get(tree);
// global event weights per tree
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
// ====== register trees ====================================================
// you can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
// tell the factory to use all remaining events in the trees after training for testing:
factory->PrepareTrainingAndTestTree( TCut(mycuts), TCut(mycutb),
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
// If no numbers of events are given, half of the events in the tree are used for training, and
// the other half for testing:
// ---- Use BDT: Adaptive Boost
factory->BookMethod( TMVA::Types::kBDT, "BDT",
"!H:!V:NTrees=400:nEventsMin=400:MaxDepth=3:BoostType=AdaBoost:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning" );
// ---- Train MVAs using the set of training events
factory->TrainAllMethods();
// ---- Evaluate all MVAs using the set of test events
factory->TestAllMethods();
// ----- Evaluate and compare performance of all configured MVAs
factory->EvaluateAllMethods();
// Save the output
outputFile->Close();
std::cout << "==> TMVAClassification is done!" << std::endl;
delete factory;
}
示例2: process
void process(const std::vector<std::string>& inputFiles, const std::string& name, const std::string& outputFile) {
TChain* signal = loadChain(inputFiles, "signal");
TChain* background = loadChain(inputFiles, "background");
TFile* output = TFile::Open(outputFile.c_str(), "recreate");
TMVA::Factory* factory = new TMVA::Factory(name.c_str(), output, "V");
factory->AddSignalTree(signal, 1.);
factory->AddBackgroundTree(background, 1.);
//{
//factory->AddVariable("lightJet1p2_Pt");
//factory->AddVariable("leptonic_B_Pt");
//factory->AddVariable("leptonic_Top_Pt");
//factory->AddVariable("leptonic_Top_M");
//factory->AddVariable("hadronic_B_Pt");
//factory->AddVariable("hadronic_W_M");
//factory->AddVariable("hadronic_Top_Pt");
//factory->AddVariable("hadronic_Top_M");
//factory->AddVariable("delta_R_tops");
//factory->AddVariable("delta_R_lightjets");
//factory->AddVariable("leptonic_B_CSV");
//factory->AddVariable("hadronic_B_CSV");
//}
// chi^2 style
{
factory->AddVariable("leptonic_Top_M");
factory->AddVariable("hadronic_W_M");
factory->AddVariable("hadronic_Top_M");
factory->AddVariable("ht_fraction");
}
factory->SetWeightExpression("weight");
factory->PrepareTrainingAndTestTree("", "", "V:VerboseLevel=Info:nTrain_Signal=100000:nTrain_Background=100000:nTest_Signal=100000:nTest_Background=100000");
factory->BookMethod(TMVA::Types::kBDT, "BDT", "V:BoostType=AdaBoost:nCuts=20:VarTransform=D");
factory->BookMethod(TMVA::Types::kMLP, "NN", "V:VarTransform=D");
//factory->BookMethod(TMVA::Types::kPDERS, "PDERS", "V");
factory->TrainAllMethods();
factory->TestAllMethods();
factory->EvaluateAllMethods();
output->Close();
delete output;
delete signal;
delete background;
}
示例3: test_train
void test_train(TString signalName = "WW",
TString bkgName = "DY")
{
TFile *outFile = new TFile("myAnalysisFile.root","RECREATE");
TMVA::Factory *factory = new TMVA::Factory(signalName, outFile,"");
TString directory = "../rootFiles/SF/MediumIDTighterIP/";
//signalName = directory + signalName;
//defining WW signal
TFile *MySignalFile = new TFile("../rootFiles/SF/MediumIDTighterIP/WW.root","READ");
TTree* sigTree = (TTree*)MySignalFile->Get("nt");
factory->AddSignalTree(sigTree,1);
//defining DY background
TFile *MyBkgFile = new TFile("../rootFiles/SF/MediumIDTighterIP/DY.root","READ");
TTree* bkgTree = (TTree*)MyBkgFile->Get("nt");
factory->AddBackgroundTree(bkgTree,1);
factory->SetWeightExpression("baseW");
//************************************ FACTORY
factory->AddVariable("fullpmet");
factory->AddVariable("trkpmet");
factory->AddVariable("ratioMet");
factory->AddVariable("ptll");
factory->AddVariable("mth");
factory->AddVariable("jetpt1");
factory->AddVariable("ptWW");
factory->AddVariable("dphilljet");
factory->AddVariable("dphillmet");
factory->AddVariable("dphijet1met");
factory->AddVariable("nvtx");
factory->PrepareTrainingAndTestTree("",500,500,500,500);
cout<<"I've prepared trees"<<endl;
//factory->BookMethod(TMVA::Types::kFisher, "Fisher","");
factory->BookMethod(TMVA::Types::kBDT, "BDT","");
cout<<"I've booked method"<<endl;
factory->TrainAllMethods();
factory->TestAllMethods();
cout<<"I've tested all methods"<<endl;
factory->EvaluateAllMethods();
cout<<"I've evaluated all methods"<<endl;
}
示例4: main
int main ()
{
TFile * outputfile = TFile::Open ("outputTMVA.root","RECREATE");
TMVA::Factory * TMVAtest = new TMVA::Factory ("TMVAtest", outputfile, "S") ;
//PG get the signal and deliver it to the TMVA factory
TFile signalFile ("/Users/govoni/data/ntuplesHWW/H160/NTUPLE_H160_output_0.root") ;
TTree * signalTree = (TTree *) signalFile.Get ("ntpla/VBFSimpleTree") ;
std::cout << "READ " << signalTree->GetEntries () << " signal events\n" ;
TMVAtest->AddSignalTree (signalTree,1) ;
//PG get the bkg and deliver it to the TMVA factory
TFile bkg1File ("/Users/govoni/data/ntuplesHWW/WW_incl/NTUPLE_WW_incl_output_0.root") ;
TTree * bkg1Tree = (TTree *) bkg1File.Get ("ntpla/VBFSimpleTree") ;
std::cout << "READ " << bkg1Tree->GetEntries () << " bkg1 events\n" ;
TMVAtest->AddBackgroundTree (bkg1Tree,1) ;
delete TMVAtest ;
delete outputfile ;
}
示例5: TMVAtest
void TMVAtest(){
//gSystem->Load("../lib/slc5_amd64_gcc462/libTAMUWWMEPATNtuple.so");
gSystem->Load("libPhysics");
//gSystem->Load("EvtTreeForAlexx_h.so");
gSystem->Load("libTMVA.1");
gSystem->Load("AutoDict_vector_TLorentzVector__cxx.so");
TMVA::Tools::Instance();
TFile* outputFile = TFile::Open("TMVA1.root", "RECREATE");
TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification",outputFile,"V=true:Color:DrawProgressBar");// ":Transformations=I;D;P;G,D" );
TFile* signal = TFile::Open("/uscms_data/d2/aperloff/Spring12ME7TeV/MEResults/microNtuples_oldStructure/microWW_EPDv01.root");
TFile* bkg = TFile::Open("/uscms_data/d2/aperloff/Spring12ME7TeV/MEResults/microNtuples_oldStructure/microWJets_EPDv01.root");
TTree* stree = (TTree*)signal->Get("METree");
TTree* btree = (TTree*)bkg->Get("METree");
factory->AddSignalTree(stree,1.0);
factory->AddBackgroundTree(btree,1.0);
factory->SetSignalWeightExpression("1.0");
factory->SetBackgroundWeightExpression("1.0");
factory->AddVariable("tEventProb[0]");
factory->AddVariable("tEventProb[1]");
factory->AddVariable("tEventProb[2]");
//factory->AddVariable("tEventProb0 := tEventProb[0]",'F');
//factory->AddVariable("tEventProb1 := tEventProb[1]",'F');
//factory->AddVariable("tEventProb2 := tEventProb[2]",'F');
TCut test("Entry$>-2 && jLV[1].Pt()>30");
TCut mycuts (test);
factory->PrepareTrainingAndTestTree(mycuts,mycuts,"nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0:SplitMode=Random:NormMode=None:V=true:VerboseLevel=DEBUG");
factory->BookMethod( TMVA::Types::kBDT, "BDT","!H:!V:NTrees=400:nEventsMin=400:MaxDepth=3:BoostType=AdaBoost:SeparationType=GiniIndex:nCuts=20:PruneMethod=NoPruning" );
factory->TrainAllMethods();
factory->TestAllMethods();
factory->EvaluateAllMethods();
outputFile->Close();
}
示例6: tmvaClassifier
//.........这里部分代码省略.........
// std::cout << "--- TMVAClassification : Using input file: " << input->GetName() << std::endl;
// --- Register the training and test trees
TChain *signal = new TChain("ewkzp2j");
TChain *background = new TChain("ewkzp2j");
TSystemDirectory dir(inputDir,inputDir);
TList *files = dir.GetListOfFiles();
if (files) {
TSystemFile *file;
TString fname;
TIter next(files);
while ((file=(TSystemFile*)next())) {
fname = file->GetName();
if(!fname.EndsWith("_summary.root")) continue;
if(fname.Contains("Data")) continue;
if(!fname.Contains("DY")) continue;
bool isSignal(false);
if(fname.Contains("JJ")) { signal->Add(fname); isSignal=true; }
else if(fname.Contains("50toInf") && fname.Contains("DY")) background->Add(fname);
cout << fname << " added as " << (isSignal ? "signal" : "background") << endl;
}
}else{
cout << "[Error] no files found in " << inputDir << endl;
}
cout << "Signal has " << signal->GetEntries() << " raw events" << endl
<< "Background has " << background->GetEntries() << " raw events"<< endl;
// global event weights per tree
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
// event-per-event weights per tree
factory->SetBackgroundWeightExpression( "weight/cnorm" );
factory->SetSignalWeightExpression( "weight/cnorm" );
//define variables for the training
if(minimalTrain)
{
factory->AddVariable( "mjj", "M_{jj}" "GeV", 'F' );
factory->AddVariable( "detajj", "#Delta#eta_{jj}", "", 'F' );
factory->AddVariable( "spt", "#Delta_{rel}", "GeV", 'F' );
}
else
{
factory->AddVariable( "mjj", "M_{jj}" "GeV", 'F' );
factory->AddVariable( "detajj", "#Delta#eta_{jj}", "", 'F' );
factory->AddVariable( "setajj", "#Sigma#eta_{j}", "", 'F' );
factory->AddVariable( "eta1", "#eta(1)", "", 'F' );
factory->AddVariable( "eta2", "#eta(2)", "", 'F' );
factory->AddVariable( "pt1", "p_{T}(1)", "GeV", 'F' );
factory->AddVariable( "pt2", "p_{T}(2)", "GeV", 'F' );
factory->AddVariable( "spt", "#Delta_{rel}", "GeV", 'F' );
if(useQG) factory->AddVariable( "qg1", "q/g(1)", "", 'F' );
if(useQG) factory->AddVariable( "qg2", "q/g(2)", "", 'F' );
}
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = ""; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = ""; // for example: TCut mycutb = "abs(var1)<0.5";
factory->PrepareTrainingAndTestTree( mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
示例7: TMVAClassificationCategory
void TMVAClassificationCategory()
{
//---------------------------------------------------------------
// Example for usage of different event categories with classifiers
std::cout << std::endl << "==> Start TMVAClassificationCategory" << std::endl;
bool batchMode = false;
// Create a new root output file.
TString outfileName( "TMVA.root" );
TFile* outputFile = TFile::Open( outfileName, "RECREATE" );
// Create the factory object (see TMVAClassification.C for more information)
std::string factoryOptions( "!V:!Silent:Transformations=I;D;P;G,D" );
if (batchMode) factoryOptions += ":!Color:!DrawProgressBar";
TMVA::Factory *factory = new TMVA::Factory( "TMVAClassificationCategory", outputFile, factoryOptions );
// Define the input variables used for the MVA training
factory->AddVariable( "var1", 'F' );
factory->AddVariable( "var2", 'F' );
factory->AddVariable( "var3", 'F' );
factory->AddVariable( "var4", 'F' );
// You can add so-called "Spectator variables", which are not used in the MVA training,
// but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the
// input variables, the response values of all trained MVAs, and the spectator variables
factory->AddSpectator( "eta" );
// Load the signal and background event samples from ROOT trees
TFile *input(0);
TString fname( "" );
if (UseOffsetMethod) fname = "data/toy_sigbkg_categ_offset.root";
else fname = "data/toy_sigbkg_categ_varoff.root";
if (!gSystem->AccessPathName( fname )) {
// first we try to find tmva_example.root in the local directory
std::cout << "--- TMVAClassificationCategory: Accessing " << fname << std::endl;
input = TFile::Open( fname );
}
if (!input) {
std::cout << "ERROR: could not open data file: " << fname << std::endl;
exit(1);
}
TTree *signal = (TTree*)input->Get("TreeS");
TTree *background = (TTree*)input->Get("TreeB");
/// Global event weights per tree (see below for setting event-wise weights)
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
/// You can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = ""; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = ""; // for example: TCut mycutb = "abs(var1)<0.5";
// Tell the factory how to use the training and testing events
factory->PrepareTrainingAndTestTree( mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
// ---- Book MVA methods
// Fisher discriminant
factory->BookMethod( TMVA::Types::kFisher, "Fisher", "!H:!V:Fisher" );
// Likelihood
factory->BookMethod( TMVA::Types::kLikelihood, "Likelihood",
"!H:!V:TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmoothBkg[1]=10:NSmooth=1:NAvEvtPerBin=50" );
// --- Categorised classifier
TMVA::MethodCategory* mcat = 0;
// The variable sets
TString theCat1Vars = "var1:var2:var3:var4";
TString theCat2Vars = (UseOffsetMethod ? "var1:var2:var3:var4" : "var1:var2:var3");
// Fisher with categories
TMVA::MethodBase* fiCat = factory->BookMethod( TMVA::Types::kCategory, "FisherCat","" );
mcat = dynamic_cast<TMVA::MethodCategory*>(fiCat);
mcat->AddMethod( "abs(eta)<=1.3", theCat1Vars, TMVA::Types::kFisher, "Category_Fisher_1","!H:!V:Fisher" );
mcat->AddMethod( "abs(eta)>1.3", theCat2Vars, TMVA::Types::kFisher, "Category_Fisher_2","!H:!V:Fisher" );
// Likelihood with categories
TMVA::MethodBase* liCat = factory->BookMethod( TMVA::Types::kCategory, "LikelihoodCat","" );
mcat = dynamic_cast<TMVA::MethodCategory*>(liCat);
mcat->AddMethod( "abs(eta)<=1.3",theCat1Vars, TMVA::Types::kLikelihood,
"Category_Likelihood_1","!H:!V:TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmoothBkg[1]=10:NSmooth=1:NAvEvtPerBin=50" );
mcat->AddMethod( "abs(eta)>1.3", theCat2Vars, TMVA::Types::kLikelihood,
"Category_Likelihood_2","!H:!V:TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmoothBkg[1]=10:NSmooth=1:NAvEvtPerBin=50" );
// ---- Now you can tell the factory to train, test, and evaluate the MVAs
// Train MVAs using the set of training events
factory->TrainAllMethods();
//.........这里部分代码省略.........
示例8: Classification
void Classification()
{
TMVA::Tools::Instance();
TMVA::PyMethodBase::PyInitialize();
TString outfileName("TMVA.root");
TFile *outputFile = TFile::Open(outfileName, "RECREATE");
TMVA::Factory *factory = new TMVA::Factory("TMVAClassification", outputFile,
"!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification");
factory->AddVariable("myvar1 := var1+var2", 'F');
factory->AddVariable("myvar2 := var1-var2", "Expression 2", "", 'F');
factory->AddVariable("var3", "Variable 3", "units", 'F');
factory->AddVariable("var4", "Variable 4", "units", 'F');
factory->AddSpectator("spec1 := var1*2", "Spectator 1", "units", 'F');
factory->AddSpectator("spec2 := var1*3", "Spectator 2", "units", 'F');
TString fname = "./tmva_class_example.root";
if (gSystem->AccessPathName(fname)) // file does not exist in local directory
gSystem->Exec("curl -O http://root.cern.ch/files/tmva_class_example.root");
TFile *input = TFile::Open(fname);
std::cout << "--- TMVAClassification : Using input file: " << input->GetName() << std::endl;
// --- Register the training and test trees
TTree *tsignal = (TTree *)input->Get("TreeS");
TTree *tbackground = (TTree *)input->Get("TreeB");
// global event weights per tree (see below for setting event-wise weights)
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
// You can add an arbitrary number of signal or background trees
factory->AddSignalTree(tsignal, signalWeight);
factory->AddBackgroundTree(tbackground, backgroundWeight);
// Set individual event weights (the variables must exist in the original TTree)
factory->SetBackgroundWeightExpression("weight");
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = ""; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = ""; // for example: TCut mycutb = "abs(var1)<0.5";
// Tell the factory how to use the training and testing events
factory->PrepareTrainingAndTestTree(mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0:SplitMode=Random:NormMode=NumEvents:!V");
///////////////////
//Booking //
///////////////////
// Boosted Decision Trees
//PyMVA methods
factory->BookMethod(TMVA::Types::kPyRandomForest, "PyRandomForest",
"!V:NEstimators=150:Criterion=gini:MaxFeatures=auto:MaxDepth=3:MinSamplesLeaf=1:MinWeightFractionLeaf=0:Bootstrap=kTRUE");
factory->BookMethod(TMVA::Types::kPyAdaBoost, "PyAdaBoost",
"!V:BaseEstimator=None:NEstimators=100:LearningRate=1:Algorithm=SAMME.R:RandomState=None");
factory->BookMethod(TMVA::Types::kPyGTB, "PyGTB",
"!V:NEstimators=150:Loss=deviance:LearningRate=0.1:Subsample=1:MaxDepth=6:MaxFeatures='auto'");
// Train MVAs using the set of training events
factory->TrainAllMethods();
// ---- Evaluate all MVAs using the set of test events
factory->TestAllMethods();
// ----- Evaluate and compare performance of all configured MVAs
factory->EvaluateAllMethods();
// --------------------------------------------------------------
// Save the output
outputFile->Close();
std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
std::cout << "==> TMVAClassification is done!" << std::endl;
}
示例9: Example_Eric
//.........这里部分代码省略.........
// load the signal and background event samples from ascii files
// format in file must be:
// var1/F:var2/F:var3/F:var4/F
// 0.04551 0.59923 0.32400 -0.19170
// ...
TString datFileS = "tmva_example_sig.dat";
TString datFileB = "tmva_example_bkg.dat";
factory->SetInputTrees( datFileS, datFileB );
}
else {
//TFile* f0 = new TFile("/opt/sbg/data/data1/cms/lebihan/clean_january_2012_2/CMSSW_4_2_8_patch7/src/MiniTreeAnalysis/NTupleAnalysis/macros/TopTauJets/TMVA_sig_newLumi.root");
//TFile* f1 = new TFile("/opt/sbg/data/data1/cms/lebihan/clean_january_2012_2/CMSSW_4_2_8_patch7/src/MiniTreeAnalysis/NTupleAnalysis/macros/TopTauJets/TMVA_bkg_newLumi.root");
TFile* f0 = TFile::Open("/opt/sbg/data/data1/cms/echabert/ttbarMET/ProdAlexMars13/CMSSW_5_3_2_patch4/src/NTuple/NTupleAnalysis/macros/TTbarMET/backup_outputProof10-04-13_16-00-57/proof_ttW.root");
TFile* f1 = TFile::Open("/opt/sbg/data/data1/cms/echabert/ttbarMET/ProdAlexMars13/CMSSW_5_3_2_patch4/src/NTuple/NTupleAnalysis/macros/TTbarMET/backup_outputProof10-04-13_16-00-57/proof_tt-dilepton.root");
TTree *signal = (TTree*)f0->Get("theTree2");
TTree *background = (TTree*)f1->Get("theTree2");
cout<<"trees: "<<signal<<" "<<background<<endl;
//Double_t backgroundWeight = 1.0;
//Double_t signalWeight = 1.0;
Double_t signalWeight = 0.30*20/185338;
Double_t backgroundWeight = 222.*0.1*20/9982625;
// ====== register trees ====================================================
//
// the following method is the prefered one:
// you can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
// factory->AddSignalTree ( signal );
//factory->AddBackgroundTree( background );
// To give different trees for training and testing, do as follows:
// factory->AddSignalTree( signalTrainingTree, signalTrainWeight, "Training" );
// factory->AddSignalTree( signalTestTree, signalTestWeight, "Test" );
// Use the following code instead of the above two or four lines to add signal and background
// training and test events "by hand"
// NOTE that in this case one should not give expressions (such as "var1+var2") in the input
// variable definition, but simply compute the expression before adding the event
//
// // --- begin ----------------------------------------------------------
// std::vector<Double_t> vars( 4 ); // vector has size of number of input variables
// Float_t treevars[4];
// for (Int_t ivar=0; ivar<4; ivar++) signal->SetBranchAddress( Form( "var%i", ivar+1 ), &(treevars[ivar]) );
// for (Int_t i=0; i<signal->GetEntries(); i++) {
// signal->GetEntry(i);
// for (Int_t ivar=0; ivar<4; ivar++) vars[ivar] = treevars[ivar];
// // add training and test events; here: first half is training, second is testing
// // note that the weight can also be event-wise
// if (i < signal->GetEntries()/2) factory->AddSignalTrainingEvent( vars, signalWeight );
// else factory->AddSignalTestEvent ( vars, signalWeight );
// }
//
// for (Int_t ivar=0; ivar<4; ivar++) background->SetBranchAddress( Form( "var%i", ivar+1 ), &(treevars[ivar]) );
// for (Int_t i=0; i<background->GetEntries(); i++) {
// background->GetEntry(i);
// for (Int_t ivar=0; ivar<4; ivar++) vars[ivar] = treevars[ivar];
// // add training and test events; here: first half is training, second is testing
示例10: ZTMVAClassification
//.........这里部分代码省略.........
// factory->AddVariable("normr","normr","", 'F');
// factory->AddVariable("normq","normq","", 'F');
//factory->AddVariable("normminm","normminm","", 'F');
factory->AddVariable("logipmax","logipmax","", 'F');
factory->AddVariable("logipmin","logipmin","", 'F');
factory->AddVariable("logfd","logfd",'F');
factory->AddVariable("logvd","logvd",'F');
//factory->AddVariable("pointAngle","pointingAngle",'F');
factory->AddVariable("logvpi","",'F');
//factory->AddVariable("logmaxprob","",'F');
//factory->AddVariable("logminprob","",'F');
factory->AddSpectator( "mReFit", "mReFit", "", 'D' );
// factory->AddSpectator( "Qdecay", "Qdecay", "",'F' );
// factory->AddSpectator( "m23", "m23", "",'F' );
// TFile * input_Background = new TFile("../back.root");
TFile * input_Signal = new TFile("../cmx12.root");
TFile * input_Background = new TFile("../background12.root");
std::cout << "--- TMVAClassification : Using input file for signal : " << input_Signal->GetName() << std::endl;
std::cout << "--- TMVAClassification : Using input file for backgound : " << input_Background->GetName() << std::endl;
// --- Register the training and test trees
TTree *signal = (TTree*)input_Signal->Get("psiCand");
TTree *background = (TTree*)input_Background->Get("psiCand");
// global event weights per tree (see below for setting event-wise weights)
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
// You can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = "QDecay < 300&&fdchi2 > 300"; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = "QDecay < 300&&fdchi2> 300"; // for example: TCut mycutb = "abs(var1)<0.5";
factory->PrepareTrainingAndTestTree( mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
// ---- Book MVA methods
//
// Please lookup the various method configuration options in the corresponding cxx files, eg:
// src/MethoCuts.cxx, etc, or here: http://tmva.sourceforge.net/optionRef.html
// it is possible to preset ranges in the option string in which the cut optimisation should be done:
// "...:CutRangeMin[2]=-1:CutRangeMax[2]=1"...", where [2] is the third input variable
// Cut optimisation
if (Use["Cuts"])
factory->BookMethod( TMVA::Types::kCuts, "Cuts",
"!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart" );
if (Use["CutsD"])
factory->BookMethod( TMVA::Types::kCuts, "CutsD",
"!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart:VarTransform=Decorrelate" );
if (Use["CutsPCA"])
factory->BookMethod( TMVA::Types::kCuts, "CutsPCA",
"!H:!V:FitMethod=MC:EffSel:SampleSize=200000:VarProp=FSmart:VarTransform=PCA" );
if (Use["CutsGA"])
factory->BookMethod( TMVA::Types::kCuts, "CutsGA",
示例11: TMVAClassification_cc1pcoh_bdt_ver6noveract
//.........这里部分代码省略.........
TString fbkg2Str="/home/cvson/cc1picoh/frkikawa/meAna/ip4tmva/ingrid_merged_nd3_ccqe_tot.root";
/*TString fsignalStr="/home/cvson/cc1picoh/frkikawa/meAna/ip4tmvafix/pm_merged_ccqe_tot.root";
TString fbarStr="/home/cvson/cc1picoh/frkikawa/meAna/ip4tmvafix/pmbar_merged_ccqe.root";
TString fbkgStr="/home/cvson/cc1picoh/frkikawa/meAna/ip4tmvafix/wall_merged_ccqe_tot.root";
TString fbkg2Str="/home/cvson/cc1picoh/frkikawa/meAna/ip4tmvafix/ingrid_merged_nd3_ccqe_tot.root";*/
TFile *pfileSignal = new TFile(fsignalStr);
TFile *pfileBar = new TFile(fbarStr);
TFile *pfileBkg = new TFile(fbkgStr);
TFile *pfileBkg2 = new TFile(fbkg2Str);
TFile *pfileRatio = new TFile(fratioStr);
TTree *ptree_sig = (TTree*)pfileSignal->Get("tree");
TTree *ptree_bar = (TTree*)pfileBar->Get("tree");
TTree *ptree_bkg = (TTree*)pfileBkg->Get("tree");
TTree *ptree_bkg2 = (TTree*)pfileBkg2->Get("tree");
// POT normalization
const int nmcFile = 3950;
const int nbarFile = 986;
const int nbkgFile = 55546;//(31085+24461);
const int nbkg2File = 7882;//(3941+3941);
// global event weights per tree (see below for setting event-wise weights)
// adding for signal sample
// using this as standard and add other later
Double_t signalWeight_sig = 1.0;
Double_t backgroundWeight_sig = 1.0;
factory->AddSignalTree ( ptree_sig, signalWeight_sig );
factory->AddBackgroundTree( ptree_sig, backgroundWeight_sig );
// Add Numubar sample
//Double_t signalWeight_bar = nmcFile/float(nbarFile);
Double_t backgroundWeight_bar = nmcFile/float(nbarFile);
//factory->AddSignalTree ( ptree_bar, signalWeight_bar );
factory->AddBackgroundTree( ptree_bar, backgroundWeight_bar );
// Add wall background
//Double_t signalWeight_bkg = nmcFile/float(nbkgFile);
Double_t backgroundWeight_bkg = nmcFile/float(nbkgFile);
//factory->AddSignalTree ( ptree_bkg, signalWeight_bkg );
factory->AddBackgroundTree( ptree_bkg, backgroundWeight_bkg );
// Add INGRID background
//Double_t signalWeight_bkg2 = nmcFile/float(nbkg2File);
Double_t backgroundWeight_bkg2 = nmcFile/float(nbkg2File);
//factory->AddSignalTree ( ptree_bkg2, signalWeight_bkg2 );
factory->AddBackgroundTree( ptree_bkg2, backgroundWeight_bkg2 );
//factory->SetSignalWeightExpression ("norm*totcrsne*2.8647e-13");
//factory->SetBackgroundWeightExpression( "norm*totcrsne*2.8647e-13" );
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = "Ntrack==2 && abs(inttype)==16 && fileIndex==1 && pang<90 && mumucl>0.6 && opening>10 && coplanarity>90 && pmucl>0.2"; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = "Ntrack==2 && (abs(inttype)!=16 || fileIndex>1) && pang<90 && mumucl>0.6 && opening>10 && coplanarity>90 && pmucl>0.2"; // for example: TCut mycutb = "abs(var1)<0.5";
// Tell the factory how to use the training and testing events
示例12: main
int main(){
TMVA::Tools::Instance();
std::cout<<"Hello world"<<std::endl;
TFile* OutputFile = TFile::Open("Outputfile.root","RECREATE");
TMVA::Factory *factory = new TMVA::Factory( "TMVAClassification", OutputFile,
"!V:!Silent:Color:DrawProgressBar:Transformations=I;D;P;G,D:AnalysisType=Classification" );
std::vector<VMVariable*> Variables;
MVariable* Var3= new MVariable("var3",F,none);
MVariable* Var4 = new MVariable("var4",F,none);
Variables.push_back(Var3);
Variables.push_back(Var4);
MVariable* Var1 = new MVariable("var1",F,none);
MVariable* Var2 = new MVariable("var2",F,none);
MultiVariable* MyVar1 = new MultiVariable("Var1+Var2",sum);
MyVar1->AddVariable(Var1);
MyVar1->AddVariable(Var2);
Variables.push_back(MyVar1);
MultiVariable* MyVar2 = new MultiVariable("Minus",subtract);
MyVar2->AddVariable(Var1);
MyVar2->AddVariable(Var2);
Variables.push_back(MyVar2);
std::string InputName= "./tmva_class_exampleD.root";
TFile *input = TFile::Open("./tmva_class_exampleD.root" );
TTree *signal = (TTree*)input->Get("TreeS");
TTree *background=(TTree*)input->Get("TreeB");
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( background, backgroundWeight );
for(auto v:Variables){
factory->AddVariable(v->GetFactoryName(),v->GetType());
}
factory->SetBackgroundWeightExpression( "weight" );
TCut mycuts = "";
TCut mycutb = "";
factory->PrepareTrainingAndTestTree( mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
std::vector<MClassifier*> Classifiers;
Classifiers.push_back(new MClassifier(TMVA::Types::kBDT, "BDT",
"!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20"));
for(auto C:Classifiers){
if(!(C->AddMethodToFactory(factory))){
std::cout<<"Booking classifier failed"<<std::endl;
return 1;
}
}
factory->TrainAllMethods();
factory->TestAllMethods();
factory->EvaluateAllMethods();
OutputFile->Close();
delete factory;
TMVA::Reader *reader = new TMVA::Reader( "!Color:!Silent" );
for(auto v: Variables){
reader->AddVariable(v->GetFactoryName(),v->GetReaderAddress());
}
for(auto C:Classifiers){
if(!(C->AddMethodToReader(reader,"./weights/","TMVAClassification"))){
std::cout<<"Failed adding classifer to reader"<<std::endl;
return 1;
}
}
TFile* Input = TFile::Open("./tmva_class_exampleD.root");
TTree* TreeToEvaluate= (TTree*)Input->Get("TreeS");
TFile* AppliedFile = new TFile("AppliedFile.root","RECREATE");
TTree* AppliedTree=TreeToEvaluate->CloneTree(0);
for(auto C:Classifiers){
if(!(C->MakeBranch(AppliedTree)))return 1;
}
for(auto Var:Variables){
if(!(Var->SetBA(TreeToEvaluate))){
std::cout<<"Problem Setting Branch addresses"<<std::endl;
return 1;
//.........这里部分代码省略.........
示例13: TMVAClassification
//.........这里部分代码省略.........
// (it is also possible to use ASCII format as input -> see TMVA Users Guide)
if (gSystem->AccessPathName( fnameTrainS )) { // file does not exist in local directory
std::cout << "Did not access " << fnameTrainS << " exiting." << std::endl;
std::exit(4);
}
//gSystem->Exec("wget http://root.cern.ch/files/tmva_class_example.root");
TFile *inputTrainS = TFile::Open( fnameTrainS );
TFile *inputTrainB = TFile::Open( fnameTrainB );
TFile *inputTestS = TFile::Open( fnameTestS );
TFile *inputTestB = TFile::Open( fnameTestB );
// --- Register the training and test trees
TTree *signalTrainTree = (TTree*)inputTrainS->Get("probe_tree");
TTree *backgroundTrainTree = (TTree*)inputTrainB->Get("probe_tree");
TTree *signalTestTree = (TTree*)inputTestS->Get("probe_tree");
TTree *backgroundTestTree = (TTree*)inputTestB->Get("probe_tree");
// global event weights per tree (see below for setting event-wise weights)
Double_t signalTrainWeight = 1.0;
Double_t backgroundTrainWeight = 1.0;
Double_t signalTestWeight = 1.0;
Double_t backgroundTestWeight = 1.0;
// Decide if using the split and mixing or the full trees
if( fnameTrainS == fnameTestS ) {
if( fnameTrainB != fnameTestB ) {
std::cout << "This macro cannot handle cases where the same signal sample is used for training and testing, but different background samples are used.";
exit(1);
}
std::cout << "--- TMVAClassification : Using input file: " << inputTrainS->GetName() << std::endl;
std::cout << "--- and file: " << inputTrainB->GetName() << std::endl;
// You can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signalTrainTree, signalTrainWeight );
factory->AddBackgroundTree( backgroundTrainTree, backgroundTrainWeight );
}
else {
if( fnameTrainB == fnameTestB ) {
std::cout << "This macro cannot handle cases where the same background sample is used for training and testing, but different signal samples are used.";
exit(1);
}
std::cout << "--- TMVAClassification : Using input file: " << inputTrainS->GetName() << std::endl;
std::cout << "--- and file: " << inputTrainB->GetName() << " for training and" << std::endl;
std::cout << "--- input file: " << inputTestS->GetName() << std::endl;
std::cout << "--- and file: " << inputTestB->GetName() << " for testing." << std::endl;
// To give different trees for training and testing, do as follows:
factory->AddSignalTree( signalTrainTree, signalTrainWeight, "Training" );
factory->AddSignalTree( signalTestTree, signalTestWeight, "Test" );
factory->AddBackgroundTree( backgroundTrainTree, backgroundTrainWeight, "Training" );
factory->AddBackgroundTree( backgroundTestTree, backgroundTestWeight, "Test" );
}
// Apply additional cuts on the signal and background samples (can be different)
TCut mycuts = "";
TCut mycutb = "";
// Tell the factory how to use the training and testing events
//
// If no numbers of events are given, half of the events in the tree are used
// for training, and the other half for testing:
// factory->PrepareTrainingAndTestTree( mycut, "SplitMode=random:!V" );
// To also specify the number of testing events, use:
// factory->PrepareTrainingAndTestTree( mycut,
// "NSigTrain=3000:NBkgTrain=3000:NSigTest=3000:NBkgTest=3000:SplitMode=Random:!V" );
示例14: TMVAClassification_qgl
//.........这里部分代码省略.........
// Read training and test data
// (it is also possible to use ASCII format as input -> see TMVA Users Guide)
//
TString fname_signal ="/afs/cern.ch/work/n/nchernya/Hbb/qgl_mva/qgl_tmva_tree_VBFHToBB_M-125_13TeV_powheg_v14"+type[set_type]+"_2jets.root";
TString fname_bg ="/afs/cern.ch/work/n/nchernya/Hbb/qgl_mva/qgl_tmva_tree_BTagCSV_v14"+type[set_type]+"_2jets.root";
if (gSystem->AccessPathName( fname_signal )) { // file does not exist in local directory
cout<<"input file "<< fname_signal<<" doesn't exist!"<<endl;
//break;
}
if (gSystem->AccessPathName( fname_bg)) { // file does not exist in local directory
cout<<"input file "<< fname_bg<<" doesn't exist!"<<endl;
//break;
}
// gSystem->Exec("wget http://root.cern.ch/files/tmva_class_example.root");
TFile *input_signal = TFile::Open( fname_signal );
TFile *input_bg = TFile::Open( fname_bg );
std::cout << "--- TMVAClassification : Using input signal file: " << input_signal->GetName() << std::endl;
std::cout << "--- TMVAClassification : Using input bg file: " << input_bg->GetName() << std::endl;
// --- Register the training and test trees
TTree *signal = (TTree*)input_signal->Get("QGL_1");
TTree *bg = (TTree*)input_bg->Get("QGL_1");
// global event weights per tree (see below for setting event-wise weights)
Double_t signalWeight = 1.0;
Double_t bgWeight = 1.0;
// You can add an arbitrary number of signal or background trees
factory->AddSignalTree ( signal, signalWeight );
factory->AddBackgroundTree( bg, bgWeight );
TCut mycuts = ""; // for example: TCut mycuts = "abs(var1)<0.5 && abs(var2-0.5)<1";
TCut mycutb = ""; // for example: TCut mycutb = "abs(var1)<0.5";
// Tell the factory how to use the training and testing events
//
// If no numbers of events are given, half of the events in the tree are used
// for training, and the other half for testing:
// factory->PrepareTrainingAndTestTree( mycut, "SplitMode=random:!V" );
// To also specify the number of testing events, use:
// factory->PrepareTrainingAndTestTree( mycut,
// "NSigTrain=3000:NBkgTrain=3000:NSigTest=3000:NBkgTest=3000:SplitMode=Random:!V" );
factory->PrepareTrainingAndTestTree( mycuts, mycutb,
"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V" );
// ---- Book MVA methods
//
// Please lookup the various method configuration options in the corresponding cxx files, eg:
// src/MethoCuts.cxx, etc, or here: http://tmva.sourceforge.net/optionRef.html
// it is possible to preset ranges in the option string in which the cut optimisation should be done:
// "...:CutRangeMin[2]=-1:CutRangeMax[2]=1"...", where [2] is the third input variable
// Fisher discriminant (same as LD)
if (Use["Fisher"])
factory->BookMethod( TMVA::Types::kFisher, "Fisher", "H:!V:Fisher:VarTransform=None:CreateMVAPdfs:PDFInterpolMVAPdf=Spline2:NbinsMVAPdf=50:NsmoothMVAPdf=10" );
if (Use["MLPBNN"])
factory->BookMethod( TMVA::Types::kMLP, "MLPBNN", "H:!V:NeuronType=tanh:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5:TrainingMethod=BFGS:UseRegulator" ); // BFGS training with bayesian regulators
if (Use["BDTD"]) // Decorrelation + Adaptive Boost
factory->BookMethod( TMVA::Types::kBDT, "BDTD",
示例15: TMVATrainer
//.........这里部分代码省略.........
factory->AddVariable("TagVarCSV_vertexMass","TagVarCSV_vertexMass","units",'F');
factory->AddVariable("TagVarCSV_vertexNTracks","TagVarCSV_vertexNTracks","units",'F');
factory->AddVariable("TagVarCSV_vertexEnergyRatio","TagVarCSV_vertexEnergyRatio","units",'F');
factory->AddVariable("TagVarCSV_vertexJetDeltaR","TagVarCSV_vertexJetDeltaR","units",'F');
factory->AddVariable("TagVarCSV_flightDistance2dSig","TagVarCSV_flightDistance2dSig","units",'F');
//factory->AddVariable("TagVarCSV_flightDistance3dSig","TagVarCSV_flightDistance3dSig","units",'F');
// You can add so-called "Spectator variables", which are not used in the MVA training,
// but will appear in the final "TestTree" produced by TMVA. This TestTree will contain the
// input variables, the response values of all trained MVAs, and the spectator variables
factory->AddSpectator("Jet_pt","Jet_pt","units",'F');
factory->AddSpectator("Jet_eta","Jet_eta","units",'F');
factory->AddSpectator("Jet_phi","Jet_phi","units",'F');
factory->AddSpectator("Jet_mass","Jet_mass","units",'F');
factory->AddSpectator("Jet_massGroomed","Jet_massGroomed","units",'F');
factory->AddSpectator("Jet_flavour","Jet_flavour","units",'F');
factory->AddSpectator("Jet_nbHadrons","Jet_nbHadrons","units",'F');
factory->AddSpectator("Jet_JP","Jet_JP","units",'F');
factory->AddSpectator("Jet_JBP","Jet_JBP","units",'F');
factory->AddSpectator("Jet_CSV","Jet_CSV","units",'F');
factory->AddSpectator("Jet_CSVIVF","Jet_CSVIVF","units",'F');
factory->AddSpectator("Jet_tau1","Jet_tau1","units",'F');
factory->AddSpectator("Jet_tau2","Jet_tau2","units",'F');
factory->AddSpectator("SubJet1_CSVIVF","SubJet1_CSVIVF","units",'F');
factory->AddSpectator("SubJet2_CSVIVF","SubJet2_CSVIVF","units",'F');
// Read training and test data
// (it is also possible to use ASCII format as input -> see TMVA Users Guide)
TString fnameSig = "RadionToHH_4b_M-800_TuneZ2star_8TeV-Madgraph_pythia6_JetTaggingVariables_training.root";
TString fnameBkg = "QCD_Pt-300to470_TuneZ2star_8TeV_pythia6_JetTaggingVariables_training.root";
TFile *inputSig = TFile::Open( fnameSig );
TFile *inputBkg = TFile::Open( fnameBkg );
std::cout << "--- TMVAClassification : Using input files: " << inputSig->GetName() << std::endl
<< inputBkg->GetName() << std::endl;
// --- Register the training and test trees
TTree *sigTree = (TTree*)inputSig->Get("tagVars/ttree");
TTree *bkgTree = (TTree*)inputBkg->Get("tagVars/ttree");
// // global event weights per tree (see below for setting event-wise weights)
Double_t signalWeight = 1.0;
Double_t backgroundWeight = 1.0;
// factory->SetInputTrees( tree,signalCut,backgroundCut );
factory->AddSignalTree ( sigTree, signalWeight );
factory->AddBackgroundTree( bkgTree, backgroundWeight );
// Apply additional cuts on the signal and background samples (can be different)
TCut signalCut = "Jet_massGroomed>80 && Jet_massGroomed<150";
TCut backgroundCut = "abs(Jet_flavour)==5 && Jet_nbHadrons>1 && Jet_massGroomed>80 && Jet_massGroomed<150";
// Tell the factory how to use the training and testing events
factory->PrepareTrainingAndTestTree( signalCut, backgroundCut,
"nTrain_Signal=22000:nTest_Signal=20000:nTrain_Background=22000:nTest_Background=2730:SplitMode=Random:!V" );
// Gradient Boost
factory->BookMethod( TMVA::Types::kBDT, "BDTG_T1000D3_fat_BBvsGSP",
"!H:!V:NTrees=1000:MaxDepth=3:MinNodeSize=1.5%:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20" );
//factory->BookMethod( TMVA::Types::kBDT, "BDTG_T1000D5_fat_BBvsGSP",
// "!H:!V:NTrees=1000:MaxDepth=5:MinNodeSize=2.5%:BoostType=Grad:Shrinkage=0.10:UseBaggedBoost:BaggedSampleFraction=0.5:nCuts=20" );
// // Adaptive Boost
// factory->BookMethod( TMVA::Types::kBDT, "BDT",
// "!H:!V:NTrees=1000:MaxDepth=5:MinNodeSize=2.5%:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20" );
// // Bagging
// factory->BookMethod( TMVA::Types::kBDT, "BDTB",
// "!H:!V:NTrees=1000:MaxDepth=5:MinNodeSize=2.5%:BoostType=Bagging:SeparationType=GiniIndex:nCuts=20" );
// // Decorrelation + Adaptive Boost
// factory->BookMethod( TMVA::Types::kBDT, "BDTD",
// "!H:!V:NTrees=1000:MaxDepth=5:MinNodeSize=2.5%:BoostType=AdaBoost:AdaBoostBeta=0.5:SeparationType=GiniIndex:nCuts=20:VarTransform=Decorrelate" );
// ---- Now you can tell the factory to train, test, and evaluate the MVAs
// Train MVAs using the set of training events
factory->TrainAllMethods();
// ---- Evaluate all MVAs using the set of test events
factory->TestAllMethods();
// ----- Evaluate and compare performance of all configured MVAs
factory->EvaluateAllMethods();
// --------------------------------------------------------------
// Save the output
outputFile->Close();
std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
std::cout << "==> TMVAClassification is done!" << std::endl;
delete factory;
// Launch the GUI for the root macros
if (!gROOT->IsBatch()) TMVAGui( outfileName );
}