ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makePlots.py
Revision: 1.31
Committed: Mon Apr 15 13:48:09 2013 UTC (12 years ago) by lantonel
Content type: text/x-python
Branch: MAIN
Changes since 1.30: +32 -16 lines
Log Message:
added shaded regions to represent stat. error bars on the background stack

File Contents

# User Rev Content
1 lantonel 1.1 #!/usr/bin/env python
2     import sys
3     import os
4 ahart 1.6 import re
5 lantonel 1.31 from math import *
6 lantonel 1.1 from array import *
7 lantonel 1.3 from decimal import *
8 lantonel 1.17 from optparse import OptionParser
9 lantonel 1.2 from OSUT3Analysis.Configuration.configurationOptions import *
10 lantonel 1.7 from OSUT3Analysis.Configuration.processingUtilities import *
11 lantonel 1.1
12 lantonel 1.17 parser = OptionParser()
13 lantonel 1.7 parser = set_commandline_arguments(parser)
14 lantonel 1.17 (arguments, args) = parser.parse_args()
15 lantonel 1.1
16 lantonel 1.16 if arguments.localConfig:
17 lantonel 1.1 sys.path.append(os.getcwd())
18 lantonel 1.16 exec("from " + arguments.localConfig.rstrip('.py') + " import *")
19 lantonel 1.1
20 lantonel 1.15
21     outputFileName = "stacked_histograms.root"
22 lantonel 1.16 if arguments.outputFileName:
23     outputFileName = arguments.outputFileName
24 lantonel 1.15
25 lantonel 1.16 condor_dir = set_condor_output_dir(arguments)
26 lantonel 1.1
27    
28 lantonel 1.15
29 lantonel 1.25 #### deal with conflicting arguments
30 lantonel 1.16 if arguments.normalizeToData and arguments.normalizeToUnitArea:
31 lantonel 1.13 print "Conflicting normalizations requsted, will normalize to unit area"
32 lantonel 1.16 arguments.normalizeToData = False
33     if arguments.normalizeToData and arguments.noStack:
34 lantonel 1.14 print "You have asked to scale non-stacked backgrounds to data. This is a very strange request. Will normalize to unit area instead"
35 lantonel 1.16 arguments.normalizeToData = False
36     arguments.normalizeToUnitArea = True
37 lantonel 1.25 if arguments.makeRatioPlots and arguments.makeDiffPlots:
38     print "You have requested both ratio and difference plots. Will make just ratio plots instead"
39     arguments.makeRatioPlots = False
40 lantonel 1.13
41 lantonel 1.15 from ROOT import TFile, gROOT, gStyle, gDirectory, TStyle, THStack, TH1F, TCanvas, TString, TLegend, TArrow, THStack, TIter, TKey, TPaveLabel, gPad
42 lantonel 1.1
43     gROOT.SetBatch()
44     gStyle.SetOptStat(0)
45     gStyle.SetCanvasBorderMode(0)
46     gStyle.SetPadBorderMode(0)
47     gStyle.SetPadColor(0)
48     gStyle.SetCanvasColor(0)
49     gStyle.SetTextFont(42)
50 lantonel 1.3 gROOT.ForceStyle()
51 lantonel 1.15 outputFile = TFile(condor_dir + "/" + outputFileName, "RECREATE")
52 lantonel 1.1
53     channels = []
54     processed_datasets = []
55    
56     #### check which input datasets have valid output files
57     for sample in datasets:
58     fileName = condor_dir + "/" + sample + ".root"
59     if not os.path.exists(fileName):
60     continue
61     testFile = TFile(fileName)
62 lantonel 1.14 if testFile.IsZombie() or not testFile.GetNkeys():
63     continue
64     processed_datasets.append(sample)
65 lantonel 1.1
66     if len(processed_datasets) is 0:
67     sys.exit("No datasets have been processed")
68    
69     #### open first input file and re-make its directory structure in the output file
70     testFile = TFile(condor_dir + "/" + processed_datasets[0] + ".root")
71     testFile.cd()
72     for key in testFile.GetListOfKeys():
73     if (key.GetClassName() != "TDirectoryFile"):
74     continue
75     outputFile.cd()
76     outputFile.mkdir(key.GetName())
77     rootDirectory = key.GetName()
78    
79     testFile.cd(key.GetName())
80     for key2 in gDirectory.GetListOfKeys():
81     if (key2.GetClassName() != "TDirectoryFile"):
82     continue
83     outputFile.cd(key.GetName())
84     gDirectory.mkdir(key2.GetName())
85     channels.append(key2.GetName())
86    
87    
88 lantonel 1.31 ## weight = intLumi / 10000.0
89     ## for dataset in processed_datasets:
90     ## dataset_file = "%s/%s.root" % (condor_dir,dataset)
91     ## fin = TFile (dataset_file)
92     ## flags = fin.Get ("flags")
93     ## noWeights = flags and flags.GetBinContent (1)
94     ## fin.Close ()
95    
96     ## if types[dataset] != "data" and not noWeights:
97     ## os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", weight))
98     ## else:
99     ## os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", 1.0))
100 lantonel 1.1
101     for channel in channels: # loop over final states, which each have their own directory
102    
103     testFile.cd(rootDirectory+"/"+channel)
104 lantonel 1.3
105 lantonel 1.10 for key in gDirectory.GetListOfKeys(): # loop over histograms in the current directory
106     histogramName = key.GetName()
107 lantonel 1.1
108 lantonel 1.10 if re.match ('TH1', key.GetClassName()): # plot a 1-D histogram
109    
110     numBgMCSamples = 0
111     numDataSamples = 0
112     numSignalSamples = 0
113 lantonel 1.1
114 lantonel 1.10 Stack = THStack("stack",histogramName)
115 lantonel 1.1
116 lantonel 1.10 if(intLumi < 1000.):
117     LumiText = "L_{int} = " + str(intLumi) + " pb^{-1}"
118     else:
119     getcontext().prec = 2
120     LumiInFb = intLumi/1000.
121     LumiText = "L_{int} = " + str(LumiInFb) + " fb^{-1}"
122    
123     LumiLabel = TPaveLabel(0.1,0.8,0.34,0.9,LumiText,"NDC")
124     LumiLabel.SetBorderSize(0)
125     LumiLabel.SetFillColor(0)
126     LumiLabel.SetFillStyle(0)
127 lantonel 1.1
128 lantonel 1.31
129 ahart 1.30 BgMCLegend = TLegend(0.70,0.65,0.94,0.89)
130     BgMCLegend.AddEntry (0, "Data & Bkgd. MC", "H").SetTextFont (62)
131 lantonel 1.10 BgMCLegend.SetBorderSize(0)
132     BgMCLegend.SetFillColor(0)
133     BgMCLegend.SetFillStyle(0)
134 ahart 1.30 SignalMCLegend = TLegend(0.45,0.65,0.70,0.89)
135     SignalMCLegend.AddEntry (0, "Signal MC", "H").SetTextFont (62)
136 lantonel 1.10 SignalMCLegend.SetBorderSize(0)
137     SignalMCLegend.SetFillColor(0)
138     SignalMCLegend.SetFillStyle(0)
139    
140     outputFile.cd(rootDirectory+"/"+channel)
141     Canvas = TCanvas(histogramName)
142     BgMCHistograms = []
143     SignalMCHistograms = []
144     DataHistograms = []
145    
146     backgroundIntegral = 0
147     dataIntegral = 0
148     scaleFactor = 1
149    
150     for sample in processed_datasets: # loop over different samples as listed in configurationOptions.py
151 ahart 1.28 dataset_file = "%s/%s.root" % (condor_dir,sample)
152 lantonel 1.10 inputFile = TFile(dataset_file)
153     Histogram = inputFile.Get(rootDirectory+"/"+channel+"/"+histogramName).Clone()
154     Histogram.SetDirectory(0)
155 lantonel 1.27 if arguments.rebinFactor:
156     RebinFactor = int(arguments.rebinFactor)
157     if Histogram.GetNbinsX() >= RebinFactor*10:
158     Histogram.Rebin(RebinFactor)
159 lantonel 1.10 inputFile.Close()
160     xAxisLabel = Histogram.GetXaxis().GetTitle()
161     histoTitle = Histogram.GetTitle()
162 wulsin 1.29
163     legLabel = labels[sample]
164     if (arguments.printYields):
165     yieldHist = Histogram.Integral()
166     legLabel = legLabel + " (%.1f)" % yieldHist
167    
168 lantonel 1.10 if( types[sample] == "bgMC"):
169    
170     numBgMCSamples += 1
171 wulsin 1.29
172 lantonel 1.16 if(arguments.noStack):
173 lantonel 1.14 Histogram.SetFillStyle(0)
174     Histogram.SetLineColor(colors[sample])
175     Histogram.SetLineWidth(2)
176 ahart 1.30 BgMCLegend.AddEntry(Histogram,legLabel,"L").SetTextFont (42)
177 lantonel 1.14 else:
178     Histogram.SetFillStyle(1001)
179     Histogram.SetFillColor(colors[sample])
180     Histogram.SetLineColor(1)
181     Histogram.SetLineWidth(1)
182 ahart 1.30 BgMCLegend.AddEntry(Histogram,legLabel,"F").SetTextFont (42)
183 lantonel 1.31
184 lantonel 1.10 Histogram.SetLineStyle(1)
185    
186     backgroundIntegral += Histogram.Integral()
187    
188     BgMCHistograms.append(Histogram)
189 lantonel 1.31
190 lantonel 1.10
191     elif( types[sample] == "signalMC"):
192    
193     numSignalSamples += 1
194 lantonel 1.11
195 lantonel 1.10 Histogram.SetFillStyle(0)
196     Histogram.SetLineColor(colors[sample])
197     Histogram.SetLineStyle(1)
198     Histogram.SetLineWidth(2)
199 lantonel 1.16 if(arguments.normalizeToUnitArea and Histogram.Integral() > 0):
200 lantonel 1.11 Histogram.Scale(1./Histogram.Integral())
201 ahart 1.30 SignalMCLegend.AddEntry(Histogram,legLabel,"L").SetTextFont (42)
202 lantonel 1.10 SignalMCHistograms.append(Histogram)
203    
204     elif( types[sample] == "data"):
205    
206     numDataSamples += 1
207    
208     Histogram.SetFillStyle(0)
209     Histogram.SetLineColor(colors[sample])
210     Histogram.SetLineStyle(1)
211     Histogram.SetLineWidth(2)
212 lantonel 1.16 if(arguments.normalizeToUnitArea and Histogram.Integral() > 0):
213 lantonel 1.11 Histogram.Scale(1./Histogram.Integral())
214 lantonel 1.10
215     dataIntegral += Histogram.Integral()
216    
217 ahart 1.30 BgMCLegend.AddEntry(Histogram,legLabel,"LEP").SetTextFont (42)
218 lantonel 1.10 DataHistograms.append(Histogram)
219    
220     if dataIntegral > 0 and backgroundIntegral > 0:
221     scaleFactor = dataIntegral/backgroundIntegral
222     for bgMCHist in BgMCHistograms:
223 lantonel 1.16 if arguments.normalizeToData:
224 lantonel 1.10 bgMCHist.Scale(scaleFactor)
225 lantonel 1.16 if arguments.normalizeToUnitArea and not arguments.noStack and backgroundIntegral > 0:
226 lantonel 1.11 bgMCHist.Scale(1./backgroundIntegral)
227 lantonel 1.16 elif arguments.normalizeToUnitArea and arguments.noStack and bgMCHist.Integral() > 0:
228 lantonel 1.14 bgMCHist.Scale(1./bgMCHist.Integral())
229 lantonel 1.16 if not arguments.noStack:
230 lantonel 1.14 Stack.Add(bgMCHist)
231 lantonel 1.3
232 lantonel 1.14
233     finalMax = 0
234 lantonel 1.16 if not arguments.noStack:
235 lantonel 1.14 finalMax = Stack.GetMaximum()
236     else:
237     for bgMCHist in BgMCHistograms:
238     if(bgMCHist.GetMaximum() > finalMax):
239     finalMax = bgMCHist.GetMaximum()
240 lantonel 1.10 for signalMCHist in SignalMCHistograms:
241     if(signalMCHist.GetMaximum() > finalMax):
242     finalMax = signalMCHist.GetMaximum()
243     for dataHist in DataHistograms:
244     if(dataHist.GetMaximum() > finalMax):
245     finalMax = dataHist.GetMaximum()
246 lantonel 1.4
247 lantonel 1.14
248    
249 lantonel 1.10 if len(DataHistograms) is 1:
250     dataIntegral += DataHistograms[0].Integral()
251 lantonel 1.15
252    
253     ### Drawing histograms to canvas
254 lantonel 1.31
255     if numBgMCSamples is not 0:
256     ErrorHisto = BgMCHistograms[0].Clone("errors")
257     ErrorHisto.SetFillStyle(3001)
258     ErrorHisto.SetFillColor(13)
259     ErrorHisto.SetLineWidth(0)
260     for Histogram in BgMCHistograms:
261     if Histogram is not BgMCHistograms[0]:
262     ErrorHisto.Add(Histogram)
263    
264 lantonel 1.10 outputFile.cd(rootDirectory+"/"+channel)
265 lantonel 1.3
266 lantonel 1.16 makeRatioPlots = arguments.makeRatioPlots
267 lantonel 1.25 makeDiffPlots = arguments.makeDiffPlots
268    
269 lantonel 1.15 if numBgMCSamples is 0 or numDataSamples is not 1:
270     makeRatioPlots = False
271 lantonel 1.25 makeDiffPlots = False
272     if makeRatioPlots or makeDiffPlots:
273 lantonel 1.15 Canvas.SetFillStyle(0)
274     Canvas.Divide(1,2)
275     Canvas.cd(1)
276     gPad.SetPad(0.01,0.25,0.99,0.99)
277     gPad.SetMargin(0.1,0.05,0.02,0.07)
278     gPad.SetFillStyle(0)
279     gPad.Update()
280     gPad.Draw()
281     Canvas.cd(2)
282     gPad.SetPad(0.01,0.01,0.99,0.25)
283 lantonel 1.25 #format: gPad.SetMargin(l,r,b,t)
284 lantonel 1.15 gPad.SetMargin(0.1,0.05,0.4,0.02)
285     gPad.SetFillStyle(0)
286     gPad.SetGridy(1)
287     gPad.Update()
288     gPad.Draw()
289    
290     Canvas.cd(1)
291    
292 lantonel 1.31 if numBgMCSamples is not 0:
293 ahart 1.28
294 lantonel 1.16 if not arguments.noStack:
295 lantonel 1.14 Stack.SetTitle(histoTitle)
296     Stack.Draw("HIST")
297     Stack.GetXaxis().SetTitle(xAxisLabel)
298     Stack.SetMaximum(1.1*finalMax)
299 lantonel 1.20 Stack.SetMinimum(0.0001)
300 lantonel 1.25 if makeRatioPlots or makeDiffPlots:
301 lantonel 1.15 Stack.GetHistogram().GetXaxis().SetLabelSize(0)
302 lantonel 1.31 #draw shaded error bands
303     ErrorHisto.Draw("E2 SAME")
304    
305    
306 lantonel 1.14 else:
307     BgMCHistograms[0].SetTitle(histoTitle)
308     BgMCHistograms[0].Draw("HIST")
309     BgMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
310     BgMCHistograms[0].SetMaximum(1.1*finalMax)
311 lantonel 1.20 BgMCHistograms[0].SetMinimum(0.0001)
312 lantonel 1.14 for bgMCHist in BgMCHistograms:
313     bgMCHist.Draw("HIST SAME")
314 lantonel 1.10 for signalMCHist in SignalMCHistograms:
315     signalMCHist.Draw("HIST SAME")
316     for dataHist in DataHistograms:
317     dataHist.Draw("E SAME")
318    
319 lantonel 1.31 elif numSignalSamples is not 0:
320 lantonel 1.10 SignalMCHistograms[0].SetTitle(histoTitle)
321     SignalMCHistograms[0].Draw("HIST")
322     SignalMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
323     SignalMCHistograms[0].SetMaximum(1.1*finalMax)
324 lantonel 1.20 SignalMCHistograms[0].SetMinimum(0.0001)
325 lantonel 1.10 for signalMCHist in SignalMCHistograms:
326     if(signalMCHist is not SignalMCHistograms[0]):
327     signalMCHist.Draw("HIST SAME")
328     for dataHist in DataHistograms:
329     dataHist.Draw("E SAME")
330 lantonel 1.1
331 lantonel 1.10 elif(numDataSamples is not 0):
332     DataHistograms[0].SetTitle(histoTitle)
333     DataHistograms[0].Draw("E")
334     DataHistograms[0].GetXaxis().SetTitle(xAxisLabel)
335     DataHistograms[0].SetMaximum(1.1*finalMax)
336 lantonel 1.20 DataHistograms[0].SetMinimum(0.0001)
337 lantonel 1.10 for dataHist in DataHistograms:
338     if(dataHist is not DataHistograms[0]):
339     dataHist.Draw("E SAME")
340 lantonel 1.3
341 lantonel 1.10
342     if(numBgMCSamples is not 0 or numDataSamples is not 0):
343     BgMCLegend.Draw()
344     if(numSignalSamples is not 0):
345     SignalMCLegend.Draw()
346    
347 lantonel 1.25 if not arguments.normalizeToUnitArea or numDataSamples > 0:
348     LumiLabel.Draw()
349 lantonel 1.16 if arguments.normalizeToData and numBgMCSamples > 0 and numDataSamples > 0:
350 lantonel 1.10 NormLabel = TPaveLabel(0.1,0.75,0.35,0.85,"MC scaled to data","NDC")
351     NormLabel.SetBorderSize(0)
352     NormLabel.SetFillColor(0)
353     NormLabel.SetFillStyle(0)
354     NormLabel.Draw()
355 lantonel 1.16 elif arguments.normalizeToUnitArea:
356 lantonel 1.13 NormLabel = TPaveLabel(0.1,0.75,0.35,0.85,"Scaled to unit area","NDC")
357     NormLabel.SetBorderSize(0)
358     NormLabel.SetFillColor(0)
359     NormLabel.SetFillStyle(0)
360     NormLabel.Draw()
361 lantonel 1.15
362    
363 lantonel 1.25 if makeRatioPlots or makeDiffPlots:
364 lantonel 1.15 Canvas.cd(2)
365     BgSum = Stack.GetStack().Last()
366 lantonel 1.25 Comparison = DataHistograms[0].Clone()
367     Comparison.Add(BgSum,-1)
368     if not makeDiffPlots:
369     Comparison.Divide(BgSum)
370     Comparison.SetTitle("")
371     Comparison.GetXaxis().SetTitle(xAxisLabel)
372     if makeRatioPlots:
373     Comparison.GetYaxis().SetTitle("#frac{Data-MC}{MC}")
374     elif makeDiffPlots:
375     Comparison.GetYaxis().SetTitle("Data-MC")
376     Comparison.GetYaxis().CenterTitle()
377     Comparison.GetYaxis().SetTitleSize(0.1)
378     Comparison.GetYaxis().SetTitleOffset(0.35)
379     Comparison.GetXaxis().SetTitleSize(0.15)
380     Comparison.GetYaxis().SetLabelSize(0.1)
381     Comparison.GetXaxis().SetLabelSize(0.15)
382     if makeRatioPlots:
383     Comparison.GetYaxis().SetRangeUser(-1,1)
384     elif makeDiffPlots:
385     YMax = Comparison.GetMaximum()
386     YMin = Comparison.GetMinimum()
387     if YMax <= 0 and YMin <= 0:
388     Comparison.GetYaxis().SetRangeUser(-1.2*YMin,0)
389     elif YMax >= 0 and YMin >= 0:
390     Comparison.GetYaxis().SetRangeUser(0,1.2*YMax)
391     else: #axis crosses y=0
392     if abs(YMax) > abs(YMin):
393     Comparison.GetYaxis().SetRangeUser(-1.2*YMax,1.2*YMax)
394     else:
395     Comparison.GetYaxis().SetRangeUser(-1.2*YMin,1.2*YMin)
396    
397     Comparison.GetYaxis().SetNdivisions(205)
398     Comparison.Draw()
399 lantonel 1.4
400 lantonel 1.10 Canvas.Write()
401 lantonel 1.1
402 lantonel 1.4
403 lantonel 1.26 if re.match ('TH2', key.GetClassName()) and arguments.draw2DPlots: # plot a 2-D histogram
404 lantonel 1.4
405 lantonel 1.10 numBgMCSamples = 0
406     numDataSamples = 0
407     numSignalSamples = 0
408    
409     if(intLumi < 1000.):
410     LumiText = "L_{int} = " + str(intLumi) + " pb^{-1}"
411     else:
412     getcontext().prec = 2
413     LumiInFb = intLumi/1000.
414     LumiText = "L_{int} = " + str(LumiInFb) + " fb^{-1}"
415    
416     LumiLabel = TPaveLabel(0.1,0.8,0.34,0.9,LumiText,"NDC")
417     LumiLabel.SetBorderSize(0)
418     LumiLabel.SetFillColor(0)
419     LumiLabel.SetFillStyle(0)
420    
421 ahart 1.30 BgMCLegend = TLegend(0.76,0.65,0.99,0.9)
422     BgMCLegend.AddEntry (0, "Data & Bkgd. MC", "H").SetTextFont (62)
423 lantonel 1.10 BgMCLegend.SetBorderSize(0)
424     BgMCLegend.SetFillColor(0)
425     BgMCLegend.SetFillStyle(0)
426 ahart 1.30 SignalMCLegend = TLegend(0.76,0.135,0.99,0.377)
427     SignalMCLegend.AddEntry (0, "Signal MC", "H").SetTextFont (62)
428 lantonel 1.10 SignalMCLegend.SetBorderSize(0)
429     SignalMCLegend.SetFillColor(0)
430     SignalMCLegend.SetFillStyle(0)
431    
432     outputFile.cd(rootDirectory+"/"+channel)
433     Canvas = TCanvas(histogramName)
434     Canvas.SetRightMargin(0.2413793);
435     BgMCHistograms = []
436     SignalMCHistograms = []
437     DataHistograms = []
438    
439     for sample in processed_datasets: # loop over different samples as listed in configurationOptions.py
440 ahart 1.28 dataset_file = "%s/%s.root" % (condor_dir,sample)
441 lantonel 1.10 inputFile = TFile(dataset_file)
442     Histogram = inputFile.Get(rootDirectory+"/"+channel+"/"+histogramName).Clone()
443     Histogram.SetDirectory(0)
444 lantonel 1.25 RebinFactor = int(arguments.rebinFactor)
445     if arguments.rebinFactor and Histogram.GetNbinsX() >= RebinFactor*10 and Histogram.GetNbinsY() >= RebinFactor*10:
446     Histogram.Rebin2D(RebinFactor)
447 lantonel 1.10 inputFile.Close()
448     xAxisLabel = Histogram.GetXaxis().GetTitle()
449     yAxisLabel = Histogram.GetYaxis().GetTitle()
450     histoTitle = Histogram.GetTitle()
451    
452     if( types[sample] == "bgMC"):
453 lantonel 1.4
454 lantonel 1.10 numBgMCSamples += 1
455     Histogram.SetMarkerColor(colors[sample])
456     Histogram.SetFillColor(colors[sample])
457 ahart 1.30 BgMCLegend.AddEntry(Histogram,labels[sample],"F").SetTextFont (42)
458 lantonel 1.10 BgMCHistograms.append(Histogram)
459    
460     elif( types[sample] == "signalMC"):
461 lantonel 1.3
462 lantonel 1.10 numSignalSamples += 1
463     Histogram.SetMarkerColor(colors[sample])
464     Histogram.SetFillColor(colors[sample])
465 ahart 1.30 SignalMCLegend.AddEntry(Histogram,labels[sample],"F").SetTextFont (42)
466 lantonel 1.10 SignalMCHistograms.append(Histogram)
467    
468     elif( types[sample] == "data"):
469    
470     numDataSamples += 1
471     Histogram.SetMarkerColor(colors[sample])
472 wulsin 1.29 Histogram.SetFillColor(colors[sample])
473 ahart 1.30 BgMCLegend.AddEntry(Histogram,labels[sample],"F").SetTextFont (42)
474 lantonel 1.10 DataHistograms.append(Histogram)
475    
476    
477     outputFile.cd(rootDirectory+"/"+channel)
478    
479     if(numBgMCSamples is not 0):
480     BgMCHistograms[0].SetTitle(histoTitle)
481     BgMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
482     BgMCHistograms[0].GetYaxis().SetTitle(yAxisLabel)
483     BgMCHistograms[0].Draw()
484     for signalMCHist in SignalMCHistograms:
485     signalMCHist.Draw("SAME")
486     for dataHist in DataHistograms:
487     dataHist.Draw("SAME")
488 lantonel 1.3
489 lantonel 1.10 elif(numSignalSamples is not 0):
490     SignalMCHistograms[0].SetTitle(histoTitle)
491     SignalMCHistograms[0].Draw()
492     SignalMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
493     SignalMCHistograms[0].GetYaxis().SetTitle(yAxisLabel)
494     for signalMCHist in SignalMCHistograms:
495     if(signalMCHist is not SignalMCHistograms[0]):
496     signalMCHist.Draw("SAME")
497     for dataHist in DataHistograms:
498     dataHist.Draw("SAME")
499    
500     elif(numDataSamples is not 0):
501     DataHistograms[0].SetTitle(histoTitle)
502     DataHistograms[0].GetXaxis().SetTitle(xAxisLabel)
503     DataHistograms[0].GetYaxis().SetTitle(yAxisLabel)
504     DataHistograms[0].Draw()
505     for dataHist in DataHistograms:
506     if(dataHist is not DataHistograms[0]):
507     dataHist.Draw("SAME")
508 lantonel 1.3
509 lantonel 1.8
510 lantonel 1.10 if(numBgMCSamples is not 0 or numDataSamples is not 0):
511     BgMCLegend.Draw()
512     if(numSignalSamples is not 0):
513     SignalMCLegend.Draw()
514 lantonel 1.25 if not arguments.normalizeToUnitArea or numDataSamples > 0:
515     LumiLabel.Draw()
516 lantonel 1.4
517 lantonel 1.10 Canvas.Write()
518    
519 lantonel 1.4
520 lantonel 1.1
521 ahart 1.28 #for dataset in processed_datasets:
522     # dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset)
523     # os.remove(dataset_file)
524 lantonel 1.1
525     outputFile.Close()