File indexing completed on 2024-04-06 12:03:32
0001
0002 """
0003 _RunRepack_
0004
0005 Test/Debugging harness for the repack configuration builder
0006
0007 """
0008 from __future__ import print_function
0009
0010 import sys
0011 import getopt
0012
0013 from Configuration.DataProcessing.Repack import repackProcess
0014
0015
0016 class RunRepack:
0017
0018 def __init__(self):
0019 self.selectEvents = None
0020 self.inputLFN = None
0021 self.dataTier = None
0022
0023 def __call__(self):
0024 if self.inputLFN == None:
0025 msg = "No --lfn specified"
0026 raise RuntimeError(msg)
0027 allowedDataTiers = ["RAW", "HLTSCOUT", "L1SCOUT"]
0028 if self.dataTier == None:
0029 self.dataTier = "RAW"
0030 elif self.dataTier not in allowedDataTiers:
0031 msg = f"{self.dataTier} isn't an allowed datatier for repacking. Allowed data tiers: {allowedDataTiers}"
0032 raise RuntimeError(msg)
0033
0034 outputs = []
0035 outputs.append( { 'moduleLabel' : f"write_PrimDS1_{self.dataTier}" } )
0036 outputs.append( { 'moduleLabel' : f"write_PrimDS2_{self.dataTier}" } )
0037 if self.selectEvents != None:
0038 outputs[0]['selectEvents'] = self.selectEvents.split(',')
0039 outputs[1]['selectEvents'] = self.selectEvents.split(',')
0040
0041 try:
0042 process = repackProcess(outputs = outputs, dataTier = self.dataTier)
0043 except Exception as ex:
0044 msg = "Error creating process for Repack:\n"
0045 msg += str(ex)
0046 raise RuntimeError(msg)
0047
0048 process.source.fileNames.append(self.inputLFN)
0049
0050 import FWCore.ParameterSet.Config as cms
0051
0052 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) )
0053
0054 psetFile = open("RunRepackCfg.py", "w")
0055 psetFile.write(process.dumpPython())
0056 psetFile.close()
0057 cmsRun = "cmsRun -e RunRepackCfg.py"
0058 print("Now do:\n%s" % cmsRun)
0059
0060
0061
0062
0063 if __name__ == '__main__':
0064 valid = ["select-events=", "lfn=", "data-tier="]
0065
0066 usage = \
0067 """
0068 RunRepack.py <options>
0069
0070 Where options are:
0071 --select-events (option, event selection based on trigger paths)
0072 --lfn=/store/input/lfn
0073 --data-tier=RAW|HLTSCOUT|L1SCOUT
0074
0075 Example:
0076 python RunRepack.py --select-events HLT:path1,HLT:path2 --lfn /store/whatever --data-tier RAW|HLTSCOUT|L1SCOUT
0077
0078 """
0079 try:
0080 opts, args = getopt.getopt(sys.argv[1:], "", valid)
0081 except getopt.GetoptError as ex:
0082 print(usage)
0083 print(str(ex))
0084 sys.exit(1)
0085
0086
0087 repackinator = RunRepack()
0088
0089 for opt, arg in opts:
0090 if opt == "--select-events":
0091 repackinator.selectEvents = arg
0092 if opt == "--lfn" :
0093 repackinator.inputLFN = arg
0094 if opt == "--data-tier" :
0095 repackinator.dataTier = arg
0096
0097 repackinator()
0098
0099