15 #include <TPolyLine.h>
20 #include <TLorentzVector.h>
26 gROOT->SetStyle(
"Plain");
27 gStyle->SetOptStat(1);
28 gStyle->SetOptTitle(1);
34 double quality_cut = 3.0;
38 sprintf(lepton,
"electron");
40 double decaymass=0.000511;
41 cout <<
"Assuming decay particle mass is " << decaymass << endl;
48 TH1F* hrquality =
new TH1F(
"hrquality",
"Reconstructed track Quality", 1000, 0, 10);
49 TH1F* hrdca2d =
new TH1F(
"hrdca2d",
"Reconstructed track dca2d", 1000, 0, 0.05);
50 TH1F* hrpt =
new TH1F(
"hrpt",
" pT", nbpt, 0.0, ptmax);
51 TH1F* hgpt =
new TH1F(
"hgpt",
"g4 pT", nbpt, 0.0, ptmax);
53 TH1D *g4mass =
new TH1D(
"g4mass",
"G4 input invariant mass",200,7.0,11.0);
54 g4mass->GetXaxis()->SetTitle(
"invariant mass (GeV/c^{2})");
55 TH1D *g4mass_primary =
new TH1D(
"g4mass_primary",
"G4 input invariant mass",200,7.0,11.0);
56 g4mass_primary->GetXaxis()->SetTitle(
"invariant mass (GeV/c^{2})");
58 TH1D *
recomass =
new TH1D(
"recomass",
"Reconstructed invariant mass",200,7.0,11.0);
59 recomass->GetXaxis()->SetTitle(
"invariant mass (GeV/c^{2})");
60 TH1D *recomass_primary =
new TH1D(
"recomass_primary",
"Reconstructed invariant mass",200,7.0,11.0);
61 recomass_primary->GetXaxis()->SetTitle(
"invariant mass (GeV/c^{2})");
68 int nups_requested = 0;
69 double pair_acc = 0.60 * 0.9 * 0.98;
71 if(ups_state == 1) nups_requested = pair_acc * (8769 * 1.126) / (0.38 * 0.9 * 0.98);
72 if(ups_state == 2) nups_requested = pair_acc * (2205 * 1.126) / (0.38 * 0.9 * 0.98);
73 if(ups_state == 3) nups_requested = pair_acc * (1156 * 1.126) / (0.38 * 0.9 * 0.98);
75 nups_requested = 100000;
77 cout <<
"ups_state = " << ups_state <<
" Upsilons requested = " << nups_requested << endl;
83 cout <<
"Reading electron ntuples " << endl;
85 double nhittpcin_cum = 0;
86 double nhittpcin_wt = 0;
89 for(
int i=0;
i<2000;
i++)
91 if(nrecormass > nups_requested)
93 cout <<
"Reached requested number of reco Upsilons, quit out of file loop" << endl;
102 sprintf(name,
"/sphenix/user/frawley/macros_newTPC_june6/macros/macros/g4simulations/intt_0layers_eval_output/g4svtx_eval_%i.root_g4svtx_eval.root",
i);
130 cout <<
"Adding file " << name << endl;
132 TChain* ntp_track =
new TChain(
"ntp_track",
"reco tracks");
133 TChain*
ntp_gtrack =
new TChain(
"ntp_gtrack",
"g4 tracks");
134 TChain* ntp_vertex =
new TChain(
"ntp_vertex",
"events");
135 TChain *ntp_cluster =
new TChain(
"ntp_cluster",
"clusters");
136 TChain *ntp_g4hit =
new TChain(
"ntp_g4hit",
"G4 hits");
138 ntp_vertex->Add(name);
139 ntp_track->Add(name);
140 ntp_gtrack->Add(name);
143 cout <<
"The ntuples contain " << ntp_vertex->GetEntries() <<
" events " << endl;
154 ntracks = ntp_track->GetEntries();
155 ngtracks = ntp_gtrack->GetEntries();
160 int nev = ntp_vertex->GetEntries();
162 for(
int iev=0;iev<nev;iev++)
165 if(nrecormass > nups_requested)
167 cout <<
"Reached requested number of reco Upsilons, quit" << endl;
174 int recoget = ntp_vertex->GetEntry(iev);
182 <<
" event " <<
event
183 <<
" ntracks (reco) " <<
ntracks
195 int ng4trevt_elec = -1;
196 int ng4trevt_pos = -1;
197 int g4trnum_elec[1000];
198 int g4trnum_pos[1000];
204 int recoget1 = ntp_gtrack->GetEntry(ig);
207 if(verbose > 0) cout <<
"Did not get entry for ig = " << ig << endl;
216 if(verbose > 0) cout <<
" reached new event for ig = " << ig <<
" tevent = " <<
tevent << endl;
220 if(ig == ng+ngtracks - 1)
222 if(verbose > 0) cout <<
" last time through loop for ig = " << ig <<
" revent = " <<
tevent << endl;
240 if(ng4trevt_elec > 999)
244 cout <<
" Found electron:" << endl
246 <<
" ng4trevt_elec " << ng4trevt_elec
254 g4trnum_elec[ng4trevt_elec] = ig;
260 if(ng4trevt_pos > 999)
264 cout <<
" Found positron:" << endl
266 <<
" ng4trevt_pos " << ng4trevt_pos
274 g4trnum_pos[ng4trevt_pos] = ig;
281 cout <<
"For this event found " << ng4trevt_elec <<
" g4 electrons and " << ng4trevt_pos <<
" g4 positrons" << endl;
284 for(
int ielec=0;ielec<ng4trevt_elec;ielec++)
286 int recoelec = ntp_gtrack->GetEntry(g4trnum_elec[ielec]);
293 double elec_eta = asinh(
tpz/sqrt(
tpx*
tpx+tpy*tpy));
298 double E1 = sqrt( pow(
tpx,2) + pow(tpy,2) + pow(
tpz,2) + pow(decaymass,2));
299 t1.SetPxPyPzE(
tpx,tpy,
tpz,E1);
303 cout <<
" Pair electron: iev " << iev <<
" ielec " << ielec
304 <<
" g4trnum_elec " << g4trnum_elec[ielec]
310 <<
" elec_eta " << elec_eta
311 <<
" elec_gpT " << elec_pT
314 for(
int ipos =0;ipos<ng4trevt_pos;ipos++)
316 int recopos = ntp_gtrack->GetEntry(g4trnum_pos[ipos]);
320 double pos_pT = sqrt(
tpx*
tpx+tpy*tpy);
321 double pos_eta = asinh(
tpz/sqrt(
tpx*
tpx+tpy*tpy));
325 cout <<
" Pair positron: iev " << iev <<
" ipos " << ipos
326 <<
" g4trnum_pos " << g4trnum_pos[ipos]
332 <<
" pos_eta " << pos_eta
333 <<
" pos_gpT " << pos_pT
339 double E2 = sqrt( pow(
tpx,2) + pow(tpy,2) + pow(
tpz,2) + pow(decaymass,2));
340 t2.SetPxPyPzE(
tpx,tpy,
tpz,E2);
342 TLorentzVector
t = t1+
t2;
345 cout <<
" reco'd g4 mass = " << t.M() << endl << endl;
347 if(t.M() > 7.0 && t.M() < 11.0)
354 g4mass_primary->Fill(t.M());
363 cout <<
" # of g4 electron tracks = " << ng4trevt_elec
364 <<
" # of g4 positron tracks = " << ng4trevt_pos << endl;
376 int rectrnum_elec[1000];
377 int rectrnum_pos[1000];
381 for(
int ir=nr;ir<nr+
ntracks;ir++)
383 int recoget = ntp_track->GetEntry(ir);
386 if(verbose > 0) cout <<
"Did not get entry for ir = " << ir << endl;
395 if(verbose > 1) cout <<
" reached new event for ir = " << ir <<
" revent = " <<
revent << endl;
399 if(ir == nr+ntracks - 1)
401 if(verbose > 0) cout <<
" last time through loop for ir = " << ir <<
" revent = " <<
revent << endl;
419 rectrnum_elec[nr_elec] = ir;
425 rectrnum_pos[nr_pos] = ir;
430 double reta = asinh(
rpz/sqrt(
rpx*
rpx+rpy*rpy));
434 cout <<
" revent " <<
revent <<
" ir " << ir
446 for(
int ielec = 0;ielec<nr_elec;ielec++)
451 int recoget1 = ntp_track->GetEntry(rectrnum_elec[ielec]);
455 double E1 = sqrt( pow(
rpx,2) + pow(
rpy,2) + pow(
rpz,2) + pow(decaymass,2));
458 for(
int ipos = 0;ipos<nr_pos;ipos++)
460 int recoget2 = ntp_track->GetEntry(rectrnum_pos[ipos]);
465 double E2 = sqrt( pow(
rpx,2) + pow(
rpy,2) + pow(
rpz,2) + pow(decaymass,2));
469 TLorentzVector
t = t1+
t2;
472 cout <<
" reco'd track mass = " << t.M() << endl;
474 if(t.M() > 7.0 && t.M() < 11.0)
477 recomass->Fill(t.M());
481 if( (trid1 == 1 || trid1 == 2) && (trid2 == 1 || trid2 == 2) )
482 recomass_primary->Fill(t.M());
494 cout <<
"nevents = " << nevents << endl;
496 cout <<
"nrecog4mass = " << nrecog4mass << endl;
498 cout <<
"nrecormass = " << nrecormass << endl;
500 cout <<
"nhittpcin per event = " << nhittpcin_cum/nhittpcin_wt << endl;
507 TCanvas *cq =
new TCanvas(
"cq",
"cq",5,5,600,600 );
517 TCanvas *cmass =
new TCanvas(
"cmass",
"cmass",10,10,800,600);
519 recomass_primary->SetLineColor(kRed);
520 recomass->SetLineColor(kBlack);
521 recomass->DrawCopy();
522 recomass_primary->DrawCopy(
"same");
524 TCanvas *cm_comp =
new TCanvas(
"cm_comp",
"cm_comp",10,10,800,800);
525 cm_comp->Divide(2,1);
528 recomass_primary->Draw(
"same");
531 double yreco = recomass->Integral();
532 double yreco_primary = recomass_primary->Integral();
533 cout <<
"Reconstructed mass spectrum has " << yreco_primary <<
" entries from primary tracks and " << yreco <<
" entries total " << endl;
537 g4mass_primary->SetLineColor(kRed);
539 g4mass_primary->Draw(
"same");
541 double yg4_primary = g4mass_primary->Integral();
542 double yg4 = g4mass->Integral();
543 cout <<
"G4 mass spectrum has " << yg4_primary <<
" entries from primary tracks and " << yg4 <<
" entries total" << endl;
545 cout <<
"Reconstruction efficiency is " << yreco_primary/yg4_primary << endl;
551 sprintf(fname,
"root_files/ups%is_qual%.2f_dca2d%.2f.root",ups_state,quality_cut,dca_cut);
553 cout <<
"Create output file " << fname << endl;
555 TFile *fout1 =
new TFile(fname,
"recreate");
557 recomass_primary->Write();
559 g4mass_primary->Write();
565 cout <<
"Finished write to file " << fname << endl;