FairRoot/PandaRoot
Functions
thailand2017/tut_ana_mcmatch.C File Reference
#include "auxtut.C"

Go to the source code of this file.

Functions

void tut_ana_mcmatch (int nevts=0, TString prefix="signal")
 

Function Documentation

void tut_ana_mcmatch ( int  nevts = 0,
TString  prefix = "signal" 
)

Definition at line 17 of file thailand2017/tut_ana_mcmatch.C.

References RhoCandList::Combine(), else, PndAnalysis::FillList(), fRun, PndAnalysis::GetEntries(), PndAnalysis::GetEvent(), RhoCandList::GetLength(), i, initrun(), PndAnalysis::McTruthMatch(), muminus, muplus, out, piminus, piplus, plotmyhistos(), PndAnalysis::PndAnalysis(), RemoveGeoManager(), RhoCandList::Select(), TString, and writemyhistos().

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  // *** create an output file for all histograms
29  TFile *out = TFile::Open(prefix+"_ana_mcmatch.root","RECREATE");
30 
31  // #### EXERCISE: create some histograms
32  TH1F *hjpsim_all = new TH1F("hjpsim_all","J/#psi mass",200,0,4.5);
33  TH1F *hjpsim_ftm = new TH1F("hjpsim_ftm","J/#psi mass (full truth match)",200,0,4.5);
34  // ...
35 
36  // ------------------------------
37  // Now the analysis stuff comes...
38  // ------------------------------
39 
40 
41  // *** the data reader object
42  PndAnalysis* theAnalysis = new PndAnalysis();
43  if (nevts==0) nevts= theAnalysis->GetEntries();
44 
45  // *** RhoCandLists for the analysis
46  RhoCandList muplus, muminus, piplus, piminus, jpsi, pbarp;
47 
48  // *** Mass selector for the jpsi cands
49  RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",3.096,1.0);
50 
51  // ***
52  // the event loop
53  // ***
54  while (theAnalysis->GetEvent() && i++<nevts)
55  {
56  if ((i%100)==0) cout<<"evt " << i << endl;
57 
58  // #### EXERCISE: Select with no PID info ('All'); type and mass are set
59  theAnalysis->FillList(muplus, "MuonAllPlus");
60  // ...
61 
62  // *** combinatorics for J/psi -> mu+ mu-, AND specify PDG type as last parameter!
63  jpsi.Combine(muplus, muminus, 443);
64 
65  // *** do the TRUTH MATCH for jpsi
66 
67  for (j=0;j<jpsi.GetLength();++j)
68  {
69  // *** fill mass in histogram
70  hjpsim_all->Fill( jpsi[j]->M() );
71 
72  // #### EXERCISE: fill mass in histogram for truth match candidates
73  if (theAnalysis->McTruthMatch(jpsi[j]))
74  {
75  //hjpsim_ftm->Fill(...
76  }
77  // #### EXERCISE: fill mass in histogram for non match candidates
78  else ;
79  //...->Fill( ...
80  }
81 
82  // *** some rough mass selection
83  jpsi.Select(jpsiMassSel);
84 
85  // #### EXERCISE: combinatorics for pbarpSystem (PDG=88888) -> J/psi pi+ pi-
86  // pbarp.Combine(...
87 
88  // *** do the TRUTH MATCH for pbarpSystem (PDG == 88888)
89 
90  for (j=0;j<pbarp.GetLength();++j)
91  {
92  // #### EXERCISE: fill histos for pbarp candidates with and w/o MC truth match
93 
94  }
95  }
96 
97  // *** change to directory where histograms are created
98  out->cd();
99 
100  // *** plot all histos
101  plotmyhistos();
102 
103  // *** write out all the histos to file
104  int nhist = writemyhistos();
105  cout<<"Writing "<<nhist<<" histograms to file"<<endl;
106  out->Save();
107 
108  // *** temporaty fix to avoid error on macro exit
110 }
Int_t GetEntries()
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
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
CandList piplus
FairRunAna * fRun
Definition: hit_dirc.C:58
CandList muplus
void Combine(RhoCandList &l1, RhoCandList &l2)
void Select(RhoParticleSelectorBase *pidmgr)
TFile * out
Definition: reco_muo.C:20
CandList piminus
Bool_t McTruthMatch(RhoCandidate *cand, Int_t level=2, bool verbose=false)
Int_t GetEvent(Int_t n=-1)
CandList muminus
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