1 #include "SaveCanvas.C"
2 #include "sPhenixStyle.C"
6 #include <TEfficiency.h>
8 #include <TGraphAsymmErrors.h>
9 #include <TGraphErrors.h>
23 #include <TVirtualFitter.h>
38 cout << "Assert (" << #exp << ") failed at " << __FILE__ << " line " << __LINE__ << endl; \
46 TCut
primPartCut(
"gpt>.1 && abs(geta)<1 && abs(gvt)<1e-10");
47 TCut
recoCut(
"nlmaps>=2 && pt>0");
48 const double pTMin(.3);
56 assert(axis->GetXmin() > 0);
57 assert(axis->GetXmax() > 0);
59 const int bins = axis->GetNbins();
61 Axis_t from = log10(axis->GetXmin());
62 Axis_t to = log10(axis->GetXmax());
63 Axis_t
width = (to - from) / bins;
64 vector<Axis_t> new_bins(bins + 1);
68 new_bins[
i] = TMath::Power(10, from +
i * width);
70 axis->Set(bins, new_bins.data());
76 TProfile *p2 = h2->ProfileX();
84 for (
int i = 1;
i <= h2->GetNbinsX();
i++)
86 TH1D *
h1 = h2->ProjectionY(Form(
"htmp_%d", rand()),
i,
i);
88 if (h1->GetSum() < 30)
90 cout <<
"FitProfile - ignore bin " <<
i << endl;
98 TF1 fgaus(
"fgaus",
"gaus", -p2->GetBinError(
i) * 4,
99 p2->GetBinError(
i) * 4);
104 fgaus.SetParameter(1, p2->GetBinContent(
i));
105 fgaus.SetParameter(2, p2->GetBinError(
i));
107 h1->Fit(&fgaus,
"MQ");
109 TF1
f2(Form(
"dgaus"),
"gaus + [3]",
110 -fgaus.GetParameter(2) * 1.5, fgaus.GetParameter(2) * 1.5);
112 f2.SetParameters(fgaus.GetParameter(0), fgaus.GetParameter(1),
113 fgaus.GetParameter(2), 0);
122 x[
n] = p2->GetBinCenter(
i);
123 ex[
n] = (p2->GetBinCenter(2) - p2->GetBinCenter(1)) / 2;
124 y[
n] = fgaus.GetParameter(2);
125 ey[
n] = fgaus.GetParError(2);
134 return new TGraphErrors(n, x, y, ex, ey);
137 void RecoCheck(
const TString &
name =
"pi",
const TCut &cut =
"abs(gflavor)==211",
const int nBins = 100)
141 TCanvas *c1 =
new TCanvas(
"RecoCheck_" +
name,
"RecoCheck_" +
name, 1800, 960);
146 p = (TPad *) c1->cd(idx++);
150 p->DrawFrame(
pTMin, 0, 20, 1.1,
"Efficiency;Truth p_{T} [GeV/c];Tracking efficiency");
151 TLine *l =
new TLine(
pTMin, 1, 20, 1);
154 TH1 *hTruthpT =
new TH1F(
"hTruthpT",
"hTruthpT;Truth p_{T} [GeV/c]", nBins,
pTMin, 20);
156 TH1 *hRecopT =
new TH1F(
"hRecopT",
"hRecopT;Truth p_{T} [GeV/c]", nBins,
pTMin, 20);
158 TH1 *hRecopTMVTX =
new TH1F(
"hRecopTMVTX",
"hRecopT;Truth p_{T} [GeV/c]", nBins,
pTMin, 20);
165 TEfficiency *hEffpTMVTX =
new TEfficiency(*hRecopTMVTX, *hTruthpT);
166 hEffpTMVTX->SetName(
"hEffpTMVTX");
167 hEffpTMVTX->SetTitle(
"Efficiency;Truth p_{T} [GeV/c];Tracking efficiency");
168 hEffpTMVTX->Draw(
"p same");
169 hEffpTMVTX->SetLineColor(kBlue + 2);
170 hEffpTMVTX->SetMarkerColor(kBlue + 2);
173 TEfficiency *hEffpT =
new TEfficiency(*hRecopT, *hTruthpT);
174 hEffpT->SetName(
"hEffpT");
175 hEffpT->SetTitle(
"Efficiency;Truth p_{T} [GeV/c];Tracking efficiency");
176 hEffpT->Draw(
"P same");
177 hEffpT->SetLineColor(kRed + 2);
178 hEffpT->SetMarkerColor(kRed + 2);
183 p = (TPad *) c1->cd(idx++);
188 TH2 *hpTResolution =
new TH2F(
"hpTResolution",
"hpTResolution;Truth p_{T} [GeV/c];#Deltap_{T}/p_{T}", nBins,
pTMin, 20, 1000, -.2, .2);
190 hpTResolution->GetYaxis()->SetRangeUser(-.1, .1);
194 TGraphErrors *gepTResolution =
FitProfile(hpTResolution);
195 gepTResolution->SetName(
"gepTResolution");
197 hpTResolution->Draw(
"colz");
198 gepTResolution->Draw(
"p");
200 p = (TPad *) c1->cd(idx++);
205 TH2 *hcotThetaResolution =
new TH2F(
"hcotThetaResolution",
"hcotThetaResolution;Truth p_{T} [GeV/c];#Delta[p_{z}/p_{T}]", nBins,
pTMin, 20, 1000, -.1, .1);
207 hcotThetaResolution->GetYaxis()->SetRangeUser(-.01, .01);
211 TGraphErrors *gecotThetaResolution =
FitProfile(hcotThetaResolution);
212 gecotThetaResolution->SetName(
"gecotThetaResolution");
214 hcotThetaResolution->Draw(
"colz");
215 gecotThetaResolution->Draw(
"p");
217 p = (TPad *) c1->cd(idx++);
222 TH2 *hsinPhiResolution =
new TH2F(
"hsinPhiResolution",
"hsinPhiResolution;Truth p_{T} [GeV/c];sin(#Delta#phi)", nBins,
pTMin, 20, 1000, -.1, .1);
224 hsinPhiResolution->GetYaxis()->SetRangeUser(-.01, .01);
228 TGraphErrors *gesinPhiResolution =
FitProfile(hsinPhiResolution);
229 gesinPhiResolution->SetName(
"gesinPhiResolution");
231 hsinPhiResolution->Draw(
"colz");
232 gesinPhiResolution->Draw(
"p");
234 p = (TPad *) c1->cd(idx++);
239 TH2 *hDCA3DXYResolution =
new TH2F(
"hDCA3DXYResolution",
"hDCA3DXYResolution;Truth p_{T} [GeV/c];DCA_{xy} [cm]", nBins,
pTMin, 20, 1000, -.2, .2);
241 hDCA3DXYResolution->GetYaxis()->SetRangeUser(-.02, .02);
245 TGraphErrors *geDCA3DXYResolution =
FitProfile(hDCA3DXYResolution);
246 geDCA3DXYResolution->SetName(
"geDCA3DXYResolution");
248 hDCA3DXYResolution->Draw(
"colz");
249 geDCA3DXYResolution->Draw(
"p");
251 p = (TPad *) c1->cd(idx++);
256 TH2 *hDCA3DZResolution =
new TH2F(
"hDCA3DZResolution",
"hDCA3DZResolution;Truth p_{T} [GeV/c];DCA_{z} [cm]", nBins,
pTMin, 20, 1000, -.2, .2);
258 hDCA3DZResolution->GetYaxis()->SetRangeUser(-.02, .02);
262 TGraphErrors *geDCA3DZResolution =
FitProfile(hDCA3DZResolution);
263 geDCA3DZResolution->SetName(
"geDCA3DZResolution");
265 hDCA3DZResolution->Draw(
"colz");
266 geDCA3DZResolution->Draw(
"p");
271 void DCACheck(
const TString &
name =
"pi",
const TCut &cut =
"abs(gflavor)==211",
const int nBins = 14)
275 const int nDCAbins = 2 * (100 / 1 * 2 + (1000 - 100) / 10 + (2000 - 1000) / 100);
277 TH3F *hDCA3Dpz =
new TH3F(
"hDCA3Dpz",
"hDCA3Dpz;DCA_{xy} [cm];DCA_{z} [cm];Truth p_{T} [GeV/c]",
282 vector<Axis_t> new_bins(nDCAbins + 1);
283 int binedge = -20000;
284 for (
int i = 0;
i <= nDCAbins;
i++)
286 new_bins[
i] = binedge * 1
e-5;
289 if (abs(binedge + .5) <= 10000)
291 if (abs(binedge + .5) <= 1000)
299 hDCA3Dpz->GetXaxis()->Set(nDCAbins, new_bins.data());
300 hDCA3Dpz->GetYaxis()->Set(nDCAbins, new_bins.data());
307 TCanvas *c1 =
new TCanvas(
"DCACheck_" +
name,
"DCACheck_" +
name, 1800, 960);
313 p = (TPad *) c1->cd(idx++);
318 TH2 *hDCA3DXYCheck =
new TH2F(
"hDCA3DXYCheck",
"hDCA3DXYCheck;Truth p_{T} [GeV/c];DCA_{xy}", nBins,
pTMin, 20, 1000, -.2, .2);
320 hDCA3DXYCheck->GetYaxis()->SetRangeUser(-.02, .02);
324 TGraphErrors *geDCA3DXYCheck =
FitProfile(hDCA3DXYCheck);
325 geDCA3DXYCheck->SetName(
"geDCA3DXYCheck");
327 hDCA3DXYCheck->Draw(
"colz");
328 geDCA3DXYCheck->Draw(
"p");
330 for (
int bin = 1; bin <= nBins; bin++)
332 p = (TPad *) c1->cd(idx++);
336 p->SetRightMargin(.15);
338 hDCA3Dpz->GetZaxis()->SetRange(bin, bin);
339 TH1 *h2D = hDCA3Dpz->Project3D(
"yx");
340 h2D->SetName(Form(
"hDCA3Dpz%d", bin));
345 c1->GetListOfPrimitives()->Add(hDCA3Dpz);
351 const TString
infile =
"/gpfs/mnt/gpfs02/sphenix/user/jinhuang/HF-jet/HF-production-piKp-pp200-dataset1_333ALL.cfg_ALL_g4svtx_eval.root",
352 const TString &
name =
"pi",
const TCut &cut =
"abs(gflavor)==211"
356 TVirtualFitter::SetDefaultFitter(
"Minuit2");
359 gSystem->Load(
"libg4eval.so");
363 TString chian_str =
infile;
364 chian_str.ReplaceAll(
"ALL",
"*");
366 TChain *
t =
new TChain(
"ntp_gtrack");
367 const int n = t->Add(chian_str);
369 cout <<
"Loaded " << n <<
" root files with " << chian_str << endl;