9 gStyle->SetOptFit(1011);
10 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
12 TString inPidFile =
"evt_pid.root";
15 TFile *
inFile = TFile::Open(inSimFile,
"READ");
16 TTree *
tree=(TTree *) inFile->Get(
"pndsim") ;
17 tree->AddFriend(
"pndsim",inPidFile);
19 TClonesArray*
mc_array=
new TClonesArray(
"PndMCTrack");
20 tree->SetBranchAddress(
"MCTrack",&mc_array);
22 FairMCEventHeader* evthead;
23 tree->SetBranchAddress(
"MCEventHeader.", &evthead);
25 TFile *
out = TFile::Open(OutFile,
"RECREATE");
28 PndEventReader evr(inPidFile);
30 TH1F *
h_etac_nocut=
new TH1F(
"h_etac_nocut",
"m(eta_c), (no cuts);E, GeV",100,2.5,3.5);
31 TH1F *
h_mphi_nocuts=
new TH1F(
"h_mphi_nocuts",
"#phi: m(K+ K-) (no cuts)",100,0.95,1.1);
33 TH1F *
h_etac_pid=
new TH1F(
"h_etac_pid",
"m(eta_c), (MC PID);E, GeV",100,2.5,3.5);
34 TH1F *
h_mphi_pid=
new TH1F(
"h_mphi_pid",
"#phi: m(K+ K-) (MC PID)",100,0.95,1.1);
36 TH1F *
h_etac_4c=
new TH1F(
"h_etac_4c",
"m(eta_c), 4C-fit",100,2.5,3.5);
37 TH1F *
h_mphi_4c=
new TH1F(
"h_mphi_4c",
"#phi: m(K+ K-) (4C-fit)",100,0.95,1.1);
39 TH1F *
h_etac_vtx=
new TH1F(
"h_etac_vtx",
"m(eta_c), Vertex fit",100,2.5,3.5);
40 TH1F *
h_mphi_vtx=
new TH1F(
"h_mphi_vtx",
"#phi: m(K+ K-) (Vertex fit)",100,0.95,1.1);
42 TH1F *h_etac_phimass=
new TH1F(
"h_etac_phimass",
"m(eta_c), (cut on #phi mass);E, GeV",100,2.5,3.5);
43 TH1F *h_mphi_final=
new TH1F(
"h_mphi_final",
"#phi: m(K+ K-)",100,0.95,1.1);
45 TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
47 TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
48 TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
49 TH1F *
h_chi2_vtx=
new TH1F(
"h_chi2_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
50 TH2F *
hvpos =
new TH2F(
"hvpos",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
51 TH1F *
hvzpos =
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-10,10);
52 TH1F *
hvtxresX =
new TH1F(
"hvtxresX",
"X resolution of fitted decay vertex",100,-0.1,0.1);
53 TH1F *
hvtxresY =
new TH1F(
"hvtxresY",
"Y resolution of fitted decay vertex",100,-0.1,0.1);
54 TH1F *
hvtxresZ =
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay vertex",100,-0.1,0.1);
56 TPidMassSelector *phiMassSel=
new TPidMassSelector(
"phi",1.02,0.02);
58 TPidPlusSelector *kplusSel=
new TPidPlusSelector(
"kplus");
59 TPidMinusSelector *kminusSel=
new TPidMinusSelector(
"kminus");
62 TCandList
p1,
p2, phi1, phi1_pid, etac, etac_pid, etac_nocut;
66 TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
67 TH1F *n_etac=
new TH1F(
"n_etac",
"number of reconstructed eta_c",1,0,1);
69 TLorentzVector ini(0,0,3.6772,4.7333);
71 if (nevts==0) nevts=evr.GetEntries();
73 n_events->SetBinContent(1,nevts);
75 int i=0,j=0, k=0, l=0;
80 while (evr.GetEvent() && i++<nevts)
83 if ((i%100)==0) cout<<
"evt " << i <<
"\n";
85 evr.FillList(p1,
"Charged");
86 evr.FillList(p2,
"Charged");
91 int nchrg=p1.GetLength()+p2.GetLength();
94 for (j=0;j<p1.GetLength();++j) {
95 p1[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
97 for (j=0;j<p2.GetLength();++j) {
98 p2[j].SetMass(TRho::Instance()->GetPDG()->GetParticle(321)->
Mass());
103 for (j=0;j<phi1.GetLength();++j) h_mphi_nocuts->Fill(phi1[j].M());
105 phi1.Select(phiMassSel);
106 etac_nocut.Combine(phi1,phi1);
108 for (l=0;l<etac_nocut.GetLength();++l) {
109 h_etac_nocut->Fill(etac_nocut[l].M());
113 TVector3 mcVertex, mcD1Vertex, mcD2vertex;
114 evthead->GetVertex(mcVertex);
120 for (l=0;l<p1.GetLength();++l) {
122 if (p1[ii].GetMicroCandidate().GetMcIndex()>-1){
136 std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
137 std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
144 for (l=0;l<p2.GetLength();++l) {
146 if (p2[ii].GetMicroCandidate().GetMcIndex()>-1){
160 std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
161 std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
166 phi1_pid.Combine(p1,p2);
168 for (j=0;j<phi1_pid.GetLength();++j) h_mphi_pid->Fill(phi1_pid[j].M());
169 phi1_pid.Select(phiMassSel);
170 etac.Combine(phi1_pid,phi1_pid);
172 for (l=0;l<etac.GetLength();++l) {
173 h_etac_pid->Fill(etac[l].M());
180 double best_chi2=1000;
182 double m_phi1, m_phi2;
183 for (l=0;l<etac.GetLength();++l) {
185 fitter.FitConserveMasses();
186 double chi2=fitter.GetChi2();
191 ccfit = (TCandidate*)fitter.FittedCand(etac[l]);
192 TCandidate *phi1best = fitter.FittedCand(*(etac[l].Daughter(0)));
193 TCandidate *phi2best = fitter.FittedCand(*(etac[l].Daughter(1)));
194 TCandidate *k1best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(0)));
195 TCandidate *k2best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(1)));
196 TCandidate *k3best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(0)));
197 TCandidate *k4best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(1)));
198 TLorentzVector tlvk1 = k1best->P4();
199 TLorentzVector tlvk2 = k2best->P4();
200 TLorentzVector tlvk3 = k3best->P4();
201 TLorentzVector tlvk4 = k4best->P4();
202 m_phi1= (tlvk1+tlvk2).M();
203 m_phi2= (tlvk3+tlvk4).M();
205 h_chi2_4c->Fill(chi2/9);
208 if (etac.GetLength()!=0) cout <<
"evt: " << i <<
"\tbest: " << best_chi2 <<
"\tlen " << etac.GetLength() << endl;
210 if((etac.GetLength()!=0))
212 h_chi2b_4c->Fill(best_chi2/9);
213 h_etac_4c->Fill(ccfit->M());
214 h_mphi_4c->Fill(m_phi1);
215 h_mphi_4c->Fill(m_phi2);
216 h_mphi_final->Fill(m_phi1);
217 h_mphi_final->Fill(m_phi2);
218 if (((m_phi1>1.02-0.02)&&(m_phi1<1.02+0.02))&&((m_phi2>1.02-0.02)&&(m_phi2<1.02+0.02)))
220 h_etac_phimass->Fill(etac[best_i].M());
221 if ((etac[best_i].M()>2.9)&&(etac[best_i].M()<3.06))
229 TCandidate *k1, *k2, *k3, *k4, *phi1tmp, *phi2tmp, *etac_tmp;
232 for (j=0;j<etac.GetLength();++j)
234 phi1tmp=etac[j].Daughter(0);
235 phi2tmp=etac[j].Daughter(1);
237 k1=phi1tmp->Daughter(0);
238 k2=phi1tmp->Daughter(1);
239 k3=phi2tmp->Daughter(0);
240 k4=phi2tmp->Daughter(1);
242 etac_tmp=k1->Combine(*k2,*k3,*k4);
243 etac_vtx.Add(*etac_tmp);
246 for (l=0;l<etac.GetLength();++l) {
247 h_etac_pid->Fill(etac_vtx[l].M());
252 double best_chi2=1000;
253 TCandidate *etacfit_best=0;
254 TCandidate *k1fit_best, *k2fit_best, *k3fit_best, *k4fit_best;
255 TCandidate *phi1fit_best, *phi2fit_best;
257 Float_t etacvtx_mass;
258 for (j=0;j<etac_vtx.GetLength();++j)
263 TCandidate *etacfit=vtxfitter.FittedCand(etac_vtx[j]);
264 TVector3 etacVtx=etacfit->Pos();
265 double chi2_vtx=vtxfitter.GlobalChi2();
266 h_chi2_vtx->Fill(chi2_vtx/5);
268 hvpos->Fill(etacVtx.X(),etacVtx.Y());
269 hvzpos->Fill(etacVtx.Z());
270 if(chi2_vtx<best_chi2)
274 etacfit_best=etacfit;
275 k1fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(0)));
276 k2fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(1)));
277 k3fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(2)));
278 k4fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(3)));
279 etacvtx_mass = etacfit_best->M();
280 bestPos = etacfit->Pos();
284 if((etac.GetLength()!=0))
287 h_etac_vtx->Fill(etacvtx_mass);
288 phi1fit_best=k1fit_best->Combine(*k2fit_best);
289 phi2fit_best=k3fit_best->Combine(*k4fit_best);
290 double m_phi1=phi1fit_best->M();
291 double m_phi2=phi2fit_best->M();
292 h_mphi_vtx->Fill(m_phi1);
293 h_mphi_vtx->Fill(m_phi2);
294 h_mphi_final->Fill(m_phi1);
295 h_mphi_final->Fill(m_phi2);
296 hvtxresX->Fill(mcVertex.X()-bestPos.X());
297 hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
298 hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
300 if (((m_phi1>1.02-0.03)&&(m_phi1<1.02+0.03))&&((m_phi2>1.02-0.03)&&(m_phi2<1.02+0.03)))
302 h_etac_phimass->Fill(etacfit_best->M());
303 if ((etacfit_best->M()>2.9)&&(etacfit_best->M()<3.06))
310 std::cout<<
"Number of reconstructed eta_c = "<<n_reco<<std::endl;
311 n_etac->SetBinContent(1,n_reco);
317 h_etac_nocut->Write();
319 h_etac_phimass->Write();
323 h_mphi_nocuts->Write();
327 h_mphi_final->Write();
TVector3 GetStartVertex() const
Int_t GetMotherID() const