10 #include "/phenix/u/yuhw/RootMacros/sPHENIXStyle/sPhenixStyle.C"
14 const char*
input =
"/sphenix/user/frawley/pileup/macros/macros/g4simulations/eval_output/g4svtx_eval_1.root_g4svtx_eval.root",
15 const int min_nfromtruth = 30
19 gROOT->SetStyle(
"Plain");
20 gStyle->SetOptStat(0);
22 gStyle->SetOptTitle(1);
31 TCut good_gtrack_cut = Form(
"gtrackID>=0 && gembed >= 2 && gntpc > 20 && gnmaps > 1");
32 TCut good_track_cut = Form(
"gtrackID>=0 && gembed >= 2 && ntpc > 20 && quality < 10 && nmaps > 1");
41 TFile *
fout =
new TFile(
"root_files/ntp_track_out.root",
"recreate");
43 TChain* ntp_track =
new TChain(
"ntp_track",
"reco tracks");
44 TChain*
ntp_gtrack =
new TChain(
"ntp_gtrack",
"g4 tracks");
46 bool use_list =
false;
51 for(
int i=0;
i<n_list;
i++)
57 sprintf(name,
"/sphenix/user/frawley/acts_qa/macros/macros/g4simulations/eval_output_2/g4svtx_eval_%i.root_g4svtx_eval.root",ifile);
61 TChain* ntp_vertex =
new TChain(
"ntp_vertex",
"events");
62 ntp_vertex->Add(name);
63 TH1D *hzvtx =
new TH1D(
"hzvtx",
"hzvtx",500,-10.0,10.0);
64 ntp_vertex->Draw(
"vz - gvz >>hzvtx");
65 double meanzdiff = hzvtx->GetMean() ;
66 cout <<
" file " <<
i <<
" has vertex mean Z difference = " << meanzdiff << endl;
67 if( fabs(meanzdiff) > 0.1 )
69 cout <<
" --- Bad event vertex, skip file number " <<
i <<
" with name " << name << endl;
78 cout <<
"Adding file number " <<
i <<
" with name " << name << endl;
80 ntp_gtrack->Add(name);
83 cout <<
" Found " << nbadvtx <<
" events with badly reconstructed vertices, and skipped them" << endl << endl;
85 cout <<
" ntp_gtrack chain entries = " << ntp_gtrack->GetEntries() << endl;
86 cout <<
" ntp_track chain entries = " << ntp_track->GetEntries() << endl;
95 TCanvas *cmvtx =
new TCanvas(
"cmvtx",
"cmvtx");
96 TH1D *hnmvtx =
new TH1D(
"hnmvtx",
"hnmvtx", 100, -1, 4);
97 ntp_track->Draw(
"nmaps>>hnmvtx", good_track_cut);
108 TCanvas *cpt =
new TCanvas(
"cpt",
"cpt");
109 TH2D *
h1 =
new TH2D(
"h1",
"h1",nbinptres, 0.0 ,ptmax,nbin,-range,range);
110 ntp_track->Draw(
"(pt-gpt)/gpt:gpt>>h1",good_track_cut);
113 TH1D*h1_1 = (TH1D*)gDirectory->Get(
"h1_1");
114 TH1D*h1_2 = (TH1D*)gDirectory->Get(
"h1_2");
118 h1_1->SetMarkerStyle(4);
119 h1_1->SetMarkerColor(kBlack);
120 h1_1->SetLineColor(kBlack);
122 h1_2->SetMarkerStyle(20);
123 h1_2->SetMarkerColor(kBlack);
124 h1_2->SetLineColor(kBlack);
125 h1_2->GetYaxis()->SetRangeUser(0, 0.10);
126 h1_2->GetYaxis()->SetTitleOffset(1.5);
128 h1_2->SetTitle(
";p_{T} [GeV/c];#frac{#Delta p_{T}}{p_{T}}");
133 TCanvas * c3 =
new TCanvas(
"c3",
"c3");
134 TH1D* h3_den =
new TH1D(
"h3_den",
"; p_{T}; Efficiency",nbinpteff, 0, ptmax);
135 TH1D* h3_num = (TH1D*)h3_den->Clone(
"h3_num");;
136 TH1D* h3_eff = (TH1D*)h3_den->Clone(
"h3_eff");;
138 cout<<__LINE__<<
": "<< good_track_cut <<endl;
139 ntp_gtrack->Draw(
"gpt>>h3_den",good_gtrack_cut);
141 ntp_track->Draw(
"gpt>>h3_num",good_track_cut);
143 for(
int i=1;
i<=h3_den->GetNbinsX();++
i){
144 double pass = h3_num->GetBinContent(
i);
145 double all = h3_den->GetBinContent(
i);
153 h3_eff->SetBinContent(
i, eff);
160 h3_eff->SetTitle(
"; p_{T} [GeV/c]; eff.");
161 h3_eff->SetMarkerStyle(20);
162 h3_eff->SetMarkerColor(kBlack);
163 h3_eff->SetLineColor(kBlack);
164 h3_eff->GetYaxis()->SetRangeUser(0.0, 1.1);
170 TCanvas *c4 =
new TCanvas(
"c4",
"c4",5,5,800,800);
173 TH2D *
h2 =
new TH2D(
"h2",
"h2",nbinptdca, 0,ptmax,nbin,-0.06,0.06);
174 ntp_track->Draw(
"(dca3dxy):gpt>>h2",good_track_cut);
176 TH1D*h2_1 = (TH1D*)gDirectory->Get(
"h2_1");
177 TH1D*h2_2 = (TH1D*)gDirectory->Get(
"h2_2");
180 h2_1->SetMarkerStyle(4);
181 h2_1->SetMarkerColor(kBlack);
182 h2_1->SetLineColor(kBlack);
184 h2_2->SetMarkerStyle(20);
185 h2_2->SetMarkerColor(kBlack);
186 h2_2->SetLineColor(kBlack);
188 h2_2->GetYaxis()->SetRangeUser(0.,0.01);
189 h2_2->GetYaxis()->SetTitleOffset(1.5);
191 h2_2->SetTitle(
";p_{T} [GeV/c];dca2d (cm)}");
197 TCanvas *c5 =
new TCanvas(
"c5",
"c5",5,5,800,800);
199 TH2D *h3 =
new TH2D(
"h3",
"h3",nbinptdca, 0, ptmax, nbin, -0.1, 0.1);
201 ntp_track->Draw(
"(dca3dz-gvz):gpt>>h3",good_track_cut);
203 ntp_track->Draw(
"(dca3dz):gpt>>h3",good_track_cut);
205 TH1D*h3_1 = (TH1D*)gDirectory->Get(
"h3_1");
206 TH1D*h3_2 = (TH1D*)gDirectory->Get(
"h3_2");
210 h3_1->SetMarkerStyle(4);
211 h3_1->SetMarkerColor(kBlack);
212 h3_1->SetLineColor(kBlack);
214 h3_2->SetMarkerStyle(20);
215 h3_2->SetMarkerColor(kBlack);
216 h3_2->SetLineColor(kBlack);
218 h3_2->GetYaxis()->SetRangeUser(0.,0.01);
219 h3_2->GetYaxis()->SetTitleOffset(1.5);
221 h3_2->SetTitle(
";p_{T} [GeV/c];dca2d (cm)}");
226 TCanvas *c6 =
new TCanvas(
"c6",
"c6", 5,5,1200, 800);
228 TH2D *h6 =
new TH2D(
"h6",
"h6",nbinptdca, 0, ptmax, nbin, -1.0, 4.0);
229 ntp_track->Draw(
"ntrumaps:gpt>>h6",good_track_cut);
232 TH1D *h6_1 =
new TH1D(
"h6_1",
"h6_1",nbin, 0.0, 1.2);
233 int binlo = h6->GetYaxis()->FindBin(2.5);
234 int binhi = h6->GetYaxis()->FindBin(3.5);
235 h6->ProjectionX(
"h6_1",binlo,binhi);
236 h6_1->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
237 h6_1->SetLineWidth(2.0);
238 h6_1->SetLineColor(kBlue);
241 TH1D *h6_2 =
new TH1D(
"h6_2",
"h6_2",nbin, 0.0, 1.2);
242 binlo = h6->GetYaxis()->FindBin(-0.5);
243 binhi = h6->GetYaxis()->FindBin(0.5);
244 h6->ProjectionX(
"h6_2",binlo,binhi);
245 h6_2->GetXaxis()->SetTitle(
"p_{T} (GeV/c)");
246 h6_2->SetLineColor(kRed);
247 h6_2->SetLineWidth(2.0);
253 TLegend *l =
new TLegend(0.15,0.75,0.45,0.85,
"",
"NDC");
255 l->AddEntry(h6_2,
"ntrumaps = 0",
"l");
256 l->AddEntry(h6_1,
"ntrumaps = 3",
"l");