7 TString OutFile=
"etac_histo_tpc.root";
12 gStyle->SetOptFit(1011);
17 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
19 TString inPidFile =
"evt_pid_tpc.root";
22 TFile *
inFile = TFile::Open(inSimFile,
"READ");
23 TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
24 tree->AddFriend(
"pndsim",inPidFile);
26 TClonesArray*
mc_array=
new TClonesArray(
"PndMCTrack");
27 tree->SetBranchAddress(
"MCTrack",&mc_array);
29 FairMCEventHeader* evthead;
30 tree->SetBranchAddress(
"MCEventHeader.", &evthead);
32 TFile *
out = TFile::Open(OutFile,
"RECREATE");
35 PndEventReader evr(inPidFile);
37 TH1F *
h_etac_nocut=
new TH1F(
"h_etac_nocut",
"#eta_{c}m(#phi,#phi), (no cuts);E, GeV",100,2.5,3.5);
38 TH1F *
h_mphi_nocuts=
new TH1F(
"h_mphi_nocuts",
"#phi: m(K+ K-) (no cuts);E, GeV",100,0.95,1.5);
40 TH1F *
h_etac_pid=
new TH1F(
"h_etac_pid",
"#eta_{c}m(#phi,#phi), (MC PID);E, GeV",100,2.5,3.5);
41 TH1F *
h_mphi_pid=
new TH1F(
"h_mphi_pid",
"#phi: m(K+ K-) (MC PID);E, GeV",100,0.95,1.5);
43 TH1F *
h_etac_4c=
new TH1F(
"h_etac_4c",
"#eta_{c}m(#phi,#phi), 4C-fit;E, GeV",100,2.5,3.5);
44 TH1F *h_etac_4c_refit=
new TH1F(
"h_etac_4c_refit",
"#eta_{c}m(#phi,#phi), 4C-fit;E, GeV",100,2.5,3.5);
45 TH1F *
h_mphi_4c=
new TH1F(
"h_mphi_4c",
"#phi: m(K+ K-) (4C-fit);E, GeV",100,0.95,1.5);
47 TH1F *
h_etac_vtx=
new TH1F(
"h_etac_vtx",
"#eta_{c}m(#phi,#phi), Vertex fit;E, GeV",100,2.5,3.5);
48 TH1F *
h_mphi_vtx=
new TH1F(
"h_mphi_vtx",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
50 TH1F *h_etac_vtx_cut=
new TH1F(
"h_etac_vtx_cut",
"#eta_{c}m(#phi,#phi), Vertex fit;E, GeV",100,2.5,3.5);
51 TH1F *h_mphi_vtx_cut=
new TH1F(
"h_mphi_vtx_cut",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
53 TH1F *
h_etac_phimass_4c=
new TH1F(
"h_etac_phimass_4c",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E, GeV",100,2.8,3.2);
54 TH1F *
h_mphi_final_4c=
new TH1F(
"h_mphi_final_4c",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
56 TH1F *
h_etac_phimass_vtx=
new TH1F(
"h_etac_phimass_vtx",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E, GeV",100,2.8,3.2);
57 TH1F *
h_mphi_final_vtx=
new TH1F(
"h_mphi_final_vtx",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
59 TH1F *h_etac_phimass_vtx_cut=
new TH1F(
"h_etac_phimass_vtx_cut",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E, GeV",100,2.8,3.2);
60 TH1F *h_mphi_final_vtx_cut=
new TH1F(
"h_mphi_final_vtx_cut",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
62 TH1F *
h_etac_phimassfit=
new TH1F(
"h_etac_phimassfit",
"#eta_{c}m(#phi,#phi);E, GeV",100,2.8,3.2);
63 TH1F *
h_mphi_final_massfit=
new TH1F(
"h_mphi_final_massfit",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
65 TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
67 TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
68 TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
69 TH1F *
h_chi2_vtx=
new TH1F(
"h_chi2_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
70 TH1F *
h_chi2b_vtx=
new TH1F(
"h_chi2b_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
72 TH1F *h_chi2_mass=
new TH1F(
"h_chi2_mass",
"#chi^{2} Mass constraint fit;#chi^{2}",100,0,100);
74 TH2F *
hvpos =
new TH2F(
"hvpos",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
75 TH1F *
hvzpos =
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-10,10);
76 TH1F *
hvtxresX =
new TH1F(
"hvtxresX",
"X resolution of fitted decay vertex",100,-0.1,0.1);
77 TH1F *
hvtxresY =
new TH1F(
"hvtxresY",
"Y resolution of fitted decay vertex",100,-0.1,0.1);
78 TH1F *
hvtxresZ =
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay vertex",100,-0.1,0.1);
80 TH2F *h_theta_p =
new TH2F(
"h_theta_p",
"Theta vs p",100,0,180,100,0,3);
81 TH2F *h_dp_p =
new TH2F(
"h_dp_p",
"Delta p vs p",100,0,3,100,0,3);
82 TH2F *h_dp_theta =
new TH2F(
"h_dp_theta",
"Delta p vs theta",100,0,3,100,0,180);
83 TH1F *h_dp=
new TH1F(
"h_dp",
"Delta p",100,0,3);
84 TH1F *h_dp_low=
new TH1F(
"h_dp_low",
"Delta p",100,0,3);
85 TH1F *h_dp_high=
new TH1F(
"h_dp_high",
"Delta p",100,0,3);
87 TPidMassSelector *phiMassSel=
new TPidMassSelector(
"phi",1.02,0.2);
89 TPidPlusSelector *kplusSel=
new TPidPlusSelector(
"kplus");
90 TPidMinusSelector *kminusSel=
new TPidMinusSelector(
"kminus");
93 TCandList
p1,
p2, phi1, phi1_pid, phi1_massfit, etac, etac_pid, etac_nocut, etac_massfit;
95 int n_reco_4c=0, n_reco_vtx=0, n_reco_vtx_cut=0;
97 TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
98 TH1F *
n_etac_4c=
new TH1F(
"n_etac_4c",
"number of reconstructed eta_c (4C-fit)",1,0,1);
99 TH1F *
n_etac_vtx=
new TH1F(
"n_etac_vtx",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
100 TH1F *n_etac_vtx_cut=
new TH1F(
"n_etac_vtx_cut",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
101 TLorentzVector ini(0,0,3.6772,4.7333);
103 if (nevts==0) nevts=evr.GetEntries();
105 n_events->SetBinContent(1,nevts);
107 int i=0,j=0, k=0, l=0;
109 TH1F *h_acc_tpc=
new TH1F(
"h_acc_tpc",
"TPC acceptance",6,0,6);
111 int nEntries = tree->GetEntriesFast();
112 for (Int_t j=0; j< nEntries; j++)
116 for (Int_t mc = 0; mc < mc_array->GetEntriesFast(); mc++)
122 h_acc_tpc->Fill(mccount);
129 while (evr.GetEvent() && i++<nevts)
132 phi1_massfit.Cleanup();
134 if ((i%100)==0) cout<<
"evt " << i <<
"\n";
136 evr.FillList(p1,
"Charged");
137 evr.FillList(p2,
"Charged");
139 double theta,
p, p_mc, delta_p;
140 for (Int_t l=0;l<p1.GetLength();l++){
141 p=p1[l].GetMicroCandidate().GetMomentum().Mag();
142 theta=p1[l].GetMicroCandidate().GetMomentum().Theta()*TMath::RadToDeg();
143 h_theta_p->Fill(theta,p);
145 (
PndMCTrack*)mc_array->At(p1[l].GetMicroCandidate().GetMcIndex());
146 if (mcTrack==0)
continue;
149 h_dp_p->Fill(delta_p,p_mc);
150 h_dp_theta->Fill(delta_p,theta);
153 h_dp_low->Fill(delta_p);
155 h_dp_high->Fill(delta_p);
159 p2.Select(kminusSel);
161 int nchrg=p1.GetLength()+p2.GetLength();
164 for (j=0;j<p1.GetLength();++j) {
165 p1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
167 for (j=0;j<p2.GetLength();++j) {
168 p2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
173 for (j=0;j<phi1.GetLength();++j) h_mphi_nocuts->Fill(phi1[j].M());
175 phi1.Select(phiMassSel);
176 etac_nocut.Combine(phi1,phi1);
178 for (l=0;l<etac_nocut.GetLength();++l) {
179 h_etac_nocut->Fill(etac_nocut[l].M());
183 TVector3 mcVertex, mcD1Vertex, mcD2vertex;
184 evthead->GetVertex(mcVertex);
190 for (l=0;l<p1.GetLength();++l) {
192 if (p1[ii].GetMicroCandidate().GetMcIndex()>-1){
194 (
PndMCTrack*)mc_array->At(p1[ii].GetMicroCandidate().GetMcIndex());
207 std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
208 std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
215 for (l=0;l<p2.GetLength();++l) {
217 if (p2[ii].GetMicroCandidate().GetMcIndex()>-1){
219 (
PndMCTrack*)mc_array->At(p2[ii].GetMicroCandidate().GetMcIndex());
232 std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
233 std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
238 phi1_pid.Combine(p1,p2);
240 for (j=0;j<phi1_pid.GetLength();++j) h_mphi_pid->Fill(phi1_pid[j].M());
241 phi1_pid.Select(phiMassSel);
242 etac.Combine(phi1_pid,phi1_pid);
244 for (l=0;l<etac.GetLength();++l) {
245 h_etac_pid->Fill(etac[l].M());
250 double best_chi2=10000;
251 TCandidate *ccfit =
new TCandidate();
252 double m_phi1, m_phi2;
253 for (l=0;l<etac.GetLength();++l) {
261 ccfit = (TCandidate*)fitter.FittedCand(etac[l]);
262 TCandidate *phi1best = fitter.FittedCand(*(etac[l].Daughter(0)));
263 TCandidate *phi2best = fitter.FittedCand(*(etac[l].Daughter(1)));
264 TCandidate *k1best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(0)));
265 TCandidate *k2best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(1)));
266 TCandidate *k3best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(0)));
267 TCandidate *k4best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(1)));
268 TLorentzVector tlvk1 = k1best->P4();
269 TLorentzVector tlvk2 = k2best->P4();
270 TLorentzVector tlvk3 = k3best->P4();
271 TLorentzVector tlvk4 = k4best->P4();
272 m_phi1= (tlvk1+tlvk2).M();
273 m_phi2= (tlvk3+tlvk4).M();
275 h_chi2_4c->Fill(chi2/9);
278 if((etac.GetLength()!=0))
280 h_chi2b_4c->Fill(best_chi2/9);
281 h_etac_4c->Fill(etac[best_i].M());
282 h_etac_4c_refit->Fill(ccfit->M());
283 h_mphi_4c->Fill(m_phi1);
284 h_mphi_4c->Fill(m_phi2);
285 h_mphi_final_4c->Fill(m_phi1);
286 h_mphi_final_4c->Fill(m_phi2);
287 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))
288 && ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
290 h_etac_phimass_4c->Fill(etac[best_i].M());
291 if ((etac[best_i].M()>2.9)&&(etac[best_i].M()<3.06))
297 TCandidate *k1, *k2, *k3, *k4, *phi1tmp, *phi2tmp, *etac_tmp;
300 for (j=0;j<etac.GetLength();++j)
302 phi1tmp=etac[j].Daughter(0);
303 phi2tmp=etac[j].Daughter(1);
305 k1=phi1tmp->Daughter(0);
306 k2=phi1tmp->Daughter(1);
307 k3=phi2tmp->Daughter(0);
308 k4=phi2tmp->Daughter(1);
310 etac_tmp=k1->Combine(*k2,*k3,*k4);
311 etac_vtx.Add(*etac_tmp);
314 for (l=0;l<etac_vtx.GetLength();++l) {
315 h_etac_pid->Fill(etac_vtx[l].M());
319 double best_chi2=10000;
320 TCandidate *etacfit_best=0;
321 TCandidate *k1fit_best=0, *k2fit_best=0, *k3fit_best=0, *k4fit_best=0;
322 TCandidate *phi1fit_best, *phi2fit_best;
324 Float_t etacvtx_mass;
325 for (j=0;j<etac_vtx.GetLength();++j)
330 TCandidate *etacfit=vtxfitter.FittedCand(etac_vtx[j]);
331 TVector3 etacVtx=etacfit->Pos();
332 double chi2_vtx=vtxfitter.GlobalChi2();
333 h_chi2_vtx->Fill(chi2_vtx/5);
335 hvpos->Fill(etacVtx.X(),etacVtx.Y());
336 hvzpos->Fill(etacVtx.Z());
337 if(chi2_vtx<best_chi2)
341 etacfit_best=etacfit;
342 k1fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(0)));
343 k2fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(1)));
344 k3fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(2)));
345 k4fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(3)));
346 etacvtx_mass = etacfit_best->M();
347 bestPos = etacfit->Pos();
351 if((etac.GetLength()!=0)&&(k1fit_best!=0)&&(k3fit_best!=0))
354 h_chi2b_vtx->Fill(best_chi2/5);
355 h_etac_vtx->Fill(etacvtx_mass);
356 phi1fit_best=k1fit_best->Combine(*k2fit_best);
357 phi2fit_best=k3fit_best->Combine(*k4fit_best);
358 double m_phi1=phi1fit_best->M();
359 double m_phi2=phi2fit_best->M();
360 h_mphi_vtx->Fill(m_phi1);
361 h_mphi_vtx->Fill(m_phi2);
362 h_mphi_final_vtx->Fill(m_phi1);
363 h_mphi_final_vtx->Fill(m_phi2);
364 hvtxresX->Fill(mcVertex.X()-bestPos.X());
365 hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
366 hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
367 if ((
fabs(bestPos.Z())<2.)&&(bestPos.Perp()<1.))
369 h_etac_vtx_cut->Fill(etacvtx_mass);
370 h_mphi_vtx_cut->Fill(m_phi1);
371 h_mphi_vtx_cut->Fill(m_phi2);
372 h_mphi_final_vtx_cut->Fill(m_phi1);
373 h_mphi_final_vtx_cut->Fill(m_phi2);
376 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&
377 ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
379 h_etac_phimass_vtx->Fill(etacvtx_mass);
380 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
382 if ((
fabs(bestPos.Z())<2.)&&(bestPos.Perp()<1.))
384 h_etac_phimass_vtx->Fill(etacvtx_mass);
385 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
419 std::cout<<
"Number of reconstructed eta_c (4C) = "<<n_reco_4c<<std::endl;
420 std::cout<<
"Number of reconstructed eta_c (Vertex fit)= "<<n_reco_vtx<<std::endl;
421 std::cout<<
"Number of reconstructed eta_c (Vertex fit, R,Z cut)= "<<n_reco_vtx_cut<<std::endl;
422 n_etac_4c->SetBinContent(1,n_reco_4c);
423 n_etac_vtx->SetBinContent(1,n_reco_vtx);
424 n_etac_vtx_cut->SetBinContent(1,n_reco_vtx_cut);
429 n_etac_vtx_cut->Write();
431 h_etac_nocut->Write();
434 h_etac_vtx_cut->Write();
436 h_etac_4c_refit->Write();
437 h_etac_phimass_4c->Write();
438 h_etac_phimass_vtx->Write();
439 h_etac_phimass_vtx_cut->Write();
440 h_etac_phimassfit->Write();
442 h_mphi_nocuts->Write();
445 h_mphi_vtx_cut->Write();
447 h_mphi_final_4c->Write();
448 h_mphi_final_vtx->Write();
449 h_mphi_final_vtx_cut->Write();
450 h_mphi_final_massfit->Write();
457 h_chi2b_vtx->Write();
458 h_chi2_mass->Write();
480 printf(
"RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
TH1F * h_mphi_final_massfit
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t GetNPoints(DetectorId detId) const
Bool_t FitConserveMasses()
TVector3 GetMomentum() const
TH1F * h_etac_phimass_vtx
friend F32vec4 fabs(const F32vec4 &a)
int run_ana_eta_c_tpc(int nevts=0)
TVector3 GetStartVertex() const
Int_t GetMotherID() const