11 #include <TGraphAsymmErrors.h>
19 #include <TObjString.h>
24 #include <TTreeIndex.h>
32 #include "/sphenix/user/hjheng/TrackletAna/analysis/plot/sPHENIXStyle/sPhenixStyle.C"
36 void calccorr(
const TString infilename,
int CentLow = -1,
int CentHigh = 10,
bool applyc =
false,
bool applyg =
false,
bool applym =
false, TString estag =
"", TString putag =
"",
bool debug =
false)
49 gStyle->SetOptTitle(0);
50 gStyle->SetOptStat(0);
51 gStyle->SetPalette(kThermometer);
53 system(Form(
"mkdir -p ./plot/corrections/CentBin%dto%d", CentLow, CentHigh));
55 TFile *finput =
new TFile(infilename,
"read");
56 TTree *tinput = (TTree *)finput->Get(
"minitree");
65 fcorr =
new TFile(Form(
"./plot/corrections/Cent%dto%d/correction_hists.root", CentLow, CentHigh));
66 cout <<
"[INFO] Applying correction factors" << endl;
93 if (CentLow == CentHigh)
95 csel = Form(
"Centrality_mbd==%d", CentLow);
99 csel = Form(
"Centrality_mbd>=%d && Centrality_mbd<=%d", CentLow, CentHigh);
101 TCut vsel =
"PV_z<=0 && PV_z>=-50";
103 TCut psel =
"process==0";
104 TCut esel = vsel && csel && osel;
105 TCut gsel = vsel && csel && psel;
107 TH1::SetDefaultSumw2();
113 float etab[neta + 1];
114 for (
int i = 0;
i <= neta;
i++)
115 etab[
i] =
i * (etamax - etamin) / neta +
etamin;
120 for (
int i = 0;
i <= nvz;
i++)
121 vzb[
i] =
i * (vzmax - vzmin) / nvz + vzmin;
123 float multb[nmult + 1] = {0, 10, 25, 50, 100, 200, 350, 550, 800, 1100, 1500, 2000, 2500, 3100, 3800, 5000};
125 TH3F *h3WEhadron =
new TH3F(
"h3WEhadron",
"h3WEhadron", neta, etab, nmult, multb, nvz, vzb);
126 TH3F *h3WGhadron =
new TH3F(
"h3WGhadron",
"h3WGhadron", neta, etab, nmult, multb, nvz, vzb);
127 TH3F *h3WEraw =
new TH3F(
"h3WEraw",
"h3WEraw", neta, etab, nmult, multb, nvz, vzb);
128 TH3F *h3WEcorr =
new TH3F(
"h3WEcorr",
"h3WEcorr", neta, etab, nmult, multb, nvz, vzb);
130 TH3F *h3alpha =
new TH3F(
"h3alpha",
"h3alpha", neta, etab, nmult, multb, nvz, vzb);
131 TH3F *h3alphafinal =
new TH3F(
"h3alphafinal",
"h3alphafinal", neta, etab, nmult, multb, nvz, vzb);
133 TH1F *h1WEvz =
new TH1F(
"h1WEvz",
"h1WEvz", nvz, vzb);
134 TH2F *h2WEvzmult =
new TH2F(
"h2WEvzmult",
"h2WEvzmult", nvz, vzb, nmult, multb);
136 TH2F *h2amapxev_prealpha;
137 TH2F *h2amapxev =
new TH2F(
"h2amapxev",
"h2amapxev", neta, etab, nvz, vzb);
138 TH3F *h3amapxemv =
new TH3F(
"h3amapxemv",
"h3amapxemv", neta, etab, nmult, multb, nvz, vzb);
140 TH1F *h1teff =
new TH1F(
"h1teff",
"h1teff", nmult, multb);
141 TH1F *h1WGOXteff =
new TH1F(
"h1WGOXteff",
"h1WGOXteff", nmult, multb);
142 TH1F *h1WGXteff =
new TH1F(
"h1WGXteff",
"h1WGXteff", nmult, multb);
144 TH1F *h1sdf =
new TH1F(
"h1sdf",
"h1sdf", nmult, multb);
145 TH1F *h1WEsdf =
new TH1F(
"h1WEsdf",
"h1WEsdf", nmult, multb);
146 TH1F *h1WENGsdf =
new TH1F(
"h1WENGsdf",
"h1WENGsdf", nmult, multb);
148 TH1F *h1empty =
new TH1F(
"h1empty",
"h1empty", neta, etab);
150 TH1F *h1alpha[neta][nvz];
151 TF1 *falpha[neta][nvz];
152 TH2F *h2alpha_multb[nmult];
153 for (
int i = 0;
i < neta;
i++)
155 for (
int j = 0;
j < nvz;
j++)
157 h1alpha[
i][
j] =
new TH1F(Form(
"alpha_etabin%i_vzbin%i",
i,
j), Form(
"alpha_etabin%i_vzbin%i",
i,
j), nmult, multb);
158 falpha[
i][
j] =
new TF1(Form(
"falpha_etabin%i_vzbin%i",
i,
j),
"[0]+[1]/(x+[2])+[3]/(x*x)", 1, 12000);
161 for (
int k = 0;
k < nmult;
k++)
163 h2alpha_multb[
k] =
new TH2F(Form(
"alphafinal2D_multbin%d",
k), Form(
"alphafinal2D_multbin%d",
k), neta, etab, nvz, vzb);
174 h2amapxev = (TH2F *)fcorr->Get(
"h2amapxev")->Clone();
175 h1teff = (TH1F *)fcorr->Get(
"h1teff")->Clone();
176 h1sdf = (TH1F *)fcorr->Get(
"h1sdf")->Clone();
177 h1empty = (TH1F *)fcorr->Get(
"h1empty")->Clone();
179 for (
int i = 0;
i < neta;
i++)
181 for (
int j = 0;
j < nvz;
j++)
183 delete h1alpha[
i][
j];
186 h1alpha[
i][
j] = (TH1F *)fcorr->Get(Form(
"alpha_etabin%i_vzbin%i",
i,
j));
187 falpha[
i][
j] = (TF1 *)fcorr->Get(Form(
"falpha_etabin%i_vzbin%i",
i,
j));
195 TH2F *haccepdata = 0;
200 haccepmc = (TH2F *)faccep->Get(
"hmccoarse");
201 haccepdata = (TH2F *)faccep->Get(
"hdatacoarse");
202 hgaccep = (TH2F *)haccepmc->Clone(
"hgaccep");
203 hgaccep->Divide(haccepdata);
208 TH1F *h1WEGevent =
new TH1F(
"h1WEGevent",
"", nvz, vzb);
209 int nWEGentry = tinput->Draw(
"PV_z>>h1WEGevent",
"pu0_sel" * (esel && gsel),
"goff");
210 float nWEGevent = h1WEGevent->Integral(-1, -1);
212 TH1F *h1WGevent =
new TH1F(
"h1WGevent",
"", nvz, vzb);
213 tinput->Draw(
"PV_z>>h1WGevent",
"pu0_sel" * (gsel),
"goff");
214 float nWGevent = h1WGevent->Integral(-1, -1);
216 cout <<
"[INFO] weighted events: " << nWEGevent <<
", entries: " << nWEGentry << endl;
219 cout <<
"[ERROR] No events selected - stopping" << endl;
223 cout <<
"[INFO] Setup the acceptance maps" << endl;
225 tinput->Project(
"h1WEvz",
"PV_z",
"pu0_sel" * (esel));
226 tinput->Project(
"h2WEvzmult",
"NRecotkl_Raw:PV_z",
"pu0_sel" * (esel));
234 for (
int i = 1;
i <= neta;
i++)
236 for (
int j = 1;
j <= nvz;
j++)
239 if (!applyc || h2amapxev->GetBinContent(
i,
j) != 0)
248 h2amapxev->SetBinContent(
i,
j, h1WEvz->GetBinContent(
j));
249 h2amapxev->SetBinError(
i,
j, 0);
250 for (
int k = 1;
k <= nmult;
k++)
251 h3amapxemv->SetBinContent(
i,
k,
j, h2WEvzmult->GetBinContent(
j,
k));
256 h2amapxev_prealpha = (TH2F *)h2amapxev->Clone(
"h2amapxev_prealpha");
259 tinput->Project(
"h3WEhadron",
"PV_z:NRecotkl_Raw:GenHadron_eta",
"pu0_sel && abs(GenHadron_eta)<4" * (esel));
260 tinput->Project(
"h3WGhadron",
"PV_z:NRecotkl_Raw:GenHadron_eta",
"pu0_sel && abs(GenHadron_eta)<4" * (gsel));
262 tinput->Project(
"h3WEraw",
"PV_z:NRecotkl_Raw:recotklraw_eta",
"pu0_sel" * (esel));
265 cout <<
"[INFO] Calculate the alpha correction" << endl;
268 for (
int x = 1;
x <= neta;
x++)
270 for (
int z = 1;
z <= nvz;
z++)
272 if (h2amapxev->GetBinContent(
x,
z) == 0)
275 printf(
" # acceptance region: eta: %2i, vz: %2i is 0\n",
x,
z);
281 for (
int y = 1;
y <= nmult;
y++)
283 h1alpha[
x - 1][
z - 1]->SetBinContent(
y, 0);
284 h1alpha[
x - 1][
z - 1]->SetBinError(
y, 0);
286 if (h3WEraw->GetBinContent(
x,
y,
z) != 0 && h3WEhadron->GetBinContent(
x,
y,
z) != 0)
288 double raw = h3WEraw->GetBinContent(
x,
y,
z);
289 double rawerr = h3WEraw->GetBinError(
x,
y,
z);
290 double truth = h3WEhadron->GetBinContent(
x,
y,
z);
291 double trutherr = h3WEhadron->GetBinError(
x,
y,
z);
293 double alpha = truth / raw;
294 double alphaerr = alpha * sqrt(rawerr / raw * rawerr / raw + trutherr / truth * trutherr / truth);
296 printf(
" ^ alpha calculation: eta: %2i, vz: %2i, ntl: %2i, alpha: %5.3f [%5.3f], alpha/alphaerr: %5.3f, raw/truth: %9.2f/%9.2f\n",
x,
z,
y, alpha, alphaerr, (alpha / alphaerr), raw, truth);
301 h3alpha->SetBinContent(
x,
y,
z, alpha);
302 h3alpha->SetBinError(
x,
y,
z, alphaerr);
303 h1alpha[
x - 1][
z - 1]->SetBinContent(
y, alpha);
304 h1alpha[
x - 1][
z - 1]->SetBinError(
y, alphaerr);
309 printf(
" ! alpha not used\n");
321 printf(
" # ! acceptance map: eta: %2i, vz: %2i set to 0 (bad acceptance/statistics)\n",
x,
z);
322 h2amapxev->SetBinContent(
x,
z, 0);
327 for (
int j = 0;
j < nvz;
j++)
329 for (
int i = 0;
i < neta;
i++)
331 falpha[
i][
j]->SetParameter(0, 0.84);
332 falpha[
i][
j]->SetParLimits(1, 1, 256);
333 falpha[
i][
j]->SetParLimits(2, 0, 512);
334 falpha[
i][
j]->SetParLimits(3, -64, 128);
335 falpha[
i][
j]->SetLineWidth(1);
336 falpha[
i][
j]->SetLineColor(46);
337 h1alpha[
i][
j]->Fit(falpha[
i][
j],
"M Q",
"", 8, 7000);
338 h1alpha[
i][
j]->Fit(falpha[
i][j],
"M E Q",
"", 8, 7000);
339 falpha[
i][
j] = h1alpha[
i][
j]->GetFunction(Form(
"falpha_%i_%i",
i, j));
344 cout <<
"[INFO] Calculate the trigger & offline selection efficiency" << endl;
345 tinput->Project(
"h1WGXteff",
"NRecotkl_Raw",
"pu0_sel" * (gsel));
346 tinput->Project(
"h1WGOXteff",
"NRecotkl_Raw",
"pu0_sel" * (gsel && osel));
347 h1teff = (TH1F *)h1WGOXteff->Clone(
"h1teff");
348 h1teff->Divide(h1WGXteff);
351 cout <<
"[INFO] Calculate the single diffractive event fraction" << endl;
352 tinput->Project(
"h1WENGsdf",
"NRecotkl_Raw",
"pu0_sel" * (esel && !gsel));
353 tinput->Project(
"h1WEsdf",
"NRecotkl_Raw",
"pu0_sel" * (esel));
354 h1sdf = (TH1F *)h1WENGsdf->Clone(
"h1sdf");
355 h1sdf->Divide(h1WEsdf);
372 cout <<
"-------------------------------------------------------------" << endl <<
"[INFO] Apply the alpha correction" << endl;
373 for (
int x = 1;
x <= neta;
x++)
375 for (
int z = 1;
z <= nvz;
z++)
377 if (h2amapxev->GetBinContent(
x,
z) == 0)
380 for (
int y = 1;
y <= nmult;
y++)
382 double raw = h3WEraw->GetBinContent(
x,
y,
z);
383 double rawerr = h3WEraw->GetBinError(
x,
y,
z);
385 double alpha = h1alpha[
x - 1][
z - 1]->GetBinContent(
y);
386 double alphaerr = h1alpha[
x - 1][
z - 1]->GetBinError(
y);
389 printf(
" ^ alpha application: eta: %2i, vz: %2i, ntl: %2i, alpha: %5.3f [%5.3f], raw: %9.2f\n",
x,
z,
y, alpha, alphaerr, raw);
391 if (alpha == 0 && falpha[
x - 1][
z - 1] != 0)
393 alpha = falpha[
x - 1][
z - 1]->Eval((multb[
y] + multb[
y - 1]) / 2);
395 printf(
" # alpha from histogram is 0 -> check fit value: %.3f\n", alpha);
400 for (
int k = 0;
k <
y;
k++)
402 alpha = h1alpha[
x - 1][
z - 1]->GetBinContent(y -
k);
403 alphaerr = h1alpha[
x - 1][
z - 1]->GetBinError(y -
k);
405 printf(
" # check other bin: %.3f, bin: %2i\n", alpha, y -
k);
420 double gaccepdata = haccepdata->GetBinContent(
x,
z);
421 double gaccepmc = haccepmc->GetBinContent(
x,
z);
423 if (gaccepdata && gaccepmc)
425 alpha = alpha * gaccepmc / gaccepdata;
426 alphaerr = alphaerr * gaccepmc / gaccepdata;
428 printf(
" & apply geo accep: %.3f", gaccepmc / gaccepdata);
433 printf(
" ! geo accep error: eta: %2i, vz: %2i\n",
x,
z);
438 printf(
" + alpha applied: [ %.3f ]\n", alpha);
440 h3alphafinal->SetBinContent(
x,
y,
z, alpha);
441 h3alphafinal->SetBinError(
x,
y,
z, alphaerr);
442 h2alpha_multb[
y - 1]->SetBinContent(
x,
z, alpha);
443 h2alpha_multb[
y - 1]->SetBinError(
x,
z, alphaerr);
445 double ncorr = raw *
alpha;
446 double ncorrerr = rawerr *
alpha;
448 h3WEcorr->SetBinContent(
x,
y,
z, ncorr);
449 h3WEcorr->SetBinError(
x,
y,
z, ncorrerr);
453 for (
int y = 1;
y <= nmult;
y++)
455 if (h3alphafinal->GetBinContent(
x,
y,
z) != 1)
462 printf(
" # ! acceptance map: eta: %2i, vz: %2i set to 0 (invalid alpha)\n",
x,
z);
463 h2amapxev->SetBinContent(
x,
z, 0);
467 for (
int z = 1;
z <= nvz;
z++)
469 if (h2amapxev->GetBinContent(
x,
z) == 0)
471 for (
int y = 1;
y <= nmult;
y++)
473 h3alphafinal->SetBinContent(
x,
y,
z, 0);
474 h3alphafinal->SetBinError(
x,
y,
z, 0);
475 h2alpha_multb[
y - 1]->SetBinContent(
x,
z, 0);
476 h2alpha_multb[
y - 1]->SetBinError(
x,
z, 0);
478 h3WEcorr->SetBinContent(
x,
y,
z, 0);
479 h3WEcorr->SetBinError(
x,
y,
z, 0);
483 hgaccep->SetBinContent(
x,
z, 0);
489 TH2D *h2WEcorr = (TH2D *)h3WEcorr->Project3D(
"zx");
490 h2WEcorr->SetName(
"h2WEcorr");
491 TH2D *h2WEraw = (TH2D *)h3WEraw->Project3D(
"zx");
492 h2WEraw->SetName(
"h2WEraw");
503 TH1F *h1accep2xe = (TH1F *)h2amapxev->ProjectionX();
504 h1accep2xe->SetName(
"h1accep2xe");
505 h1accep2xe->Scale(1. / h1accep2xe->GetMaximum());
508 TH1F *h1WEraw = (TH1F *)h3WEraw->Project3D(
"x");
509 h1WEraw->SetName(
"h1WEraw");
510 h1WEraw->Scale(1. / nWEGevent,
"width");
511 h1WEraw->Divide(h1accep2xe);
513 TH1F *h1WEcorr = (TH1F *)h3WEcorr->Project3D(
"x");
514 h1WEcorr->SetName(
"h1WEcorr");
515 h1WEcorr->Scale(1. / nWEGevent,
"width");
516 h1WEcorr->Divide(h1accep2xe);
519 TH1F *h1WGhadron = (TH1F *)h3WGhadron->Project3D(
"x");
520 h1WGhadron->SetName(
"h1WGhadron");
521 h1WGhadron->Scale(1. / nWGevent,
"width");
525 cout <<
"[INFO] Calculate final results with trigger and SDF corrections" << endl;
526 TH2F *h2WEtcorr =
new TH2F(
"h2WEtcorr",
"", neta, etab, nmult, multb);
528 for (
int x = 1;
x <= neta;
x++)
530 for (
int y = 1;
y <= nmult;
y++)
532 double sum = 0, sumerr = 0;
533 double mcsum = 0, mcsumerr = 0;
535 for (
int z = 1;
z <= nvz;
z++)
537 if (h2amapxev->GetBinContent(
x,
z) != 0)
539 sum += h3WEcorr->GetBinContent(
x,
y,
z);
540 double err = h3WEcorr->GetBinError(
x,
y,
z);
541 sumerr = sqrt(sumerr * sumerr + err * err);
545 h2WEtcorr->SetBinContent(
x,
y, sum);
546 h2WEtcorr->SetBinError(
x,
y, sumerr);
551 for (
int y = 1;
y <= nmult;
y++)
553 double sdfrac = h1sdf->GetBinContent(
y);
554 double trigeff = h1teff->GetBinContent(
y);
556 double totalc = (1 - sdfrac *
SDMULT) / trigeff;
558 for (
int x = 1;
x <= neta;
x++)
562 h2WEtcorr->SetBinContent(
x,
y, h2WEtcorr->GetBinContent(
x,
y) * totalc);
563 h2WEtcorr->SetBinError(
x,
y, h2WEtcorr->GetBinError(
x,
y) * totalc);
566 for (
int z = 1;
z <= nvz;
z++)
568 if (h2amapxev->GetBinContent(
x,
z) != 0)
571 h3amapxemv->SetBinContent(
x,
y,
z, h3amapxemv->GetBinContent(
x,
y,
z) * totalc);
575 h3amapxemv->SetBinContent(
x,
y,
z, 0);
582 TH1F *h1accep3xe = (TH1F *)h3amapxemv->Project3D(
"x");
583 h1accep3xe->SetName(
"h1accep3xe");
585 TH1F *h1WEtcorr = (TH1F *)h2WEtcorr->ProjectionX();
586 h1WEtcorr->SetName(
"h1WEtcorr");
587 h1WEtcorr->Scale(1.,
"width");
588 h1WEtcorr->Divide(h1accep3xe);
591 cout <<
"[INFO] Calculate and apply the empty correction" << endl;
594 h1empty = (TH1F *)h1WGhadron->Clone(
"h1empty");
595 h1empty->Divide(h1WEtcorr);
598 TH1F *h1WEprefinal = (TH1F *)h1WEtcorr->Clone(
"h1WEprefinal");
599 h1WEprefinal->Multiply(h1empty);
601 TH1F *h1WEfinal = (TH1F *)h1WEprefinal->Clone(
"h1WEfinal");
604 TH1F *h1pu = (TH1F *)fpu->Get(
"h1pu")->Clone(
"h1pu");
605 h1WEfinal->Multiply(h1pu);
610 cout <<
"[INFO] Making checking plots: intermediate steps" << endl;
611 TGraphAsymmErrors *trigeff =
new TGraphAsymmErrors(h1WGXteff, h1WGOXteff);
612 TGraphAsymmErrors *sdfrac =
new TGraphAsymmErrors(h1WENGsdf, h1WEsdf);
614 TCanvas *ccheck =
new TCanvas(
"ccheck",
"ccheck", nw * 400, nh * 400);
615 ccheck->Divide(nw, nh);
616 TLatex *
t =
new TLatex();
620 h1WEvz->GetXaxis()->SetTitle(
"v_{z} (cm)");
621 h1WEvz->GetYaxis()->SetTitle(
"Entries");
622 h1WEvz->GetYaxis()->SetRangeUser(0, h1WEvz->GetMaximum() * 1.2);
623 h1WEvz->SetLineColor(1);
624 h1WEvz->Draw(
"histtext");
625 t->DrawLatexNDC(0.5, 1.0, h1WEvz->GetName());
628 gPad->SetRightMargin(0.13);
629 h2amapxev_prealpha->GetXaxis()->SetTitle(
"#eta");
630 h2amapxev_prealpha->GetYaxis()->SetTitle(
"v_{z} (cm)");
631 h2amapxev_prealpha->Draw(
"colztext45");
632 t->DrawLatexNDC(0.5, 1.0, h2amapxev_prealpha->GetName());
636 gPad->SetRightMargin(0.13);
637 gPad->SetLeftMargin(0.13);
638 h2WEvzmult->GetYaxis()->SetMoreLogLabels();
639 h2WEvzmult->GetXaxis()->SetTitle(
"v_{z} (cm)");
640 h2WEvzmult->GetYaxis()->SetTitle(
"Tracklet multiplicity");
641 h2WEvzmult->GetYaxis()->SetTitleOffset(2.1);
642 h2WEvzmult->Draw(
"colztext");
643 t->DrawLatexNDC(0.5, 1.0, h2WEvzmult->GetName());
647 gPad->SetLeftMargin(0.12);
648 trigeff->GetXaxis()->SetMoreLogLabels();
649 trigeff->GetXaxis()->SetTitle(
"Tracklet multiplicity");
650 trigeff->GetYaxis()->SetTitle(
"Efficiency");
651 trigeff->GetXaxis()->SetTitleOffset(1.4);
652 trigeff->SetMarkerStyle(20);
653 trigeff->SetMarkerColor(1);
654 trigeff->SetLineColor(1);
655 trigeff->Draw(
"ALPE");
656 t->DrawLatexNDC(0.5, 1.0,
"Trigger efficiency");
660 gPad->SetLeftMargin(0.12);
661 sdfrac->GetXaxis()->SetMoreLogLabels();
662 sdfrac->GetXaxis()->SetTitle(
"Tracklet multiplicity");
663 sdfrac->GetYaxis()->SetTitle(
"SD event fraction");
664 sdfrac->GetXaxis()->SetTitleOffset(1.4);
665 sdfrac->SetMarkerStyle(20);
666 sdfrac->SetMarkerColor(1);
667 sdfrac->SetLineColor(1);
668 sdfrac->Draw(
"ALPE");
669 t->DrawLatexNDC(0.5, 1.0,
"SD event fraction");
672 gPad->SetRightMargin(0.13);
673 h2amapxev->GetXaxis()->SetTitle(
"#eta");
674 h2amapxev->GetYaxis()->SetTitle(
"v_{z} (cm)");
675 h2amapxev->Draw(
"colztext45");
676 t->DrawLatexNDC(0.5, 1.0, Form(
"%s_postalpha", h2amapxev->GetName()));
680 h1accep2xe->GetXaxis()->SetTitle(
"#eta");
681 h1accep2xe->GetYaxis()->SetTitle(
"A.U");
682 h1accep2xe->GetYaxis()->SetRangeUser(0, h1accep2xe->GetMaximum() * 1.2);
683 h1accep2xe->SetLineColor(1);
684 h1accep2xe->Draw(
"histtext");
685 t->DrawLatexNDC(0.5, 1.0, h1accep2xe->GetName());
689 gPad->SetRightMargin(0.13);
690 gPad->SetLeftMargin(0.13);
691 h2WEtcorr->GetYaxis()->SetMoreLogLabels();
692 h2WEtcorr->GetXaxis()->SetTitle(
"#eta");
693 h2WEtcorr->GetYaxis()->SetTitle(
"Tracklet multiplicity");
694 h2WEtcorr->GetYaxis()->SetTitleOffset(2.1);
695 h2WEtcorr->Draw(
"colz");
696 t->DrawLatexNDC(0.5, 1.0, h2WEtcorr->GetName());
699 h1empty->GetXaxis()->SetTitle(
"#eta");
700 h1empty->GetYaxis()->SetTitle(
"Ratio");
701 h1empty->GetYaxis()->SetRangeUser(h1empty->GetMinimum(0) * 0.7, h1empty->GetMaximum() * 1.2);
702 h1empty->SetLineColor(1);
703 h1empty->Draw(
"histtext");
704 t->DrawLatexNDC(0.5, 1.0, h1empty->GetName());
705 for (
int i = 0;
i < nw * nw;
i++)
711 ccheck->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/Check_Intermediate.pdf", CentLow, CentHigh));
714 cout <<
"[INFO] Making checking plots: 1D alpha and fits" << endl;
715 TLatex *
t1 =
new TLatex();
716 t1->SetTextAlign(23);
717 TCanvas *cfalphavz =
new TCanvas(
"cfalphavz",
"", 2000, 1600);
718 cfalphavz->Divide(5, 4);
720 for (
int x = 1;
x <= neta;
x++)
722 cfalphavz->Clear(
"d");
723 for (
int z = 1;
z <= nvz;
z++)
729 h1alpha[
x - 1][
z - 1]->GetYaxis()->SetRangeUser(0, h1alpha[
x - 1][
z - 1]->GetMaximum() * 2.5);
730 h1alpha[
x - 1][
z - 1]->SetMarkerStyle(20);
731 h1alpha[
x - 1][
z - 1]->SetMarkerSize(1);
732 h1alpha[
x - 1][
z - 1]->SetMarkerColor(1);
733 h1alpha[
x - 1][
z - 1]->SetLineColor(1);
734 h1alpha[
x - 1][
z - 1]->Draw();
736 TLine *l =
new TLine(multb[0], 1, multb[nmult], 1);
737 l->SetLineColorAlpha(38, 0.7);
740 t1->DrawLatexNDC(0.5, 1.0, Form(
"%.1f < #eta < %.1f, %.1f < v_{z} < %.1f", etab[
x - 1], etab[
x], vzb[
z - 1], vzb[
z]));
743 cfalphavz->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/alpha1Dfit-etabin%i.pdf", CentLow, CentHigh,
x - 1));
746 TCanvas *cfalphaeta =
new TCanvas(
"cfalphaeta",
"", 2400, 2400);
747 cfalphaeta->Divide(6, 6);
749 for (
int z = 1;
z <= nvz;
z++)
751 cfalphaeta->Clear(
"d");
752 for (
int x = 1;
x <= neta;
x++)
758 h1alpha[
x - 1][
z - 1]->SetMarkerStyle(20);
759 h1alpha[
x - 1][
z - 1]->SetMarkerSize(1);
760 h1alpha[
x - 1][
z - 1]->SetMarkerColor(1);
761 h1alpha[
x - 1][
z - 1]->SetLineColor(1);
762 h1alpha[
x - 1][
z - 1]->Draw();
764 TLine *l =
new TLine(multb[0], 1, multb[nmult], 1);
765 l->SetLineColorAlpha(38, 0.7);
768 t1->DrawLatexNDC(0.5, 1.0, Form(
"%.1f < #eta < %.1f, %.1f < v_{z} < %.1f", etab[
x - 1], etab[
x], vzb[
z - 1], vzb[
z]));
771 cfalphaeta->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/alpha1Dfit-vzbin%i.pdf", CentLow, CentHigh,
z));
775 cout <<
"[INFO] Making checking plots: 2D alpha (eta, vz), inclusive tracklet multiplicity" << endl;
776 TCanvas *calpha =
new TCanvas(
"calpha",
"calpha",
CANVASW,
CANVASH);
777 gPad->SetRightMargin(0.18);
778 gPad->SetLeftMargin(0.12);
780 TH2D *h2alphafinal = (TH2D *)h2WEcorr->Clone(
"h2alphafinal");
781 h2alphafinal->Divide(h2WEraw);
782 h2alphafinal->GetXaxis()->SetTitle(
"#eta");
783 h2alphafinal->GetYaxis()->SetTitle(
"v_{z} (cm)");
784 h2alphafinal->GetZaxis()->SetTitle(
"#alpha (#eta, v_{z})");
785 h2alphafinal->GetZaxis()->SetTitleOffset(1.2);
786 h2alphafinal->GetZaxis()->SetRangeUser(0, 3);
787 gStyle->SetPaintTextFormat(
"1.3f");
788 h2alphafinal->SetMarkerSize(0.6);
789 h2alphafinal->SetContour(1000);
790 h2alphafinal->Draw(
"colz");
791 calpha->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/alpha2D_inclTklMult.pdf", CentLow, CentHigh));
793 for (
int k = 0;
k < nmult;
k++)
797 h2alpha_multb[
k]->GetXaxis()->SetTitle(
"#eta");
798 h2alpha_multb[
k]->GetYaxis()->SetTitle(
"v_{z} (cm)");
799 h2alpha_multb[
k]->GetYaxis()->SetTitleOffset(1.1);
800 h2alpha_multb[
k]->GetZaxis()->SetTitle(
"#alpha (#eta, v_{z})");
801 h2alpha_multb[
k]->GetZaxis()->SetTitleOffset(1.2);
803 h2alpha_multb[
k]->GetZaxis()->SetRangeUser(0, 3);
804 gStyle->SetPaintTextFormat(
"1.3f");
805 h2alpha_multb[
k]->SetMarkerSize(0.6);
806 h2alpha_multb[
k]->SetContour(1000);
807 h2alpha_multb[
k]->Draw(
"colz");
808 calpha->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/alpha2D_TklMultb%d.pdf", CentLow, CentHigh,
k));
812 vector<TH1F *> vechist = {h1WGhadron, h1WEraw, h1WEcorr, h1WEtcorr, h1WEfinal};
813 vector<const char *> vcolor{
"#20262E",
"#1C82AD",
"#1F8A70",
"#FC7300",
"#EFA3C8"};
814 vector<int> vlwidth = {3, 3, 3, 2, 2};
815 vector<int> vstyle = {1, 1, 1, 2, 2};
816 TCanvas *cstage =
new TCanvas(
"cstage",
"cstage",
CANVASW,
CANVASH);
817 gPad->SetRightMargin(0.05);
818 gPad->SetTopMargin(0.05);
822 TH1F *hframe =
new TH1F(
"hframe",
"", 1, etamin, etamax);
824 for (
size_t i = 0;
i < vechist.size();
i++)
826 if (vechist[
i]->GetMaximum() >
ymax)
827 ymax = vechist[
i]->GetMaximum();
829 hframe->GetYaxis()->SetRangeUser(0, ymax * 1.6);
831 hframe->GetXaxis()->SetTitle(
"#eta");
832 hframe->GetYaxis()->SetTitle(
"dN/d#eta");
834 for (
size_t i = 0;
i < vechist.size();
i++)
836 vechist[
i]->SetLineColor(TColor::GetColor(vcolor[
i]));
837 vechist[
i]->SetLineWidth(vlwidth[i]);
838 vechist[
i]->SetLineStyle(vstyle[i]);
839 vechist[
i]->Draw(
"hist same");
842 TLegend *
l1 =
new TLegend(0.18, 0.68, 0.5, 0.92);
843 l1->SetHeader(Form(
"Closure test: Centrality %d to %d", CentLow, CentHigh,
"l"));
844 l1->AddEntry(h1WGhadron,
"Truth",
"l");
845 l1->AddEntry(h1WEraw,
"Reco-tracklets before corrections",
"l");
846 l1->AddEntry(h1WEcorr,
"Corrected for #alpha",
"l");
847 l1->AddEntry(h1WEtcorr,
"Corrected for #alpha, trigger & sdf",
"l");
848 l1->AddEntry(h1WEfinal,
"Corrected for #alpha, trigger & sdf, and empty event (final)",
"l");
849 l1->SetTextSize(0.033);
851 l1->SetBorderSize(0);
854 cstage->SaveAs(Form(
"./plot/corrections/CentBin%dto%d/Closure.pdf", CentLow, CentHigh));
857 TFile *outf =
new TFile(Form(
"./plot/corrections/CentBin%dto%d/correction_hists.root", CentLow, CentHigh),
"recreate");
874 for (
int i = 0;
i < neta;
i++)
876 for (
int j = 0;
j < nvz;
j++)
879 falpha[
i][
j]->Write();
881 h1alpha[
i][
j]->Write();
885 for (
int k = 0;
k < nmult;
k++)
886 h2alpha_multb[
k]->
Write();
888 outf->Write(
"", TObject::kOverwrite);
892 int main(
int argc,
char *argv[])
897 gStyle->SetPaintTextFormat();
898 TString
input =
"/sphenix/user/hjheng/TrackletAna/minitree/INTT/TrackletMinitree_ana398_zvtx-20cm_dummyAlignParams/sim/TrackletAna_minitree_merged.root";
899 calccorr(input, 5, 95,
false,
false,
false,
"",
"",
false);
900 for (
int i = 0;
i < 10;
i++)
902 gStyle->SetPaintTextFormat();
903 int cent = 5 * (2 *
i + 1);
904 calccorr(input, cent, cent,
false,
false,
false,
"",
"",
false);