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

Go to the source code of this file.

Functions

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

Function Documentation

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

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

References RhoKinFitter::Add4MomConstraint(), RhoKinFitter::AddMassConstraint(), RhoTuple::Column(), RhoCandList::Combine(), RhoCandidate::Daughter(), RhoTuple::DumpData(), f, PndAnalysis::FillList(), RhoKinFitter::Fit(), RhoFitterBase::Fit(), fRun, RhoFitterBase::GetChi2(), PndAnalysis::GetEntries(), PndAnalysis::GetEvent(), RhoTuple::GetInternalTree(), RhoCandList::GetLength(), RhoFitterBase::GetProb(), RhoCandidate::GetRecoCandidate(), i, initrun(), PndAnalysis::McTruthMatch(), muminus, mup, muplus, out, P, piminus, piplus, RhoCandidate::Pos(), RemoveGeoManager(), RhoTuple::RhoTuple(), RhoCandList::SetType(), and TString.

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_ntp.root","RECREATE");
30 
31  // *** create ntuples for J/psi and psi(2S)
32  RhoTuple *njpsi = new RhoTuple("njpsi","J/psi Analysis");
33  RhoTuple *npsip = new RhoTuple("npsip","psi' Analysis");
34 
35  // *** create some columns which might not be filled sometimes
36  njpsi->Column("tjpsim", 0.0f, -999.9f);
37  njpsi->Column("tjpsip", 0.0f, -999.9f);
38  njpsi->Column("tjpsitht", 0.0f, -999.9f);
39 
40  npsip->Column("tpsim", 0.0f, -999.9f);
41  npsip->Column("tpsip", 0.0f, -999.9f);
42  npsip->Column("tpsitht", 0.0f, -999.9f);
43 
44  //
45  // Now the analysis stuff comes...
46  //
47 
48  // *** the data reader object
49  PndAnalysis* theAnalysis = new PndAnalysis();
50  if (nevts==0) nevts= theAnalysis->GetEntries();
51 
52  // *** RhoCandLists for the analysis
53  RhoCandList muplus, muminus, piplus, piminus, jpsi, psi2s, allpart;
54 
55  // *** Mass selector for the jpsi cands
56  double m0_jpsi = TDatabasePDG::Instance()->GetParticle("J/psi")->Mass(); // Get nominal PDG mass of the J/psi
57  RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",m0_jpsi,1.0);
58 
59  // *** Pid Selection Algorithms
60  TString pidSelection = "PidAlgoEmcBayes;PidAlgoDrc;PidAlgoDisc;PidAlgoStt;PidAlgoMdtHardCuts";
61 
62  // *** the lorentz vector of the initial psi(2S)
63  TLorentzVector ini(0, 0, 6.231552, 7.240065);
64 
65  // *** the QA tool for easy ntuple output
66  PndRhoTupleQA qa(theAnalysis,ini.P());
67 
68 
69  // ***
70  // the event loop
71  // ***
72  while (theAnalysis->GetEvent() && i++<nevts)
73  {
74  if ((i%100)==0) cout<<"evt " << i << endl;
75 
76  // *** Select with no PID info ('All'); type and mass are set
77  theAnalysis->FillList(muplus, "MuonAllPlus", pidSelection);
78  theAnalysis->FillList(muminus, "MuonAllMinus", pidSelection);
79  theAnalysis->FillList(piplus, "PionAllPlus", pidSelection);
80  theAnalysis->FillList(piminus, "PionAllMinus", pidSelection);
81 
82  // *** prepare PndEventShape
83  theAnalysis->FillList(allpart, "All", pidSelection);
84  PndEventShape evtsh(allpart, ini, 0.05, 0.1);
85 
86  // *** combinatorics for J/psi -> mu+ mu-
87  jpsi.Combine(muplus, muminus);
88  jpsi.SetType(443);
89 
90  // *** some mass pre selection
91  //jpsi.Select(jpsiMassSel);
92 
93  // ***
94  // *** do all kind of analysis and store in N-tuple
95  // ***
96  for (j=0;j<jpsi.GetLength();++j)
97  {
98  // get daughters
99  RhoCandidate *mup = jpsi[j]->Daughter(0);
100  RhoCandidate *mum = jpsi[j]->Daughter(1);
103 
104  // get truth information
105  bool mct = theAnalysis->McTruthMatch(jpsi[j]);
106  RhoCandidate *true_jpsi = jpsi[j]->GetMcTruth();
107 
108  // perform vertex fitter
109  RhoKinVtxFitter vtxfitter(jpsi[j]); // instantiate a vertex fitter
110  vtxfitter.Fit();
111 
112  RhoCandidate *fitvtx_jpsi = jpsi[j]->GetFit();
113  double chi2_vtx = vtxfitter.GetChi2(); // access chi2 of fit
114  double prob_vtx = vtxfitter.GetProb(); // access probability of fit
115  TVector3 vtxpos(-999.,-999.,-999.);
116  if (fitvtx_jpsi) vtxpos = fitvtx_jpsi->Daughter(0)->Pos();
117 
118  // perform mass fit
119  RhoKinFitter mfitter(jpsi[j]); // instantiate the RhoKinFitter in psi(2S)
120  mfitter.AddMassConstraint(m0_jpsi); // add the mass constraint
121  mfitter.Fit(); // do fit
122 
123  RhoCandidate *fitmass_jpsi = jpsi[j]->GetFit();
124  double chi2_mass = mfitter.GetChi2(); // get chi2 of fit
125  double prob_mass = mfitter.GetProb(); // access probability of fit
126 
127  // #### EXERCISE: now write ntuple information
128 
129  // *** general event info
130  njpsi->Column("ev", (Float_t) i, -999.9f);
131  njpsi->Column("cand", (Float_t) j, -999.9f);
132 
133  // *** basic J/psi info
134  njpsi->Column("jpsim", (Float_t) jpsi[j]->M(), -999.9f);
135  njpsi->Column("jpsip", (Float_t) jpsi[j]->P(), -999.9f);
136  njpsi->Column("jpsipt", (Float_t) jpsi[j]->P3().Pt(), -999.9f);
137  // ...
138  // #### EXERCISE: you can also use PndRhoTupleQA instead
139  //
140 
141  // *** MC truth info
142  njpsi->Column("mct", (Float_t) mct, -999.9f);
143  if (true_jpsi)
144  {
145  // ...
146 
147  }
148 
149  // *** fitting info
150  // ...
151 
152  // *** kinematic info of daughters
153  // ...
154 
155  // *** PID info of daughters
156  // ...
157 
158  // *** and finally FILL Ntuple
159  njpsi->DumpData();
160 
161  }
162 
163  // *** combinatorics for psi(2S) -> J/psi pi+ pi-
164  psi2s.Combine(jpsi, piplus, piminus);
165  psi2s.SetType(88888);
166 
167  for (j=0;j<psi2s.GetLength();++j)
168  {
169  // get daughters
170  RhoCandidate *jp = psi2s[j]->Daughter(0);
171  RhoCandidate *pip = psi2s[j]->Daughter(1);
172  RhoCandidate *pim = psi2s[j]->Daughter(2);
173  RhoCandidate *mup = psi2s[j]->Daughter(0)->Daughter(0);
174  RhoCandidate *mum = psi2s[j]->Daughter(0)->Daughter(1);
175 
178 
179  // get truth information
180  bool mct = theAnalysis->McTruthMatch(psi2s[j]);
181  RhoCandidate *true_psi = psi2s[j]->GetMcTruth();
182 
183  // do 4C fit
184  RhoKinFitter fitter(psi2s[j]); // instantiate the kin fitter in psi(2S)
185  fitter.Add4MomConstraint(ini); // set 4 constraint
186  fitter.Fit(); // do fit
187  RhoCandidate *fit4c_jpsi = psi2s[j]->Daughter(0)->GetFit(); // get fitted J/psi
188 
189  double chi2_4c = fitter.GetChi2(); // get chi2 of fit
190  double prob_4c = fitter.GetProb(); // access probability of fit
191 
192  // #### EXERCISE: now write ntuple information
193  // #### EXERCISE: you can also use PndRhoTupleQA
194 
195  // *** general event info
196  // ...
197 
198  // *** basic psi(2s) info
199  // qa.qaCand(...
200 
201  // *** basic J/psi info
202  // ...
203 
204  // *** MC truth info
205  if (true_psi)
206  {
207  }
208 
209  // *** kinematic info of daughters
210  // ...
211 
212  // *** PID info of daughters
213  // qa.qaPid(...
214 
215  // *** Event shape info
216  // qa.qaEventShape(...
217 
218  // *** and finally FILL Ntuple
219  npsip->DumpData();
220  }
221 
222  }
223 
224  // *** write out all the histos
225  out->cd();
226 
227  njpsi->GetInternalTree()->Write();
228  npsip->GetInternalTree()->Write();
229 
230  out->Save();
231 
232  // *** temporaty fix to avoid error on macro exit
234 }
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
TVector3 Pos() const
Definition: RhoCandidate.h:186
Int_t GetLength() const
Definition: RhoCandList.h:46
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
PndPidCandidate * GetRecoCandidate() const
Definition: RhoCandidate.h:376
RhoCandidate * Daughter(Int_t n)
CandList piplus
FairRunAna * fRun
Definition: hit_dirc.C:58
CandList muplus
void Combine(RhoCandList &l1, RhoCandList &l2)
TFile * f
Definition: bump_analys.C:12
void Column(const char *label, Bool_t value, Bool_t defval=0, const char *block=0)
Definition: RhoTuple.cxx:56
void SetType(const TParticlePDG *pdt, int start=0)
TFile * out
Definition: reco_muo.C:20
void DumpData()
Definition: RhoTuple.cxx:391
GeV c P
CandList piminus
TTree * GetInternalTree()
Definition: RhoTuple.h:207
Bool_t McTruthMatch(RhoCandidate *cand, Int_t level=2, bool verbose=false)
Int_t GetEvent(Int_t n=-1)
CandList muminus
static const double mup
Definition: mzparameters.h:21