8 TString inPidFile =
"evt_pid_stt.root";
11 TString inParFile =
"evt_params_stt.root";
13 gStyle->SetOptFit(1011);
14 gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
16 FairLogger::GetLogger()->SetLogToFile(kFALSE);
20 FairRunAna*
fRun =
new FairRunAna();
21 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
22 fRun->SetInputFile(inSimFile);
23 fRun->AddFriend(inPidFile);
24 fRun->AddFriend(inRecoFile);
26 FairParRootFileIo* parIO =
new FairParRootFileIo();
27 parIO->open(inParFile);
28 rtdb->setFirstInput(parIO);
29 rtdb->setOutput(parIO);
31 fRun->SetOutputFile(OutFile);
34 TFile *
out = TFile::Open(
"output_newmc.root",
"RECREATE");
37 TH1F *
h_etac_nocut=
new TH1F(
"h_etac_nocut",
"m(eta_c), (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)",100,0.95,1.1);
40 TH1F *
h_etac_pid=
new TH1F(
"h_etac_pid",
"m(eta_c), (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)",100,0.95,1.1);
43 TH1F *
h_etac_4c=
new TH1F(
"h_etac_4c",
"m(eta_c), 4C-fit",100,2.5,3.5);
44 TH1F *
h_mphi_4c=
new TH1F(
"h_mphi_4c",
"#phi: m(K+ K-) (4C-fit)",100,0.95,1.1);
46 TH1F *
h_etac_vtx=
new TH1F(
"h_etac_vtx",
"m(eta_c), Vertex fit",100,2.5,3.5);
47 TH1F *
h_mphi_vtx=
new TH1F(
"h_mphi_vtx",
"#phi: m(K+ K-) (Vertex fit)",100,0.95,1.1);
49 TH1F *
h_etac_phimass=
new TH1F(
"h_etac_phimass",
"m(eta_c), (cut on #phi mass);E, GeV",100,2.5,3.5);
50 TH1F *
h_mphi_final=
new TH1F(
"h_mphi_final",
"#phi: m(K+ K-)",100,0.95,1.1);
52 TH1F *
nc=
new TH1F(
"nc",
"n charged",20,0,20);
54 TH1F *
h_chi2_4c=
new TH1F(
"h_chi2_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
55 TH1F *
h_chi2b_4c=
new TH1F(
"h_chi2b_4c",
"#chi^{2} 4C-fit;#chi^{2}/N_{df}",100,0,100);
56 TH1F *
h_chi2_vtx=
new TH1F(
"h_chi2_vtx",
"#chi^{2} vertex;#chi^{2}/N_{df}",100,0,100);
57 TH2F *
hvpos =
new TH2F(
"hvpos",
"(x,y) projection of fitted decay vertex",100,-5,5,100,-5,5);
58 TH1F *
hvzpos =
new TH1F(
"hvzpos",
"z position of fitted decay vertex",100,-10,10);
59 TH1F *
hvtxresX =
new TH1F(
"hvtxresX",
"X resolution of fitted decay vertex",100,-0.1,0.1);
60 TH1F *
hvtxresY =
new TH1F(
"hvtxresY",
"Y resolution of fitted decay vertex",100,-0.1,0.1);
61 TH1F *
hvtxresZ =
new TH1F(
"hvtxresZ",
"Z resolution of fitted decay vertex",100,-0.1,0.1);
63 TPidMassSelector *phiMassSel=
new TPidMassSelector(
"phi",1.02,0.02);
66 TCandList
p1,
p2, phi1, phi1_pid, etac, etac_pid, etac_nocut, mctracks;
70 TH1F *
n_events=
new TH1F(
"n_events",
"total number of events",1,0,1);
71 TH1F *
n_etac=
new TH1F(
"n_etac",
"number of reconstructed eta_c",1,0,1);
73 TLorentzVector ini(0,0,3.6772,4.7333);
76 if (nevts==0) nevts= theAnalysis->
GetEntries();
77 n_events->SetBinContent(1,nevts);
79 int i=0,j=0, k=0, l=0;
84 while (theAnalysis->
GetEvent() && i++<nevts)
88 if ((i%100)==0) cout<<
"evt " << i << endl;
91 theAnalysis->
FillList(mctracks,
"McTruth");
92 theAnalysis->
FillList(p1,
"KaonVeryLoosePlus");
93 theAnalysis->
FillList(p2,
"KaonVeryLooseMinus");
95 int nchrg=p1.GetLength()+p2.GetLength();
99 for (j=0;j<phi1.GetLength();++j) h_mphi_nocuts->Fill(phi1[j].M());
101 phi1.Select(phiMassSel);
102 etac_nocut.Combine(phi1,phi1);
104 for (l=0;l<etac_nocut.GetLength();++l) {
105 h_etac_nocut->Fill(etac_nocut[l].M());
109 TVector3 mcVertex, mcD1Vertex, mcD2vertex;
110 evthead->GetVertex(mcVertex);
116 for (l=0;l<p1.GetLength();++l) {
118 Int_t mcIndex = p1[ii].GetMicroCandidate().GetMcIndex();
120 if ((mctracks[mcIndex].PdgCode()!=321))
125 if (mcIndex==0) mcD1Vertex = mctracks[mcIndex].Pos();
126 if (mcIndex==2) mcD1Vertex = mctracks[mcIndex].Pos();
130 std::cout<<
"stt h: " << p1[ii].GetMicroCandidate().GetSttHits() << std::endl;
131 std::cout<<
"Kaon list 1, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
137 for (l=0;l<p2.GetLength();++l) {
139 Int_t mcIndex = p2[ii].GetMicroCandidate().GetMcIndex();
141 if ((mctracks[mcIndex].PdgCode()!=-321))
146 if (mcIndex==1) mcD1Vertex = mctracks[mcIndex].Pos();
147 if (mcIndex==3) mcD1Vertex = mctracks[mcIndex].Pos();
151 std::cout<<
"stt h: " << p2[ii].GetMicroCandidate().GetSttHits() << std::endl;
152 std::cout<<
"Kaon list 2, element "<<l<<
" has no assosiated mcTRack"<<std::endl;
156 phi1_pid.Combine(p1,p2);
158 for (j=0;j<phi1_pid.GetLength();++j) h_mphi_pid->Fill(phi1_pid[j].M());
159 phi1_pid.Select(phiMassSel);
160 etac.Combine(phi1_pid,phi1_pid);
162 for (l=0;l<etac.GetLength();++l) {
163 h_etac_pid->Fill(etac[l].M());
170 double best_chi2=1000;
172 double m_phi1, m_phi2;
173 for (l=0;l<etac.GetLength();++l) {
181 ccfit = (TCandidate*)fitter.FittedCand(etac[l]);
182 TCandidate *phi1best = fitter.FittedCand(*(etac[l].Daughter(0)));
183 TCandidate *phi2best = fitter.FittedCand(*(etac[l].Daughter(1)));
184 TCandidate *k1best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(0)));
185 TCandidate *k2best = fitter.FittedCand(*(etac[l].Daughter(0)->Daughter(1)));
186 TCandidate *k3best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(0)));
187 TCandidate *k4best = fitter.FittedCand(*(etac[l].Daughter(1)->Daughter(1)));
188 TLorentzVector tlvk1 = k1best->P4();
189 TLorentzVector tlvk2 = k2best->P4();
190 TLorentzVector tlvk3 = k3best->P4();
191 TLorentzVector tlvk4 = k4best->P4();
192 m_phi1= (tlvk1+tlvk2).M();
193 m_phi2= (tlvk3+tlvk4).M();
195 h_chi2_4c->Fill(chi2/9);
198 if (etac.GetLength()!=0) cout <<
"evt: " << i <<
"\tbest: " << best_chi2 <<
"\tlen " << etac.GetLength() << endl;
200 if((etac.GetLength()!=0))
202 h_chi2b_4c->Fill(best_chi2/9);
203 h_etac_4c->Fill(ccfit->M());
204 h_mphi_4c->Fill(m_phi1);
205 h_mphi_4c->Fill(m_phi2);
206 h_mphi_final->Fill(m_phi1);
207 h_mphi_final->Fill(m_phi2);
208 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)))
210 h_etac_phimass->Fill(etac[best_i].M());
211 if ((etac[best_i].M()>2.9)&&(etac[best_i].M()<3.06))
219 TCandidate *k1, *k2, *k3, *k4, *phi1tmp, *phi2tmp, *etac_tmp;
222 for (j=0;j<etac.GetLength();++j)
224 phi1tmp=etac[j].Daughter(0);
225 phi2tmp=etac[j].Daughter(1);
227 k1=phi1tmp->Daughter(0);
228 k2=phi1tmp->Daughter(1);
229 k3=phi2tmp->Daughter(0);
230 k4=phi2tmp->Daughter(1);
232 etac_tmp=k1->Combine(*k2,*k3,*k4);
233 etac_vtx.Add(*etac_tmp);
236 for (l=0;l<etac.GetLength();++l) {
237 h_etac_pid->Fill(etac_vtx[l].M());
242 double best_chi2=1000;
243 TCandidate *etacfit_best=0;
244 TCandidate *k1fit_best, *k2fit_best, *k3fit_best, *k4fit_best;
245 TCandidate *phi1fit_best, *phi2fit_best;
247 Float_t etacvtx_mass;
248 for (j=0;j<etac_vtx.GetLength();++j)
254 TCandidate *etacfit=vtxfitter.FittedCand(etac_vtx[j]);
255 TVector3 etacVtx=etacfit->Pos();
256 double chi2_vtx=vtxfitter.GlobalChi2();
257 h_chi2_vtx->Fill(chi2_vtx/5);
259 hvpos->Fill(etacVtx.X(),etacVtx.Y());
260 hvzpos->Fill(etacVtx.Z());
261 if(chi2_vtx<best_chi2)
265 etacfit_best=etacfit;
266 k1fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(0)));
267 k2fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(1)));
268 k3fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(2)));
269 k4fit_best=vtxfitter.FittedCand(*(etacfit_best->Daughter(3)));
270 etacvtx_mass = etacfit_best->M();
271 bestPos = etacfit->Pos();
275 if((etac.GetLength()!=0))
278 h_etac_vtx->Fill(etacvtx_mass);
279 phi1fit_best=k1fit_best->Combine(*k2fit_best);
280 phi2fit_best=k3fit_best->Combine(*k4fit_best);
281 double m_phi1=phi1fit_best->M();
282 double m_phi2=phi2fit_best->M();
283 h_mphi_vtx->Fill(m_phi1);
284 h_mphi_vtx->Fill(m_phi2);
285 h_mphi_final->Fill(m_phi1);
286 h_mphi_final->Fill(m_phi2);
287 hvtxresX->Fill(mcVertex.X()-bestPos.X());
288 hvtxresY->Fill(mcVertex.Y()-bestPos.Y());
289 hvtxresZ->Fill(mcVertex.Z()-bestPos.Z());
291 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)))
293 h_etac_phimass->Fill(etacvtx_mass);
294 if ((etacvtx_mass>2.9)&&(etacvtx_mass<3.06))
301 std::cout<<
"Number of reconstructed eta_c = "<<n_reco<<std::endl;
302 n_etac->SetBinContent(1,n_reco);
308 h_etac_nocut->Write();
310 h_etac_phimass->Write();
314 h_mphi_nocuts->Write();
318 h_mphi_final->Write();
FairMCEventHeader * GetEventHeader()
Bool_t FitConserveMasses()
Bool_t FillList(RhoCandList &l, TString listkey="All", TString pidTcaNames="", int trackHypothesis=-1)
int newana_check_eta(int nevts=0)
void AddMassConstraint(double mass)
Int_t GetEvent(Int_t n=-1)