FairRoot/PandaRoot
thailand2017/tut_ana_mclist.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 void tut_ana_mclist(int nevts = 0, TString prefix = "signal")
18 {
19  // *** some variables
20  int i=0,j=0, k=0, l=0;
21  gStyle->SetOptFit(1011);
22 
23  // *** Initialize FairRunAna with defaults
24  TString OutFile="out_dummy.root";
25  FairRunAna* fRun = initrun(prefix, OutFile);
26  fRun->Init();
27 
28  //
29  // Now the analysis stuff comes...
30  //
31 
32 
33  // *** the data reader object
34  PndAnalysis* theAnalysis = new PndAnalysis();
35  if (nevts==0) nevts= theAnalysis->GetEntries();
36 
37  // *** RhoCandLists for the analysis
38  RhoCandList mctruth;
39 
40  // ***
41  // the event loop
42  // ***
43  while (theAnalysis->GetEvent() && i++<nevts)
44  {
45  cout<<"****** Evt " << i << endl;
46 
47  // *** the MC Truth objects
48  theAnalysis->FillList(mctruth,"McTruth");
49 
50  //
51  // Print MC Truth list with mother-daughter relations
52  //
53  for (j=0;j<mctruth.GetLength();++j)
54  {
55  RhoCandidate *mcmother = mctruth[j]->TheMother();
56 
57  int muid = -1;
58  if (mcmother) muid = mcmother->GetTrackNumber();
59 
60  cout << "Track "<< mctruth[j]->GetTrackNumber()<<" (PDG:"<<mctruth[j]->PdgCode() <<") has mother "<<muid;
61 
62  if (mctruth[j]->NDaughters()>0) cout <<" and daughter(s) ";
63  for (k=0;k<mctruth[j]->NDaughters();++k) cout <<mctruth[j]->Daughter(k)->GetTrackNumber()<<" ";
64 
65  cout<<endl;
66  }
67  cout <<endl;
68  }
69 
70  // *** temporaty fix to avoid error on macro exit
72 }
Int_t GetEntries()
FairRunAna * initrun(TString prefix, TString outfile, int min=-1, int max=-1)
Definition: QA/auxi.C:32
Int_t GetTrackNumber() const
Definition: RhoCandidate.h:417
Int_t i
Definition: run_full.C:25
void RemoveGeoManager()
Definition: auxtut.C:11
Int_t GetLength() const
Definition: RhoCandList.h:46
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
FairRunAna * fRun
Definition: hit_dirc.C:58
PndAnalysis(TString tname1="", TString tname2="", TString algnamec="PidAlgoIdealCharged", TString algnamen="PidAlgoIdealNeutral")
Definition: PndAnalysis.cxx:48
void tut_ana_mclist(int nevts=0, TString prefix="signal")
Int_t GetEvent(Int_t n=-1)