CMS 3D CMS Logo

Functions | Variables
SteerMultipleCompare Namespace Reference

Functions

def CleanArguments (argv, option)
 
def CreateBaseDirectory (options)
 
def CreateDirectory (dir, addToExisting=False)
 
def CreateSubDirectory (basedir, path)
 
def main (argv=None)
 
def plotDefault (argv, outputDir, name, type, plots, addArgv=[])
 
def plotDefaults (argv, options, outputDir)
 
def plotOneByOne (argv, outputDir, histoList, histoSubNames, paths)
 
def StripPath (name)
 

Variables

 __author__
 
 __doc__
 

Function Documentation

def SteerMultipleCompare.CleanArguments (   argv,
  option 
)

Definition at line 53 of file SteerMultipleCompare.py.

Referenced by main().

53 def CleanArguments(argv, option):
54  #remove existing output arguments
55  while argv.count(option) > 0:
56  index = argv.index(option)
57  if index < len(argv)-1:
58  argv.pop(index+1)#drop the corresponding value
59  argv.pop(index)#drop the option itself
60 
61 
62 #execute Multicompare for each plot as a comparison one by one
63 #argv was modified to contain only one plot each
def CleanArguments(argv, option)
def SteerMultipleCompare.CreateBaseDirectory (   options)

Definition at line 38 of file SteerMultipleCompare.py.

References CreateDirectory().

Referenced by main().

38 def CreateBaseDirectory(options):
39  if options.out == 'MultipleCompare.png' or options.out.find('.')!=-1:
40  #default case, so no directory was given
41  #or a filename was given
42  outputDirName = 'MultipleCompareOutput'
43  else:
44  outputDirName = options.out
45  outputDir = os.path.join(os.getcwd(), outputDirName)
46  CreateDirectory(outputDir)
47  return outputDir
48 
def CreateDirectory(dir, addToExisting=False)
def CreateBaseDirectory(options)
def SteerMultipleCompare.CreateDirectory (   dir,
  addToExisting = False 
)

Definition at line 25 of file SteerMultipleCompare.py.

Referenced by CreateBaseDirectory(), and CreateSubDirectory().

25 def CreateDirectory(dir,addToExisting=False):
26  if os.path.exists(dir) and not addToExisting:
27  print "Output directory %s already exists! OK to overwrite?" % dir
28  while True:
29  input = raw_input("Please enter [y/n] ")
30  if (input == 'y'):
31  break
32  elif (input == 'n'):
33  print " ...exiting."
34  sys.exit()
35  if not os.path.exists(dir):
36  os.makedirs(dir)
37 
def CreateDirectory(dir, addToExisting=False)
def SteerMultipleCompare.CreateSubDirectory (   basedir,
  path 
)

Definition at line 49 of file SteerMultipleCompare.py.

References CreateDirectory().

Referenced by plotOneByOne().

49 def CreateSubDirectory(basedir, path):
50  outputDir = os.path.join(basedir, path)
51  CreateDirectory(outputDir,True)
52 
def CreateSubDirectory(basedir, path)
def CreateDirectory(dir, addToExisting=False)
def SteerMultipleCompare.main (   argv = None)

Definition at line 120 of file SteerMultipleCompare.py.

References CleanArguments(), CreateBaseDirectory(), MultipleCompare.LoadCommandlineOptions(), MultipleCompare.MapDirStructure(), MultipleCompare.Match(), plotDefaults(), plotOneByOne(), and StripPath().

120 def main(argv=None):
121  if argv is None:
122  argv = sys.argv
123 
124  options, toPlot = MultipleCompare.LoadCommandlineOptions(argv)
125 
126  gROOT.SetBatch()
127 
128  testFile = TFile(options.test)
129  refFile = None
130  if options.ref != '':
131  refFile = TFile(options.ref)
132 
133  plotList = []
134  MultipleCompare.MapDirStructure( testFile,'',plotList)
135 
136  if len(plotList)<1:
137  print '\tError: Please specify at least one histogram. The following ones are available in the root file.'
138  print plotList
139  sys.exit()
140 
141  histoList = []
142  histoSubNames = []
143  paths = []
144  massiveMode = False
145  for plot in toPlot:
146  #clean the arguments. toPlot contains the list of positional arguments leftover after parsing options
147  argv.remove(plot)
148  for path in plotList:
149  if MultipleCompare.Match(plot.lower(),path.lower()):
150  histoList.append(path)
151  strippedPath, strippedPlot = StripPath(path)
152  paths.append(strippedPath)
153  histoSubNames.append(strippedPlot)
154  #print histoSubNames[-1]
155  elif plot.find('massiveMode') != -1:
156  massiveMode = True
157 
158  CleanArguments(argv,'--output')
159  CleanArguments(argv,'-o')
160 
161  outputDir = CreateBaseDirectory(options)
162 
163  if massiveMode:
164  print "Massive mode: scan all subdirs and make plots comparing each histogram one by one."
165  plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
166  else:
167  print "Default mode: Make default plot combinations."
168  plotDefaults(argv, options, outputDir)
169 
170 
171 #only execute main() if manually run
def LoadCommandlineOptions(argv)
def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
def MapDirStructure(directory, dirName, objectList)
def Match(required, got)
def CreateBaseDirectory(options)
def CleanArguments(argv, option)
def plotDefaults(argv, options, outputDir)
def SteerMultipleCompare.plotDefault (   argv,
  outputDir,
  name,
  type,
  plots,
  addArgv = [] 
)

Definition at line 74 of file SteerMultipleCompare.py.

References MultipleCompare.main().

Referenced by plotDefaults().

74 def plotDefault(argv, outputDir, name, type, plots, addArgv=[]):
75  tmpArgv = argv[:]
76  tmpArgv.append('-o')
77  tmpArgv.append(outputDir+'/'+name+type)
78  tmpArgv.extend(addArgv)
79  tmpArgv.extend(plots)
80  MultipleCompare.main(tmpArgv)
81 
82 #make some default plots grouping several histograms
def plotDefault(argv, outputDir, name, type, plots, addArgv=[])
def main(argv=None)
def SteerMultipleCompare.plotDefaults (   argv,
  options,
  outputDir 
)

Definition at line 83 of file SteerMultipleCompare.py.

References plotDefault().

Referenced by main().

83 def plotDefaults(argv, options, outputDir):
84  name = 'Validation_'
85  if options.testLabel != None:
86  name += options.testLabel+'_'
87  else:
88  name += options.test+'_vs_'
89  if options.refLabel != None:
90  name += options.refLabel+'_'
91  else:
92  name += options.ref+'_'
93  outputType = '.eps'
94  additionalArgv = []
95  if outputDir.find('QCD')!=-1:
96  additionalArgv.append('-f') #fakerate
97  plotDefault(argv, outputDir, name, 'LeptonRejectionEffphi'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effphi'], additionalArgv)
98  plotDefault(argv, outputDir, name, 'LeptonRejectionEffeta'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effeta'], additionalArgv)
99  plotDefault(argv, outputDir, name, 'LeptonRejectionEffpt'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effpt'], additionalArgv)
100 
101  if outputDir.find('QCD')!=-1:
102  additionalArgv.append('--logScale')
103  plotDefault(argv, outputDir, name, 'Effphi'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effphi', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effphi'], additionalArgv)
104  plotDefault(argv, outputDir, name, 'Effeta'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effeta', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effeta'], additionalArgv)
105  plotDefault(argv, outputDir, name, 'Effpt'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effpt', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effpt'], additionalArgv)
106 
107  plotDefault(argv, outputDir, name, 'pTRatio_allHadronic'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_allHadronic', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_allHadronic'])
108  plotDefault(argv, outputDir, name, 'pTRatio_oneProng1Pi0'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_oneProng1Pi0', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_oneProng1Pi0'])
109  plotDefault(argv, outputDir, name, 'pTRatio_threeProng0Pi0'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_threeProng0Pi0', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_threeProng0Pi0'])
110 
111  plotDefault(argv, outputDir, name, 'Size_isolationPFChargedHadrCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFChargedHadrCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFChargedHadrCands'])
112  plotDefault(argv, outputDir, name, 'Size_isolationPFNeutrHadrCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFNeutrHadrCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFNeutrHadrCands'])
113  plotDefault(argv, outputDir, name, 'Size_isolationPFGammaCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFGammaCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFGammaCands'])
114 
115  plotDefault(argv, outputDir, name, 'SumPt_isolationPFChargedHadrCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFChargedHadrCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFChargedHadrCands'])
116  plotDefault(argv, outputDir, name, 'SumPt_isolationPFNeutrHadrCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFNeutrHadrCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFNeutrHadrCands'])
117  plotDefault(argv, outputDir, name, 'SumPt_isolationPFGammaCands'+outputType, ['DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFGammaCands', 'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFGammaCands'])
118 
119 
def plotDefault(argv, outputDir, name, type, plots, addArgv=[])
def plotDefaults(argv, options, outputDir)
def SteerMultipleCompare.plotOneByOne (   argv,
  outputDir,
  histoList,
  histoSubNames,
  paths 
)

Definition at line 64 of file SteerMultipleCompare.py.

References CreateSubDirectory(), MultipleCompare.main(), and ComparisonHelper.zip().

Referenced by main().

64 def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths):
65  for hist, name, path in zip(histoList, histoSubNames, paths):
66  CreateSubDirectory(outputDir, path)
67  #now give modified arguments to MultipleCompare
68  tmpArgv = argv[:]
69  tmpArgv.append('-o')
70  tmpArgv.append(outputDir+'/'+path+'/'+name+'.png')
71  tmpArgv.append(hist)
72  MultipleCompare.main(tmpArgv)
73 
def CreateSubDirectory(basedir, path)
def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def main(argv=None)
def SteerMultipleCompare.StripPath (   name)

Definition at line 16 of file SteerMultipleCompare.py.

Referenced by main().

16 def StripPath(name):
17  path = ''
18  plot = ''
19  matches = re.match(r'(.*)\/(.*)$', name)
20  if matches:
21  path = matches.group(1)
22  plot = matches.group(2)
23  return [path, plot]
24 

Variable Documentation

SteerMultipleCompare.__author__
private

Definition at line 10 of file SteerMultipleCompare.py.

SteerMultipleCompare.__doc__
private

Definition at line 11 of file SteerMultipleCompare.py.