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