7 TString OutFile=
"etac_histo_stt.root";
11 gStyle->SetOptFit(1011);
16 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
18 TString inPidFile =
"evt_pid_stt.root";
21 TFile *
inFile = TFile::Open(inSimFile,
"READ");
22 TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
23 tree->AddFriend(
"pndsim",inPidFile);
25 TClonesArray*
mc_array=
new TClonesArray(
"PndMCTrack");
26 tree->SetBranchAddress(
"MCTrack",&mc_array);
28 TClonesArray* cand_array=
new TClonesArray(
"PndPidCandidate");
29 tree->SetBranchAddress(
"PidChargedCand", &cand_array);
32 FairMCEventHeader* evthead;
33 tree->SetBranchAddress(
"MCEventHeader.", &evthead);
35 TFile *
out = TFile::Open(OutFile,
"RECREATE");
38 PndEventReader evr(inPidFile);
40 TH1F *
h_etac_nocut=
new TH1F(
"h_etac_nocut",
"#eta_{c}m(#phi,#phi), (no cuts);E, GeV",100,2.5,3.5);
41 TH1F *
h_mphi_nocuts=
new TH1F(
"h_mphi_nocuts",
"#phi: m(K+ K-) (no cuts);E, GeV",100,0.95,1.5);
43 TH1F *
h_etac_pid=
new TH1F(
"h_etac_pid",
"#eta_{c}m(#phi,#phi), (MC PID);E, GeV",100,2.5,3.5);
44 TH1F *
h_mphi_pid=
new TH1F(
"h_mphi_pid",
"#phi: m(K+ K-) (MC PID);E, GeV",100,0.95,1.5);
46 TH1F *
h_etac_4c=
new TH1F(
"h_etac_4c",
"#eta_{c}m(#phi,#phi), 4C-fit;E, GeV",100,2.5,3.5);
47 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);
48 TH1F *
h_mphi_4c=
new TH1F(
"h_mphi_4c",
"#phi: m(K+ K-) (4C-fit);E, GeV",100,0.95,1.5);
50 TH1F *
h_etac_vtx=
new TH1F(
"h_etac_vtx",
"#eta_{c}m(#phi,#phi), Vertex fit;E, GeV",100,2.5,3.5);
51 TH1F *
h_mphi_vtx=
new TH1F(
"h_mphi_vtx",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
53 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);
54 TH1F *
h_mphi_vtx_2=
new TH1F(
"h_mphi_vtx_2",
"#phi: m(K+ K-) (Vertex fit);E, GeV",100,0.95,1.5);
56 TH1F *
h_etac_phimass_4c=
new TH1F(
"h_etac_phimass_4c",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
58 TH1F *
h_mphi_final_4c=
new TH1F(
"h_mphi_final_4c",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
60 TH1F *
h_etac_phimass_vtx=
new TH1F(
"h_etac_phimass_vtx",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
62 TH1F *
h_mphi_final_vtx=
new TH1F(
"h_mphi_final_vtx",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
64 TH1F *
h_etac_phimass_vtx_2=
new TH1F(
"h_etac_phimass_vtx_2",
"#eta_{c}m(#phi,#phi), (cut on #phi mass);E,
66 TH1F *
h_mphi_final_vtx_2=
new TH1F(
"h_mphi_final_vtx_2",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
68 TH1F *
h_etac_phimassfit=
new TH1F(
"h_etac_phimassfit",
"#eta_{c}m(#phi,#phi);E, GeV",100,2.8,3.2);
69 TH1F *
h_mphi_final_massfit=
new TH1F(
"h_mphi_final_massfit",
"#phi: m(K+ K-);E, GeV",100,0.95,1.1);
71 TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
73 TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
74 TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
75 TH1F *
h_chi2_vtx=
new TH1F(
"h_chi2_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
76 TH1F *
h_chi2b_vtx=
new TH1F(
"h_chi2b_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
78 TH1F *
h_chi2_prefit=
new TH1F(
"h_chi2_prefit",
"#chi^{2} prefit;#chi^{2}",100,0,100);
80 TH1F *h_chi2_mass=
new TH1F(
"h_chi2_mass",
"#chi^{2} Mass constraint fit;#chi^{2}",100,0,100);
82 TH2F *
hvpos =
new TH2F(
"hvpos",
"(x,y) projection of fitted decay
83 vertex",100,-5,5,100,-5,5);
84 TH1F *
hvzpos =
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-10,10);
85 TH1F *
hvtxresX =
new TH1F(
"hvtxresX",
"X resolution of fitted decay
86 vertex",100,-0.1,0.1);
87 TH1F *
hvtxresY =
new TH1F(
"hvtxresY",
"Y resolution of fitted decay
88 vertex",100,-0.1,0.1);
89 TH1F *
hvtxresZ =
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay
90 vertex",100,-0.1,0.1);
92 TH2F *h_theta_p =
new TH2F(
"h_theta_p",
"Theta vs p",100,0,180,100,0.,3);
93 TH2F *h_theta_p_nr =
new TH2F(
"h_theta_p_nr",
"Theta vs p",100,0,180,100,0.,3);
95 TH2F *h_dp_p =
new TH2F(
"h_dp_p",
"Delta p vs p",100,-3.,3,100,0,3);
96 TH2F *h_dp_theta =
new TH2F(
"h_dp_theta",
"Delta p vs theta",100,-3.,3,100,0,180);
97 TH1F *h_dp=
new TH1F(
"h_dp",
"Delta p",100,-3.,3.);
98 TH1F *h_dp_low=
new TH1F(
"h_dp_low",
"Delta p",100,-3.,3);
99 TH1F *h_dp_high=
new TH1F(
"h_dp_high",
"Delta p",100,-3.,3);
101 TPidMassSelector *phiMassSel=
new TPidMassSelector(
"phi",1.02,0.2);
103 TPidPlusSelector *kplusSel=
new TPidPlusSelector(
"kplus");
104 TPidMinusSelector *kminusSel=
new TPidMinusSelector(
"kminus");
107 TCandList
p1,
p2, phi1, phi1_pid, phi1_massfit, phi1_massfit_cut, etac, etac_pid, etac_nocut, etac_massfit, etac_massfit_cut;
109 int n_reco_4c=0, n_reco_vtx=0, n_reco_vtx_2=0;
111 TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
112 TH1F *
n_etac_4c=
new TH1F(
"n_etac_4c",
"number of reconstructed eta_c (4C-fit)",1,0,1);
113 TH1F *
n_etac_vtx=
new TH1F(
"n_etac_vtx",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
114 TH1F *
n_etac_vtx_2=
new TH1F(
"n_etac_vtx_2",
"number of reconstructed eta_c (Vertex fit)",1,0,1);
116 TLorentzVector ini(0,0,3.6772,4.7333);
118 if (nevts==0) nevts=evr.GetEntries();
120 n_events->SetBinContent(1,nevts);
122 int i=0,j=0, k=0, l=0;
125 TH1F *h_acc_stt=
new TH1F(
"h_acc_stt",
"STT acceptance",6,0,6);
127 Double_t mc_mom, mc_theta, rec_mom, rec_theta, delta_p;
128 int nEntries = tree->GetEntriesFast();
129 for (Int_t j=0; j< nEntries; j++)
133 for (Int_t mc = 0; mc < mc_array->GetEntriesFast(); mc++)
139 mc_theta = mctrack->
GetMomentum().Theta()*TMath::RadToDeg();
141 for (Int_t pp=0; pp<cand_array->GetEntriesFast(); pp++)
145 if ( (cand_mult==0) || ((cand_mult>0) && (
fabs(rec_mom-mc_mom)>
fabs(pidCand->
GetMomentum().Mag()-mc_mom))) )
155 h_theta_p_nr->Fill(mc_theta, mc_mom);
157 delta_p=rec_mom-mc_mom;
158 h_theta_p->Fill(mc_theta, mc_mom);
159 h_dp_p->Fill(delta_p,mc_mom);
160 h_dp_theta->Fill(delta_p,mc_theta);
163 h_dp_low->Fill(delta_p);
165 h_dp_high->Fill(delta_p);
167 h_acc_stt->Fill(mccount);
173 while (evr.GetEvent() && i++<nevts)
176 phi1_massfit.Cleanup();
177 phi1_massfit_cut.Cleanup();
179 if ((i%100)==0) cout<<
"evt " << i <<
"\n";
181 evr.FillList(p1,
"Charged");
182 evr.FillList(p2,
"Charged");
185 p2.Select(kminusSel);
189 for (Int_t l=0;l<p1.GetLength();l++){
191 if((p1[ii].GetMicroCandidate().GetSttHits())==0){
199 for (Int_t l=0;l<p2.GetLength();l++){
201 if((p2[ii].GetMicroCandidate().GetSttHits())==0){
207 int nchrg=p1.GetLength()+p2.GetLength();
210 for (j=0;j<p1.GetLength();++j) {
211 p1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
213 for (j=0;j<p2.GetLength();++j) {
214 p2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
219 for (j=0;j<phi1.GetLength();++j) h_mphi_nocuts->Fill(phi1[j].M());
221 phi1.Select(phiMassSel);
222 etac_nocut.Combine(phi1,phi1);
224 for (l=0;l<etac_nocut.GetLength();++l) {
225 h_etac_nocut->Fill(etac_nocut[l].M());
229 TVector3 mcVertex, mcD1Vertex, mcD2vertex;
230 evthead->GetVertex(mcVertex);
238 for (l=0;l<p1.GetLength();++l) {
240 if (p1[ii].GetMicroCandidate().GetMcIndex()>-1){
242 (
PndMCTrack*)mc_array->At(p1[ii].GetMicroCandidate().GetMcIndex());
255 std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
256 std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
262 std::cout<<
"MC index =-1"<<std::endl;
270 for (l=0;l<p2.GetLength();++l) {
272 if (p2[ii].GetMicroCandidate().GetMcIndex()>-1){
274 (
PndMCTrack*)mc_array->At(p2[ii].GetMicroCandidate().GetMcIndex());
287 std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
288 std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
294 std::cout<<
"MC index =-1"<<std::endl;
301 phi1_pid.Combine(p1,p2);
303 for (j=0;j<phi1_pid.GetLength();++j) h_mphi_pid->Fill(phi1_pid[j].M());
304 phi1_pid.Select(phiMassSel);
305 etac.Combine(phi1_pid,phi1_pid);
307 for (l=0;l<etac.GetLength();++l) {
308 h_etac_pid->Fill(etac[l].M());
313 double best_chi2=10000;
314 TCandidate *ccfit =
new TCandidate();
315 double m_phi1, m_phi2;
316 for (l=0;l<etac.GetLength();++l) {
324 ccfit = (TCandidate*)fitter.FittedCand(etac[l]);
325 TCandidate *phi1best = fitter.FittedCand(*(etac[l].Daughter(0)));
326 TCandidate *phi2best = fitter.FittedCand(*(etac[l].Daughter(1)));
327 TCandidate *k1best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(0)));
328 TCandidate *k2best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(1)));
329 TCandidate *k3best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(0)));
330 TCandidate *k4best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(1)));
331 TLorentzVector tlvk1 = k1best->P4();
332 TLorentzVector tlvk2 = k2best->P4();
333 TLorentzVector tlvk3 = k3best->P4();
334 TLorentzVector tlvk4 = k4best->P4();
335 m_phi1= (tlvk1+tlvk2).M();
336 m_phi2= (tlvk3+tlvk4).M();
338 h_chi2_4c->Fill(chi2/9);
341 if((etac.GetLength()!=0))
343 h_chi2b_4c->Fill(best_chi2/9);
344 h_etac_4c->Fill(etac[best_i].M());
345 h_etac_4c_refit->Fill(ccfit->M());
346 h_mphi_4c->Fill(m_phi1);
347 h_mphi_4c->Fill(m_phi2);
348 h_mphi_final_4c->Fill(m_phi1);
349 h_mphi_final_4c->Fill(m_phi2);
350 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))
351 && ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
353 h_etac_phimass_4c->Fill(etac[best_i].M());
354 if ((etac[best_i].M()>2.9)&&(etac[best_i].M()<3.06))
360 TCandidate *k1, *k2, *k3, *k4, *phi1tmp, *phi2tmp, *etac_tmp;
363 for (j=0;j<etac.GetLength();++j)
365 phi1tmp=etac[j].Daughter(0);
366 phi2tmp=etac[j].Daughter(1);
368 k1=phi1tmp->Daughter(0);
369 k2=phi1tmp->Daughter(1);
370 k3=phi2tmp->Daughter(0);
371 k4=phi2tmp->Daughter(1);
373 etac_tmp=k1->Combine(*k2,*k3,*k4);
374 etac_vtx.Add(*etac_tmp);
377 for (l=0;l<etac_vtx.GetLength();++l) {
378 h_etac_pid->Fill(etac_vtx[l].M());
382 double best_chi2=10000;
383 TCandidate *etacfit_best=0;
384 TCandidate *k1fit_best=0, *k2fit_best=0, *k3fit_best=0, *k4fit_best=0;
385 TCandidate *phi1fit_best, *phi2fit_best;
387 Float_t etacvtx_mass;
388 for (j=0;j<etac_vtx.GetLength();++j)
393 TCandidate *etacfit=vtxfitter.FittedCand(etac_vtx[j]);
394 TVector3 etacVtx=etacfit->Pos();
395 double chi2_vtx=vtxfitter.GlobalChi2();
396 h_chi2_vtx->Fill(chi2_vtx/5);
398 hvpos->Fill(etacVtx.X(),etacVtx.Y());
399 hvzpos->Fill(etacVtx.Z());
400 if(chi2_vtx<best_chi2)
404 etacfit_best=etacfit;
405 k1fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(0)));
406 k2fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(1)));
407 k3fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(2)));
408 k4fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(3)));
409 etacvtx_mass = etacfit_best->M();
410 bestPos = etacfit->Pos();
414 if((etac.GetLength()!=0)&&(k1fit_best!=0)&&(k3fit_best!=0))
417 h_chi2b_vtx->Fill(best_chi2/5);
418 h_etac_vtx->Fill(etacvtx_mass);
419 phi1fit_best=k1fit_best->Combine(*k2fit_best);
420 phi2fit_best=k3fit_best->Combine(*k4fit_best);
421 double m_phi1=phi1fit_best->M();
422 double m_phi2=phi2fit_best->M();
423 h_mphi_vtx->Fill(m_phi1);
424 h_mphi_vtx->Fill(m_phi2);
425 h_mphi_final_vtx->Fill(m_phi1);
426 h_mphi_final_vtx->Fill(m_phi2);
427 hvtxresX->Fill(mcVertex.X()-bestPos.X());
428 hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
429 hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
431 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&
432 ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
434 h_etac_phimass_vtx->Fill(etacvtx_mass);
435 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
444 double best_chi2_prefit=1e6;
445 TCandidate *etacprefit_best=0;
446 TCandidate *k1prefit_best=0, *k2prefit_best=0, *k3prefit_best=0, *k4prefit_best=0;
447 TCandidate *phi1prefit_best, *phi2prefit_best;
449 Double_t sigma_etac=0.0331, sigma_phi=0.00392;
450 Double_t m_etac_pdg=2.98, m_phi_pdg=1.02;
452 for (j=0;j<etac_vtx.GetLength();++j)
454 metac=etac_vtx[j].M();
455 k1=etac_vtx[j].Daughter(0);
456 k2=etac_vtx[j].Daughter(1);
457 k3=etac_vtx[j].Daughter(2);
458 k4=etac_vtx[j].Daughter(3);
459 phi1prefit_best=k1->Combine(*k2);
460 phi2prefit_best=k3->Combine(*k4);
461 m_phi1=phi1prefit_best->M();
462 m_phi2=phi2prefit_best->M();
464 double chi2_prefit=pow(metac-m_etac_pdg,2)/pow(sigma_etac,2)+
465 pow(m_phi1-m_phi_pdg,2)/pow(sigma_phi,2)+pow(m_phi1-m_phi_pdg,2)/pow(sigma_phi,2);
466 h_chi2_prefit->Fill(chi2_prefit);
468 if(chi2_prefit<best_chi2_prefit)
470 best_chi2_prefit=chi2_prefit;
472 etacprefit_best=etac_vtx[j];
473 etacvtx_mass=etacprefit_best->M();
477 if (etacprefit_best!=0)
481 TCandidate *etacfit=vtxfitter.FittedCand(*etacprefit_best);
482 k1prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(0)));
483 k2prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(1)));
484 k3prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(2)));
485 k4prefit_best=vtxfitter.FittedCand(*(etacfit->Daughter(3)));
486 phi1prefit_best=k1prefit_best->Combine(*k2prefit_best);
487 phi2prefit_best=k3prefit_best->Combine(*k4prefit_best);
488 double m_phi1=phi1prefit_best->M();
489 double m_phi2=phi2prefit_best->M();
490 h_mphi_vtx_2->Fill(m_phi1);
491 h_mphi_vtx_2->Fill(m_phi2);
492 h_mphi_final_vtx_2->Fill(m_phi1);
493 h_mphi_final_vtx_2->Fill(m_phi2);
494 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&
495 ((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
497 h_etac_phimass_vtx_2->Fill(etacvtx_mass);
498 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
549 std::cout<<
"Number of reconstructed eta_c (4C) = "<<n_reco_4c<<std::endl;
550 std::cout<<
"Number of reconstructed eta_c (Vertex fit)= "<<n_reco_vtx<<std::endl;
551 std::cout<<
"Number of reconstructed eta_c (Vertex fit, preselection)= "<<n_reco_vtx_2<<std::endl;
552 n_etac_4c->SetBinContent(1,n_reco_4c);
553 n_etac_vtx->SetBinContent(1,n_reco_vtx);
554 n_etac_vtx_2->SetBinContent(1,n_reco_vtx_2);
559 n_etac_vtx_2->Write();
561 h_etac_nocut->Write();
564 h_etac_vtx_2->Write();
566 h_etac_4c_refit->Write();
567 h_etac_phimass_4c->Write();
568 h_etac_phimass_vtx->Write();
569 h_etac_phimass_vtx_2->Write();
570 h_etac_phimassfit->Write();
572 h_mphi_nocuts->Write();
575 h_mphi_vtx_2->Write();
577 h_mphi_final_4c->Write();
578 h_mphi_final_vtx->Write();
579 h_mphi_final_vtx_2->Write();
580 h_mphi_final_massfit->Write();
587 h_chi2b_vtx->Write();
588 h_chi2_mass->Write();
589 h_chi2_prefit->Write();
598 h_theta_p_nr->Write();
612 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)
Int_t GetNPoints(DetectorId detId) const
Bool_t FitConserveMasses()
TVector3 GetMomentum() const
TH1F * h_etac_phimass_vtx
friend F32vec4 fabs(const F32vec4 &a)
TH1F * h_etac_phimass_vtx_2
int run_ana_eta_c_stt(int nevts=0, bool usePID=true)
TVector3 GetStartVertex() const
Int_t GetMotherID() const
TVector3 GetMomentum() const