6 ReleaseBase = os.path.join(os.environ[
'CMSSW_BASE'],
"src")
7 ReleaseVersion = os.environ[
'CMSSW_VERSION']
9 print "CMSSW enviroment not set, please run cmsenv!"
14 import FWCore.ParameterSet.VarParsing
as VarParsing
19 options.register(
'compareTo',
21 VarParsing.VarParsing.multiplicity.singleton,
22 VarParsing.VarParsing.varType.string,
23 "Specify path to directory to compare to. e.g. Validation_CMSSW_2_2_9/ZTT_recoFiles"
26 options.register(
'testLabel',
28 VarParsing.VarParsing.multiplicity.singleton,
29 VarParsing.VarParsing.varType.string,
30 "Label for test release (this one)"
33 options.register(
'referenceLabel',
35 VarParsing.VarParsing.multiplicity.singleton,
36 VarParsing.VarParsing.varType.string,
37 "Label for reference release (to compare too)"
40 options.register(
'referenceUsesLegacyProdNames',
42 VarParsing.VarParsing.multiplicity.singleton,
43 VarParsing.VarParsing.varType.int,
44 "Set to 1 if the reference files contains old (eg pfRecoTauProducer) PFTau product names"
47 options.register(
'usesLegacyProdNames',
49 VarParsing.VarParsing.multiplicity.singleton,
50 VarParsing.VarParsing.varType.int,
51 "Set to 2 if ALL files contains old (eg pfRecoTauProducer) PFTau product names"
54 options.register(
'scale',
56 VarParsing.VarParsing.multiplicity.singleton,
57 VarParsing.VarParsing.varType.string,
58 "Set scale of yaxis on plots (linear/log/smartlog) smartlog option sets only high-purity (TaNC, electron, muon) discriminators to log"
61 options.parseArguments()
63 process = cms.Process(
'MakingPlots')
64 process.DQMStore = cms.Service(
"DQMStore")
66 process.maxEvents = cms.untracked.PSet(
67 input = cms.untracked.int32(0)
70 process.source = cms.Source(
"EmptySource")
73 rootFilesInCurrentDirectory = glob.glob(
"*.root")
74 if len(rootFilesInCurrentDirectory) != 1:
75 print "There must be one (and only one) root files in the current directory, otherwise I don't know what to compare!"
77 testRootFile = rootFilesInCurrentDirectory[0]
78 print "Loading test file: ", testRootFile
82 if testRootFile.find(
"ZTT"):
84 elif testRootFile.find(
'QCD'):
86 elif testRootFile.find(
'ZEE'):
88 elif testRootFile.find(
'ZMM'):
92 refDirectory = os.path.abspath(options.compareTo)
93 rootFilesInRefDirectory = glob.glob(os.path.join(refDirectory,
"*.root"))
94 if len(rootFilesInCurrentDirectory) != 1:
95 print "There must be one (and only one) root files in the test directory, otherwise I don't know what to compare!"
98 refRootFile = rootFilesInRefDirectory[0]
99 print "Loading reference file: ", refRootFile
103 CleanReferenceLabel = options.referenceLabel.replace(
" ",
"").
replace(
"-",
"")
104 CleanTestLabel = options.testLabel.replace(
" ",
"").
replace(
"-",
"")
107 PlotOutputDir =
"ComparedTo" + CleanReferenceLabel
110 RefOutputDir = os.path.join(PlotOutputDir,
"ReferenceData")
111 if not os.path.exists(RefOutputDir):
112 os.makedirs(RefOutputDir)
114 shutil.copy(refRootFile, RefOutputDir)
115 shutil.copytree(os.path.join(refDirectory,
"Config"), os.path.join(RefOutputDir,
"Config"))
117 PlotOutputDir = os.path.join(PlotOutputDir,
"Plots")
118 if not os.path.exists(PlotOutputDir):
119 os.makedirs(PlotOutputDir)
123 process.load(
"Validation.RecoTau.RecoTauValidation_cfi")
128 if options.scale ==
'log':
129 print "Setting everything to log scale"
131 elif options.scale ==
'smartlog':
132 print "Setting high purity discriminators to log scale"
148 if options.usesLegacyProdNames == 1:
151 process.plotTauValidation = cms.Sequence(process.plotTauValidationNoTanc)
152 UseLegacyProductNames(process.plotTauValidation)
153 elif options.referenceUsesLegacyProdNames == 1:
157 print process.plotTauValidation
162 for baseDir, producerPlotDir
in [os.path.split(x)
for x
in filter(os.path.isdir, glob.glob(os.path.join(PlotOutputDir,
"*")))]:
163 baseDirCommand =
"cd %s;" % baseDir
164 webpageMaker =
"$VALTOOLS/make_comparison_webpage ";
165 webpageOptions =
"%s %s %s %s" % (CleanTestLabel, CleanReferenceLabel, producerPlotDir, EventType)
166 os.system(baseDirCommand+webpageMaker+webpageOptions)
176 process.p = cms.Path( process.loadTau
177 +process.plotTauValidation
180 cfgLog = open(os.path.join(PlotOutputDir,
"plot_config.py"),
"write")
182 print >>cfgLog, process.dumpPython()
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
def SetReferenceFileToPlot
def SetTestAndReferenceLabels
def SetCompareToLegacyProductNames