7 import MultipleCompare
as MultipleCompare
10 __author__ =
"Lars Perchalla (lars.perchalla@cern.ch)" 11 __doc__ =
"""Script to execute multiple plotting commands via MultipleCompare.py. Switch between massiveMode producing a set of plots comparing each one by one, and defaultMode producing a smaller set of default plot combinations by adding the commandline option massiveMode:\n\n 12 Usage: SteerMultipleCompare.py -T testFile -R refFile [options] [search strings that you want to apply '*' is supported as special character] 13 see MultiCompare.py for details 19 matches = re.match(
r'(.*)\/(.*)$', name)
21 path = matches.group(1)
22 plot = matches.group(2)
26 if os.path.exists(dir)
and not addToExisting:
27 print "Output directory %s already exists! OK to overwrite?" % dir
29 input = raw_input(
"Please enter [y/n] ")
35 if not os.path.exists(dir):
39 if options.out ==
'MultipleCompare.png' or options.out.find(
'.')!=-1:
42 outputDirName =
'MultipleCompareOutput' 44 outputDirName = options.out
45 outputDir = os.path.join(os.getcwd(), outputDirName)
50 outputDir = os.path.join(basedir, path)
55 while argv.count(option) > 0:
56 index = argv.index(option)
57 if index < len(argv)-1:
64 def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths):
65 for hist, name, path
in zip(histoList, histoSubNames, paths):
70 tmpArgv.append(outputDir+
'/'+path+
'/'+name+
'.png')
74 def plotDefault(argv, outputDir, name, type, plots, addArgv=[]):
77 tmpArgv.append(outputDir+
'/'+name+type)
78 tmpArgv.extend(addArgv)
85 if options.testLabel !=
None:
86 name += options.testLabel+
'_' 88 name += options.test+
'_vs_' 89 if options.refLabel !=
None:
90 name += options.refLabel+
'_' 92 name += options.ref+
'_' 95 if outputDir.find(
'QCD')!=-1:
96 additionalArgv.append(
'-f')
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)
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)
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'])
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'])
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'])
128 testFile = TFile(options.test)
130 if options.ref !=
'':
131 refFile = TFile(options.ref)
137 print '\tError: Please specify at least one histogram. The following ones are available in the root file.' 148 for path
in plotList:
150 histoList.append(path)
151 strippedPath, strippedPlot =
StripPath(path)
152 paths.append(strippedPath)
153 histoSubNames.append(strippedPlot)
155 elif plot.find(
'massiveMode') != -1:
164 print "Massive mode: scan all subdirs and make plots comparing each histogram one by one." 165 plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
167 print "Default mode: Make default plot combinations." 172 if __name__ ==
'__main__':
177 print "This is ",__name__
def LoadCommandlineOptions(argv)
def CreateSubDirectory(basedir, path)
def plotDefault(argv, outputDir, name, type, plots, addArgv=[])
def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def MapDirStructure(directory, dirName, objectList)
def CreateDirectory(dir, addToExisting=False)
def CreateBaseDirectory(options)
def CleanArguments(argv, option)
def plotDefaults(argv, options, outputDir)