10 TString pidFile =
"evt_pid_stt.root";
16 gStyle->SetOptFit(1011);
21 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
24 TH1F *
h_etac_nocut=
new TH1F(
"h_etac_nocut",
"#eta_{c}m(#phi,#phi), (no cuts);E, GeV",100,2.5,3.5);
25 TH1F *
h_mphi_nocuts=
new TH1F(
"h_mphi_nocuts",
"#phi: m(K+ K-) (no cuts);E, GeV",100,0.95,1.5);
27 TH1F *
h_etac_pid=
new TH1F(
"h_etac_pid",
"#eta_{c}m(#phi,#phi), (MC PID);E, GeV",100,2.5,3.5);
28 TH1F *
h_mphi_pid=
new TH1F(
"h_mphi_pid",
"#phi: m(K+ K-) (MC PID);E, GeV",100,0.95,1.5);
30 TH1F *
h_etac_4c=
new TH1F(
"h_etac_4c",
"#eta_{c}m(#phi,#phi), 4C-fit;E, GeV",100,2.5,3.5);
31 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);
32 TH1F *
h_mphi_4c=
new TH1F(
"h_mphi_4c",
"#phi: m(K+ K-) (4C-fit);E, GeV",100,0.95,1.5);
34 TH1F *
h_etac_vtx=
new TH1F(
"h_etac_vtx",
"#eta_{c}m(#phi,#phi), Vertex fit;E, GeV",100,2.5,3.5);
35 TH1F *
h_mphi_vtx=
new TH1F(
"h_mphi_vtx",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
37 TH1F *h_etac_vtx_2=
new TH1F(
"h_etac_vtx_2",
"#eta_{c}m(#phi,#phi), Vertex fit;E, GeV",100,2.5,3.5);
38 TH1F *
h_mphi_vtx_2=
new TH1F(
"h_mphi_vtx_2",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
40 TH1F *
h_etac_phimass_4c=
new TH1F(
"h_etac_phimass_4c",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
42 TH1F *
h_mphi_final_4c=
new TH1F(
"h_mphi_final_4c",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
44 TH1F *
h_etac_phimass_vtx=
new TH1F(
"h_etac_phimass_vtx",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
46 TH1F *
h_mphi_final_vtx=
new TH1F(
"h_mphi_final_vtx",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
48 TH1F *
h_etac_phimass_vtx_2=
new TH1F(
"h_etac_phimass_vtx_2",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
50 TH1F *
h_mphi_final_vtx_2=
new TH1F(
"h_mphi_final_vtx_2",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
52 TH1F *
h_etac_phimassfit=
new TH1F(
"h_etac_phimassfit",
"#eta_{c}m(#phi,#phi);E, GeV",100,2.8,3.2);
53 TH1F *
h_mphi_final_massfit=
new TH1F(
"h_mphi_final_massfit",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
55 TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
57 TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
58 TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
59 TH1F *
h_chi2_vtx=
new TH1F(
"h_chi2_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
60 TH1F *
h_chi2b_vtx=
new TH1F(
"h_chi2b_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
62 TH1F *
h_chi2_prefit=
new TH1F(
"h_chi2_prefit",
"#chi^{2} prefit;#chi^{2}",100,0,100);
64 TH1F *h_chi2_mass=
new TH1F(
"h_chi2_mass",
"#chi^{2} Mass constraint fit;#chi^{2}",100,0,100);
66 TH2F *
hvpos =
new TH2F(
"hvpos",
"(x,y) projection of fitted decay
67 vertex",100,-5,5,100,-5,5);
68 TH1F *
hvzpos =
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-10,10);
69 TH1F *
hvtxresX =
new TH1F(
"hvtxresX",
"X resolution of fitted decay
70 vertex",100,-0.1,0.1);
71 TH1F *
hvtxresY =
new TH1F(
"hvtxresY",
"Y resolution of fitted decay
72 vertex",100,-0.1,0.1);
73 TH1F *
hvtxresZ =
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay
74 vertex",100,-0.1,0.1);
76 TH2F *h_theta_p =
new TH2F(
"h_theta_p",
"Theta vs p",100,0,180,100,0.,3);
77 TH2F *h_theta_p_nr =
new TH2F(
"h_theta_p_nr",
"Theta vs p",100,0,180,100,0.,3);
79 TH2F *h_dp_p =
new TH2F(
"h_dp_p",
"Delta p vs p",100,-3.,3,100,0,3);
80 TH2F *h_dp_theta =
new TH2F(
"h_dp_theta",
"Delta p vs theta",100,-3.,3,100,0,180);
81 TH1F *h_dp=
new TH1F(
"h_dp",
"Delta p",100,-3.,3.);
82 TH1F *h_dp_low=
new TH1F(
"h_dp_low",
"Delta p",100,-3.,3);
83 TH1F *h_dp_high=
new TH1F(
"h_dp_high",
"Delta p",100,-3.,3);
86 TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
87 TH1F *
n_etac_4c=
new TH1F(
"n_etac_4c",
"number of reconstructed eta_c (4C-fit)",1,0,1);
88 TH1F *
n_etac_vtx=
new TH1F(
"n_etac_vtx",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
89 TH1F *
n_etac_vtx_2=
new TH1F(
"n_etac_vtx_2",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
94 FairLogger::GetLogger()->SetLogToFile(kFALSE);
97 FairRunAna*
fRun =
new FairRunAna();
98 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
100 fRun->SetInputFile(simFile);
101 fRun->AddFriend(recoFile);
102 fRun->AddFriend(pidFile);
103 FairParRootFileIo* parIO =
new FairParRootFileIo();
104 parIO->open(parFile.Data());
105 rtdb->setFirstInput(parIO);
106 rtdb->setOutput(parIO);
108 fRun->SetOutputFile(outFile.Data());
111 TFile *
out = TFile::Open(outFile,
"RECREATE");
116 TCandList
p1,
p2, phi1, phi1_pid, phi1_massfit, phi1_massfit_cut;
117 TCandList etac, etac_pid, etac_nocut, etac_massfit, etac_massfit_cut;
122 if (nevts>0 && nevts<evts) evts=nevts;
123 n_events->SetBinContent(1,evts);
125 TPidMassSelector *phiMassSel=
new TPidMassSelector(
"phi",1.02,0.2);
126 TPidPlusSelector *kplusSel=
new TPidPlusSelector(
"kplus");
127 TPidMinusSelector *kminusSel=
new TPidMinusSelector(
"kminus");
129 int n_reco_4c=0, n_reco_vtx=0, n_reco_vtx_2=0;
131 TLorentzVector ini(0,0,3.6772,4.7333);
133 int i=0,j=0, k=0, l=0;
135 Double_t mc_mom, mc_theta, rec_mom, rec_theta, delta_p;
137 while (theAnalysis->
GetEvent() && ievt++<evts)
140 phi1_massfit.Cleanup();
141 phi1_massfit_cut.Cleanup();
142 if ((ievt%100)==0) cout<<
"evt " << ievt <<
"\n";
144 theAnalysis->
FillList(mctracks,
"McTruth");
145 theAnalysis->
FillList(p1,
"Charged");
146 theAnalysis->
FillList(p2,
"Charged");
149 p2.Select(kminusSel);
153 for (Int_t l=0;l<p1.GetLength();l++){
155 if((p1[ii].GetMicroCandidate().GetSttHits())==0){
163 for (Int_t l=0;l<p2.GetLength();l++){
165 if((p2[ii].GetMicroCandidate().GetSttHits())==0){
171 int nchrg=p1.GetLength()+p2.GetLength();
174 for (j=0;j<p1.GetLength();++j) {
175 p1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
177 for (j=0;j<p2.GetLength();++j) {
178 p2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
183 for (j=0;j<phi1.GetLength();++j) h_mphi_nocuts->Fill(phi1[j].M());
185 phi1.Select(phiMassSel);
186 etac_nocut.Combine(phi1,phi1);
188 for (l=0;l<etac_nocut.GetLength();++l) {
189 h_etac_nocut->Fill(etac_nocut[l].M());
192 TVector3 mcVertex, mcD1Vertex, mcD2vertex;
193 FairMCEventHeader* evthead =
194 (FairMCEventHeader*)(FairRootManager::Instance()->GetObject(
"EvtHeader"));
195 evthead->GetVertex(mcVertex);
203 for (l=0;l<p1.GetLength();++l) {
205 Int_t mcIndex = p1[ii].GetMicroCandidate().GetMcIndex();
207 if ((mctracks[mcIndex].PdgCode()!=321))
215 std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
216 std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
223 for (l=0;l<p2.GetLength();++l) {
225 Int_t mcIndex = p2[ii].GetMicroCandidate().GetMcIndex();
227 if ((mctracks[mcIndex].PdgCode()!=-321))
235 std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
236 std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
243 phi1_pid.Combine(p1,p2);
245 for (j=0;j<phi1_pid.GetLength();++j) h_mphi_pid->Fill(phi1_pid[j].M());
246 phi1_pid.Select(phiMassSel);
247 etac.Combine(phi1_pid,phi1_pid);
249 for (l=0;l<etac.GetLength();++l) {
250 h_etac_pid->Fill(etac[l].M());
255 double best_chi2=10000;
256 TCandidate *ccfit =
new TCandidate();
257 double m_phi1, m_phi2;
258 for (l=0;l<etac.GetLength();++l) {
266 ccfit = (TCandidate*)fitter.FittedCand(etac[l]);
267 TCandidate *phi1best = fitter.FittedCand(*(etac[l].Daughter(0)));
268 TCandidate *phi2best = fitter.FittedCand(*(etac[l].Daughter(1)));
269 TCandidate *k1best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(0)));
270 TCandidate *k2best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(1)));
271 TCandidate *k3best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(0)));
272 TCandidate *k4best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(1)));
273 TLorentzVector tlvk1 = k1best->P4();
274 TLorentzVector tlvk2 = k2best->P4();
275 TLorentzVector tlvk3 = k3best->P4();
276 TLorentzVector tlvk4 = k4best->P4();
277 m_phi1= (tlvk1+tlvk2).M();
278 m_phi2= (tlvk3+tlvk4).M();
280 h_chi2_4c->Fill(chi2/9);
283 if((etac.GetLength()!=0))
285 h_chi2b_4c->Fill(best_chi2/9);
286 h_etac_4c->Fill(etac[best_i].M());
287 h_etac_4c_refit->Fill(ccfit->M());
288 h_mphi_4c->Fill(m_phi1);
289 h_mphi_4c->Fill(m_phi2);
290 h_mphi_final_4c->Fill(m_phi1);
291 h_mphi_final_4c->Fill(m_phi2);
292 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))
293 && ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
295 h_etac_phimass_4c->Fill(etac[best_i].M());
296 if ((etac[best_i].M()>2.9)&&(etac[best_i].M()<3.06))
302 TCandidate *k1, *k2, *k3, *k4, *phi1tmp, *phi2tmp, *etac_tmp;
305 for (j=0;j<etac.GetLength();++j)
307 phi1tmp=etac[j].Daughter(0);
308 phi2tmp=etac[j].Daughter(1);
310 k1=phi1tmp->Daughter(0);
311 k2=phi1tmp->Daughter(1);
312 k3=phi2tmp->Daughter(0);
313 k4=phi2tmp->Daughter(1);
315 etac_tmp=k1->Combine(*k2,*k3,*k4);
316 etac_vtx.Add(*etac_tmp);
319 for (l=0;l<etac_vtx.GetLength();++l) {
320 h_etac_pid->Fill(etac_vtx[l].M());
324 double best_chi2=10000;
325 TCandidate *etacfit_best=0;
326 TCandidate *k1fit_best=0, *k2fit_best=0, *k3fit_best=0, *k4fit_best=0;
327 TCandidate *phi1fit_best, *phi2fit_best;
329 Float_t etacvtx_mass;
330 for (j=0;j<etac_vtx.GetLength();++j)
335 TCandidate *etacfit=vtxfitter.FittedCand(etac_vtx[j]);
336 TVector3 etacVtx=etacfit->Pos();
337 double chi2_vtx=vtxfitter.GlobalChi2();
338 h_chi2_vtx->Fill(chi2_vtx/5);
340 hvpos->Fill(etacVtx.X(),etacVtx.Y());
341 hvzpos->Fill(etacVtx.Z());
342 if(chi2_vtx<best_chi2)
346 etacfit_best=etacfit;
347 k1fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(0)));
348 k2fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(1)));
349 k3fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(2)));
350 k4fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(3)));
351 etacvtx_mass = etacfit_best->M();
352 bestPos = etacfit->Pos();
356 if((etac.GetLength()!=0)&&(k1fit_best!=0)&&(k3fit_best!=0))
359 h_chi2b_vtx->Fill(best_chi2/5);
360 h_etac_vtx->Fill(etacvtx_mass);
361 phi1fit_best=k1fit_best->Combine(*k2fit_best);
362 phi2fit_best=k3fit_best->Combine(*k4fit_best);
363 double m_phi1=phi1fit_best->M();
364 double m_phi2=phi2fit_best->M();
365 h_mphi_vtx->Fill(m_phi1);
366 h_mphi_vtx->Fill(m_phi2);
367 h_mphi_final_vtx->Fill(m_phi1);
368 h_mphi_final_vtx->Fill(m_phi2);
369 hvtxresX->Fill(mcVertex.X()-bestPos.X());
370 hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
371 hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
373 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&
374 ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
376 h_etac_phimass_vtx->Fill(etacvtx_mass);
377 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
386 double best_chi2_prefit=1e6;
387 TCandidate *etacprefit_best=0;
388 TCandidate *k1prefit_best=0, *k2prefit_best=0, *k3prefit_best=0, *k4prefit_best=0;
389 TCandidate *phi1prefit_best, *phi2prefit_best;
391 Double_t sigma_etac=0.0331, sigma_phi=0.00392;
392 Double_t m_etac_pdg=2.98, m_phi_pdg=1.02;
394 for (j=0;j<etac_vtx.GetLength();++j)
396 metac=etac_vtx[j].M();
397 k1=etac_vtx[j].Daughter(0);
398 k2=etac_vtx[j].Daughter(1);
399 k3=etac_vtx[j].Daughter(2);
400 k4=etac_vtx[j].Daughter(3);
401 phi1prefit_best=k1->Combine(*k2);
402 phi2prefit_best=k3->Combine(*k4);
403 m_phi1=phi1prefit_best->M();
404 m_phi2=phi2prefit_best->M();
406 double chi2_prefit=pow(metac-m_etac_pdg,2)/pow(sigma_etac,2)+
407 pow(m_phi1-m_phi_pdg,2)/pow(sigma_phi,2)+pow(m_phi1-m_phi_pdg,2)/pow(sigma_phi,2);
408 h_chi2_prefit->Fill(chi2_prefit);
410 if(chi2_prefit<best_chi2_prefit)
412 best_chi2_prefit=chi2_prefit;
414 etacprefit_best=etac_vtx[j];
415 etacvtx_mass=etacprefit_best->M();
419 if (etacprefit_best!=0)
423 TCandidate *etacfit=vtxfitter.FittedCand(*etacprefit_best);
424 k1prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(0)));
425 k2prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(1)));
426 k3prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(2)));
427 k4prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(3)));
428 phi1prefit_best=k1prefit_best->Combine(*k2prefit_best);
429 phi2prefit_best=k3prefit_best->Combine(*k4prefit_best);
430 double m_phi1=phi1prefit_best->M();
431 double m_phi2=phi2prefit_best->M();
432 h_mphi_vtx_2->Fill(m_phi1);
433 h_mphi_vtx_2->Fill(m_phi2);
434 h_mphi_final_vtx_2->Fill(m_phi1);
435 h_mphi_final_vtx_2->Fill(m_phi2);
436 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&
437 ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
439 h_etac_phimass_vtx_2->Fill(etacvtx_mass);
440 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
446 std::cout<<
"Number of reconstructed eta_c (4C) = "<<n_reco_4c<<std::endl;
447 std::cout<<
"Number of reconstructed eta_c (Vertex fit)= "<<n_reco_vtx<<std::endl;
448 std::cout<<
"Number of reconstructed eta_c (Vertex fit, preselection)= "<<n_reco_vtx_2<<std::endl;
449 n_etac_4c->SetBinContent(1,n_reco_4c);
450 n_etac_vtx->SetBinContent(1,n_reco_vtx);
451 n_etac_vtx_2->SetBinContent(1,n_reco_vtx_2);
456 n_etac_vtx_2->Write();
458 h_etac_nocut->Write();
461 h_etac_vtx_2->Write();
463 h_etac_4c_refit->Write();
464 h_etac_phimass_4c->Write();
465 h_etac_phimass_vtx->Write();
466 h_etac_phimass_vtx_2->Write();
467 h_etac_phimassfit->Write();
469 h_mphi_nocuts->Write();
472 h_mphi_vtx_2->Write();
474 h_mphi_final_4c->Write();
475 h_mphi_final_vtx->Write();
476 h_mphi_final_vtx_2->Write();
477 h_mphi_final_massfit->Write();
484 h_chi2b_vtx->Write();
485 h_chi2_mass->Write();
486 h_chi2_prefit->Write();
499 printf(
"RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
TH1F * h_mphi_final_vtx_2
TH1F * h_mphi_final_massfit
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Bool_t FitConserveMasses()
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
int run_ana_eta_c_stt_v2(int nevts=0, bool usePID=true)
TH1F * h_etac_phimass_vtx
TH1F * h_etac_phimass_vtx_2
Int_t GetEvent(Int_t n=-1)