CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
MultipleCompare Namespace Reference

Functions

def DetermineHistType
 
def Divide
 
def DrawBranding
 
def DrawTitle
 
def FindParents
 
def findRange
 
def GetContent
 
def getMaximumIncludingErrors
 
def getMinimumIncludingErrors
 
def LoadCommandlineOptions
 
def main
 
def MapDirStructure
 
def Match
 
def optimizeRangeMainPad
 
def optimizeRangeSubPad
 
def Rebin
 

Variables

string __author__ = "Mauro Verzetti (mauro.verzetti@cern.ch) and Lucia Perrini (lucia.perrini@cern.ch)"
 
string __doc__
 

Function Documentation

def MultipleCompare.DetermineHistType (   name)

Definition at line 98 of file MultipleCompare.py.

Referenced by main().

98 
99 def DetermineHistType(name):
100  #automatically derive all plot types in the future?
101  type = ''
102  label = ''
103  prefix = ''
104  #assuming plots name like: tauType_plotType_xAxis or tauType_plotType_selection
105  matches = re.match(r'.*/(.*)_(.*)_(.*)', name)
106  if matches:
107  prefix = matches.group(1)
108  label = matches.group(3)
109  knowntypes = (['pTRatio','SumPt','Size'])
110  for knowntype in knowntypes:
111  if matches.group(2) == knowntype:
112  type = knowntype
113  if not type: #there are plots labelled ..._vs_...
114  type = 'Eff'
115  else:
116  type = 'Eff'
117 
118  prefixParts = prefix.partition('Discrimination')
119  if prefixParts[2] != '':
120  prefix = prefixParts[2]
121  prefixParts = prefix.partition('By')
122  if prefixParts[2] != '':
123  prefix = prefixParts[2]
124 
125  #print 'type is ' + type
126  return [type, label, prefix]
def MultipleCompare.Divide (   hNum,
  hDen 
)

Definition at line 79 of file MultipleCompare.py.

Referenced by FlavourHistograms2D< T, G >.divide(), main(), and plotscripts.segdiff().

79 
80 def Divide(hNum,hDen):
81  ret = hNum.Clone('Division')
82  ret.GetYaxis().SetTitle('Ratio')
83  for binI in range(hNum.GetNbinsX()+1):
84  denVal = hDen.GetBinContent(binI)
85  denErr = hDen.GetBinError(binI)
86  numErr = hNum.GetBinError(binI)
87  numVal = hNum.GetBinContent(binI)
88  if denVal == 0:
89  ret.SetBinContent(binI,0)
90  ret.SetBinError(binI,0)
91  else:
92  ret.SetBinContent(binI,numVal/denVal)
93  if numVal==0:
94  ret.SetBinError(binI,1)
95  else:
96  ret.SetBinError(binI,(numVal/denVal)*math.sqrt(math.pow(numErr/numVal,2) + math.pow(denErr/denVal,2) ) )
97  return ret
def MultipleCompare.DrawBranding (   options,
  label = '' 
)

Definition at line 136 of file MultipleCompare.py.

Referenced by main().

137 def DrawBranding(options, label=''):
138  if options.branding != None or label != '':
139  text = TLatex()
140  text.SetNDC();
141  text.SetTextAlign(11)#3*10=right,3*1=top
142  text.SetTextSize(.025)
143  text.SetTextColor(13)
144  if options.out.find(".eps")!=-1:
145  text.SetTextAngle(-91.0)#eps BUG
146  else:
147  text.SetTextAngle(-90.0)
148  rightMargin = 1 - gStyle.GetPadRightMargin()
149  topMargin = 1 - gStyle.GetPadTopMargin()
150  if label!='':
151  label += ': '
152  text.DrawLatex(rightMargin+.01, topMargin+0.025, label+options.branding);
153 
def MultipleCompare.DrawTitle (   text)

Definition at line 127 of file MultipleCompare.py.

Referenced by main().

128 def DrawTitle(text):
129  title = TLatex()
130  title.SetNDC()
131  title.SetTextAlign(12)#3*10=right,3*1=top
132  title.SetTextSize(.035)
133  leftMargin = gStyle.GetPadLeftMargin()
134  topMargin = 1 - 0.5*gStyle.GetPadTopMargin()
135  title.DrawLatex(leftMargin, topMargin, text)
def MultipleCompare.FindParents (   histoPath)

Definition at line 154 of file MultipleCompare.py.

References assert(), and python.rootplot.root2matplotlib.replace().

Referenced by Rebin().

155 def FindParents(histoPath):
156  root = histoPath[:histoPath.find('_')]
157  par = histoPath[histoPath.find('Eff')+3:]
158  validationPlots = validation.proc.efficiencies.plots._Parameterizable__parameterNames
159  found =0
160  num = ''
161  den = ''
162  for efficiency in validationPlots:
163  effpset = getattr(validation.proc.efficiencies.plots,efficiency)
164  effName = effpset.efficiency.value()
165  effNameCut = effName[effName.find('_'):effName.find('#')]
166  if effNameCut in histoPath:
167  if found == 1:
168  print 'More than one pair of parents found for ' + histopath + ':'
169  assert(False)
170  num = root + effpset.numerator.value()[effName.find('_'):].replace('#PAR#',par)
171  den = root + effpset.denominator.value()[effName.find('_'):].replace('#PAR#',par)
172  found += 1
173  return [num,den]
assert(m_qm.get())
def MultipleCompare.findRange (   hists,
  min0 = -1,
  max0 = -1 
)

Definition at line 195 of file MultipleCompare.py.

References getMaximumIncludingErrors(), and getMinimumIncludingErrors().

Referenced by optimizeRangeMainPad(), and optimizeRangeSubPad().

196 def findRange(hists, min0=-1, max0=-1):
197  if len(hists) < 1:
198  return
199  #auto ranges if no user value provided
200  min = min0
201  max = max0
202  if min0 == -1 or max0 == -1:
203  for hist in hists:
204  if min0 == -1:
205  #Divide() sets bin to zero if division not possible. Ignore these bins.
206  minTmp = getMinimumIncludingErrors(hist)
207  if minTmp < min or min == -1:
208  min = minTmp
209  if max0 == -1:
210  maxTmp = getMaximumIncludingErrors(hist)
211  if maxTmp > max or max == -1:
212  max = maxTmp
213  return [min, max]
def MultipleCompare.GetContent (   dir)

Definition at line 56 of file MultipleCompare.py.

Referenced by MapDirStructure().

56 
57 def GetContent(dir):
58  tempList = dir.GetListOfKeys()
59  retList = []
60  for it in range(0,tempList.GetSize()):
61  retList.append(tempList.At(it).ReadObj())
62  return retList
def MultipleCompare.getMaximumIncludingErrors (   hist)

Definition at line 285 of file MultipleCompare.py.

Referenced by findRange().

286 def getMaximumIncludingErrors(hist):
287 #find maximum considering also the errors
288  distance = 1.
289  max = -1
290  pos = 0
291  for i in range(1, hist.GetNbinsX()):
292  if hist.GetBinContent(i) > max:#ignore errors here
293  max = hist.GetBinContent(i)
294  pos = i
295  return max + distance*hist.GetBinError(pos)
def MultipleCompare.getMinimumIncludingErrors (   hist)

Definition at line 296 of file MultipleCompare.py.

Referenced by findRange().

297 def getMinimumIncludingErrors(hist):
298  #find minimum considering also the errors
299  #ignoring zero bins
300  distance = 1.
301  min = -1
302  pos = 0
303  for i in range(1, hist.GetNbinsX()):
304  if hist.GetBinContent(i)<=0.:#ignore errors here
305  continue
306  if hist.GetBinContent(i) < min or min==-1:
307  min = hist.GetBinContent(i)
308  pos = i
309  if min < 0:
310  min = 0
311  return min - distance*hist.GetBinError(pos)
312 
def MultipleCompare.LoadCommandlineOptions (   argv)

Definition at line 16 of file MultipleCompare.py.

Referenced by SteerMultipleCompare.main(), and main().

16 
17 def LoadCommandlineOptions(argv):
18  sys.argv = argv
19  parser = OptionParser(description=__doc__)
20  parser.add_option('--myhelp',metavar='', action="store_true",help='prints this output message',dest='help',default = False)
21  parser.add_option('--TestFile','-T',metavar='testFile', type=str,help='Sets the test file',dest='test',default = '')
22  parser.add_option('--RefFile','-R',metavar='refFile', type=str,help='Sets the reference file',dest='ref',default = None)
23  parser.add_option('--output','-o',metavar='outputFile', type=str,help='Sets the output file',dest='out',default = 'MultipleCompare.png')
24  parser.add_option('--logScaleY',action="store_true", dest="logScaleY", default=False, help="Sets the log scale in the plot (Y axis)")
25  parser.add_option('--logScaleX',action="store_true", dest="logScaleX", default=False, help="Sets the log scale in the plot (X axis)")
26  parser.add_option('--fakeRate','-f',action="store_true", dest="fakeRate", default=False, help="Sets the fake rate options and put the correct label (implies --logScale)")
27  parser.add_option('--testLabel','-t',metavar='testLabel', type=str,help='Sets the label to put in the plots for test file',dest='testLabel',default = None)
28  parser.add_option('--refLabel','-r',metavar='refLabel', type=str,help='Sets the label to put in the plots for ref file',dest='refLabel',default = None)
29  parser.add_option('--sampleLabel','-s',metavar='sampleLabel', type=str,help='Sets the label to indicate the sample used',dest='sampleLabel',default = None)
30  parser.add_option('--maxLogX',metavar='number', type=float,help='Sets the maximum of the scale in log scale both in the main and in the sub pad (requires --logScale or -f to work)',dest='maxLogX',default = 100)
31  parser.add_option('--minLogX',metavar='number', type=float,help='Sets the minimum of the scale in log scale (requires --logScale or -f to work)',dest='minLogX',default = 0.001)
32  parser.add_option('--minLogY',metavar='number', type=float,help='Sets the minimum of the scale in log scale (requires --logScale or -f to work)',dest='minLogY',default = 0.0001)
33  parser.add_option('--maxLogY',metavar='number', type=float,help='Sets the maximum of the scale in log scale (requires --logScale or -f to work)',dest='maxLogY',default = 3)
34  parser.add_option('--minYR',metavar='number', type=float,help='Sets the minimum of the scale in sub pad',dest='minYR',default = 0)
35  parser.add_option('--maxYR',metavar='number', type=float,help='Sets the maximum of the scale in sub pad',dest='maxYR',default = 1.2)
36 # parser.add_option('--minDivY',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivY',default = 0.)
37 # parser.add_option('--maxDivY',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivY',default = 2)
38 # parser.add_option('--minDivX',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivX',default = 0.)
39 # parser.add_option('--maxDivX',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivX',default = 2)
40  parser.add_option('--logDiv',action="store_true", dest="logDiv", default=False, help="Sets the log scale in the plot")
41  parser.add_option('--normalize',action="store_true", dest="normalize", default=False, help="plot normalized")
42  parser.add_option('--maxRange',metavar='number',type=float, dest="maxRange", default=1.6, help="Sets the maximum range in linear plots")
43  parser.add_option('--maxXaxis',metavar='number',type=float, dest="maxXaxis", default=800, help="Sets the maximum range on x axis in the main pad")
44  parser.add_option('--minXaxis',metavar='number',type=float,help="Sets the minimum range on x axis in the main pad",dest="minXaxis", default=-3)
45  parser.add_option('--maxYaxis',metavar='number',type=float, dest="maxYaxis", default=2, help="Sets the maximum range on Y axis in the main pad")
46  parser.add_option('--minYaxis',metavar='number',type=float, dest="minYaxis", default=0, help="Sets the minimum range on Y axis in the main pad")
47  parser.add_option('--rebin', dest="rebin", type=int, default=-1, help="Sets the rebinning scale")
48  parser.add_option('--branding','-b',metavar='branding', type=str,help='Define a branding to label the plots (in the top right corner)',dest='branding',default = None)
49  #parser.add_option('--search,-s',metavar='searchStrings', type=str,help='Sets the label to put in the plots for ref file',dest='testLabel',default = None) No idea on how to tell python to use all the strings before a new option, thus moving this from option to argument (but may be empty)
50 
51  (options,toPlot) = parser.parse_args()
52  if options.help:
53  parser.print_help()
54  sys.exit(0)
55  return [options, toPlot]
def MultipleCompare.main (   argv = None)

Definition at line 313 of file MultipleCompare.py.

References DetermineHistType(), Divide(), DrawBranding(), DrawTitle(), citk.if(), LoadCommandlineOptions(), MapDirStructure(), Match(), optimizeRangeMainPad(), optimizeRangeSubPad(), and Rebin().

Referenced by SteerMultipleCompare.plotDefault(), and SteerMultipleCompare.plotOneByOne().

314 def main(argv=None):
315  if argv is None:
316  argv = sys.argv
317 
318  options, toPlot = LoadCommandlineOptions(argv)
319 
320  gROOT.SetStyle('Plain')
321  gROOT.SetBatch()
322  gStyle.SetPalette(1)
323  gStyle.SetOptStat(0)
324  gStyle.SetPadGridX(True)
325  gStyle.SetPadGridY(True)
326  gStyle.SetOptTitle(0)
327  gStyle.SetPadTopMargin(0.1)
328  gStyle.SetPadBottomMargin(0.1)
329  gStyle.SetPadLeftMargin(0.13)
330  gStyle.SetPadRightMargin(0.07)
331 
332 
333  testFile = TFile(options.test)
334  refFile = None
335  if options.ref != None:
336  refFile = TFile(options.ref)
337 
338  #Takes the position of all plots that were produced
339  plotList = []
340  MapDirStructure( testFile,'',plotList)
341 
342  histoList = []
343  for plot in toPlot:
344  for path in plotList:
345  if Match(plot.lower(),path.lower()):
346  histoList.append(path)
347 
348 # print "options: ",options
349 # print "toPlot: ",toPlot
350  print histoList
351 
352  if len(histoList)<1:
353  print '\tError: Please specify at least one histogram.'
354  if len(toPlot)>0:
355  print 'Check your plot list:', toPlot
356  sys.exit()
357 
358 
359  #WARNING: For now the hist type is assumed to be constant over all histos.
360  histType, label, prefix = DetermineHistType(histoList[0])
361  #decide whether or not to scale to an integral of 1
362  #should usually not be used most plot types. they are already normalized.
363  scaleToIntegral = False
364  if options.normalize:
365  scaleToIntegral = True
366 
367  ylabel = 'Efficiency'
368 
369  if options.fakeRate:
370  ylabel = 'Fake rate'
371 
372  drawStats = False
373  if histType=='pTRatio' and len(histoList)<3:
374  drawStats = True
375 
376  #legend = TLegend(0.50,0.73,0.50+0.37,1)
377  x1 = 0.33
378  x2 = 1-gStyle.GetPadRightMargin()
379  y2 = 1-gStyle.GetPadTopMargin()
380  lineHeight = .055
381  if len(histoList) == 1:
382  lineHeight = .05
383  y1 = y2 - lineHeight*len(histoList)
384  legend = TLegend(x1,y1,x2,y2)
385  legend.SetHeader(label)
386  legend.SetFillColor(0)
387  legend.SetTextSize(0.032)
388  if drawStats:
389  y2 = y1
390  y1 = y2 - .07*len(histoList)
391  statsBox = TPaveText(x1,y1,x2,y2,"NDC")
392  statsBox.SetFillColor(0)
393  statsBox.SetTextAlign(12)#3*10=right,3*1=top
394  statsBox.SetMargin(0.05)
395  statsBox.SetBorderSize(1)
396 
397 
398  canvas = TCanvas('MultiPlot','MultiPlot',validation.standardDrawingStuff.canvasSizeX.value(),832)
399  effPad = TPad('effPad','effPad',0.01,0.35,0.99,0.99)#0,0.25,1.,1.,0,0)
400  effPad.SetBottomMargin(0.0)#0.1)
401  #effPad.SetTopMargin(0.1)
402  #effPad.SetLeftMargin(0.13)
403  #effPad.SetRightMargin(0.07)
404  effPad.Draw()
405  header = ''
406  if options.sampleLabel != None:
407  header += 'Sample: '+options.sampleLabel
408  if options.testLabel != None:
409  header += ' Dots: '+options.testLabel
410  if options.refLabel != None:
411  header += ' Line: '+options.refLabel
412  DrawTitle(header)
413  DrawBranding(options)
414  diffPad = TPad('diffPad','diffPad',0.01,0.01,0.99,0.32)#0.,0.,1,.25,0,0)
415  diffPad.SetTopMargin(0.00);
416  diffPad.SetBottomMargin(0.30);
417  diffPad.Draw()
418  colors = [2,3,4,6,5,7,28,1,2,3,4,6,5,7,28,1,2,3,4,6,5,7,28,1,2,3,4,6,5,7,28,1,2,3,4,6,5,7,28,1]
419  first = True
420  divHistos = []
421  statTemplate = '%s Mean: %.3f RMS: %.3f'
422  testHs = []
423  refHs = []
424  for histoPath,color in zip(histoList,colors):
425  if(options.rebin == -1):
426  testH = testFile.Get(histoPath)
427  else:
428  testH = Rebin(testFile,histoPath,options.rebin)
429  if type(testH) != TH1F:
430  print 'Looking for '+histoPath
431  print 'Test plot now found! What the hell are you doing? Exiting...'
432  sys.exit()
433  testHs.append(testH)
434  xAx = histoPath[histoPath.find('Eff')+len('Eff'):]
435  effPad.cd()
436  if not testH.GetXaxis().GetTitle(): #only overwrite label if none already existing
437  if hasattr(validation.standardDrawingStuff.xAxes,xAx):
438  testH.GetXaxis().SetTitle( getattr(validation.standardDrawingStuff.xAxes,xAx).xAxisTitle.value())
439  if not testH.GetYaxis().GetTitle(): #only overwrite label if none already existing
440  testH.GetYaxis().SetTitle(ylabel)
441  if label!='':
442  testH.GetXaxis().SetTitle(label+': '+testH.GetXaxis().GetTitle())
443  testH.GetXaxis().SetTitleOffset(1.1)
444  testH.GetXaxis().SetRangeUser(options.minXaxis,options.maxXaxis)
445  testH.GetYaxis().SetTitleOffset(1.1)
446  #testH.GetYaxis().SetTitleSize(0.08)
447  #testH.GetYaxis().CenterTitle()
448  testH.SetMarkerSize(1)
449  testH.SetMarkerStyle(20)
450  testH.SetMarkerColor(color)
451  if histType == 'Eff':
452  legend.AddEntry(testH,histoPath[histoPath.rfind('/')+1:histoPath.find(histType)],'p')
453  else:
454  legend.AddEntry(testH,DetermineHistType(histoPath)[2],'p')
455  if drawStats:
456  text = statsBox.AddText(statTemplate % ('Dots',testH.GetMean(), testH.GetRMS()) )
457  text.SetTextColor(color)
458  if first:
459  first = False
460  if options.logScaleY:
461  effPad.SetLogy()
462  if options.logScaleX:
463  effPad.SetLogx()
464  diffPad.SetLogx()
465  if scaleToIntegral:
466  if testH.GetEntries() > 0:
467  if not testH.GetSumw2N():
468  testH.Sumw2()
469  testH.DrawNormalized('ex0 P')
470  else:
471  print "--> Warning! You tried to normalize a histogram which seems to be already scaled properly. Draw it unscaled."
472  scaleToIntegral = False
473  testH.Draw('ex0')
474  else:
475  testH.Draw('ex0')
476  else:
477  if scaleToIntegral:
478  if testH.GetEntries() > 0:
479  testH.DrawNormalized('same p')
480  else:
481  testH.Draw('same ex0 l')
482  if refFile == None:
483  continue
484  if(options.rebin == -1):
485  refH = refFile.Get(histoPath)
486  else:
487  refH = Rebin(refFile,histoPath,options.rebin)
488  if type(refH) != TH1F:
489  continue
490  refHs.append(refH)
491  refH.SetLineColor(color)
492  refH.SetLineWidth(1)
493  if scaleToIntegral:
494  if testH.GetEntries() > 0:
495  refH.DrawNormalized('same hist')
496  else:
497  refH.DrawCopy('same hist')
498  if drawStats:
499  text = statsBox.AddText(statTemplate % ('Line',refH.GetMean(), refH.GetRMS()) )
500  text.SetTextColor(color)
501  #refH.SetFillColor(color)
502  #refH.SetFillStyle(3001)
503  if scaleToIntegral:
504  entries = testH.GetEntries()
505  if entries > 0:
506  testH.Scale(1./entries)
507  entries = refH.GetEntries()
508  refH.Sumw2()
509  if entries > 0:
510  refH.Scale(1./entries)
511  refH.Draw('same hist')
512  divHistos.append(Divide(testH,refH))
513 
514  if options.maxLogY > 0:
515  maxlY=options.maxLogY
516  if options.maxLogX > 0:
517  maxlX=options.maxLogX
518 
519  tmpHists = []
520  tmpHists.extend(testHs)
521  tmpHists.extend(refHs)
522  optimizeRangeMainPad(argv, effPad, tmpHists, maxlX, options.minXaxis, options.maxXaxis, maxlY, options.minYaxis, options.maxYaxis)
523 
524  firstD = True
525  if refFile != None:
526  for histo,color in zip(divHistos,colors):
527  diffPad.cd()
528  histo.SetMarkerSize(1)
529  histo.SetMarkerStyle(20)
530  histo.SetMarkerColor(color)
531  histo.GetYaxis().SetLabelSize(0.07)
532  histo.GetYaxis().SetTitleOffset(0.75)
533  histo.GetYaxis().SetTitleSize(0.08)
534  histo.GetXaxis().SetLabelSize(0.08)
535  histo.GetXaxis().SetTitleSize(0.08)
536  #histo.GetYaxis().CenterTitle()
537 
538 
539  if firstD:
540  histo.Draw('ex0')
541  firstD = False
542  else:
543  histo.Draw('same ex0')
544  diffPad.Update()
545 
546  if options.maxLogX > 0:
547  maxlX=options.maxLogX
548  optimizeRangeSubPad(argv, diffPad, divHistos, maxlX, options.minXaxis, options.maxXaxis, options.minYR, options.maxYR)
549 
550  effPad.cd()
551  legend.Draw()
552 
553  if drawStats:
554  statsBox.Draw()
555 
556  canvas.Print(options.out)
557 
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
def MultipleCompare.MapDirStructure (   directory,
  dirName,
  objectList 
)

Definition at line 63 of file MultipleCompare.py.

References GetContent().

Referenced by SteerMultipleCompare.main(), and main().

63 
64 def MapDirStructure( directory, dirName, objectList ):
65  dirContent = GetContent(directory)
66  for entry in dirContent:
67  if type(entry) is TDirectory or type(entry) is TDirectoryFile:
68  subdirName = os.path.join(dirName,entry.GetName())
69  MapDirStructure(entry, subdirName,objectList)
70  else:
71  pathname = os.path.join(dirName,entry.GetName())
72  objectList.append(pathname)
def MultipleCompare.Match (   required,
  got 
)

Definition at line 73 of file MultipleCompare.py.

Referenced by FWGeometryTableManager.loadGeometry(), SteerMultipleCompare.main(), main(), lhef::JetMatchingMLM.match(), lhef::Matching< Delta >.match(), btag::Matching< Delta >.match(), and MatchJet.matchCollections().

73 
74 def Match(required, got):
75  for part in required.split('*'):
76  if got.find(part) == -1:
77  return False
78  return True
def MultipleCompare.optimizeRangeMainPad (   argv,
  pad,
  hists,
  maxLogX_,
  minX_,
  maxX_,
  maxLogY_,
  minY_,
  maxY_ 
)

Definition at line 214 of file MultipleCompare.py.

References findRange().

Referenced by main().

215 def optimizeRangeMainPad(argv, pad, hists, maxLogX_, minX_, maxX_, maxLogY_, minY_, maxY_):
216  pad.Update()
217  if pad.GetLogy():
218  if maxLogY_ > 0:
219  maxLogY = maxLogY_
220  else:
221  maxLogY = -1
222  minY, maxY = findRange(hists, -1, maxLogY)
223  else:
224  minY, maxY = findRange(hists, minY_, maxY_)
225 
226  if pad.GetLogy():
227  if minY == 0:
228  minY = 0.001
229  else:
230  if minY < 0.7:
231  minY = minY #start from zero if possible
232  if maxY <= 1.1 and maxY > 0.7:
233  maxY = 1.2 #prefere fixed range for easy comparison
234  hists[0].SetAxisRange(minY, maxY, "Y")
235 
236  if pad.GetLogx():
237  if maxLogX_ > 0:
238  maxLogX = maxLogX_
239  else:
240  maxLogX = -1
241  minX, maxX = findRange(hists, -1, maxLogX)
242  else:
243  minX, maxX = findRange(hists, minX_, maxX_)
244 
245  if pad.GetLogx():
246  if minX == 0:
247  minX = 0.001
248  else:
249  if minX < 0.7:
250  minX = minX #start from zero if possible
251  if maxX <= 1.1 and maxX > 0.7:
252  maxX = 1.2 #prefere fixed range for easy comparison
253  hists[0].SetAxisRange(minX, maxX, "X")
def MultipleCompare.optimizeRangeSubPad (   argv,
  pad,
  hists,
  maxLogX_,
  minX_,
  maxX_,
  minYRatio_,
  maxYRatio_ 
)

Definition at line 254 of file MultipleCompare.py.

References findRange().

Referenced by main().

255 def optimizeRangeSubPad(argv, pad, hists, maxLogX_, minX_, maxX_, minYRatio_, maxYRatio_):
256  pad.Update()
257  if pad.GetLogx():
258  if maxLogX_ > 0:
259  maxLogX = maxLogX_
260  else:
261  maxLogX = -1
262  minX, maxX = findRange(hists, -1, maxLogX)
263  else:
264  minX, maxX = findRange(hists, minX_, maxX_)
265  if pad.GetLogx():
266  if minX == 0:
267  minX = 0.001
268  else:
269  if minX < 0.7:
270  minX = minX #start from zero if possible
271  if maxX <= 1.1 and maxX > 0.7:
272  maxX = 1.2 #prefere fixed range for easy comparison
273  hists[0].SetAxisRange(minX, maxX, "X")
274 
275  min = -1
276  max = -1
277  if minYRatio_ > 0:
278  min = minYRatio_
279  if maxYRatio_ > 0:
280  max = maxYRatio_
281  min, max = findRange(hists, min, max)
282  if max > 2:
283  max = 2 #maximal bound
284  hists[0].SetAxisRange(min, max, "Y")
def MultipleCompare.Rebin (   tfile,
  histoPath,
  rebinVal 
)

Definition at line 174 of file MultipleCompare.py.

References FindParents().

Referenced by histoStyle.histoProducer(), and main().

175 def Rebin(tfile, histoPath, rebinVal):
176  parents = FindParents(histoPath)
177  num = tfile.Get(parents[0])
178  if type(num) != TH1F:
179  print 'Looking for ' + num
180  print 'Plot now found! What the hell are you doing? Exiting...'
181  sys.exit()
182  denSingle = tfile.Get(parents[1])
183  if type(denSingle) != TH1F:
184  print 'Looking for '+denSingle
185  print 'Plot now found! What the hell are you doing? Exiting...'
186  sys.exit()
187  num.Rebin(rebinVal)
188  den = denSingle.Rebin(rebinVal,'denClone')
189  retVal = num.Clone(histoPath+'Rebin%s'%rebinVal)
190  #print 'Num : ' + parents[0]
191  #print 'Den : ' +parents[1]
192  #print "NumBins: %s DenBins: %s" % (num.GetNbinsX(), den.GetNbinsX() )
193  retVal.Divide(num,den,1,1,'B')
194  return retVal

Variable Documentation

string MultipleCompare.__author__ = "Mauro Verzetti (mauro.verzetti@cern.ch) and Lucia Perrini (lucia.perrini@cern.ch)"

Definition at line 12 of file MultipleCompare.py.

string MultipleCompare.__doc__
Initial value:
1 = """Script to plot the content of a Validation .root file and compare it to a different file:\n\n
2 Usage: MultipleCompare.py -T testFile -R refFile [options] [search strings that you want to apply '*' is supported as special character]"""

Definition at line 13 of file MultipleCompare.py.