CMS 3D CMS Logo

Functions | Variables
MultipleCompare Namespace Reference

Functions

def DetermineHistType (name)
 
def Divide (hNum, hDen)
 
def DrawBranding (options, label='')
 
def DrawTitle (text)
 
def FindParents (histoPath)
 
def findRange (hists, min0=-1, max0=-1)
 
def GetContent (dir)
 
def getMaximumIncludingErrors (hist)
 
def getMinimumIncludingErrors (hist)
 
def LoadCommandlineOptions (argv)
 
def main (argv=None)
 
def MapDirStructure (directory, dirName, objectList)
 
def Match (required, got)
 
def optimizeRangeMainPad (argv, pad, hists, maxLogX_, minX_, maxX_, maxLogY_, minY_, maxY_)
 
def optimizeRangeSubPad (argv, pad, hists, maxLogX_, minX_, maxX_, minYRatio_, maxYRatio_)
 
def Rebin (tfile, histoPath, rebinVal)
 

Variables

 __author__
 
 __doc__
 

Function Documentation

◆ DetermineHistType()

def MultipleCompare.DetermineHistType (   name)

Definition at line 100 of file MultipleCompare.py.

Referenced by main().

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

◆ Divide()

def MultipleCompare.Divide (   hNum,
  hDen 
)

Definition at line 81 of file MultipleCompare.py.

References FastTimerService_cff.range.

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

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

◆ DrawBranding()

def MultipleCompare.DrawBranding (   options,
  label = '' 
)

Definition at line 138 of file MultipleCompare.py.

Referenced by main().

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

◆ DrawTitle()

def MultipleCompare.DrawTitle (   text)

Definition at line 129 of file MultipleCompare.py.

Referenced by main().

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

◆ FindParents()

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().

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

◆ findRange()

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().

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

◆ GetContent()

def MultipleCompare.GetContent (   dir)

Definition at line 58 of file MultipleCompare.py.

References FastTimerService_cff.range.

Referenced by MapDirStructure().

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

◆ getMaximumIncludingErrors()

def MultipleCompare.getMaximumIncludingErrors (   hist)

Definition at line 287 of file MultipleCompare.py.

References FastTimerService_cff.range.

Referenced by findRange().

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

◆ getMinimumIncludingErrors()

def MultipleCompare.getMinimumIncludingErrors (   hist)

Definition at line 298 of file MultipleCompare.py.

References FastTimerService_cff.range.

Referenced by findRange().

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

◆ LoadCommandlineOptions()

def MultipleCompare.LoadCommandlineOptions (   argv)

Definition at line 18 of file MultipleCompare.py.

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

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

◆ main()

def MultipleCompare.main (   argv = None)

Definition at line 315 of file MultipleCompare.py.

References DetermineHistType(), Divide(), DrawBranding(), DrawTitle(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets.if(), LoadCommandlineOptions(), MapDirStructure(), Match(), optimizeRangeMainPad(), optimizeRangeSubPad(), print(), Rebin(), and reco.zip().

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

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

◆ MapDirStructure()

def MultipleCompare.MapDirStructure (   directory,
  dirName,
  objectList 
)

Definition at line 65 of file MultipleCompare.py.

References GetContent().

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

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

◆ Match()

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 def Match(required, got):
76  for part in required.split('*'):
77  if got.find(part) == -1:
78  return False
79  return True
80 
def Match(required, got)

◆ optimizeRangeMainPad()

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().

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

◆ optimizeRangeSubPad()

def MultipleCompare.optimizeRangeSubPad (   argv,
  pad,
  hists,
  maxLogX_,
  minX_,
  maxX_,
  minYRatio_,
  maxYRatio_ 
)

Definition at line 256 of file MultipleCompare.py.

References findRange().

Referenced by main().

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

◆ Rebin()

def MultipleCompare.Rebin (   tfile,
  histoPath,
  rebinVal 
)

Definition at line 176 of file MultipleCompare.py.

References FindParents(), and print().

Referenced by main().

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

Variable Documentation

◆ __author__

MultipleCompare.__author__
private

Definition at line 14 of file MultipleCompare.py.

◆ __doc__

MultipleCompare.__doc__
private

Definition at line 15 of file MultipleCompare.py.