File indexing completed on 2023-03-17 11:10:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 from __future__ import print_function
0012 import FWCore.ParameterSet.Config as cms
0013 import HLTriggerOffline.Egamma.EgammaHLTValidationUtils as EgammaHLTValidationUtils
0014 import sys, os
0015
0016
0017
0018 msgPrefix = ''
0019
0020
0021
0022
0023
0024 def makeOnePath(path, isFastSim):
0025 """ given a path object, returns the python text to be written
0026 to a _cff.py file"""
0027
0028
0029 pathName = path.label_()
0030
0031
0032
0033
0034
0035
0036
0037 moduleCXXtypes = EgammaHLTValidationUtils.getCXXTypesOfPath(refProcess,path)
0038
0039
0040 hasProblematicType = False
0041
0042 for problematicType in [
0043
0044 'HLTEgammaTriggerFilterObjectWrapper',
0045 'EgammaHLTPhotonTrackIsolationProducersRegional',
0046 ]:
0047
0048 if problematicType in moduleCXXtypes:
0049 print(msgPrefix + "SKIPPING PATH",pathName,"BECAUSE DON'T KNOW HOW TO HANDLE A MODULE WITH C++ TYPE",problematicType, file=sys.stderr)
0050 return None
0051
0052
0053
0054 dqmModuleName = pathName
0055 if isFastSim:
0056 dqmModuleName = dqmModuleName + "FastSim"
0057
0058 dqmModuleName = dqmModuleName + "_DQM"
0059
0060
0061
0062 dqmModule = EgammaHLTValidationUtils.EgammaDQMModuleMaker(refProcess, pathName,
0063 thisCategoryData['genPid'],
0064 thisCategoryData['numGenerated']
0065 ).getResult()
0066
0067
0068 return dqmModuleName + " = " + repr(dqmModule)
0069
0070
0071
0072
0073
0074
0075
0076
0077 from optparse import OptionParser
0078
0079 parser = OptionParser(
0080 """
0081 usage: %prog [options] output_dir
0082 creates a set of files configuring the EmDQM module
0083 which can then be included from HLTriggerOffline/Egamma/python/EgammaValidation_cff.py
0084
0085 """
0086 )
0087 (options, ARGV) = parser.parse_args()
0088
0089 isFastSim = False
0090
0091
0092
0093 if len(ARGV) != 1:
0094 print("must specify exactly one non-option argument: the output directory", file=sys.stderr)
0095 sys.exit(1)
0096
0097 outputDir = ARGV.pop(0)
0098
0099 if os.path.exists(outputDir):
0100 print("output directory " + outputDir + " already exists, refusing to overwrite it / files in it", file=sys.stderr)
0101 sys.exit(1)
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 configData = {
0113 "singleElectron": { "genPid" : 11, "numGenerated" : 1,},
0114 "doubleElectron": { "genPid" : 11, "numGenerated" : 2 },
0115 "singlePhoton": { "genPid" : 22, "numGenerated" : 1 },
0116 "doublePhoton": { "genPid" : 22, "numGenerated" : 2 },
0117 }
0118
0119
0120 egammaValidators = []
0121 egammaValidatorsFS = []
0122
0123 pathToPythonText = {}
0124
0125
0126
0127
0128
0129 refProcess = cms.Process("REF")
0130
0131 if isFastSim:
0132 refProcess.load("FastSimulation.Configuration.HLT_GRun_cff")
0133 else:
0134 refProcess.load("HLTrigger.Configuration.HLT_GRun_cff")
0135
0136
0137
0138 pathsByCategory = EgammaHLTValidationUtils.findEgammaPaths(refProcess)
0139
0140 os.mkdir(outputDir)
0141 allPathsWritten = []
0142
0143
0144
0145 for hltPathCategory, thisCategoryData in configData.items():
0146
0147
0148 paths = pathsByCategory[hltPathCategory]
0149
0150
0151
0152
0153 path = None
0154 dqmModule = None
0155
0156 for path in paths:
0157
0158 pathName = path.label_()
0159
0160 res = makeOnePath(path, isFastSim)
0161
0162 if res == None:
0163 continue
0164
0165 res = res.splitlines()
0166
0167 res = [
0168 "#----------------------------------------",
0169 "# path " + pathName,
0170 "#----------------------------------------",
0171 "",
0172 "import FWCore.ParameterSet.Config as cms",
0173 "",
0174 ] + res
0175
0176 outputFname = os.path.join(outputDir,pathName + "_DQM_cfi.py")
0177 assert(not os.path.exists(outputFname))
0178 fout = open(outputFname,"w")
0179 for line in res:
0180 print(line, file=fout)
0181 fout.close()
0182
0183 print("wrote",outputFname, file=sys.stderr)
0184 allPathsWritten.append(pathName)
0185
0186
0187
0188
0189
0190 print("generated the following paths:", file=sys.stderr)
0191 for pathName in sorted(allPathsWritten):
0192 print(" " + pathName)