File indexing completed on 2024-11-28 23:10:44
0001
0002 """
0003 _RunVisualizationProcessing_
0004
0005 Test wrapper to generate an express processing config and actually push
0006 it into cmsRun for testing with a few input files etc from the command line
0007
0008 """
0009
0010 import sys
0011 import getopt
0012 import pickle
0013
0014 from Configuration.DataProcessing.GetScenario import getScenario
0015
0016
0017
0018 class RunVisualizationProcessing:
0019
0020 def __init__(self):
0021 self.scenario = None
0022 self.writeRaw = False
0023 self.writeReco = False
0024 self.writeFevt = False
0025 self.writeAlca = False
0026 self.writeDqm = False
0027 self.noOutput = False
0028 self.globalTag = None
0029 self.inputLFN = None
0030 self.preFilter = None
0031
0032
0033
0034
0035
0036 def __call__(self):
0037 if self.scenario == None:
0038 msg = "No --scenario specified"
0039 raise RuntimeError(msg)
0040 if self.globalTag == None:
0041 msg = "No --global-tag specified"
0042 raise RuntimeError(msg)
0043
0044
0045
0046 try:
0047 scenario = getScenario(self.scenario)
0048 except Exception as ex:
0049 msg = "Error getting Scenario implementation for %s\n" % (
0050 self.scenario,)
0051 msg += str(ex)
0052 raise RuntimeError(msg)
0053
0054 print("Retrieved Scenario: %s" % self.scenario)
0055 print("Using Global Tag: %s" % self.globalTag)
0056
0057 dataTiers = []
0058 if self.writeRaw:
0059 dataTiers.append("RAW")
0060 print("Configuring to Write out Raw...")
0061 if self.writeReco:
0062 dataTiers.append("RECO")
0063 print("Configuring to Write out Reco...")
0064 if self.writeFevt:
0065 dataTiers.append("FEVT")
0066 print("Configuring to Write out Fevt...")
0067 if self.writeAlca:
0068 dataTiers.append("ALCARECO")
0069 print("Configuring to Write out Alca...")
0070 if self.writeDqm:
0071 dataTiers.append("DQM")
0072 print("Configuring to Write out Dqm...")
0073
0074
0075
0076 try:
0077 kwds = {}
0078 if self.inputLFN != None:
0079 kwds['inputSource'] = 'EDM'
0080
0081 if self.noOutput:
0082
0083 kwds['writeTiers'] = []
0084
0085 elif len(dataTiers) > 0:
0086
0087 kwds['writeTiers'] = dataTiers
0088
0089 if self.preFilter:
0090 kwds['preFilter'] = self.preFilter
0091
0092
0093
0094
0095 process = scenario.visualizationProcessing(self.globalTag, **kwds)
0096
0097 except NotImplementedError as ex:
0098 print("This scenario does not support Visualization Processing:\n")
0099 return
0100 except Exception as ex:
0101 msg = "Error creating Visualization Processing config:\n"
0102 msg += str(ex)
0103 raise RuntimeError(msg)
0104
0105 if self.inputLFN != None:
0106 process.source.fileNames = [self.inputLFN]
0107
0108 import FWCore.ParameterSet.Config as cms
0109
0110 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) )
0111
0112 pklFile = open("RunVisualizationProcessingCfg.pkl", "wb")
0113 psetFile = open("RunVisualizationProcessingCfg.py", "w")
0114 try:
0115 pickle.dump(process, pklFile, protocol=0)
0116 psetFile.write("import FWCore.ParameterSet.Config as cms\n")
0117 psetFile.write("import pickle\n")
0118 psetFile.write("handle = open('RunVisualizationProcessingCfg.pkl','rb')\n")
0119 psetFile.write("process = pickle.load(handle)\n")
0120 psetFile.write("handle.close()\n")
0121 psetFile.close()
0122 except Exception as ex:
0123 print("Error writing out PSet:")
0124 print(traceback.format_exc())
0125 raise ex
0126 finally:
0127 psetFile.close()
0128 pklFile.close()
0129
0130 cmsRun = "cmsRun -e RunVisualizationProcessingCfg.py"
0131 print("Now do:\n%s" % cmsRun)
0132
0133
0134
0135 if __name__ == '__main__':
0136 valid = ["scenario=", "reco", "fevt", "no-output",
0137 "global-tag=", "lfn=",'preFilter=']
0138 usage = \
0139 """
0140 RunVisualizationProcessing.py <options>
0141
0142 Where options are:
0143 --scenario=ScenarioName
0144 --reco (to enable RECO output)
0145 --fevt (to enable FEVT output)
0146 --no-output (create config with no output, overrides other settings)
0147 --global-tag=GlobalTag
0148 --lfn=/store/input/lfn
0149 --preFilter=/sybsystem/package/filtername.sequence
0150
0151 Example:
0152 python RunVisualizationProcessing.py --scenario cosmics --global-tag GLOBALTAG::ALL --lfn /store/whatever --reco
0153
0154 """
0155 try:
0156 opts, args = getopt.getopt(sys.argv[1:], "", valid)
0157 except getopt.GetoptError as ex:
0158 print(usage)
0159 print(str(ex))
0160 sys.exit(1)
0161
0162
0163 visualizator = RunVisualizationProcessing()
0164
0165 for opt, arg in opts:
0166 if opt == "--scenario":
0167 visualizator.scenario = arg
0168 if opt == "--reco":
0169 visualizator.writeReco = True
0170 if opt == "--fevt":
0171 visualizator.writeFevt = True
0172 if opt == "--no-output":
0173 visualizator.noOutput = True
0174 if opt == "--global-tag":
0175 visualizator.globalTag = arg
0176 if opt == "--lfn" :
0177 visualizator.inputLFN = arg
0178 if opt == "--preFilter":
0179 visualizator.preFilter = arg
0180
0181 visualizator()