15 orange_hex =
'#e99960'
16 purple_hex =
'#7F167F'
18 yellow_hex =
'#ffcc66'
25 return [blue_hex, red_hex]
27 return [blue_hex, red_hex, green_hex]
29 return [blue_hex, red_hex, green_hex, orange_hex]
31 return [blue_hex, red_hex, green_hex, orange_hex, purple_hex]
33 print (
"Attempt to use more than 5 colors")
34 return [blue_hex, red_hex, green_hex, orange_hex, purple_hex, pink_hex, yellow_hex, cyan_hex]
37 def Draw_1Dhist(hist, IsData, norm1, logy, ymaxscale, XaxisName, Ytitle_unit, outname):
39 binwidth = hist.GetXaxis().GetBinWidth(1)
40 c = TCanvas(
'c',
'c', 800, 700)
42 hist.Scale(1. / hist.Integral(-1, -1))
46 gPad.SetRightMargin(RightMargin)
47 gPad.SetTopMargin(TopMargin)
48 gPad.SetLeftMargin(LeftMargin)
49 gPad.SetBottomMargin(BottomMargin)
53 'Normalized entries / ({:g})'.
format(binwidth))
56 'Normalized entries / ({:g} {unit})'.
format(binwidth, unit=Ytitle_unit))
62 'Entries / ({:g} {unit})'.
format(binwidth, unit=Ytitle_unit))
66 hist.GetYaxis().SetRangeUser(hist.GetMinimum(0)*0.5, (hist.GetMaximum()) * ymaxscale)
68 hist.GetYaxis().SetRangeUser(0., (hist.GetMaximum()) * ymaxscale)
70 hist.GetXaxis().SetTickSize(TickSize)
71 hist.GetXaxis().SetTitleSize(AxisTitleSize)
72 hist.GetXaxis().SetLabelSize(AxisLabelSize)
73 hist.GetYaxis().SetTickSize(TickSize)
74 hist.GetYaxis().SetTitleSize(AxisTitleSize)
75 hist.GetYaxis().SetLabelSize(AxisLabelSize)
76 hist.GetXaxis().SetTitleOffset(1.1)
77 hist.GetYaxis().SetTitleOffset(1.35)
81 leg = TLegend((1-RightMargin)-0.45, (1-TopMargin)-0.13,
82 (1-RightMargin)-0.1, (1-TopMargin)-0.03)
86 leg.AddEntry(
"",
"#it{#bf{sPHENIX}} Work-in-progress",
"")
87 leg.AddEntry(
"",
"Au+Au #sqrt{s_{NN}}=200 GeV",
"")
89 leg.AddEntry(
"",
"#it{#bf{sPHENIX}} Simulation",
"")
90 leg.AddEntry(
"",
"Au+Au #sqrt{s_{NN}}=200 GeV",
"")
94 c.SaveAs(outname+
'.pdf')
95 c.SaveAs(outname+
'.png')
98 gSystem.ProcessEvents()
103 def Draw_1DhistsComp(lhist, norm1, logx, logy, ymaxscale, XaxisName, Ytitle_unit, outname):
104 color = [
'#1B1A17',
'#035397',
'#9B0000']
105 legtext = [
'1st+2nd layers',
'2nd+3rd layers',
'1st+3rd layers']
110 if h.GetMaximum() > ymax:
111 ymax = h.GetMaximum()
112 if h.GetMinimum(0) < ymin:
113 ymin = h.GetMinimum(0)
115 h.Scale(1. / h.Integral(-1, -1))
116 ymax = h.GetMaximum()
117 ymin = h.GetMinimum(0)
119 binwidth_bin1 = lhist[0].
GetXaxis().GetBinWidth(1)
120 binwidth_bin2 = lhist[0].
GetXaxis().GetBinWidth(2)
122 if binwidth_bin1 != binwidth_bin2:
123 printbinwidth =
False
125 c = TCanvas(
'c',
'c', 800, 700)
131 gPad.SetRightMargin(RightMargin)
132 gPad.SetTopMargin(TopMargin)
133 gPad.SetLeftMargin(LeftMargin)
134 gPad.SetBottomMargin(BottomMargin)
137 if Ytitle_unit ==
'':
140 lhist[0].
GetYaxis().
SetTitle(
'Normalized entries / ({:g} {unit})'.
format(binwidth_bin1, unit=Ytitle_unit))
142 if Ytitle_unit ==
'':
148 if Ytitle_unit ==
'':
153 if Ytitle_unit ==
'':
159 lhist[0].
GetYaxis().SetRangeUser(ymin * 0.05, ymax * 100)
161 lhist[0].
GetYaxis().SetRangeUser(0., ymax * ymaxscale)
163 lhist[0].
GetXaxis().SetTickSize(TickSize)
164 lhist[0].
GetXaxis().SetTitleSize(AxisTitleSize)
165 lhist[0].
GetXaxis().SetLabelSize(AxisLabelSize)
166 lhist[0].
GetYaxis().SetTickSize(TickSize)
167 lhist[0].
GetYaxis().SetTitleSize(AxisTitleSize)
168 lhist[0].
GetYaxis().SetLabelSize(AxisLabelSize)
169 lhist[0].
GetXaxis().SetTitleOffset(1.1)
170 lhist[0].
GetYaxis().SetTitleOffset(1.4)
173 h.SetLineColor(TColor.GetColor(color[i]))
177 h.SetLineColor(TColor.GetColor(color[i]))
181 leg = TLegend((1-RightMargin)-0.45, (1-TopMargin)-0.15,
182 (1-RightMargin)-0.1, (1-TopMargin)-0.03)
183 leg.SetTextSize(0.045)
185 leg.AddEntry(
"",
"#it{#bf{sPHENIX}} Simulation",
"")
186 leg.AddEntry(
"",
"Au+Au #sqrt{s_{NN}}=200 GeV",
"")
189 leg1 = TLegend(LeftMargin+0.04, (1-TopMargin)-0.21,
190 LeftMargin+0.34, (1-TopMargin)-0.03)
191 leg1.SetTextSize(0.035)
194 leg1.AddEntry(h, legtext[i],
"l")
198 c.SaveAs(outname+
'.pdf')
199 c.SaveAs(outname+
'.png')
202 gSystem.ProcessEvents()
207 def Draw_2Dhist(hist, IsData, logz, norm1, rmargin, XaxisName, YaxisName, drawopt, outname):
208 c = TCanvas(
'c',
'c', 800, 700)
212 gPad.SetRightMargin(rmargin)
213 gPad.SetTopMargin(TopMargin)
214 gPad.SetLeftMargin(LeftMargin)
215 gPad.SetBottomMargin(BottomMargin)
217 hist.Scale(1. / hist.Integral(-1, -1, -1, -1))
220 hist.GetXaxis().SetTickSize(TickSize)
221 hist.GetYaxis().SetTickSize(TickSize)
222 hist.GetXaxis().SetTitleSize(AxisTitleSize)
223 hist.GetYaxis().SetTitleSize(AxisTitleSize)
224 hist.GetXaxis().SetLabelSize(AxisLabelSize)
225 hist.GetYaxis().SetLabelSize(AxisLabelSize)
226 hist.GetXaxis().SetTitleOffset(1.1)
227 hist.GetYaxis().SetTitleOffset(1.3)
228 hist.GetZaxis().SetLabelSize(AxisLabelSize)
229 hist.SetContour(1000)
243 c.SaveAs(outname+
'.pdf')
244 c.SaveAs(outname+
'.png')
247 gSystem.ProcessEvents()
251 def plot_Stack(totalhist, list_hist, color, list_legtext, logy, ymaxscale, XaxisName, Ytitle_unit, plotname):
253 binwidth = totalhist.GetXaxis().GetBinWidth(1)
254 hs = THStack(
'hs',
'hs');
258 hist.SetFillColor(TColor.GetColor(color[i]))
263 c = TCanvas(
'c',
'c', 800, 700)
269 if Ytitle_unit ==
'':
272 hist.GetYaxis().
SetTitle(
'Entries / ({:g} {unit})'.
format(binwidth, unit=Ytitle_unit))
273 hs.GetXaxis().SetTitleSize(AxisTitleSize)
274 hs.GetYaxis().SetTitleSize(AxisTitleSize)
275 hs.GetXaxis().SetTickSize(TickSize)
276 hs.GetYaxis().SetTickSize(TickSize)
277 hs.GetXaxis().SetLabelSize(AxisLabelSize)
278 hs.GetYaxis().SetLabelSize(AxisLabelSize)
279 hs.GetYaxis().SetTitleOffset(1.3)
280 hs.SetMaximum(totalhist.GetMaximum() * ymaxscale)
282 totalhist.SetLineWidth(3)
283 totalhist.SetLineColor(1)
284 totalhist.Draw(
'histsame')
286 leg = TLegend((1-RightMargin)-0.45, (1-TopMargin)-0.15,
287 (1-RightMargin)-0.1, (1-TopMargin)-0.03)
288 leg.SetTextSize(0.045)
290 leg.AddEntry(
'',
'#it{#bf{sPHENIX}} Simulation',
'')
291 leg.AddEntry(
'',
'Au+Au #sqrt{s_{NN}}=200 GeV',
'')
293 leg1 = TLegend(LeftMargin+0.05, (1-TopMargin)-0.22,
294 LeftMargin+0.3, (1-TopMargin)-0.01)
296 leg1.SetTextSize(0.03)
299 leg1.AddEntry(list_hist[i], text,
'f')
302 c.SaveAs(plotname+
'.png')
303 c.SaveAs(plotname+
'.pdf')
306 gSystem.ProcessEvents()
312 f = TFile(filename,
'r')
320 return str(s).replace(
'.',
'p')