FairRoot/PandaRoot
ana_psi2s_fit.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 
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 
18 void ana_psi2s_fit(TString fname, int nevts=0)
19 {
20  TStopwatch timer;
21  timer.Start();
22 
23  gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C");rootlogon();
24 
25  TCanvas *c1=new TCanvas("c1","c1",600,600);
26 
27  PndEventReader evr(fname);
28 
29  if (nevts==0) nevts=evr.GetEntries();
30 
31  // **** create and setup some histos for QA plots
32  //
33  TH1F *jpsimass = new TH1F("jpsimass","J/psi cands",100,3.1-0.3,3.1+0.3);
34  TH1F *jpsi2mass = new TH1F("jpsi2mass","J/psi cands 4C fit",100,3.1-0.3,3.1+0.3);
35 
36  TH1F *ppmass = new TH1F("ppmass","pbarp cands",100,3.68598-0.5,3.68598+0.5);
37  TH1F *pp2mass = new TH1F("pp2mass","pbarp fitted",100,3.68598-0.5,3.68598+0.5);
38 
39  // **** create all the particle lists we'll need for rebuilding the decay tree
40  //
41  TCandList pip, pim, ep, em;
42  TCandList jpsi,pp;
43 
44  TPidMassSelector *jpsiMSel = new TPidMassSelector("jpsiSelector" , 3.096 , 0.3);
45 
46  TLorentzVector ini(0,0,6.23164,7.24015);
47 
48  int i=0,j=0;
49 
50  // **** loop over all _events_
51  //
52  while (evr.GetEvent() && ++i<nevts)
53  {
54  if (!(i%100))
55  cout <<"evt "<<i<<endl;
56 
57  evr.FillList(pip,"PionLoosePlus");
58  evr.FillList(pim,"PionLooseMinus");
59  evr.FillList(ep, "ElectronLoosePlus");
60  evr.FillList(em, "ElectronLooseMinus");
61 
62  jpsi.Combine(ep,em);
63 
64  for (j=0;j<jpsi.GetLength();++j)
65  {
66  jpsimass->Fill(jpsi[j].M());
67  }
68 
69  // for the 4C fit we need to add the daughters individually
70  pp.Combine(jpsi,pip,pim);
71 
72  for (j=0;j<pp.GetLength();++j)
73  {
74  ppmass->Fill(pp[j].M());
75 
76  //do the 4C fit on the pbar p System
77  Rho4CFitter fitter(pp[j],ini);
78 
79  fitter.FitConserveMasses();
80 
81  TCandidate *ppfit=fitter.FittedCand(pp[j]);
82  pp2mass->Fill(ppfit->M());
83 
84  TCandidate *epfit=fitter.FittedCand(*(pp[j].Daughter(0)->Daughter(0)));
85  TCandidate *emfit=fitter.FittedCand(*(pp[j].Daughter(0)->Daughter(1)));
86 
87  TLorentzVector sum=epfit->P4()+emfit->P4();
88 
89  jpsi2mass->Fill(sum.Mag());
90 
91  }
92  }
93 
94  // **** plot all that stuff
95  //
96 
97  c1->Divide(2,2);
98 
99  c1->cd(1); jpsimass->Draw();
100  c1->cd(2); jpsi2mass->Draw();
101  c1->cd(3); ppmass->Draw();
102  c1->cd(4); pp2mass->Draw();
103  c1->cd();
104 
105  timer.Stop();
106  Double_t rtime = timer.RealTime();
107  Double_t ctime = timer.CpuTime();
108 
109  printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
110 
111 }
Double_t p
Definition: anasim.C:58
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
void ana_psi2s_fit(TString fname, int nevts=0)
Definition: ana_psi2s_fit.C:18
Double_t
TStopwatch timer
Definition: hit_dirc.C:51
c1
Definition: plot_dirc.C:35
Double_t ctime
Definition: hit_dirc.C:114
void printCand(TLorentzVector l, TVector3 p)
Double_t rtime
Definition: hit_dirc.C:113