Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:48:54

0001 #!/usr/bin/env python3
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 
0022     def __call__(self):
0023         if self.inputLFN == None:
0024             msg = "No --lfn specified"
0025             raise RuntimeError(msg)
0026 
0027         outputs = []
0028         outputs.append( { 'moduleLabel' : "write_PrimDS1_RAW" } )
0029         outputs.append( { 'moduleLabel' : "write_PrimDS2_RAW" } )
0030         if self.selectEvents != None:
0031             outputs[0]['selectEvents'] = self.selectEvents.split(',')
0032             outputs[1]['selectEvents'] = self.selectEvents.split(',')
0033 
0034         try:
0035             process = repackProcess(outputs = outputs)
0036         except Exception as ex:
0037             msg = "Error creating process for Repack:\n"
0038             msg += str(ex)
0039             raise RuntimeError(msg)
0040 
0041         process.source.fileNames.append(self.inputLFN)
0042 
0043         import FWCore.ParameterSet.Config as cms
0044 
0045         process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(10) )
0046 
0047         psetFile = open("RunRepackCfg.py", "w")
0048         psetFile.write(process.dumpPython())
0049         psetFile.close()
0050         cmsRun = "cmsRun -e RunRepackCfg.py"
0051         print("Now do:\n%s" % cmsRun)
0052         
0053                 
0054 
0055 
0056 if __name__ == '__main__':
0057     valid = ["select-events=", "lfn="]
0058              
0059     usage = \
0060 """
0061 RunRepack.py <options>
0062 
0063 Where options are:
0064  --select-events (option, event selection based on trigger paths)
0065  --lfn=/store/input/lfn
0066 
0067 Example:
0068 python RunRepack.py --select-events HLT:path1,HLT:path2 --lfn /store/whatever
0069 
0070 """
0071     try:
0072         opts, args = getopt.getopt(sys.argv[1:], "", valid)
0073     except getopt.GetoptError as ex:
0074         print(usage)
0075         print(str(ex))
0076         sys.exit(1)
0077 
0078 
0079     repackinator = RunRepack()
0080 
0081     for opt, arg in opts:
0082         if opt == "--select-events":
0083             repackinator.selectEvents = arg
0084         if opt == "--lfn" :
0085             repackinator.inputLFN = arg
0086 
0087     repackinator()