ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/Configuration/scripts/makePlots.py
(Generate patch)

Comparing UserCode/OSUT3Analysis/Configuration/scripts/makePlots.py (file contents):
Revision 1.32 by lantonel, Fri Apr 19 09:54:38 2013 UTC vs.
Revision 1.33 by lantonel, Sun Apr 28 14:29:05 2013 UTC

# Line 98 | Line 98 | for key in testFile.GetListOfKeys():
98   ##     else:
99   ##         os.system("mergeTFileServiceHistograms -i %s -o %s -w %g" % (dataset_file, dataset_file + "_tmp", 1.0))
100  
101 +
102   for channel in channels: # loop over final states, which each have their own directory
103  
104      testFile.cd(rootDirectory+"/"+channel)
# Line 234 | Line 235 | for channel in channels: # loop over fin
235                      Stack.Add(bgMCHist)
236  
237                  
237            finalMax = 0
238            if not arguments.noStack:
239                finalMax = Stack.GetMaximum()
240            else:
241                for bgMCHist in BgMCHistograms:
242                    if(bgMCHist.GetMaximum() > finalMax):
243                        finalMax = bgMCHist.GetMaximum()
244            for signalMCHist in SignalMCHistograms:
245                if(signalMCHist.GetMaximum() > finalMax):
246                    finalMax = signalMCHist.GetMaximum()
247            for dataHist in DataHistograms:
248                if(dataHist.GetMaximum() > finalMax):
249                    finalMax = dataHist.GetMaximum()
250
251
238  
253            if len(DataHistograms) is 1:
254                dataIntegral += DataHistograms[0].Integral()
239  
240  
241              ### formatting data histograms and adding to legend
# Line 262 | Line 246 | for channel in channels: # loop over fin
246  
247  
248              ### creating the histogram to represent the statistical errors on the stack
249 <            if numBgMCSamples is not 0:
249 >            if numBgMCSamples is not 0 and not arguments.noStack:
250                  ErrorHisto = BgMCHistograms[0].Clone("errors")
251                  ErrorHisto.SetFillStyle(3001)
252                  ErrorHisto.SetFillColor(13)
# Line 290 | Line 274 | for channel in channels: # loop over fin
274  
275  
276  
277 +            ### finding the maximum value of anything going on the canvas, and know how to set the y-axis
278 +            finalMax = 0
279 +            if numBgMCSamples is not 0 and not arguments.noStack:
280 +                finalMax = ErrorHisto.GetMaximum() + ErrorHisto.GetBinError(ErrorHisto.GetMaximumBin())
281 +            else:
282 +                for bgMCHist in BgMCHistograms:
283 +                    if(bgMCHist.GetMaximum() > finalMax):
284 +                        finalMax = bgMCHist.GetMaximum()
285 +            for signalMCHist in SignalMCHistograms:
286 +                if(signalMCHist.GetMaximum() > finalMax):
287 +                    finalMax = signalMCHist.GetMaximum()
288 +            for dataHist in DataHistograms:
289 +                if(dataHist.GetMaximum() > finalMax):
290 +                    finalMax = dataHist.GetMaximum() + dataHist.GetBinError(dataHist.GetMaximumBin())
291 +            finalMax = 1.1*finalMax
292 +
293 +
294              ### Drawing histograms to canvas
295  
296  
# Line 327 | Line 328 | for channel in channels: # loop over fin
328                      Stack.SetTitle(histoTitle)
329                      Stack.Draw("HIST")
330                      Stack.GetXaxis().SetTitle(xAxisLabel)
331 <                    Stack.SetMaximum(1.1*finalMax)
331 >                    Stack.SetMaximum(finalMax)
332                      Stack.SetMinimum(0.0001)
333                      if makeRatioPlots or makeDiffPlots:
334                          Stack.GetHistogram().GetXaxis().SetLabelSize(0)
# Line 339 | Line 340 | for channel in channels: # loop over fin
340                      BgMCHistograms[0].SetTitle(histoTitle)
341                      BgMCHistograms[0].Draw("HIST")
342                      BgMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
343 <                    BgMCHistograms[0].SetMaximum(1.1*finalMax)
343 >                    BgMCHistograms[0].SetMaximum(finalMax)
344                      BgMCHistograms[0].SetMinimum(0.0001)
345                      for bgMCHist in BgMCHistograms:
346                          bgMCHist.Draw("A HIST SAME")
# Line 352 | Line 353 | for channel in channels: # loop over fin
353                  SignalMCHistograms[0].SetTitle(histoTitle)
354                  SignalMCHistograms[0].Draw("HIST")
355                  SignalMCHistograms[0].GetXaxis().SetTitle(xAxisLabel)
356 <                SignalMCHistograms[0].SetMaximum(1.1*finalMax)
356 >                SignalMCHistograms[0].SetMaximum(finalMax)
357                  SignalMCHistograms[0].SetMinimum(0.0001)
358                  for signalMCHist in SignalMCHistograms:
359                      if(signalMCHist is not SignalMCHistograms[0]):
# Line 364 | Line 365 | for channel in channels: # loop over fin
365                  DataHistograms[0].SetTitle(histoTitle)
366                  DataHistograms[0].Draw("E")
367                  DataHistograms[0].GetXaxis().SetTitle(xAxisLabel)
368 <                DataHistograms[0].SetMaximum(1.1*finalMax)
368 >                DataHistograms[0].SetMaximum(finalMax)
369                  DataHistograms[0].SetMinimum(0.0001)
370                  for dataHist in DataHistograms:
371                      if(dataHist is not DataHistograms[0]):
# Line 435 | Line 436 | for channel in channels: # loop over fin
436                  Comparison.GetYaxis().SetLabelSize(0.1)
437                  Comparison.GetXaxis().SetLabelSize(0.15)
438                  if makeRatioPlots:
439 <                    Comparison.GetYaxis().SetRangeUser(-1,1)
439 >                    Comparison.GetYaxis().SetRangeUser(-1.15,1.15)
440                  elif makeDiffPlots:
441                      YMax = Comparison.GetMaximum()
442                      YMin = Comparison.GetMinimum()
# Line 572 | Line 573 | for channel in channels: # loop over fin
573              Canvas.Write()
574          
575  
575
576   #for dataset in processed_datasets:
577   #    dataset_file = "%s/%s.root_tmp" % (condor_dir,dataset)
578   #    os.remove(dataset_file)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines