1 from builtins
import range
15 cv = ROOT.TCanvas(name.replace(
'.pdf',
''), name.replace(
'.pdf',
''), 10, 10, 700, 600)
18 cv.Divide(1, 2, 0.0, 0.0)
20 cv.GetPad(1).SetPad(0.0, 0.32, 1., 1.0)
21 cv.GetPad(2).SetPad(0.0, 0.00, 1., 0.34)
22 cv.GetPad(1).SetFillStyle(4000)
23 cv.GetPad(2).SetFillStyle(4000)
26 ROOT.gPad.SetTopMargin(0.08)
27 ROOT.gPad.SetLeftMargin(0.12)
28 ROOT.gPad.SetBottomMargin(0.03)
29 ROOT.gPad.SetRightMargin(0.1)
32 ROOT.gPad.SetBottomMargin(0.35)
33 ROOT.gPad.SetLeftMargin(0.12)
34 ROOT.gPad.SetRightMargin(0.1)
36 bogyHist = ROOT.TH1F(
"legendPseudoHist",
"", 1, 1., 2.)
37 bogyHist.SetFillColor(errorBandFillColor)
38 bogyHist.SetFillStyle(errorBandStyle)
39 bogyHist.SetLineColor(0)
47 for ib
in range(0, histos[0].GetNbinsX()):
48 for ih, h
in enumerate(histos):
50 if not histos[0].GetBinContent(ib+1) == 0:
51 rel_diff+=((h.GetBinContent(ib+1)-histos[0].GetBinContent(ib+1))/histos[0].GetBinContent(ib+1))*((h.GetBinContent(ib+1)-histos[0].GetBinContent(ib+1))/histos[0].GetBinContent(ib+1))
52 return math.sqrt(rel_diff)
59 self.
canvas = ROOT.TCanvas(name.replace(
'.pdf',
''))
63 self.
Legend = ROOT.TLegend(0.15, 0.79, 0.5, 0.89)
68 self.
box = ROOT.TPave(0.93,0.85,0.98,0.90)
74 def Draw(self, histos, titles):
76 ymax =
max(h.GetMaximum()
for h
in self.
histos)
79 for i, h
in enumerate(self.
histos):
81 h.GetYaxis().SetRangeUser(0., ymax * 1.3)
82 self.
Legend.AddEntry(h, title +
': ' +
str(h.Integral()))
90 self.
box.SetLineColor(1)
91 self.
box.SetLineWidth(1)
92 self.
box.SetShadowColor(0)
94 self.
box.SetFillColor(416)
95 elif rel_diff <= 0.10:
96 self.
box.SetFillColor(797)
98 self.
box.SetFillColor(632)
99 self.
box.ConvertNDCtoPad()
106 histPull = copy.deepcopy(self.
histos[ihist])
107 pull_histos.append(histPull)
108 histPull.Divide(self.
histos[0])
109 histPull.UseCurrentStyle()
110 histPull.SetLineColor(self.
histos[ihist].GetLineColor())
111 histPull.SetMarkerColor(self.
histos[ihist].GetLineColor())
112 histPull.SetLineStyle(self.
histos[ihist].GetLineStyle())
113 histPull.SetLineWidth(self.
histos[ihist].GetLineWidth())
116 defaultYtoPixel = self.
canvas.GetPad(1).YtoPixel(0.)
117 pad2YtoPixel =
float(self.
canvas.GetPad(2).YtoPixel(0))
118 pad2XaxisFactor = defaultYtoPixel / pad2YtoPixel
119 histPull.GetXaxis().SetLabelSize(self.
histos[0].GetXaxis().GetLabelSize()*pad2XaxisFactor)
120 histPull.GetXaxis().SetLabelOffset(self.
histos[0].GetXaxis().GetLabelOffset()*pad2XaxisFactor)
121 histPull.GetXaxis().SetTitleSize(self.
histos[0].GetXaxis().GetTitleSize()*pad2XaxisFactor)
122 histPull.GetXaxis().SetTitleOffset(self.
histos[0].GetXaxis().GetTitleOffset()/pad2XaxisFactor*2.5)
123 histPull.GetYaxis().SetLabelSize(self.
histos[0].GetYaxis().GetLabelSize()*pad2XaxisFactor)
124 histPull.GetYaxis().SetLabelOffset(self.
histos[0].GetYaxis().GetLabelOffset()*pad2XaxisFactor)
125 histPull.GetYaxis().SetTitleSize(self.
histos[0].GetYaxis().GetTitleSize()*pad2XaxisFactor)
126 histPull.GetYaxis().SetTitleOffset(self.
histos[0].GetYaxis().GetTitleOffset()/pad2XaxisFactor)
127 histPull.GetYaxis().CenterTitle()
128 histPull.GetXaxis().SetTickLength(histPull.GetXaxis().GetTickLength()*pad2XaxisFactor)
129 histPull.GetYaxis().SetNdivisions(306)
130 histPull.GetYaxis().SetTitle(
"Ratio to " + titles[0])
131 histPull.SetTitle(
'')
135 histPull.Draw(
"same ep")
138 for i, h
in enumerate(self.
histos):
139 h.GetXaxis().SetLabelSize(0)
def __init__(self, name, ratio)
def checkDifferences(histos)
def createRatioCanvas(name, errorBandFillColor=14, errorBandStyle=3354)
def applyLegendSettings(leg)
def Draw(self, histos, titles)