FairRoot/PandaRoot
QAmacro_fastsim_2.C
Go to the documentation of this file.
1 #include "TFile.h"
2 #include "TH1F.h"
3 #include "TH2F.h"
4 #include "TCanvas.h"
5 #include "TStopwatch.h"
6 #include "TROOT.h"
7 #include "TSystem.h"
8 #include "TTree.h"
9 #include "TString.h"
10 #include "../auxi.C"
11 
12 void printCand(TLorentzVector l, TVector3 p)
13 {
14  cout <<"vtx("<<p.X()<<"/"<<p.Y()<<"/"<<p.Z()<<") p4("<<l.Px()<<"/"<<l.Py()<<"/"<<l.Pz()<<")="<<l.Vect().Mag()<<endl;
15 }
16 
17 int QAmacro_fastsim_2(int nevts=0)
18 {
19  TStopwatch timer;
20  timer.Start();
21 
22  FairLogger::GetLogger()->SetLogToFile ( kFALSE );
23 
24  // *** initialization
25  FairRunAna* fRun = new FairRunAna();
26  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
27  fRun->SetInputFile ( "sim_fast.root" );
28  fRun->SetOutputFile ( "dummyout.root" );
29 
30  FairParRootFileIo* parIO = new FairParRootFileIo();
31  parIO->open ( "dummypar.root" );
32  rtdb->setFirstInput ( parIO );
33  rtdb->setOutput ( parIO );
34 
35  fRun->Init();
36 
37  PndAnalysis* theAnalysis = new PndAnalysis ( "SttMvdGemGenTrack" , "FtsIdealGenTrack", "PidChargedProbability", "PidNeutralProbability" );
38 
39  // adding particles from our decay which are not present in the particle table
40  if ( nevts==0 ) nevts= theAnalysis->GetEntries();
41 
42  // **** create and setup some histos for QA plots
43  //
44  TH1F *jpsimass = new TH1F("jpsimass","J/psi cands",100,3.1-0.3,3.1+0.3);
45  TH1F *jpsi2mass = new TH1F("jpsi2mass","J/psi cands 4C fit",100,3.1-0.3,3.1+0.3);
46 
47  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,3.68598-0.3,3.68598+0.3);
48  TH1F *pp2mass = new TH1F("pp2mass","pbarp fitted",100,3.68598-0.02,3.68598+0.02);
49 
50  // **** create all the particle lists we'll need for rebuilding the decay tree
51  //
52  RhoCandList pip, pim, ep, em;
53  RhoCandList jpsi,pp;
54 
55  RhoMassParticleSelector *jpsiMSel = new RhoMassParticleSelector("jpsiSelector" , 3.096 , 0.3);
56 
57  TLorentzVector ini(0,0,6.23164,7.24015);
58 
59  int i=0,j=0;
60 
61  // **** loop over all _events_
62  //
63  while ( theAnalysis->GetEvent() && i++<nevts )
64  {
65  if (!(i%100))
66  cout <<"evt "<<i<<endl;
67 
68  //cout<<"e mass:" <<TRho::Instance()->GetPDG()->GetParticle(11)->Mass()<<endl;
69 
70  theAnalysis->FillList(pip,"PionVeryLoosePlus","PidChargedProbability");
71  theAnalysis->FillList(pim,"PionVeryLooseMinus","PidChargedProbability");
72  theAnalysis->FillList(ep, "ElectronVeryLoosePlus","PidChargedProbability");
73  theAnalysis->FillList(em, "ElectronVeryLooseMinus","PidChargedProbability");
74 
75 /* for (j=0;j<ep.GetLength();++j)
76  {
77  ep[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(11)->Mass());
78  cout <<"e: "<<ep[j].Uid()<<" ";
79 
80  }
81  cout <<endl;
82  for (j=0;j<em.GetLength();++j) cout <<"e-:"<<em[j].Uid()<<" ";
83  cout <<endl;*/
84 
85  jpsi.Combine(ep,em);
86  //jpsi.Select(jpsiMSel);
87  for (j=0;j<jpsi.GetLength();++j)
88  {
89  jpsimass->Fill(jpsi[j]->M());
90  }
91 
92  // for the 4C fit we need to add the daughters individually
93  pp.Combine(jpsi,pip,pim);
94 
95  for (j=0;j<pp.GetLength();++j)
96  {
97  ppmass->Fill(pp[j]->M());
98 
99  //do the 4C fit on the pbar p System
100  Rho4CFitter fitter(pp[j],ini);
101 
102  fitter.FitConserveMasses();
103 
104  RhoCandidate *ppfit=pp[j]->GetFit();
105  pp2mass->Fill(ppfit->M());
106 
107  RhoCandidate *epfit=ppfit->Daughter(0)->Daughter(0);
108  RhoCandidate *emfit=ppfit->Daughter(0)->Daughter(1);
109 
110  TLorentzVector sum=epfit->P4()+emfit->P4();
111 
112  jpsi2mass->Fill(sum.Mag());
113 
114  }
115  }
116 
117  timer.Stop();
118  Double_t rtime = timer.RealTime();
119  Double_t ctime = timer.CpuTime();
120 
121  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
122 
123  TCanvas *c1=new TCanvas("c1","c1",800,800);
124  c1->Divide(2,2);
125  c1->cd(1);jpsimass->Draw();
126  c1->cd(2);jpsi2mass->Draw();
127  c1->cd(3);ppmass->Draw();
128  c1->cd(4);pp2mass->Draw();
129  c1->Print("testplots.png");
130 
131  Bool_t fTest=kTRUE;
132 
133  Double_t mean_jpsimass=jpsimass->GetMean();
134  Double_t mean_jpsi2mass=jpsi2mass->GetMean();
135 
136  Double_t mean_ppmass=ppmass->GetMean();
137  Double_t mean_pp2mass=pp2mass->GetMean();
138 
139  if (mean_jpsimass>3.0 && mean_jpsimass<3.2 && mean_jpsi2mass>3.0 && mean_jpsi2mass<3.2)
140  {
141  cout<<"\n J/Psi mass - ACCEPTABLE "<<endl;
142  }
143  else
144  {
145  cout<<" \n J/Psi mass - SOMETHING WENT WRONG "<<endl;
146  cout<<" Mean = " << mean_jpsimass << endl;
147  cout<<" Mean (after kinfit) = " << mean_jpsi2mass << endl;
148  fTest=kFALSE;
149  }
150 
151  if (mean_ppmass>3.5 && mean_ppmass<3.7 && mean_pp2mass>3.5 && mean_pp2mass<3.7)
152  {
153  cout<<"\n psi(2s) mass - ACCEPTABLE "<<endl;
154  }
155  else
156  {
157  cout<<" \n psi(2s) mass - SOMETHING WENT WRONG "<<endl;
158  cout<<" Mean = " << mean_ppmass << endl;
159  cout<<" Mean (after kinfit) = " << mean_pp2mass << endl;
160  fTest=kFALSE;
161  }
162 
163  if (fTest){
164  cout << " Test passed" << endl;
165  cout << " All ok " << endl;
166  }
167  CloseGeoManager();
168  return 0;
169 }
Int_t GetEntries()
void printCand(TLorentzVector l, TVector3 p)
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t i
Definition: run_full.C:25
Bool_t FitConserveMasses()
Definition: Rho4CFitter.cxx:64
Int_t GetLength() const
Definition: RhoCandList.h:46
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
RhoCandidate * Daughter(Int_t n)
Double_t p
Definition: anasim.C:58
void CloseGeoManager()
Definition: QA/auxi.C:11
FairRunAna * fRun
Definition: hit_dirc.C:58
void Combine(RhoCandList &l1, RhoCandList &l2)
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
TLorentzVector P4() const
Definition: RhoCandidate.h:195
int QAmacro_fastsim_2(int nevts=0)
c1
Definition: plot_dirc.C:35
Double_t M() const
Double_t ctime
Definition: hit_dirc.C:114
Int_t GetEvent(Int_t n=-1)
Double_t rtime
Definition: hit_dirc.C:113