FairRoot/PandaRoot
thailand2017/tut_ana.C
Go to the documentation of this file.
1 class RhoCandList;
2 class RhoCandidate;
5 class PndAnalysis;
6 
7 // **** some auxilliary functions in auxtut.C ****
8 // - FairRunAna* initrun(TString prefix, TString outfile, int min=-1, int max=-1) --> Init FairRunAna
9 // - plotmyhistos() --> Plots all histograms in current TDirectory on a autosized canvas
10 // - writemyhistos() --> Writes all histos in current TFile
11 // - fillM(RhoCandList l, TH1* h) --> Fill mass histogram h with masses of candidates in l
12 // - RemoveGeoManager() --> Temporary fix for error on macro exit
13 // **** some auxilliary functions in auxtut.C ****
14 #include "auxtut.C"
15 
16 
17 // *** routine to only keep PID matched candidates in list
19 
20 void tut_ana(int nevts = 0, TString prefix = "signal")
21 {
22  // *** some variables
23  int i=0,j=0, k=0, l=0;
24  gStyle->SetOptFit(1011);
25 
26  // *** Initialize FairRunAna with defaults
27  TString OutFile="out_dummy.root";
28  FairRunAna* fRun = initrun(prefix, OutFile);
29  fRun->Init();
30 
31  // *** create an output file for all histograms
32  TFile *out = TFile::Open(prefix+"_ana.root","RECREATE");
33 
34  // ------------------------------
35  // Now the analysis stuff comes...
36  // ------------------------------
37 
38  // *** the data reader object
39  PndAnalysis* theAnalysis = new PndAnalysis();
40  if (nevts==0) nevts= theAnalysis->GetEntries();
41 
42  // ---------------------------------------------------------------------
43  // ---------------------------------------------------------------------
44  // ---------------------------------------------------------------------
45  // This macro combines all tasks (combinatorics, MC truth, PID, fitting)
46  // try to complete everything, perhaps for a different decay mode
47  // ---------------------------------------------------------------------
48  // ---------------------------------------------------------------------
49  // ---------------------------------------------------------------------
50 
51  // #### EXERCISE: create all necessary histograms
52  // ...
53 
54  // #### EXERCISE: create RhoCandLists for the analysis, mass selector, etc...
55 
56  // ***
57  // the event loop
58  // ***
59  while (theAnalysis->GetEvent() && i++<nevts)
60  {
61  // #### EXERCISE
62  // (1) combinatorics with desired PID algorithms and tightness, and PDG set for truth match
63  // (2) select rought mass window for resonances
64  // (3) do vertex fitting for resonances to charged particles
65  // (4) fill final histograms, with and without truth match
66  }
67 
68  // *** change to directory where histograms are created
69  out->cd();
70 
71  // *** plot all histos
72  plotmyhistos();
73 
74  // *** write out all the histos to file
75  int nhist = writemyhistos();
76  cout<<"Writing "<<nhist<<" histograms to file"<<endl;
77  out->Save();
78 
79  // *** temporaty fix to avoid error on macro exit
81 }
82 
84 {
85  int removed = 0;
86 
87  for (int ii=l.GetLength()-1;ii>=0;--ii)
88  {
89  if ( !(ana->McTruthMatch(l[ii])) )
90  {
91  l.Remove(l[ii]);
92  removed++;
93  }
94  }
95 
96  return removed;
97 }
98 
99 
Int_t GetEntries()
int SelectTruePid(PndAnalysis *ana, RhoCandList &l)
FairRunAna * initrun(TString prefix, TString outfile, int min=-1, int max=-1)
Definition: QA/auxi.C:32
Int_t i
Definition: run_full.C:25
void RemoveGeoManager()
Definition: auxtut.C:11
Int_t GetLength() const
Definition: RhoCandList.h:46
void tut_ana(TString pref="pid_complete.root", int min=-1, int max=1, int nevts=0)
Definition: dec13/tut_ana.C:33
FairRunAna * fRun
Definition: hit_dirc.C:58
PndAnalysis(TString tname1="", TString tname2="", TString algnamec="PidAlgoIdealCharged", TString algnamen="PidAlgoIdealNeutral")
Definition: PndAnalysis.cxx:48
TFile * out
Definition: reco_muo.C:20
Int_t Remove(RhoCandidate *)
Bool_t McTruthMatch(RhoCandidate *cand, Int_t level=2, bool verbose=false)
Int_t GetEvent(Int_t n=-1)
int writemyhistos(int maxy=800, double asp=1.1)
Definition: QA/auxi.C:121
void plotmyhistos(std::vector< TH1 * > h, int maxy=700, double asp=1.1)
Definition: QA/auxi.C:62