CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 100 of file MultipleCompare.py.

Referenced by main().

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

Definition at line 81 of file MultipleCompare.py.

References sistrip::SpyUtilities.range().

Referenced by main(), and plotscripts.segdiff().

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

Definition at line 138 of file MultipleCompare.py.

Referenced by main().

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

Definition at line 129 of file MultipleCompare.py.

Referenced by main().

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

Definition at line 156 of file MultipleCompare.py.

References cms::cuda.assert(), print(), and python.rootplot.root2matplotlib.replace().

Referenced by Rebin().

157 def FindParents(histoPath):
158  root = histoPath[:histoPath.find('_')]
159  par = histoPath[histoPath.find('Eff')+3:]
160  validationPlots = validation.proc.efficiencies.plots._Parameterizable__parameterNames
161  found =0
162  num = ''
163  den = ''
164  for efficiency in validationPlots:
165  effpset = getattr(validation.proc.efficiencies.plots,efficiency)
166  effName = effpset.efficiency.value()
167  effNameCut = effName[effName.find('_'):effName.find('#')]
168  if effNameCut in histoPath:
169  if found == 1:
170  print('More than one pair of parents found for ' + histopath + ':')
171  assert(False)
172  num = root + effpset.numerator.value()[effName.find('_'):].replace('#PAR#',par)
173  den = root + effpset.denominator.value()[effName.find('_'):].replace('#PAR#',par)
174  found += 1
175  return [num,den]
assert(be >=bs)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def MultipleCompare.findRange (   hists,
  min0 = -1,
  max0 = -1 
)

Definition at line 197 of file MultipleCompare.py.

References getMaximumIncludingErrors(), and getMinimumIncludingErrors().

Referenced by optimizeRangeMainPad(), and optimizeRangeSubPad().

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

Definition at line 58 of file MultipleCompare.py.

References sistrip::SpyUtilities.range().

Referenced by MapDirStructure().

58 
59 def GetContent(dir):
60  tempList = dir.GetListOfKeys()
61  retList = []
62  for it in range(0,tempList.GetSize()):
63  retList.append(tempList.At(it).ReadObj())
64  return retList
const uint16_t range(const Frame &aFrame)
def MultipleCompare.getMaximumIncludingErrors (   hist)

Definition at line 287 of file MultipleCompare.py.

References sistrip::SpyUtilities.range().

Referenced by findRange().

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

Definition at line 298 of file MultipleCompare.py.

References sistrip::SpyUtilities.range().

Referenced by findRange().

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

Definition at line 18 of file MultipleCompare.py.

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

18 
19 def LoadCommandlineOptions(argv):
20  sys.argv = argv
21  parser = OptionParser(description=__doc__)
22  parser.add_option('--myhelp',metavar='', action="store_true",help='prints this output message',dest='help',default = False)
23  parser.add_option('--TestFile','-T',metavar='testFile', type=str,help='Sets the test file',dest='test',default = '')
24  parser.add_option('--RefFile','-R',metavar='refFile', type=str,help='Sets the reference file',dest='ref',default = None)
25  parser.add_option('--output','-o',metavar='outputFile', type=str,help='Sets the output file',dest='out',default = 'MultipleCompare.png')
26  parser.add_option('--logScaleY',action="store_true", dest="logScaleY", default=False, help="Sets the log scale in the plot (Y axis)")
27  parser.add_option('--logScaleX',action="store_true", dest="logScaleX", default=False, help="Sets the log scale in the plot (X axis)")
28  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)")
29  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)
30  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)
31  parser.add_option('--sampleLabel','-s',metavar='sampleLabel', type=str,help='Sets the label to indicate the sample used',dest='sampleLabel',default = None)
32  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)
33  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)
34  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)
35  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)
36  parser.add_option('--minYR',metavar='number', type=float,help='Sets the minimum of the scale in sub pad',dest='minYR',default = 0)
37  parser.add_option('--maxYR',metavar='number', type=float,help='Sets the maximum of the scale in sub pad',dest='maxYR',default = 1.2)
38 # parser.add_option('--minDivY',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivY',default = 0.)
39 # parser.add_option('--maxDivY',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivY',default = 2)
40 # parser.add_option('--minDivX',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivX',default = 0.)
41 # parser.add_option('--maxDivX',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivX',default = 2)
42  parser.add_option('--logDiv',action="store_true", dest="logDiv", default=False, help="Sets the log scale in the plot")
43  parser.add_option('--normalize',action="store_true", dest="normalize", default=False, help="plot normalized")
44  parser.add_option('--maxRange',metavar='number',type=float, dest="maxRange", default=1.6, help="Sets the maximum range in linear plots")
45  parser.add_option('--maxXaxis',metavar='number',type=float, dest="maxXaxis", default=800, help="Sets the maximum range on x axis in the main pad")
46  parser.add_option('--minXaxis',metavar='number',type=float,help="Sets the minimum range on x axis in the main pad",dest="minXaxis", default=-3)
47  parser.add_option('--maxYaxis',metavar='number',type=float, dest="maxYaxis", default=2, help="Sets the maximum range on Y axis in the main pad")
48  parser.add_option('--minYaxis',metavar='number',type=float, dest="minYaxis", default=0, help="Sets the minimum range on Y axis in the main pad")
49  parser.add_option('--rebin', dest="rebin", type=int, default=-1, help="Sets the rebinning scale")
50  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)
51  #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 python3 to use all the strings before a new option, thus moving this from option to argument (but may be empty)
52 
53  (options,toPlot) = parser.parse_args()
54  if options.help:
55  parser.print_help()
56  sys.exit(0)
57  return [options, toPlot]
def MultipleCompare.main (   argv = None)

Definition at line 315 of file MultipleCompare.py.

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

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

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

Definition at line 65 of file MultipleCompare.py.

References GetContent().

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

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

Definition at line 75 of file MultipleCompare.py.

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

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

Definition at line 216 of file MultipleCompare.py.

References findRange().

Referenced by main().

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

Definition at line 256 of file MultipleCompare.py.

References findRange().

Referenced by main().

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

Definition at line 176 of file MultipleCompare.py.

References FindParents(), and print().

Referenced by histoStyle.histoProducer(), main(), bigModule.plot(), and subModule.plot().

177 def Rebin(tfile, histoPath, rebinVal):
178  parents = FindParents(histoPath)
179  num = tfile.Get(parents[0])
180  if not isinstance(num, TH1F):
181  print('Looking for ' + num)
182  print('Plot now found! What the hell are you doing? Exiting...')
183  sys.exit()
184  denSingle = tfile.Get(parents[1])
185  if not isinstance(denSingle, TH1F):
186  print('Looking for '+denSingle)
187  print('Plot now found! What the hell are you doing? Exiting...')
188  sys.exit()
189  num.Rebin(rebinVal)
190  den = denSingle.Rebin(rebinVal,'denClone')
191  retVal = num.Clone(histoPath+'Rebin%s'%rebinVal)
192  #print 'Num : ' + parents[0]
193  #print 'Den : ' +parents[1]
194  #print "NumBins: %s DenBins: %s" % (num.GetNbinsX(), den.GetNbinsX() )
195  retVal.Divide(num,den,1,1,'B')
196  return retVal
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

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

Definition at line 14 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 15 of file MultipleCompare.py.