17 |
|
sys.path.append(os.getcwd()) |
18 |
|
exec("from " + options.localConfig.rstrip('.py') + " import *") |
19 |
|
|
20 |
+ |
|
21 |
+ |
outputFileName = "stacked_histograms.root" |
22 |
+ |
if options.outputFileName: |
23 |
+ |
outputFileName = options.outputFileName |
24 |
+ |
|
25 |
|
condor_dir = set_condor_output_dir(options) |
26 |
|
|
27 |
|
|
28 |
+ |
|
29 |
+ |
|
30 |
|
if options.normalizeToData and options.normalizeToUnitArea: |
31 |
|
print "Conflicting normalizations requsted, will normalize to unit area" |
32 |
|
options.normalizeToData = False |
35 |
|
options.normalizeToData = False |
36 |
|
options.normalizeToUnitArea = True |
37 |
|
|
38 |
< |
from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TArrow, THStack, TIter, TKey, TPaveLabel |
38 |
> |
from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TArrow, THStack, TIter, TKey, TPaveLabel, gPad |
39 |
|
|
40 |
|
gROOT.SetBatch() |
41 |
|
gStyle.SetOptStat(0) |
45 |
|
gStyle.SetCanvasColor(0) |
46 |
|
gStyle.SetTextFont(42) |
47 |
|
gROOT.ForceStyle() |
48 |
< |
outputFile = TFile(condor_dir + "/stacked_histograms.root", "RECREATE") |
48 |
> |
outputFile = TFile(condor_dir + "/" + outputFileName, "RECREATE") |
49 |
|
|
50 |
|
channels = [] |
51 |
|
processed_datasets = [] |
117 |
|
LumiLabel.SetFillColor(0) |
118 |
|
LumiLabel.SetFillStyle(0) |
119 |
|
|
120 |
< |
BgMCLegend = TLegend(0.70,0.65,0.99,0.89, "Data & Bkgd. MC") |
120 |
> |
BgMCLegend = TLegend(0.70,0.65,0.94,0.89, "Data & Bkgd. MC") |
121 |
|
BgMCLegend.SetBorderSize(0) |
122 |
|
BgMCLegend.SetFillColor(0) |
123 |
|
BgMCLegend.SetFillStyle(0) |
227 |
|
|
228 |
|
if len(DataHistograms) is 1: |
229 |
|
dataIntegral += DataHistograms[0].Integral() |
230 |
+ |
|
231 |
+ |
|
232 |
+ |
### Drawing histograms to canvas |
233 |
+ |
|
234 |
|
|
235 |
|
outputFile.cd(rootDirectory+"/"+channel) |
236 |
|
|
237 |
+ |
makeRatioPlots = options.makeRatioPlots |
238 |
+ |
if numBgMCSamples is 0 or numDataSamples is not 1: |
239 |
+ |
makeRatioPlots = False |
240 |
+ |
if makeRatioPlots: |
241 |
+ |
Canvas.SetFillStyle(0) |
242 |
+ |
Canvas.Divide(1,2) |
243 |
+ |
Canvas.cd(1) |
244 |
+ |
gPad.SetPad(0.01,0.25,0.99,0.99) |
245 |
+ |
gPad.SetMargin(0.1,0.05,0.02,0.07) |
246 |
+ |
gPad.SetFillStyle(0) |
247 |
+ |
gPad.Update() |
248 |
+ |
gPad.Draw() |
249 |
+ |
Canvas.cd(2) |
250 |
+ |
gPad.SetPad(0.01,0.01,0.99,0.25) |
251 |
+ |
#gPad.SetMargin(l,r,b,t) |
252 |
+ |
gPad.SetMargin(0.1,0.05,0.4,0.02) |
253 |
+ |
gPad.SetFillStyle(0) |
254 |
+ |
gPad.SetGridy(1) |
255 |
+ |
gPad.Update() |
256 |
+ |
gPad.Draw() |
257 |
+ |
|
258 |
+ |
Canvas.cd(1) |
259 |
+ |
|
260 |
|
if(numBgMCSamples is not 0): |
261 |
|
if not options.noStack: |
262 |
|
Stack.SetTitle(histoTitle) |
263 |
|
Stack.Draw("HIST") |
264 |
|
Stack.GetXaxis().SetTitle(xAxisLabel) |
265 |
|
Stack.SetMaximum(1.1*finalMax) |
266 |
+ |
if makeRatioPlots: |
267 |
+ |
Stack.GetHistogram().GetXaxis().SetLabelSize(0) |
268 |
|
else: |
269 |
|
BgMCHistograms[0].SetTitle(histoTitle) |
270 |
|
BgMCHistograms[0].Draw("HIST") |
316 |
|
NormLabel.SetFillColor(0) |
317 |
|
NormLabel.SetFillStyle(0) |
318 |
|
NormLabel.Draw() |
319 |
+ |
|
320 |
+ |
|
321 |
+ |
if makeRatioPlots: |
322 |
+ |
Canvas.cd(2) |
323 |
+ |
BgSum = Stack.GetStack().Last() |
324 |
+ |
Ratio = DataHistograms[0].Clone() |
325 |
+ |
Ratio.Add(BgSum,-1) |
326 |
+ |
Ratio.Divide(BgSum) |
327 |
|
|
328 |
+ |
Ratio.SetTitle("") |
329 |
+ |
Ratio.GetXaxis().SetTitle(xAxisLabel) |
330 |
+ |
Ratio.GetYaxis().SetTitle("#frac{Data-MC}{MC}") |
331 |
+ |
Ratio.GetYaxis().CenterTitle() |
332 |
+ |
Ratio.GetYaxis().SetTitleSize(0.1) |
333 |
+ |
Ratio.GetYaxis().SetTitleOffset(0.3) |
334 |
+ |
Ratio.GetXaxis().SetTitleSize(0.15) |
335 |
+ |
Ratio.GetYaxis().SetLabelSize(0.1) |
336 |
+ |
Ratio.GetXaxis().SetLabelSize(0.15) |
337 |
+ |
Ratio.GetYaxis().SetRangeUser(-1,1) |
338 |
+ |
Ratio.GetYaxis().SetNdivisions(205) |
339 |
+ |
Ratio.Draw() |
340 |
|
|
341 |
|
Canvas.Write() |
342 |
|
|