FairRoot/PandaRoot
ana_jpsi.C
Go to the documentation of this file.
1 int ana_jpsi(TString InFile="test_fast.root", int nevts=0, double pbarmom = 6.231552)
2 {
3  // *** some variables
4  int i=0,j=0, k=0, l=0;
5  gStyle->SetOptFit(1011);
6 
7  if (!InFile.EndsWith(".root")) InFile+="_fast.root";
8 
9  // *** the output file for FairRunAna
10  TString OutFile="dummy_out.root";
11 
12  // *** initialization
13  FairLogger::GetLogger()->SetLogToFile(kFALSE);
14 
15  FairRunAna* fRun = new FairRunAna();
16  fRun->SetGenerateRunInfo(kFALSE);
17  fRun->SetInputFile(InFile);
18  fRun->SetOutputFile(OutFile); // only dummy; the real output is
19 
20  fRun->Init();
21 
22  // *** take constant field; needed for PocaVtx
24 
25  // *** create an output file for all histograms
26  TFile *out = TFile::Open(InFile+"_ana.root","RECREATE");
27 
28  // *** create some ntuples
29  RhoTuple *ntp1 = new RhoTuple("ntp1", "jpsi analysis");
30  RhoTuple *ntp2 = new RhoTuple("ntp2", "psi(2S) analysis");
31  RhoTuple *nmc = new RhoTuple("nmc", "mctruth info");
32 
33  //
34  // Now the analysis stuff comes...
35  //
36 
37  // *** the data reader object
38  PndAnalysis* theAnalysis = new PndAnalysis();
39  if (nevts==0) nevts= theAnalysis->GetEntries();
40 
41  // *** name of the only PidAlgo TClonesArray in fsim
42  TString pidalg = "PidChargedProbability";
43 
44  // *** QA tool for simple dumping of analysis results in RhoRuple
45  // *** WIKI: https://panda-wiki.gsi.de/foswiki/bin/view/Computing/PandaRootAnalysisJuly13#PndRhoTupleQA
46  PndRhoTupleQA qa(theAnalysis, pbarmom);
47 
48  // *** RhoCandLists for the analysis
49  RhoCandList muplus, muminus, piplus, piminus, jpsi, psi2s, all, mclist;
50 
51  // *** Mass selector for the jpsi cands
52  double m0_jpsi = TDatabasePDG::Instance()->GetParticle("J/psi")->Mass(); // Get nominal PDG mass of the J/psi
53  RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",m0_jpsi,1.0);
54 
55  // *** the lorentz vector of the initial psi(2S)
56  double m0_p = TDatabasePDG::Instance()->GetParticle("proton")->Mass(); // Get nominal PDG mass of the proton
57  TLorentzVector ini(0, 0, pbarmom, sqrt(m0_p*m0_p + pbarmom*pbarmom) + m0_p);
58 
59  // ***
60  // the event loop
61  // ***
62 
63  while (theAnalysis->GetEvent() && i++<nevts)
64  {
65  if ((i%100)==0) cout<<"evt " << i << endl;
66 
67  // *** get MC list and store info in ntuple
68  theAnalysis->FillList(mclist, "McTruth");
69 
70  nmc->Column("ev", (Int_t) i);
71  qa.qaMcList("", mclist, nmc);
72  nmc->DumpData();
73 
74 
75  // *** Setup event shape object
76  theAnalysis->FillList(all, "All", pidalg);
77  PndEventShape evsh(all, ini, 0.05, 0.1);
78 
79 
80  // *** Select with no PID info ('All'); type and mass are set
81  theAnalysis->FillList(muplus, "MuonAllPlus", pidalg);
82  theAnalysis->FillList(muminus, "MuonAllMinus", pidalg);
83  theAnalysis->FillList(piplus, "PionAllPlus", pidalg);
84  theAnalysis->FillList(piminus, "PionAllMinus", pidalg);
85 
86 
87  // *****
88  // *** combinatorics for J/psi -> mu+ mu-
89  // *****
90 
91  jpsi.Combine(muplus, muminus);
92  jpsi.SetType(443);
93  int njmct = theAnalysis->McTruthMatch(jpsi);
94 
95  for (j=0;j<jpsi.GetLength();++j)
96  {
97  // some general info about event (actually written for each candidate!)
98  ntp1->Column("ev", (Float_t) i);
99  ntp1->Column("cand", (Float_t) j);
100  ntp1->Column("ncand", (Float_t) jpsi.GetLength());
101  ntp1->Column("nmct", (Float_t) njmct);
102 
103  // store info about initial 4-vector
104  qa.qaP4("beam", ini, ntp1);
105 
106  // store information about composite candidate tree recursively (see analysis/AnalysisTools/PndRhoTupleQA)
107  qa.qaComp("j", jpsi[j], ntp1);
108 
109  // store info about event shapes
110  qa.qaEventShapeShort("es",&evsh, ntp1);
111 
112 
113  // store the 4-vector of the truth matched candidate (or a dummy, if not matched to keep ntuple consistent)
114  RhoCandidate *truth = jpsi[j]->GetMcTruth();
115  TLorentzVector lv;
116  if (truth) lv = truth->P4();
117  qa.qaP4("trj", lv, ntp1);
118 
119  ntp1->DumpData();
120  }
121 
122 
123  // *****
124  // *** combinatorics for psi(2S) -> J/psi pi+ pi-
125  // *****
126 
127  // *** some rough mass selection on J/psi before
128  jpsi.Select(jpsiMassSel);
129 
130  psi2s.Combine(jpsi, piplus, piminus);
131  psi2s.SetType(100443);
132  int npsimct = theAnalysis->McTruthMatch(psi2s);
133 
134  for (j=0;j<psi2s.GetLength();++j)
135  {
136  // some general info about event (actually written for each candidate!)
137  ntp2->Column("ev", (Float_t) i);
138  ntp2->Column("cand", (Float_t) j);
139  ntp2->Column("ncand", (Float_t) psi2s.GetLength());
140  ntp2->Column("nmct", (Float_t) npsimct);
141 
142  RhoKinFitter kinfit(psi2s[j]);
143  kinfit.Add4MomConstraint(ini);
144  kinfit.Fit();
145 
146  RhoCandidate *psifit=psi2s[j]->GetFit();
147 
148  // store info about initial 4-vector
149  qa.qaP4("beam", ini, ntp2);
150 
151  // store information about composite candidate tree recursively (see analysis/AnalysisTools/PndRhoTupleQA)
152  qa.qaComp("psi", psi2s[j], ntp2);
153  qa.qaComp("fpsi",psifit, ntp2);
154 
155  // store info about event shapes
156  qa.qaEventShapeShort("es",&evsh, ntp2);
157 
158  // *** store the 4-vector of the truth matched candidate (or a dummy, if not matched to keep ntuple consistent)
159  RhoCandidate *truth = psi2s[j]->GetMcTruth();
160  TLorentzVector lv;
161  if (truth) lv = truth->P4();
162  qa.qaP4("trpsi", lv, ntp2);
163 
164  ntp2->DumpData();
165  }
166  }
167 
168  // *** write out all the histos
169  out->cd();
170 
171  ntp1->GetInternalTree()->Write();
172  ntp2->GetInternalTree()->Write();
173  nmc->GetInternalTree()->Write();
174 
175  out->Save();
176 
177  return 0;
178 }
Int_t GetEntries()
CandList mclist
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Int_t GetLength() const
Definition: RhoCandList.h:46
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
CandList piplus
void qaP4(TString pre, TLorentzVector c, RhoTuple *n, bool skip=false)
void Add4MomConstraint(TLorentzVector lv)
int ana_jpsi(TString InFile="test_fast.root", int nevts=0, double pbarmom=6.231552)
Definition: ana_jpsi.C:1
void qaMcList(TString pre, RhoCandList &l, RhoTuple *n, int max=10000)
static void ForceConstantBz(Double_t bz=0.)
Force a constant B field value for all positions.
FairRunAna * fRun
Definition: hit_dirc.C:58
CandList muplus
void Combine(RhoCandList &l1, RhoCandList &l2)
void qaComp(TString pre, RhoCandidate *c, RhoTuple *n, bool covs=false, bool pulls=false)
void Select(RhoParticleSelectorBase *pidmgr)
TLorentzVector P4() const
Definition: RhoCandidate.h:195
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
void qaEventShapeShort(TString pre, PndEventShape *evsh, RhoTuple *n)
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)
Bool_t Fit()
CandList muminus