FairRoot/PandaRoot
Functions
run_ana_invariantmass_4pi_tpc.C File Reference

Go to the source code of this file.

Functions

int run_ana_invariantmass_4pi_tpc (int nEntries=0)
 

Function Documentation

int run_ana_invariantmass_4pi_tpc ( int  nEntries = 0)

Definition at line 5 of file run_ana_invariantmass_4pi_tpc.C.

References RhoFitterBase::Fit(), PndMCTrack::GetMotherID(), PndMCTrack::GetPdgCode(), hvpos, hvtxresX, hvtxresY, hvtxresZ, hvzpos, i, inFile, inSimFile, Mass, mc_array, nc, out, timer, tree, TString, and y.

6 {
7  gStyle->SetOptFit(1011);
8 
9  TStopwatch timer;
10  timer.Start();
11 
12  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
13 
14  TString inPidFile = "evt_pid_tpc.root";
15  TString inSimFile = "evt_points_tpc.root";
16  TFile *inFile = TFile::Open(inSimFile,"READ");
17  TTree *tree=(TTree *) inFile->Get("pndsim") ;
18  tree->AddFriend("pndsim",inPidFile);
19  TClonesArray* mc_array=new TClonesArray("PndMCTrack");
20  tree->SetBranchAddress("MCTrack",&mc_array);
21 
22  TClonesArray* cand_array=new TClonesArray("PndPidCandidate");
23  tree->SetBranchAddress("PidChargedCand",&cand_array);
24 
25  FairMCEventHeader* evthead;
26  tree->SetBranchAddress("MCEventHeader.", &evthead);
27 
28  TFile *out=TFile::Open("invariantmass_4pi_tpc.root","RECREATE");
29 
30  PndEventReader evr(inPidFile);
31 
32  TH1F *nc=new TH1F("nc","Number of Charged Tracks; Charged Tracks",20,-0.5,19.5);
33  TH1F *invmassnosel=new TH1F("invmassnosel","2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,0,10);
34  TH1F *invmassnocut=new TH1F("invmassnocut","2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
35  // TH1F *invmassvtx=new TH1F("invmassvtx","2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
36  TH1F *invmasswithpid=new TH1F("invmasswithpid","#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,0,10);
37  TH1F *invmasswithpid_sel=new TH1F("invmasswithpid_sel","#pi^{+}#pi^{-} Invariant mass;Invariant Mass (GeV)",100,2,4);
38 TH1F *invmass_trackhighmom= new TH1F("invmass_trackhighmom","2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
39  TH1F *invmasschicut=new TH1F("invmasschicut","#2(pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
40  TH1F *invmasschicut_best=new TH1F("invmasschicut_best","2(#pi^{+}#pi^{-}) Invariant mass;Invariant Mass (GeV)",100,2,4);
41 
42  TH2F *hvpos = new TH2F("hvpos","(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
43  TH1F *hvzpos = new TH1F("hvzpos","z position of fitted decay vertex",100,-4,4);
44 
45  TH1F *chivtx=new TH1F("chivtx","Chi Square RhoKinVtxFitter; Chi Square / N_{df}",100,0,100);
46  TH1F *hvtxresX = new TH1F("hvtxresX","X resolution of fitted decay vertex",100,-0.3,0.3);
47  TH1F *hvtxresY = new TH1F("hvtxresY","Y resolution of fitted decay vertex",100,-0.3,0.3);
48  TH1F *hvtxresZ = new TH1F("hvtxresZ","Z resolution of fitted decay vertex",100,-0.3,0.3);
49 
50 
51  TPidPlusSelector *piplusSel=new TPidPlusSelector("piplus");
52  TPidMinusSelector *piminusSel=new TPidMinusSelector("piminus");
53 
54  TCandList pp, pm, pipi,pipinosel, pipiwithpid;
55 
56  int n_reco=0;
57 
58  TLorentzVector ini(0,0,4.0,5.04684);
59  int i=0,j=0,k=0,l=0,y=0;
60 
61  TLorentzVector beam;
62  beam.SetXYZM (0.0,0.0,4.0,0.938272);
63  TLorentzVector target;
64  target.SetXYZM (0.0,0.0,0.0,0.938272);
65  TLorentzVector pbarp=beam+target;
66 
67 
68 
69  float energypip, energypim, momxpip, momypip, momzpip;
70  TPidMassSelector *pipisel=new TPidMassSelector("pipisel",3.07,0.5); //energy in the center of mass 3.07GeV
71  TPidPlusSelector *piplusSel=new TPidPlusSelector("piplus");
72  TPidMinusSelector *piminusSel=new TPidMinusSelector("piminus");
73 
74  if (nEntries==0) nEntries=evr.GetEntries();
75  while (evr.GetEvent() && i++<nEntries){
76 
77  if (!((i+1)%100)) cout<<"evt " << i << "\n";
78 
79  evr.FillList(pp,"Charged");
80  evr.FillList(pm,"Charged");
81 
82  pp.Select(piplusSel);
83  pm.Select(piminusSel);
84 
85  int nchrg=pp.GetLength();
86  nc->Fill(nchrg);
87 
88 
89  float momentumpplus, momentumpminus, theta1, theta2, phi1, phi2;
90 
91  for (Int_t l=0;l<pp.GetLength();l++){
92  pp[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->Mass());
93  momentumpplus=pp[l].GetMicroCandidate().GetMomentum().Mag();
94 
95  }
96  for (Int_t l=0;l<pm.GetLength();l++){
97  pm[l].SetMass(TRho::Instance()->GetPDG()->GetParticle(211)->Mass());
98  momentumpminus=pm[l].GetMicroCandidate().GetMomentum().Mag();
99 
100 }
101 
102 
103  pipinosel.Combine(pp,pm,pp,pm);
104 
105  for (y=0;y<pipinosel.GetLength();++y){
106  invmassnosel->Fill(pipinosel[y].M());
107  }
108 
109  pipi.Combine(pp,pm,pp,pm);
110  pipi.Select(pipisel);
111 
112  for (y=0;y<pipi.GetLength();++y){
113  invmassnocut->Fill(pipi[y].M());
114  if (momentumpplus>0.3 && momentumpminus >0.3){
115  invmass_trackhighmom->Fill(pipi[y].M());
116  }
117 
118 }
119 
120 
121  //MonteCarlo PID
122  tree->GetEntry(i-1);
123 
124  TVector3 mcVertex;
125  evthead->GetVertex(mcVertex);
126 
127 // MC PID
128  // Leave only pions in particle lists
129  int n_removed=0;
130  int ii=0;
131  for (l=0;l<pp.GetLength();++l) {
132  ii=l-n_removed;
133  if (pp[ii].GetMicroCandidate().GetMcIndex()>-1){
134  PndMCTrack *mcTrack = (PndMCTrack*)mc_array->At(pp[ii].GetMicroCandidate().GetMcIndex());
135  if (mcTrack!=0)
136  {
137  if ((mcTrack->GetPdgCode()!=211) || (mcTrack->GetMotherID()!=-1))
138  {
139  pp.Remove(pp[ii]);
140  n_removed++;
141  }
142  }
143  else
144  {
145  std::cout<<"Pi plus, element "<<l<<" has no assosiated mcTRack"<<std::endl;
146  }
147  }
148  }
149 
150 
151  n_removed=0;
152  ii=0;
153  for (l=0;l<pm.GetLength();++l) {
154  ii=l-n_removed;
155  if (pm[ii].GetMicroCandidate().GetMcIndex()>-1){
156  PndMCTrack *mcTrack = (PndMCTrack*)mc_array->At(pm[ii].GetMicroCandidate().GetMcIndex());
157  if (mcTrack!=0)
158  {
159  if ((mcTrack->GetPdgCode()!=-211) || (mcTrack->GetMotherID()!=-1))
160  {
161  pm.Remove(pm[ii]);
162  n_removed++;
163  }
164  }
165  else
166  {
167  std::cout<<"Pi Minus, element "<<l<<" has no assosiated mcTRack"<<std::endl;
168  }
169  }
170  }
171 
172 
173  pipiwithpid.Combine(pp,pm,pp,pm);
174  for (y=0;y<pipiwithpid.GetLength();++y){
175  invmasswithpid->Fill(pipiwithpid[y].M());
176  }
177 
178 
179  pipiwithpid.Combine(pp,pm,pp,pm);
180  pipiwithpid.Select(pipisel); //Mass selector
181  for (y=0;y<pipiwithpid.GetLength();++y){
182  invmasswithpid_sel->Fill(pipiwithpid[y].M());
183  }
184 
185 
186  int best_i=0;
187  double best_chi2=1000;
188  TCandidate *pipifit_best=0;
189  Float_t pipivtx_mass;
190  for (y=0;y<pipiwithpid.GetLength();++y){
191 
192  RhoKinVtxFitter vtxfitter(pipiwithpid[y]);
193  vtxfitter.Fit();
194  TCandidate *pipifit=vtxfitter.FittedCand(pipiwithpid[y]);
195 
196  TVector3 pipiVtx=pipifit->Pos();
197  double chi2_vtx=vtxfitter.GlobalChi2();
198 
199  hvpos->Fill(pipiVtx.X(),pipiVtx.Y());
200  hvzpos->Fill(pipiVtx.Z());
201 
202  if(chi2_vtx<best_chi2)
203  {
204  best_chi2=chi2_vtx;
205  best_i=y;
206  pipifit_best=pipifit;
207  pipivtx_mass=pipifit_best->M();
208  bestPos = pipifit->Pos();
209  }
210  chivtx->Fill(chi2_vtx/5); // Number degree of freedom 2N-3=5; N=number of charged tracks
211 
212  }
213 
214  if((pipiwithpid.GetLength()!=0))
215  {
216  invmasschicut_best->Fill(pipivtx_mass);
217  n_reco++;
218  hvtxresX->Fill(mcVertex.X()-bestPos.X());
219  hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
220  hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
221  }
222 
223  }
224 
225  out->cd();
226  out->Write();
227  out->Save();
228 
229 
230  return 0;
231 }
TH1F * hvtxresX
Int_t i
Definition: run_full.C:25
TTree * tree
Definition: plot_dirc.C:12
Int_t GetPdgCode() const
Definition: PndMCTrack.h:73
TH1F * hvzpos
TClonesArray * mc_array
Definition: anaLmdCluster.C:25
TString inFile
Definition: hit_dirc.C:8
TString inSimFile
TStopwatch timer
Definition: hit_dirc.C:51
TFile * out
Definition: reco_muo.C:20
TH1F * hvtxresZ
Double_t y
Int_t GetMotherID() const
Definition: PndMCTrack.h:74
TH1F * hvtxresY
TH2F * hvpos
TH1F * nc