114 |
|
iLo,iHi = sorted([iG,iH]) |
115 |
|
return regroup(groups[:iLo] + [groups[iLo]+groups[iHi]] + groups[iHi+1:]) |
116 |
|
|
117 |
< |
groups = regroup( [(i,) for i in range(1,1+dataHist.GetNbinsX())] ) |
118 |
< |
ratio = TH1F("ratio","",len(groups), array('d', [dataHist.GetBinLowEdge(min(g)) for g in groups ] + [dataHist.GetXaxis().GetBinUpEdge(dataHist.GetNbinsX())]) ) |
119 |
< |
for i,g in enumerate(groups) : |
120 |
< |
ratio.SetBinContent(i+1,groupR(g)) |
121 |
< |
ratio.SetBinError(i+1,groupErr(g)) |
117 |
> |
#don't rebin the histograms of the number of a given object (except for the pileup ones) |
118 |
> |
if dataHist.GetName().find("num") is not -1 and dataHist.GetName().find("Primaryvertexs") is -1: |
119 |
> |
ratio = dataHist.Clone() |
120 |
> |
ratio.Add(mcHist,-1) |
121 |
> |
ratio.Divide(mcHist) |
122 |
> |
ratio.SetTitle("") |
123 |
> |
else: |
124 |
> |
groups = regroup( [(i,) for i in range(1,1+dataHist.GetNbinsX())] ) |
125 |
> |
ratio = TH1F("ratio","",len(groups), array('d', [dataHist.GetBinLowEdge(min(g)) for g in groups ] + [dataHist.GetXaxis().GetBinUpEdge(dataHist.GetNbinsX())]) ) |
126 |
> |
for i,g in enumerate(groups) : |
127 |
> |
ratio.SetBinContent(i+1,groupR(g)) |
128 |
> |
ratio.SetBinError(i+1,groupErr(g)) |
129 |
> |
|
130 |
> |
ratio.GetYaxis().SetTitle("#frac{Data-MC}{MC}") |
131 |
|
ratio.SetLineColor(1) |
132 |
|
ratio.SetLineWidth(2) |
124 |
– |
|
133 |
|
return ratio |
134 |
|
|
135 |
|
########################################################################################################################################## |
148 |
|
|
149 |
|
LumiLabel = TPaveLabel(topLeft_x_left,topLeft_y_bottom,topLeft_x_right,topLeft_y_top,LumiText,"NDC") |
150 |
|
LumiLabel.SetBorderSize(0) |
143 |
– |
LumiLabel.SetTextSize(0.32) |
151 |
|
LumiLabel.SetFillColor(0) |
152 |
|
LumiLabel.SetFillStyle(0) |
153 |
|
|
157 |
|
NormLabel.SetX2NDC(topLeft_x_right) |
158 |
|
|
159 |
|
NormLabel.SetBorderSize(0) |
153 |
– |
NormLabel.SetTextSize(0.32) |
160 |
|
NormLabel.SetFillColor(0) |
161 |
|
NormLabel.SetFillStyle(0) |
162 |
|
|
286 |
|
### formatting data histograms and adding to legend |
287 |
|
legendIndex = 0 |
288 |
|
for Histogram in DataHistograms: |
289 |
< |
BgMCLegend.AddEntry(Histogram,DataLegendEntries[legendIndex],"LEP").SetTextFont (42) |
289 |
> |
BgMCLegend.AddEntry(Histogram,DataLegendEntries[legendIndex],"LEP") |
290 |
|
legendIndex = legendIndex+1 |
291 |
|
|
292 |
|
|
296 |
|
ErrorHisto.SetFillStyle(3001) |
297 |
|
ErrorHisto.SetFillColor(13) |
298 |
|
ErrorHisto.SetLineWidth(0) |
299 |
< |
BgMCLegend.AddEntry(ErrorHisto,"Stat. Errors","F").SetTextFont (42) |
299 |
> |
BgMCLegend.AddEntry(ErrorHisto,"Stat. Errors","F") |
300 |
|
for Histogram in BgMCHistograms: |
301 |
|
if Histogram is not BgMCHistograms[0]: |
302 |
|
ErrorHisto.Add(Histogram) |
306 |
|
legendIndex = numBgMCSamples-1 |
307 |
|
for Histogram in reversed(BgMCHistograms): |
308 |
|
if(arguments.noStack): |
309 |
< |
BgMCLegend.AddEntry(Histogram,BgMCLegendEntries[legendIndex],"L").SetTextFont (42) |
309 |
> |
BgMCLegend.AddEntry(Histogram,BgMCLegendEntries[legendIndex],"L") |
310 |
|
else: |
311 |
< |
BgMCLegend.AddEntry(Histogram,BgMCLegendEntries[legendIndex],"F").SetTextFont (42) |
311 |
> |
BgMCLegend.AddEntry(Histogram,BgMCLegendEntries[legendIndex],"F") |
312 |
|
legendIndex = legendIndex-1 |
313 |
|
|
314 |
|
|
315 |
|
### formatting signalMC histograms and adding to legend |
316 |
|
legendIndex = 0 |
317 |
|
for Histogram in SignalMCHistograms: |
318 |
< |
SignalMCLegend.AddEntry(Histogram,SignalMCLegendEntries[legendIndex],"L").SetTextFont (42) |
318 |
> |
SignalMCLegend.AddEntry(Histogram,SignalMCLegendEntries[legendIndex],"L") |
319 |
|
legendIndex = legendIndex+1 |
320 |
|
|
321 |
|
|
472 |
|
if makeRatioPlots or makeDiffPlots: |
473 |
|
Canvas.cd(2) |
474 |
|
BgSum = Stack.GetStack().Last() |
469 |
– |
Comparison = ratioHistogram(DataHistograms[0],BgSum) |
470 |
– |
Comparison.GetXaxis().SetTitle(xAxisLabel) |
475 |
|
if makeRatioPlots: |
476 |
< |
Comparison.GetYaxis().SetTitle("#frac{Data-MC}{MC}") |
476 |
> |
Comparison = ratioHistogram(DataHistograms[0],BgSum) |
477 |
|
elif makeDiffPlots: |
478 |
+ |
Comparison = DataHistograms[0].Clone() |
479 |
+ |
Comparison.Add(BgSum,-1) |
480 |
+ |
Comparison.SetTitle("") |
481 |
|
Comparison.GetYaxis().SetTitle("Data-MC") |
482 |
+ |
Comparison.GetXaxis().SetTitle(xAxisLabel) |
483 |
|
Comparison.GetYaxis().CenterTitle() |
484 |
|
Comparison.GetYaxis().SetTitleSize(0.1) |
485 |
< |
Comparison.GetYaxis().SetTitleOffset(0.35) |
485 |
> |
Comparison.GetYaxis().SetTitleOffset(0.4) |
486 |
|
Comparison.GetXaxis().SetTitleSize(0.15) |
487 |
|
Comparison.GetYaxis().SetLabelSize(0.1) |
488 |
|
Comparison.GetXaxis().SetLabelSize(0.15) |
489 |
< |
if makeRatioPlots: |
490 |
< |
RatioYRange = float(arguments.ratioYRange) |
489 |
> |
if makeRatioPlots: |
490 |
> |
RatioYRange = 1.15 |
491 |
> |
if arguments.ratioYRange: |
492 |
> |
RatioYRange = float(arguments.ratioYRange) |
493 |
|
Comparison.GetYaxis().SetRangeUser(-1*RatioYRange, RatioYRange) |
494 |
|
elif makeDiffPlots: |
495 |
|
YMax = Comparison.GetMaximum() |