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,
"AnalysisType=Regression");
36 factory->AddRegressionTree(signalTree,1.0);
37 factory->AddVariable(
"track1_pt",
'F');
38 factory->AddVariable(
"track2_pt",
'F');
39 factory->AddVariable(
"track1_phi",
'F');
40 factory->AddVariable(
"track1_phi-track2_phi",
"d#phi",
"rad");
41 factory->AddVariable(
"track1_eta",
'F');
42 factory->AddVariable(
"track1_eta-track2_eta",
"d#eta",
"rad");
43 factory->AddVariable(
"(vtx_radius)/(track_layer+1)",
'F');
44 factory->AddVariable(
"vtx_radius",
"radius",
"cm");
45 factory->AddTarget(
"tvtx_radius",
"radius",
"cm");
47 string track_pT_cut =
"track1_pt>.6&&track2_pt>.6";
50 string tCutInitializer = track_pT_cut;
51 TCut preTraingCuts(tCutInitializer.c_str());
52 factory->PrepareTrainingAndTestTree(preTraingCuts,
"nTrain_Regression=0:nTest_Regression=0");
53 factory->BookMethod(Types::kKNN,
"kNN14L",
"VarTransform=G:nkNN=16");
54 factory->BookMethod(Types::kKNN,
"kNN12L",
"VarTransform=G:nkNN=8");
60 factory->TrainAllMethods();
61 factory->TestAllMethods();
62 factory->EvaluateAllMethods();
70 string treePath =
"/sphenix/user/vassalli/gammasample/conversionembededonlineanalysis";
71 string treeExtension =
".root";
72 string outname =
"/direct/phenix+u/vassalli/sphenix/single/Training/condorout/vtxTrainRS.root";
73 unsigned int nFiles=200;
75 TChain *signalTree =
handleFile(treePath,treeExtension,
"vtxingTree",nFiles);