7 #if not defined(__CINT__) || defined(__MAKECINT__)
9 #include "TMVA/Factory.h"
10 #include "TMVA/Tools.h"
16 TChain *all =
new TChain(treename.c_str());
18 for (
int i = 0;
i < filecount; ++
i)
23 temp = name+
string(s.str())+extension;
24 all->Add(temp.c_str());
33 TString jobname(factoryname.c_str());
34 TFile *targetFile =
new TFile(outfile.c_str(),
"RECREATE");
35 Factory *factory =
new Factory(jobname,targetFile,
"Correlations=True");
36 DataLoader *
loader =
new DataLoader();
37 loader->AddSignalTree(signalTree,1.0);
38 loader->AddBackgroundTree(backTree,1.0);
40 loader->AddBackgroundTree(bgTree2,1.0);
42 loader->AddVariable(
"track_deta",
'F');
45 loader->AddVariable(
"track_pT",
'F');
47 loader->AddVariable(
"approach_dist",
'F');
48 loader->AddVariable(
"vtx_radius",
'F');
49 loader->AddVariable(
"vtx_chi2",
'F');
54 loader->AddVariable(
"cluster_prob",
'F');
56 string track_pT_cut =
"track_pT>0";
57 string vtx_radius_cut =
"vtx_radius>0";
58 string em_prob_cut =
"cluster_prob>=0";
60 string dist_cuts =
"vtxTrackRZ_dist>=0&&vtxTrackRPhi_dist>=0&&approach_dist>=0";
62 string tCutInitializer = em_prob_cut+
"&&"+ vtx_radius_cut+
"&&"+track_pT_cut+
"&&"+dist_cuts;
63 TCut preTraingCuts(tCutInitializer.c_str());
66 loader->PrepareTrainingAndTestTree(preTraingCuts,
"nTrain_Signal=0:nTrain_Background=0:nTest_Signal=0:nTest_Background=0");
67 factory->BookMethod(
loader,TMVA::Types::kLikelihood,
"LikelihoodD",
68 "!H:!V:!TransformOutput:PDFInterpol=Spline2:NSmoothSig[0]=20:NSmoothBkg[0]=20:NSmooth=5:NAvEvtPerBin=50:VarTransform=Decorrelate" );
69 factory->BookMethod(
loader,Types::kCuts,
"Cuts",
"");
82 factory->TrainAllMethods();
83 factory->TestAllMethods();
84 factory->EvaluateAllMethods();
92 string treePath =
"/sphenix/user/vassalli/gammasample/conversiononlineanalysis";
93 string treeExtension =
".root";
94 string outname =
"cutTrainA.root";
95 unsigned int nFiles=200;
97 TChain *signalTree =
handleFile(treePath,treeExtension,
"cutTreeSignal",nFiles);
98 TChain *backHTree =
handleFile(treePath,treeExtension,
"cutTreeBackh",nFiles);
99 TChain *backETree =
handleFile(treePath,treeExtension,
"cutTreeBacke",nFiles);
100 makeFactory(signalTree,backHTree,outname,
"aback",backETree);