1 #include "sPhenixStyle.C"
2 #include "sPhenixStyle.h"
4 TPad*
getPad(
int j,
int k,
int l,
float cw,
float ch,
const int nEBins,
const int nCutBins);
7 void drawCanvas_invMass(TCanvas *
c, TH1F *hCorr,
int pad_x,
int pad_y, TPad *pad,
int isEta,
float peakPos,
float peakW);
9 void SetHistoStyle(TH1F *histo,
int cutBin,
int eBin,
float low,
float hi,
int isEta);
13 void GetSubtractedDist(TH1F *histOrig, TH1F *histSub, TF1 *invMassFit, TF1 *invMassBG);
16 float eBins[] = {1,2,3,4,5,6,7,8,9,10,11,12,13};
18 float eCuts[] = {0.5,0.6,0.7,0.8,0.9,1.,1.1};
25 TFile *fin =
new TFile(input);
27 const int nEBins = (int)
sizeof(
eBins)/
sizeof(
eBins[0]);
28 const int nCutBins = (int)
sizeof(
eCuts)/
sizeof(
eCuts[0]);
34 float cw = 2*966, ch = 1.3*637;
37 TPad *pad_invMass[nEBins-1][nCutBins][
nEtaBins];
40 TPad *pad_invMassSub[nEBins-1][nCutBins][
nEtaBins];
43 TPad *pad_matchMass[nEBins-1][nCutBins][
nEtaBins];
48 TGraphErrors *yields[nCutBins][
nEtaBins];
49 TGraphErrors *yieldsMatched[nCutBins][
nEtaBins];
50 TGraphErrors *matchZeroFrac[nCutBins][
nEtaBins];
51 TF1 *invMassFit, *invMassFitBG;
52 int colors[] = {1,2,4,kGreen+2, kViolet,kCyan,kOrange+2,kMagenta+2,kAzure-2};
53 TLegend *leggy =
new TLegend(.161, .729, .722, .939 );
54 leggy -> SetNColumns(3);
59 float xStartFit = 0.07;
60 float xEndHist = 0.25;
61 float xStartHist = 0.07;
62 float invMassWindow[2] = {0.112, 0.162};
63 float peakPos[nEBins - 1][nCutBins][
nEtaBins];
64 float peakW[nEBins - 1][nCutBins][
nEtaBins];
72 cSubMass[
k]=
new TCanvas(Form(
"cMassSubPi0_Eta%d",
k),
"Subtracted Mass Dist",cw,ch);
73 cSubMass[
k] ->
Range(0,0,1,1);
75 cPi0Cut[
k] =
new TCanvas(Form(
"cMassPi0_Eta%d",
k),
"Invariant Mass",cw,ch);
76 cPi0Cut[
k] ->
Range(0,0,1,1);
78 hist[
k] = (TH3F*)fin ->
Get(Form(
"ePi0InvMassEcut_Eta%d",
k));
80 for(
int i = 0;
i < nEBins - 1;
i++)
82 for(
int j = 0;
j < nCutBins;
j++)
86 mass[
j][
k] =
new TGraphErrors();
89 width[
j][
k] =
new TGraphErrors();
92 yields[
j][
k] =
new TGraphErrors();
98 pad_invMass[
i][
j][
k] =
getPad(
i,
j,
k,cw,ch,nEBins , nCutBins);
99 pad_invMass[
i][
j][
k] ->
cd();
101 pad_invMassSub[
i][
j][
k] =
getPad(
i,
j,
k,cw,ch,nEBins , nCutBins);
108 TH1F *invMassSub = (TH1F*)hist1D -> Clone();
111 invMassFit =
new TF1(Form(
"invMassFit_E%d_Cut%d_Eta%d",
i,
j,
k),
"[5]*exp(-(([7]-x)^2)/(2*[6]^2))");
119 invMassFit ->
SetParLimits(7, 0.135 - 0.07, 0.135 + 0.07);
122 invMassFit ->
SetParameter(5, hist1D -> GetMaximum()*2);
125 else invMassFit ->
SetParameter(5,hist1D -> GetMaximum());
126 hist1D -> Fit(invMassFit,
"Q",
"",xStartFit, xEndFit);
130 peakPos[
i][
j][
k] = peakPosition;
133 peakW[
i][
j][
k] = peakWidth;
137 if(hist1D -> Integral() == 0) yield = 0;
138 else yield = invMassSub -> IntegralAndError(invMassSub ->
GetXaxis() -> FindBin((peakPosition - sigma*peakWidth)+0.0001), invMassSub ->
GetXaxis() -> FindBin((peakPosition + sigma*peakWidth)+0.0001), yieldErr,
"");
155 hist1D ->
GetXaxis() -> SetRangeUser(xStartHist,xEndHist);
157 TCanvas *cMassFitCheck =
new TCanvas();
158 hist1D ->
SetTitle(
";M_{#gamma#gamma} [GeV/c^{2}];");
159 hist1D ->
Draw(
"epx0");
162 marks.DrawLatexNDC(0.7,0.8,Form(
"#splitline{E_{Min} > %g GeV}{%g > E_{#pi^{0}} > %g}",
eCuts[
j],
eBins[
i],
eBins[i+1]));
163 cMassFitCheck -> SaveAs(Form(
"plots/invMassFitCheck_%dE_%dCut_Sigma%g_Eta%d.pdf",i,j,sigma,
k));
165 drawCanvas_invMass(cPi0Cut[
k], hist1D, j, i, pad_invMass[i][j][k], 0, peakPos[i][j][k], sigma*peakW[i][j][k]);
166 pad_invMassSub[
i][
j][
k] ->
cd();
168 invMassSub ->
GetXaxis() -> SetRangeUser(xStartHist, xEndHist);
169 drawCanvas_invMass(cSubMass[k], invMassSub, j, i, pad_invMassSub[i][j][k], 0, peakPos[i][j][k], sigma*peakW[i][j][k]);
175 cPi0Cut[
k] -> SaveAs(Form(
"plots/invMassCuts_Sigma%g_Eta%d.pdf",sigma,
k));
176 cSubMass[
k] -> SaveAs(Form(
"plots/invMassCutsSubtracted_Sigma%g_Eta%d.pdf",sigma,
k));
183 cMass[
k] =
new TCanvas();
184 for(
int i = 0;
i < nCutBins;
i++)
189 mass[
i][
k] ->
GetYaxis() -> SetRangeUser(0.130,0.180);
194 else mass[
i][
k] ->
Draw(
"samep");
198 leggy ->
Draw(
"same");
199 cMass[
k] -> SaveAs(Form(
"plots/invMassGraphPeakPos_Sigma%g_Eta%d.pdf",sigma,
k));
205 cWidth[
k] =
new TCanvas();
207 for(
int i = 0;
i < nCutBins;
i++)
211 width[
i][
k] ->
Draw(
"ap");
212 width[
i][
k] ->
GetYaxis() -> SetRangeUser(0.013, 0.028);
217 else width[
i][
k] ->
Draw(
"samep");
220 leggy ->
Draw(
"same");
221 cWidth[
k] -> SaveAs(Form(
"plots/invMassGraphPeakWidth_Sigma%g_Eta%d.pdf",sigma,
k));
227 cYields[
k] =
new TCanvas();
228 for(
int i = 0;
i < nCutBins;
i++)
232 yields[
i][
k] ->
Draw(
"ap");
233 yields[
i][
k] ->
GetYaxis() -> SetRangeUser(1e3,1e7);
237 else yields[
i][
k] ->
Draw(
"samep");
241 leggy ->
Draw(
"same");
242 cYields[
k] -> SaveAs(Form(
"plots/invMassYield_Sigma%g_Eta%d.pdf",sigma,
k));
247 for(
int i = 0;
i <
nEtaBins;
i++) pi0TruSpec[
i] = (TH1F*)fin ->
Get(Form(
"primPi0E_Eta%d",
i));
248 TGraphErrors *pi0Eff[nCutBins][
nEtaBins];
255 cEff[
k] =
new TCanvas();
259 for(
int i = 0;
i < nCutBins ;
i++)
261 pi0Eff[
i][
k] =
new TGraphErrors();
262 for(
int j = 0;
j < nEBins -1;
j++)
264 Double_t pi0TruthYieldErr;
265 float pi0TruthYield = pi0TruSpec[
k] -> IntegralAndError(pi0TruSpec[
k] ->
GetXaxis() -> FindBin(
eBins[
j]+0.001), pi0TruSpec[
k] ->
GetXaxis() -> FindBin(
eBins[
j+1]-0.001), pi0TruthYieldErr,
"");
268 Double_t
x, pi0YieldMeas, pi0YieldErr;
269 yields[
i][
k] -> GetPoint(
j, x, pi0YieldMeas);
270 pi0YieldErr = yields[
i][
k] -> GetErrorY(
j);
271 float eff = pi0YieldMeas/pi0TruthYield;
272 float err = eff*sqrt(pow(pi0YieldErr/pi0YieldMeas,2) + pow(pi0TruthYieldErr/pi0TruthYield,2));
274 if(eff < scaleMin) scaleMin = eff;
275 if(eff > scaleMax) scaleMax = eff;
280 pi0Eff[
i][
k] ->
SetName(Form(
"pi0Eff_Eta%d_ECut%d",
k,i));
284 pi0Eff[
i][
k] ->
Draw(
"ap");
285 pi0Eff[
i][
k] ->
GetYaxis() -> SetRangeUser(-0.05,scaleMax*1.4);
289 else pi0Eff[
i][
k] ->
Draw(
"samep");
292 leggy ->
Draw(
"same");
293 cEff[
k] -> SaveAs(Form(
"plots/pi0Eff_Sigma%g_Eta%d.pdf",sigma,
k));
297 TCanvas *cAngle2D =
new TCanvas();
298 TH2F *deltaR2D = (TH2F*)fin ->
Get(
"truthPi0EDeltaR");
300 deltaR2D ->
SetTitle(
";E_{#pi^{0}}^{Truth} [GeV];#Delta R");
301 deltaR2D ->
GetYaxis() -> SetRangeUser(0,0.5);
302 deltaR2D ->
Draw(
"colz");
303 cAngle2D -> SaveAs(
"plots/deltaR.pdf");
305 TH1F *deltaRproj[nEBins-1];
306 TCanvas *cAngleProj =
new TCanvas();
308 for(
int i = 0;
i < nEBins - 1;
i++)
311 deltaRproj[
i] ->
Draw();
312 cAngleProj -> SaveAs(Form(
"plots/deltaR_proj%d.pdf",
i));
315 TCanvas *cAsym =
new TCanvas();
316 TH2F *asym = (TH2F*)fin ->
Get(
"truthPi0EAsym");
318 asym ->
SetTitle(
";E_{#pi^{0}}^{Truth [GeV];#frac{|E^{#gamma_{1}} - E^{#gamma_{2}}|}{#lower[0.2]{E^{#gamma_{1}} + E^{#gamma_{2}}}}");
319 asym ->
GetYaxis() -> SetTitleOffset(1.3);
320 asym ->
Draw(
"colz");
321 cAsym -> SaveAs(
"plots/asymE.pdf");
325 TPad*
getPad(
int j,
int k,
int l,
float cw,
float ch,
const int nEBins,
const int nCutBins)
327 float xpos[nCutBins+1], ypos[nEBins];
329 float marginLeft = 0.07;
330 float marginRight = 0.035;
332 float marginTop = 0.03;
333 float marginBottom = 0.06;
335 float marginColumn = 0.04;
337 float w = (1 - marginLeft - marginRight - marginColumn*(nCutBins-2 + nCutOffset))/(nCutBins - 1+ nCutOffset);
338 float h = (1 - marginTop - marginBottom)/(nEBins - 1);
340 for(
int m = 0;
m < nCutBins + nCutOffset;
m++)
342 if(
m == 0) xpos[
m] = 0;
343 else if(
m == nCutBins - 1+ nCutOffset) xpos[
m] = 1.;
344 else xpos[
m] = marginLeft +
m*w + (
m-1)*marginColumn;
347 for(
int m = 0;
m < nEBins;
m++)
349 if(
m==0) ypos[nEBins -1 -
m] = 0;
350 else if (
m == nEBins - 1) ypos[nEBins-1-
m] = 1.;
351 else ypos[nEBins - 1 -
m] = marginBottom +
m*
h;
354 TPad *myPad =
new TPad(Form(
"pad%d%d%d",j,k,l),Form(
"pad%d%d%d",j,k,l),xpos[k],ypos[j+1],xpos[k+1],ypos[j]);
356 if(k==0) myPad->SetLeftMargin(marginLeft/(xpos[k+1] - xpos[k]));
357 else myPad ->
SetLeftMargin(marginColumn/(xpos[k+1] - xpos[k]));
359 if(k == nCutBins - 2+ nCutOffset) myPad ->
SetRightMargin(marginRight/(xpos[k+1]-xpos[k]));
362 if(j == 0) myPad ->
SetTopMargin(marginTop/(ypos[j] - ypos[j+1]));
365 if(j == nEBins - 2) myPad ->
SetBottomMargin(marginBottom/(ypos[j] - ypos[j+1]));
371 void drawCanvas_invMass(TCanvas *
c, TH1F *hCorr,
int pad_x,
int pad_y, TPad *pad,
int mode,
float peakPos,
float peakW)
374 float range = hCorr -> GetMaximum() - hCorr -> GetMinimum();
375 SetHistoStyle(hCorr, pad_x, pad_y, hCorr -> GetMinimum(), hCorr->GetMaximum() + 0.2*range,
mode);
383 TLine *massWindow[2];
388 hCorr ->
Draw(
"epX0");
390 if(mode == 1) gPad ->
SetLogy();
393 massWindow[0] =
new TLine(peakPos - peakW,0,peakPos - peakW,hCorr->GetMaximum());
398 massWindow[1] =
new TLine(peakPos + peakW,0,peakPos + peakW,hCorr->GetMaximum());
401 massWindow[0] ->
Draw(
"same");
402 massWindow[1] ->
Draw(
"same");
411 void SetHistoStyle(TH1F *histo,
int cutBin,
int eBin,
float low,
float hi,
int mode)
413 if(hi > low) histo ->
GetYaxis() -> SetRangeUser(low,hi);
416 histo ->
GetYaxis() -> SetRangeUser(0.1,10*hi);
420 int xTitleBin[3][2] = {{11,3},{11,3},{3,3}};
421 int yTitleBin[3][2] = {{5,0},{5,0},{2,0}};
423 float yTitleOffset[3] = {0.3, 0.4, 1};
424 float xTitleOffset[3] = {0.7, 0.7, 0.7};
426 float yTitleSize[3] = {0.5, 0.5, 0.15};
427 float xTitleSize[3] = {0.28, 0.28, 0.13};
429 if(eBin == xTitleBin[mode][0] && cutBin == xTitleBin[mode][1]) histo ->
GetXaxis() ->
SetTitle(
"M_{#gamma#gamma}");
430 if(eBin == yTitleBin[mode][0] && cutBin == yTitleBin[mode][1]) histo ->
GetYaxis() ->
SetTitle(
"N_{#gamma#gamma}");
432 histo ->
GetXaxis() -> SetTitleSize(xTitleSize[mode]);
433 histo ->
GetXaxis() -> SetTitleOffset(xTitleOffset[mode]);
434 histo ->
GetXaxis() -> CenterTitle();
436 histo ->
GetXaxis() -> SetLabelFont(43);
437 histo ->
GetXaxis() -> SetLabelSize(18);
438 histo ->
GetXaxis() -> SetLabelOffset(0.0);
439 histo -> SetTickLength(0.05,
"X");
440 histo -> SetNdivisions(505,
"x");
443 histo ->
GetYaxis() -> SetNdivisions(505);
444 histo ->
GetYaxis() -> SetTitleSize(yTitleSize[mode]);
445 histo ->
GetYaxis() -> SetTitleOffset(yTitleOffset[mode]);
446 histo ->
GetYaxis() -> CenterTitle();
448 histo ->
GetYaxis() -> SetLabelFont(43);
449 histo ->
GetYaxis() -> SetLabelSize(19);
450 histo ->
GetYaxis() -> SetLabelOffset(0.003);
451 histo ->
GetYaxis() -> SetNoExponent();
452 histo -> SetTickLength(0.04,
"Y");
466 float Y2 = gPad -> GetUymax();
467 float Y1 = gPad -> GetUymin();
468 float rangeY = Y2 - Y1;
469 float xtop[3] = {0.8, -0.1, 0};
470 float xbottom[3] = {0.273152, 1.01, 1.1};
471 double ytop[3] = {Y2+0.01*rangeY, Y2+1*rangeY, Y2+0.01*rangeY};
472 double ybottom[3] = { 0.98*Y2, 0.98*Y2, 0.9*Y2};
483 textCut =
new TText(xtop[mode], ytop[mode], Form(
"Min E > %g GeV",
eCuts[x]));
492 if(mode < 2)textCut =
new TText(xbottom[mode], ybottom[mode], Form(
"%g-%gGeV",
eBins[y],
eBins[y+1]));
493 else textCut =
new TText(xbottom[mode], ybottom[mode], Form(
"%g-%gGeV",
eBinsEta[y],
eBinsEta[y+1]));
494 textCut -> SetTextAngle(270);
502 void GetSubtractedDist(TH1F *histOrig, TH1F *histSub, TF1 *invMassFit, TF1 *invMassBG)
506 for(
int i = 0;
i < invMassFit -> GetNpar();
i++)
511 for(
int i = 1;
i < histSub -> GetNbinsX() + 1;
i++)
513 histSub ->
SetBinContent(
i, histOrig -> GetBinContent(
i) - invMassBG -> Eval(histOrig -> GetBinCenter(
i)));