3 from __future__
import print_function
8 import MultipleCompare
as MultipleCompare
11 __author__ =
"Lars Perchalla (lars.perchalla@cern.ch)" 12 __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 13 Usage: SteerMultipleCompare.py -T testFile -R refFile [options] [search strings that you want to apply '*' is supported as special character] 14 see MultiCompare.py for details 20 matches = re.match(
r'(.*)\/(.*)$', name)
22 path = matches.group(1)
23 plot = matches.group(2)
27 if os.path.exists(dir)
and not addToExisting:
28 print(
"Output directory %s already exists! OK to overwrite?" % dir)
30 input = raw_input(
"Please enter [y/n] ")
36 if not os.path.exists(dir):
40 if options.out ==
'MultipleCompare.png' or options.out.find(
'.')!=-1:
43 outputDirName =
'MultipleCompareOutput' 45 outputDirName = options.out
46 outputDir = os.path.join(os.getcwd(), outputDirName)
51 outputDir = os.path.join(basedir, path)
56 while argv.count(option) > 0:
57 index = argv.index(option)
58 if index < len(argv)-1:
65 def plotOneByOne(argv, outputDir, histoList, histoSubNames, paths):
66 for hist, name, path
in zip(histoList, histoSubNames, paths):
71 tmpArgv.append(outputDir+
'/'+path+
'/'+name+
'.png')
75 def plotDefault(argv, outputDir, name, type, plots, addArgv=[]):
78 tmpArgv.append(outputDir+
'/'+name+type)
79 tmpArgv.extend(addArgv)
86 if options.testLabel !=
None:
87 name += options.testLabel+
'_' 89 name += options.test+
'_vs_' 90 if options.refLabel !=
None:
91 name += options.refLabel+
'_' 93 name += options.ref+
'_' 96 if outputDir.find(
'QCD')!=-1:
97 additionalArgv.append(
'-f')
98 plotDefault(argv, outputDir, name,
'LeptonRejectionEffphi'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effphi'], additionalArgv)
99 plotDefault(argv, outputDir, name,
'LeptonRejectionEffeta'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effeta'], additionalArgv)
100 plotDefault(argv, outputDir, name,
'LeptonRejectionEffpt'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*Rejection/*Effpt'], additionalArgv)
102 if outputDir.find(
'QCD')!=-1:
103 additionalArgv.append(
'--logScale')
104 plotDefault(argv, outputDir, name,
'Effphi'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effphi',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effphi'], additionalArgv)
105 plotDefault(argv, outputDir, name,
'Effeta'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effeta',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effeta'], additionalArgv)
106 plotDefault(argv, outputDir, name,
'Effpt'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*Effpt',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*Effpt'], additionalArgv)
108 plotDefault(argv, outputDir, name,
'pTRatio_allHadronic'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_allHadronic',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_allHadronic'])
109 plotDefault(argv, outputDir, name,
'pTRatio_oneProng1Pi0'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_oneProng1Pi0',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_oneProng1Pi0'])
110 plotDefault(argv, outputDir, name,
'pTRatio_threeProng0Pi0'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_pTRatio_threeProng0Pi0',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_pTRatio_threeProng0Pi0'])
112 plotDefault(argv, outputDir, name,
'Size_isolationPFChargedHadrCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFChargedHadrCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFChargedHadrCands'])
113 plotDefault(argv, outputDir, name,
'Size_isolationPFNeutrHadrCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFNeutrHadrCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFNeutrHadrCands'])
114 plotDefault(argv, outputDir, name,
'Size_isolationPFGammaCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_Size_isolationPFGammaCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_Size_isolationPFGammaCands'])
116 plotDefault(argv, outputDir, name,
'SumPt_isolationPFChargedHadrCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFChargedHadrCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFChargedHadrCands'])
117 plotDefault(argv, outputDir, name,
'SumPt_isolationPFNeutrHadrCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFNeutrHadrCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFNeutrHadrCands'])
118 plotDefault(argv, outputDir, name,
'SumPt_isolationPFGammaCands'+outputType, [
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationByDecayModeFinding/*_SumPt_isolationPFGammaCands',
'DQMData/RecoTauV/hpsPFTauProducer_hpsPFTauDiscriminationBy*CombinedIsolationDBSumPtCorr/*_SumPt_isolationPFGammaCands'])
129 testFile = TFile(options.test)
131 if options.ref !=
'':
132 refFile = TFile(options.ref)
138 print(
'\tError: Please specify at least one histogram. The following ones are available in the root file.')
149 for path
in plotList:
151 histoList.append(path)
152 strippedPath, strippedPlot =
StripPath(path)
153 paths.append(strippedPath)
154 histoSubNames.append(strippedPlot)
156 elif plot.find(
'massiveMode') != -1:
165 print(
"Massive mode: scan all subdirs and make plots comparing each histogram one by one.")
166 plotOneByOne(argv, outputDir, histoList, histoSubNames, paths)
168 print(
"Default mode: Make default plot combinations.")
173 if __name__ ==
'__main__':
178 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)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def CreateDirectory(dir, addToExisting=False)
def CreateBaseDirectory(options)
def CleanArguments(argv, option)
def plotDefaults(argv, options, outputDir)