CMS 3D CMS Logo

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.

00099                            :
00100   #automatically derive all plot types in the future?
00101   type = ''
00102   label = ''
00103   prefix = ''
00104   #assuming plots name like: tauType_plotType_xAxis or tauType_plotType_selection
00105   matches = re.match(r'.*/(.*)_(.*)_(.*)', name)
00106   if matches:
00107     prefix = matches.group(1) 
00108     label = matches.group(3)
00109     knowntypes = (['pTRatio','SumPt','Size'])
00110     for knowntype in knowntypes:
00111       if matches.group(2) == knowntype:
00112         type = knowntype
00113     if not type:  #there are plots labelled ..._vs_...
00114       type = 'Eff'
00115   else:
00116     type = 'Eff'
00117 
00118   prefixParts = prefix.partition('Discrimination')
00119   if prefixParts[2] != '':
00120     prefix = prefixParts[2]
00121     prefixParts = prefix.partition('By')
00122     if prefixParts[2] != '':
00123       prefix = prefixParts[2]
00124 
00125   #print 'type is ' + type
00126   return [type, label, prefix]

def MultipleCompare::Divide (   hNum,
  hDen 
)

Definition at line 79 of file MultipleCompare.py.

Referenced by FlavourHistograms2D< T, G >::divide(), and FlavourHistograms< T >::divide().

00080                      :
00081     ret = hNum.Clone('Division')
00082     ret.GetYaxis().SetTitle('Ratio')
00083     for binI in range(hNum.GetNbinsX()+1):
00084         denVal = hDen.GetBinContent(binI)
00085         denErr = hDen.GetBinError(binI)
00086         numErr = hNum.GetBinError(binI)
00087         numVal = hNum.GetBinContent(binI)
00088         if denVal == 0:
00089             ret.SetBinContent(binI,0)
00090             ret.SetBinError(binI,0)
00091         else:
00092             ret.SetBinContent(binI,numVal/denVal)
00093             if numVal==0:
00094                 ret.SetBinError(binI,1)
00095             else:
00096                 ret.SetBinError(binI,(numVal/denVal)*math.sqrt(math.pow(numErr/numVal,2) + math.pow(denErr/denVal,2) ) )
00097     return ret

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

Definition at line 136 of file MultipleCompare.py.

00137                                    :
00138   if options.branding != None or label != '':
00139     text = TLatex()
00140     text.SetNDC();
00141     text.SetTextAlign(11)#3*10=right,3*1=top
00142     text.SetTextSize(.025)
00143     text.SetTextColor(13)
00144     if options.out.find(".eps")!=-1:
00145       text.SetTextAngle(-91.0)#eps BUG
00146     else:
00147       text.SetTextAngle(-90.0)
00148     rightMargin = 1 - gStyle.GetPadRightMargin()
00149     topMargin = 1 - gStyle.GetPadTopMargin()
00150     if label!='':
00151       label += ': '
00152     text.DrawLatex(rightMargin+.01, topMargin+0.025, label+options.branding);
00153 

def MultipleCompare::DrawTitle (   text)

Definition at line 127 of file MultipleCompare.py.

00128                    :
00129         title = TLatex()
00130         title.SetNDC()
00131         title.SetTextAlign(12)#3*10=right,3*1=top
00132         title.SetTextSize(.035) 
00133         leftMargin = gStyle.GetPadLeftMargin()
00134         topMargin = 1 - 0.5*gStyle.GetPadTopMargin()
00135         title.DrawLatex(leftMargin, topMargin, text)

def MultipleCompare::FindParents (   histoPath)

Definition at line 154 of file MultipleCompare.py.

00155                           :
00156     root = histoPath[:histoPath.find('_')]
00157     par = histoPath[histoPath.find('Eff')+3:]
00158     validationPlots = validation.proc.efficiencies.plots._Parameterizable__parameterNames
00159     found =0
00160     num = ''
00161     den = ''
00162     for efficiency in validationPlots:
00163         effpset = getattr(validation.proc.efficiencies.plots,efficiency)
00164         effName = effpset.efficiency.value()
00165         effNameCut = effName[effName.find('_'):effName.find('#')]
00166         if effNameCut in histoPath:
00167             if found == 1:
00168                 print 'More than one pair of parents found for ' + histopath + ':'
00169                 assert(False)
00170             num = root + effpset.numerator.value()[effName.find('_'):].replace('#PAR#',par)
00171             den = root + effpset.denominator.value()[effName.find('_'):].replace('#PAR#',par)
00172             found += 1
00173     return [num,den]

def MultipleCompare::findRange (   hists,
  min0 = -1,
  max0 = -1 
)

Definition at line 195 of file MultipleCompare.py.

00196                                       :
00197   if len(hists) < 1:
00198     return
00199   #auto ranges if no user value provided
00200   min = min0
00201   max = max0
00202   if min0 == -1 or max0 == -1:
00203     for hist in hists:
00204       if min0 == -1:
00205         #Divide() sets bin to zero if division not possible. Ignore these bins.
00206         minTmp = getMinimumIncludingErrors(hist)
00207         if minTmp < min or min == -1:
00208           min = minTmp
00209       if max0 == -1:
00210         maxTmp = getMaximumIncludingErrors(hist)
00211         if maxTmp > max or max == -1:
00212           max = maxTmp
00213   return [min, max]

def MultipleCompare::GetContent (   dir)

Definition at line 56 of file MultipleCompare.py.

00057                    :
00058     tempList = dir.GetListOfKeys()
00059     retList = []
00060     for it in range(0,tempList.GetSize()):
00061        retList.append(tempList.At(it).ReadObj())
00062     return retList

def MultipleCompare::getMaximumIncludingErrors (   hist)

Definition at line 285 of file MultipleCompare.py.

00286                                    :
00287 #find maximum considering also the errors
00288   distance = 1.
00289   max = -1
00290   pos = 0
00291   for i in range(1, hist.GetNbinsX()):
00292     if hist.GetBinContent(i) > max:#ignore errors here
00293       max = hist.GetBinContent(i)
00294       pos = i
00295   return max + distance*hist.GetBinError(pos)

def MultipleCompare::getMinimumIncludingErrors (   hist)

Definition at line 296 of file MultipleCompare.py.

00297                                    :
00298   #find minimum considering also the errors
00299   #ignoring zero bins
00300   distance = 1.
00301   min = -1
00302   pos = 0
00303   for i in range(1, hist.GetNbinsX()):
00304     if hist.GetBinContent(i)<=0.:#ignore errors here
00305       continue
00306     if hist.GetBinContent(i) < min or min==-1:
00307       min = hist.GetBinContent(i)
00308       pos = i
00309       if min < 0:
00310         min = 0  
00311   return min - distance*hist.GetBinError(pos)
00312 

def MultipleCompare::LoadCommandlineOptions (   argv)

Definition at line 16 of file MultipleCompare.py.

00017                                 :
00018   sys.argv = argv
00019   parser = OptionParser(description=__doc__)
00020   parser.add_option('--myhelp',metavar='', action="store_true",help='prints this output message',dest='help',default = False)
00021   parser.add_option('--TestFile','-T',metavar='testFile', type=str,help='Sets the test file',dest='test',default = '')
00022   parser.add_option('--RefFile','-R',metavar='refFile', type=str,help='Sets the reference file',dest='ref',default = None)
00023   parser.add_option('--output','-o',metavar='outputFile', type=str,help='Sets the output file',dest='out',default = 'MultipleCompare.png')
00024   parser.add_option('--logScaleY',action="store_true", dest="logScaleY", default=False, help="Sets the log scale in the plot (Y axis)")
00025   parser.add_option('--logScaleX',action="store_true", dest="logScaleX", default=False, help="Sets the log scale in the plot (X axis)")
00026   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)")
00027   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)
00028   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)
00029   parser.add_option('--sampleLabel','-s',metavar='sampleLabel', type=str,help='Sets the label to indicate the sample used',dest='sampleLabel',default = None)
00030   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)
00031   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)
00032   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)
00033   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)
00034   parser.add_option('--minYR',metavar='number', type=float,help='Sets the minimum of the scale in sub pad',dest='minYR',default = 0)
00035   parser.add_option('--maxYR',metavar='number', type=float,help='Sets the maximum of the scale in sub pad',dest='maxYR',default = 1.2)
00036 #  parser.add_option('--minDivY',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivY',default = 0.)
00037 #  parser.add_option('--maxDivY',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivY',default = 2)
00038 #  parser.add_option('--minDivX',metavar='number', type=float,help='Sets the minimum of the scale in the ratio pad',dest='minDivX',default = 0.)
00039 #  parser.add_option('--maxDivX',metavar='number', type=float,help='Sets the maximum of the scale in the ratio pad',dest='maxDivX',default = 2)
00040   parser.add_option('--logDiv',action="store_true", dest="logDiv", default=False, help="Sets the log scale in the plot")
00041   parser.add_option('--normalize',action="store_true", dest="normalize", default=False, help="plot normalized")
00042   parser.add_option('--maxRange',metavar='number',type=float, dest="maxRange", default=1.6, help="Sets the maximum range in linear plots")
00043   parser.add_option('--maxXaxis',metavar='number',type=float, dest="maxXaxis", default=800, help="Sets the maximum range on x axis in the main pad")
00044   parser.add_option('--minXaxis',metavar='number',type=float,help="Sets the minimum range on x axis in the main pad",dest="minXaxis", default=-3)
00045   parser.add_option('--maxYaxis',metavar='number',type=float, dest="maxYaxis", default=2, help="Sets the maximum range on Y axis in the main pad")
00046   parser.add_option('--minYaxis',metavar='number',type=float, dest="minYaxis", default=0, help="Sets the minimum range on Y axis in the main pad")
00047   parser.add_option('--rebin', dest="rebin", type=int, default=-1, help="Sets the rebinning scale")
00048   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)
00049   #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)  
00050   
00051   (options,toPlot) = parser.parse_args()
00052   if options.help:
00053     parser.print_help()
00054     sys.exit(0)
00055   return [options, toPlot]

def MultipleCompare::main (   argv = None)

Definition at line 313 of file MultipleCompare.py.

00314                    :
00315   if argv is None:
00316     argv = sys.argv
00317 
00318   options, toPlot = LoadCommandlineOptions(argv)
00319 
00320   gROOT.SetStyle('Plain')
00321   gROOT.SetBatch()
00322   gStyle.SetPalette(1)
00323   gStyle.SetOptStat(0)
00324   gStyle.SetPadGridX(True)
00325   gStyle.SetPadGridY(True)
00326   gStyle.SetOptTitle(0)
00327   gStyle.SetPadTopMargin(0.1)
00328   gStyle.SetPadBottomMargin(0.1)
00329   gStyle.SetPadLeftMargin(0.13)
00330   gStyle.SetPadRightMargin(0.07)
00331 
00332 
00333   testFile = TFile(options.test)
00334   refFile = None
00335   if options.ref != None:
00336     refFile = TFile(options.ref)
00337 
00338   #Takes the position of all plots that were produced
00339   plotList = []
00340   MapDirStructure( testFile,'',plotList)
00341 
00342   histoList = []
00343   for plot in toPlot:
00344     for path in plotList:
00345         if Match(plot.lower(),path.lower()):
00346             histoList.append(path)
00347 
00348 #  print "options: ",options
00349 #  print "toPlot: ",toPlot
00350   print histoList
00351 
00352   if len(histoList)<1:
00353     print '\tError: Please specify at least one histogram.'
00354     if len(toPlot)>0:
00355       print 'Check your plot list:', toPlot
00356     sys.exit()
00357 
00358 
00359   #WARNING: For now the hist type is assumed to be constant over all histos.
00360   histType, label, prefix = DetermineHistType(histoList[0])
00361   #decide whether or not to scale to an integral of 1
00362   #should usually not be used most plot types. they are already normalized.
00363   scaleToIntegral = False
00364   if options.normalize:
00365     scaleToIntegral = True
00366 
00367   ylabel = 'Efficiency'
00368 
00369   if options.fakeRate:
00370     ylabel = 'Fake rate'
00371 
00372   drawStats = False
00373   if histType=='pTRatio' and len(histoList)<3:
00374     drawStats = True
00375 
00376   #legend = TLegend(0.50,0.73,0.50+0.37,1)
00377   x1 = 0.33
00378   x2 = 1-gStyle.GetPadRightMargin()
00379   y2 = 1-gStyle.GetPadTopMargin()
00380   lineHeight = .055
00381   if len(histoList) == 1:
00382     lineHeight = .05
00383   y1 = y2 - lineHeight*len(histoList)
00384   legend = TLegend(x1,y1,x2,y2)
00385   legend.SetHeader(label)
00386   legend.SetFillColor(0)
00387   legend.SetTextSize(0.032)
00388   if drawStats:
00389     y2 = y1
00390     y1 = y2 - .07*len(histoList)
00391     statsBox = TPaveText(x1,y1,x2,y2,"NDC")
00392     statsBox.SetFillColor(0)
00393     statsBox.SetTextAlign(12)#3*10=right,3*1=top
00394     statsBox.SetMargin(0.05)
00395     statsBox.SetBorderSize(1)
00396 
00397     
00398   canvas = TCanvas('MultiPlot','MultiPlot',validation.standardDrawingStuff.canvasSizeX.value(),832)
00399   effPad = TPad('effPad','effPad',0.01,0.35,0.99,0.99)#0,0.25,1.,1.,0,0)
00400   effPad.SetBottomMargin(0.0)#0.1)
00401   #effPad.SetTopMargin(0.1)
00402   #effPad.SetLeftMargin(0.13)
00403   #effPad.SetRightMargin(0.07)
00404   effPad.Draw()
00405   header = ''
00406   if options.sampleLabel != None:
00407     header += 'Sample: '+options.sampleLabel
00408   if options.testLabel != None:
00409     header += ' Dots: '+options.testLabel
00410   if options.refLabel != None:
00411     header += ' Line: '+options.refLabel
00412   DrawTitle(header)
00413   DrawBranding(options)
00414   diffPad = TPad('diffPad','diffPad',0.01,0.01,0.99,0.32)#0.,0.,1,.25,0,0)
00415   diffPad.SetTopMargin(0.00);
00416   diffPad.SetBottomMargin(0.30);
00417   diffPad.Draw()
00418   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]
00419   first = True
00420   divHistos = []
00421   statTemplate = '%s Mean: %.3f RMS: %.3f'
00422   testHs = []
00423   refHs = []
00424   for histoPath,color in zip(histoList,colors):
00425     if(options.rebin == -1):
00426       testH = testFile.Get(histoPath)
00427     else:
00428         testH = Rebin(testFile,histoPath,options.rebin)
00429     if type(testH) != TH1F:
00430         print 'Looking for '+histoPath
00431         print 'Test plot now found! What the hell are you doing? Exiting...'
00432         sys.exit()
00433     testHs.append(testH)
00434     xAx = histoPath[histoPath.find('Eff')+len('Eff'):]
00435     effPad.cd()
00436     if not testH.GetXaxis().GetTitle():  #only overwrite label if none already existing
00437       if hasattr(validation.standardDrawingStuff.xAxes,xAx):
00438         testH.GetXaxis().SetTitle( getattr(validation.standardDrawingStuff.xAxes,xAx).xAxisTitle.value())
00439     if not testH.GetYaxis().GetTitle():  #only overwrite label if none already existing
00440       testH.GetYaxis().SetTitle(ylabel)
00441     if label!='':
00442       testH.GetXaxis().SetTitle(label+': '+testH.GetXaxis().GetTitle())
00443     testH.GetXaxis().SetTitleOffset(1.1)
00444     testH.GetXaxis().SetRangeUser(options.minXaxis,options.maxXaxis)
00445     testH.GetYaxis().SetTitleOffset(1.1)
00446     #testH.GetYaxis().SetTitleSize(0.08)
00447     #testH.GetYaxis().CenterTitle()
00448     testH.SetMarkerSize(1)
00449     testH.SetMarkerStyle(20)
00450     testH.SetMarkerColor(color)
00451     if histType == 'Eff':
00452       legend.AddEntry(testH,histoPath[histoPath.rfind('/')+1:histoPath.find(histType)],'p')
00453     else:
00454       legend.AddEntry(testH,DetermineHistType(histoPath)[2],'p')
00455     if drawStats:
00456         text = statsBox.AddText(statTemplate % ('Dots',testH.GetMean(), testH.GetRMS()) )
00457         text.SetTextColor(color)
00458     if first:
00459         first = False
00460         if options.logScaleY:
00461             effPad.SetLogy()
00462         if options.logScaleX:
00463             effPad.SetLogx()
00464             diffPad.SetLogx()
00465         if scaleToIntegral:
00466           if testH.GetEntries() > 0:
00467             if not testH.GetSumw2N():
00468               testH.Sumw2()
00469               testH.DrawNormalized('ex0 P')
00470             else:
00471               print "--> Warning! You tried to normalize a histogram which seems to be already scaled properly. Draw it unscaled."
00472               scaleToIntegral = False
00473               testH.Draw('ex0')
00474         else:
00475           testH.Draw('ex0')
00476     else:
00477         if scaleToIntegral:
00478           if testH.GetEntries() > 0:
00479             testH.DrawNormalized('same p')
00480         else:
00481             testH.Draw('same ex0 l')
00482     if refFile == None:
00483         continue
00484     if(options.rebin == -1):
00485         refH = refFile.Get(histoPath)
00486     else:
00487         refH = Rebin(refFile,histoPath,options.rebin)
00488     if type(refH) != TH1F:
00489         continue
00490     refHs.append(refH)
00491     refH.SetLineColor(color)
00492     refH.SetLineWidth(1)
00493     if scaleToIntegral:
00494       if testH.GetEntries() > 0:
00495         refH.DrawNormalized('same hist')
00496     else:
00497         refH.DrawCopy('same hist')
00498     if drawStats:
00499       text = statsBox.AddText(statTemplate % ('Line',refH.GetMean(), refH.GetRMS()) )
00500       text.SetTextColor(color)
00501     #refH.SetFillColor(color)
00502     #refH.SetFillStyle(3001)
00503     if scaleToIntegral:
00504         entries = testH.GetEntries()
00505         if entries > 0:
00506           testH.Scale(1./entries)
00507         entries = refH.GetEntries()
00508         refH.Sumw2()
00509         if entries > 0:
00510           refH.Scale(1./entries)
00511     refH.Draw('same hist')
00512     divHistos.append(Divide(testH,refH))
00513 
00514     if options.maxLogY > 0:
00515        maxlY=options.maxLogY
00516     if options.maxLogX > 0:
00517        maxlX=options.maxLogX
00518 
00519   tmpHists = []
00520   tmpHists.extend(testHs)
00521   tmpHists.extend(refHs)
00522   optimizeRangeMainPad(argv, effPad, tmpHists, maxlX, options.minXaxis, options.maxXaxis, maxlY, options.minYaxis, options.maxYaxis)
00523   
00524   firstD = True
00525   if refFile != None:
00526     for histo,color in zip(divHistos,colors):
00527       diffPad.cd()
00528       histo.SetMarkerSize(1)
00529       histo.SetMarkerStyle(20)
00530       histo.SetMarkerColor(color)
00531       histo.GetYaxis().SetLabelSize(0.07)
00532       histo.GetYaxis().SetTitleOffset(0.75)
00533       histo.GetYaxis().SetTitleSize(0.08)
00534       histo.GetXaxis().SetLabelSize(0.08)
00535       histo.GetXaxis().SetTitleSize(0.08)
00536       #histo.GetYaxis().CenterTitle()
00537                                          
00538 
00539       if firstD:
00540         histo.Draw('ex0')
00541         firstD = False
00542       else:
00543         histo.Draw('same ex0')
00544         diffPad.Update()
00545         
00546     if options.maxLogX > 0:
00547       maxlX=options.maxLogX
00548     optimizeRangeSubPad(argv, diffPad, divHistos, maxlX, options.minXaxis, options.maxXaxis, options.minYR, options.maxYR)
00549 
00550   effPad.cd()
00551   legend.Draw()
00552 
00553   if drawStats:
00554     statsBox.Draw()
00555   
00556   canvas.Print(options.out)
00557 

def MultipleCompare::MapDirStructure (   directory,
  dirName,
  objectList 
)

Definition at line 63 of file MultipleCompare.py.

00064                                                      :
00065     dirContent = GetContent(directory)
00066     for entry in dirContent:
00067         if type(entry) is TDirectory or type(entry) is TDirectoryFile:
00068             subdirName = os.path.join(dirName,entry.GetName())
00069             MapDirStructure(entry, subdirName,objectList)
00070         else:
00071             pathname = os.path.join(dirName,entry.GetName())
00072             objectList.append(pathname)

def MultipleCompare::Match (   required,
  got 
)

Definition at line 73 of file MultipleCompare.py.

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

00074                         :
00075     for part in required.split('*'):
00076         if got.find(part) == -1:
00077             return False
00078     return True

def MultipleCompare::optimizeRangeMainPad (   argv,
  pad,
  hists,
  maxLogX_,
  minX_,
  maxX_,
  maxLogY_,
  minY_,
  maxY_ 
)

Definition at line 214 of file MultipleCompare.py.

00215                                                                                           :
00216   pad.Update()
00217   if pad.GetLogy():
00218     if maxLogY_ > 0:
00219       maxLogY = maxLogY_
00220     else:
00221       maxLogY = -1
00222     minY, maxY = findRange(hists, -1, maxLogY)
00223   else:
00224     minY, maxY = findRange(hists, minY_, maxY_)
00225 
00226   if pad.GetLogy():
00227     if minY == 0:
00228       minY = 0.001
00229   else:
00230     if minY < 0.7:
00231       minY = minY #start from zero if possible
00232     if maxY <= 1.1 and maxY > 0.7:
00233       maxY = 1.2 #prefere fixed range for easy comparison
00234   hists[0].SetAxisRange(minY, maxY, "Y")
00235 
00236   if pad.GetLogx():
00237     if maxLogX_ > 0:
00238       maxLogX = maxLogX_
00239     else:
00240       maxLogX = -1
00241     minX, maxX = findRange(hists, -1, maxLogX)
00242   else:
00243     minX, maxX = findRange(hists, minX_, maxX_)
00244     
00245   if pad.GetLogx():
00246     if minX == 0:
00247       minX = 0.001
00248   else:
00249     if minX < 0.7:
00250       minX = minX #start from zero if possible
00251     if maxX <= 1.1 and maxX > 0.7:
00252       maxX = 1.2 #prefere fixed range for easy comparison
00253   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.

00255                                                                                          :
00256   pad.Update()
00257   if pad.GetLogx():
00258     if maxLogX_ > 0:
00259       maxLogX = maxLogX_
00260     else:
00261       maxLogX = -1
00262     minX, maxX = findRange(hists, -1, maxLogX)
00263   else:
00264     minX, maxX = findRange(hists, minX_, maxX_)
00265   if pad.GetLogx():
00266     if minX == 0:
00267       minX = 0.001
00268   else:
00269     if minX < 0.7:
00270       minX = minX #start from zero if possible
00271     if maxX <= 1.1 and maxX > 0.7:
00272       maxX = 1.2 #prefere fixed range for easy comparison
00273   hists[0].SetAxisRange(minX, maxX, "X")
00274 
00275   min = -1
00276   max = -1
00277   if minYRatio_ > 0:
00278     min = minYRatio_
00279   if maxYRatio_ > 0:
00280     max = maxYRatio_
00281   min, max = findRange(hists, min, max)
00282   if max > 2:
00283     max = 2 #maximal bound
00284   hists[0].SetAxisRange(min, max, "Y")                                     

def MultipleCompare::Rebin (   tfile,
  histoPath,
  rebinVal 
)

Definition at line 174 of file MultipleCompare.py.

00175                                      :
00176     parents = FindParents(histoPath)
00177     num = tfile.Get(parents[0])
00178     if type(num) != TH1F:
00179         print 'Looking for ' + num
00180         print 'Plot now found! What the hell are you doing? Exiting...'
00181         sys.exit()
00182     denSingle = tfile.Get(parents[1])
00183     if type(denSingle) != TH1F:
00184         print 'Looking for '+denSingle
00185         print 'Plot now found! What the hell are you doing? Exiting...'
00186         sys.exit()
00187     num.Rebin(rebinVal)
00188     den = denSingle.Rebin(rebinVal,'denClone')
00189     retVal = num.Clone(histoPath+'Rebin%s'%rebinVal)
00190     #print 'Num : ' + parents[0]
00191     #print 'Den : ' +parents[1]
00192     #print "NumBins: %s DenBins: %s" % (num.GetNbinsX(), den.GetNbinsX() )
00193     retVal.Divide(num,den,1,1,'B')
00194     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.

Initial value:
00001 """Script to plot the content of a Validation .root file and compare it to a different file:\n\n
00002 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.