FairRoot/PandaRoot
run_pid_Mva.C
Go to the documentation of this file.
1 {
2  // ========================================================================
3  // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
4  Int_t iVerbose = 0;
5  Int_t nEvents = 0;
6  // ---- Load libraries -------------------------------------------------
7  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");
8  rootlogon();
9  TString sysFile = gSystem->Getenv("VMCWORKDIR");
10  // ------------------------------------------------------------------------
11  // Output file
12  TString parFile = "params_sttcombi.root";
13  TString inSimuFile = "points_sttcombi.root";
14  TString inDigiFile = "digi_sttcombi.root";
15  TString inRecoFile = "reco_sttcombi.root";
16 
17  TString outFile = "pid_sttcombi.root";
18 
19  // In general, the following parts need not be touched
20  // ========================================================================
21 
22  // ----- Timer --------------------------------------------------------
23  TStopwatch timer;
24  timer.Start();
25  // ------------------------------------------------------------------------
26 
27  // ----- Reconstruction run -------------------------------------------
28  FairRunAna *fRun= new FairRunAna();
29  fRun->SetInputFile(inSimuFile);
30  fRun->AddFriend(inDigiFile);
31  fRun->AddFriend(inRecoFile);
32  fRun->SetOutputFile(outFile.Data());
33  FairGeane *Geane = new FairGeane();
34  fRun->AddTask(Geane);
35  // ----- Parameter database --------------------------------------------
36  TString allDigiFile = sysFile+"/macro/params/all.par";
37 
38  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
39  FairParRootFileIo* parInput1 = new FairParRootFileIo();
40  parInput1->open(parFile.Data());
41 
42  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
43  parIo1->open(allDigiFile.Data(),"in");
44 
45  rtdb->setFirstInput(parInput1);
46  rtdb->setSecondInput(parIo1);
47  // ------------------------------------------------------------------------
48 
50  corr->SetVerbose(10);
51  corr->SetBarrelTrackBranch("SttMvdGemGenTrack");
52  corr->SetInputIDBranch("SttMvdGemGenTrackID");
53  //corr->SetForwardTrackBranch("FTSTrkIdeal");
54  //corr->SetInputIDBranch2("FTSTrkIdealID");
55  //corr->SetBarrelTrackBranch("SttMvdGenTrack");
56  corr->SetDebugMode(kTRUE);
57  //corr->SetFast(kTRUE);
58  fRun->AddTask(corr);
59 
60  // ----- Intialise and run --------------------------------------------
62 
64  std::vector<std::string> labels;
65  std::vector<std::string> vars;
66 
67  labels.push_back("electron");
68  labels.push_back("pion");
69 
70  vars.push_back("emc");
71  vars.push_back("lat");
72  vars.push_back("z20");
73  vars.push_back("z53");
74  vars.push_back("E9E25");
75 
77  // Set the path to the weightFiles; otherwise the standard
78  // path is used.
79  ts->SetWeightFileName("/tmp/test.root");
80 
81  // Set variable- and class-names.
82  ts->SetClassNames(labels);
83  ts->SetVarNames(vars);
84 
85  // Set classifiers type.
86  /*
87  * KNN, KNN methode.
88  * LVQ, LVQ methode.
89  * TMVA_MLP, Multi label TMVA ANN.
90  * TMVA_BDT, Multi label TMVA BDT.
91  * See PndPidMvaAssociatorTask.cxx
92  */
93  ts->SetClassifier(LVQ);
94 
95  // If KNN is selected, then set the number of neighbors.
96  ts->SetNumNeigh(250);
97 
98  //Add task
99  fRun->AddTask(ts);
100 
102  fRun->Init();
103  fRun->Run(0,nEvents);
104 
105  // ------------------------------------------------------------------------
106  rtdb->print();
107 
108  // ----- Finish -------------------------------------------------------
109  timer.Stop();
110  Double_t rtime = timer.RealTime();
111  Double_t ctime = timer.CpuTime();
112  cout << "\n\nMacro finished succesfully.\n"
113  << "Output file is " << outFile
114  << "\nParameter file is " << parFile
115  << "\nReal time " << rtime << " s, CPU time "
116  << ctime << " s.\n";
117  // ------------------------------------------------------------------------
118  exit(0);
119 }
PndPidCorrelator * corr
exit(0)
TString outFile
Definition: hit_dirc.C:17
TString inRecoFile
void SetBarrelTrackBranch(TString branch)
TString allDigiFile
Definition: hit_muo.C:36
TString inSimuFile
FairGeane * Geane
std::vector< std::string > labels
FairRunAna * fRun
Definition: hit_dirc.C:58
TString sysFile
void SetDebugMode(Bool_t debug)
Double_t
TString parFile
Definition: hit_dirc.C:14
Int_t nEvents
Definition: hit_dirc.C:11
TStopwatch timer
Definition: hit_dirc.C:51
TString vars[MAX]
Definition: autocutx.C:34
static void Init(Int_t MapVersion)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TString inDigiFile
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
Double_t ctime
Definition: hit_dirc.C:114
FairParAsciiFileIo * parIo1
Definition: bump_emc.C:53
void SetWeightFileName(std::string const &wFileName)
void SetClassifier(Mva_MethodType const &methodT)
void SetClassNames(std::vector< std::string > const &clNames)
Int_t iVerbose
Double_t rtime
Definition: hit_dirc.C:113
PndPidEmcAssociatorTask * ts
virtual void SetVarNames(std::vector< std::string > const &vNames)