def mergeProcess(*inputFiles, **options): """ _mergeProcess_ Creates and returns a merge process that will merge the provided filenames supported options: - process_name : name of the process, defaults to Merge - outputmod_label : label of the output module, defaults to Merged - newDQMIO : specifies if the new DQM format should be used to merge the files - output_file : sets the output file name - output_lfn : sets the output LFN """ # // # // process supported options #// processName = options.get("process_name", "Merge") outputModLabel = options.get("outputmod_label", "Merged") outputFilename = options.get("output_file", "Merged.root") outputLFN = options.get("output_lfn", None) dropDQM = options.get("drop_dqm", False) newDQMIO = options.get("newDQMIO", False) # // # // build process #// process = Process(processName) # // # // input source #// if newDQMIO: process.source = Source("DQMRootSource") process.add_(Service("DQMStore")) else: process.source = Source("PoolSource") if dropDQM: process.source.inputCommands = CfgTypes.untracked.vstring('keep *','drop *_EDMtoMEConverter_*_*') process.source.fileNames = CfgTypes.untracked(CfgTypes.vstring()) for entry in inputFiles: process.source.fileNames.append(str(entry)) # // # // output module #// if newDQMIO: outMod = OutputModule("DQMRootOutputModule") else: outMod = OutputModule("PoolOutputModule") outMod.fileName = CfgTypes.untracked.string(outputFilename) if outputLFN != None: outMod.logicalFileName = CfgTypes.untracked.string(outputLFN) setattr(process, outputModLabel, outMod) process.outputPath = EndPath(outMod) return process
def testModifiedObjectsHistory(self): process = cms.Process('unittest') process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root")) changeSource(process,"file:filename.root") self.assertEqual(len(process.history()[0][1]),1) process.source.fileNames=cms.untracked.vstring("file:replacedfile.root") self.assertEqual(len(process.history()[0][1]),1) self.assertEqual(len(process.history()[1][1]),1) process.source.fileNames=["test2"] self.assertEqual(len(process.history()[0][1]),1) self.assertEqual(len(process.history()[1][1]),1) changeSource(process,"file:filename2.root") self.assertEqual(len(process.history()[0][1]),1) self.assertEqual(len(process.history()[1][1]),1) self.assertEqual(len(process.history()[2][1]),1) process.source.fileNames=cms.untracked.vstring("file:replacedfile2.root") self.assertEqual(len(process.history()[0][1]),1) self.assertEqual(len(process.history()[1][1]),1) self.assertEqual(len(process.history()[2][1]),1) self.assertEqual(len(process.history()[3][1]),1)
def testdumpHistory(self): process = cms.Process('unittest') process.source=Source("PoolSource",fileNames = cms.untracked.string("file:file.root")) changeSource(process,"file:filename.root") self.assertEqual(changeSource._parameters['source'].value,"file:filename.root") changeSource(process,"file:filename2.root") self.assertEqual(changeSource._parameters['source'].value,"file:filename2.root") changeSource(process,"file:filename3.root") self.assertEqual(changeSource._parameters['source'].value,"file:filename3.root") self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n") process.source.fileNames=cms.untracked.vstring("file:replacedfile.root") self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n") process.disableRecording() changeSource.setParameter('source',"file:filename4.root") action=changeSource.__copy__() process.addAction(action) self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\nprocess.source.fileNames = cms.untracked.vstring('file:replacedfile.root')\n") process.enableRecording() changeSource.setParameter('source',"file:filename5.root") action=changeSource.__copy__() process.addAction(action) process.deleteAction(3) self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename.root')\n\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n") process.deleteAction(0) self.assertEqual(process.dumpHistory(),"\nfrom FWCore.GuiBrowsers.editorTools import *\n\nchangeSource(process , 'file:filename2.root')\n\n\nchangeSource(process , 'file:filename3.root')\n\n\nchangeSource(process , 'file:filename5.root')\n\n")
def testdumpPython(self): process = cms.Process('unittest') process.source = Source( "PoolSource", fileNames=cms.untracked.string("file:file.root")) changeSource(process, "file:filename.root") self.assertEqual( changeSource.dumpPython(), ('\nfrom FWCore.GuiBrowsers.editorTools import *\n', "\nchangeSource(process , 'file:filename.root')\n"))
def mergeProcess(*inputFiles, **options): """ _mergeProcess_ Creates and returns a merge process that will merge the provided filenames supported options: - process_name : name of the procee, defaults to Merge - output_file : sets the output file name - output_lfn : sets the output LFN """ # // # // process supported options #// processName = options.get("process_name", "Merge") outputFilename = options.get("output_file", "Merged.root") outputLFN = options.get("output_lfn", None) # // # // build process #// process = Process(processName) # // # // input source #// process.source = Source("PoolSource") process.source.fileNames = CfgTypes.untracked(CfgTypes.vstring()) for entry in inputFiles: process.source.fileNames.append(str(entry)) # // # // output module #// process.Merged = OutputModule("PoolOutputModule") process.Merged.fileName = CfgTypes.untracked(CfgTypes.string( outputFilename)) if outputLFN != None: process.Merged.logicalFileName = CfgTypes.untracked(CfgTypes.string( outputLFN)) process.outputPath = EndPath(process.Merged) return process
def mergeProcess(*inputFiles, **options): """ _mergeProcess_ Creates and returns a merge process that will merge the provided filenames supported options: - process_name : name of the process, defaults to Merge - outputmod_label : label of the output module, defaults to Merged - newDQMIO : specifies if the new DQM format should be used to merge the files - output_file : sets the output file name - output_lfn : sets the output LFN - mergeNANO : to merge NanoAOD - bypassVersionCheck : to bypass version check in case merging happened in lower version of CMSSW (i.e. UL HLT case). This will be TRUE by default. """ # // # // process supported options #// processName = options.get("process_name", "Merge") outputModLabel = options.get("outputmod_label", "Merged") outputFilename = options.get("output_file", "Merged.root") outputLFN = options.get("output_lfn", None) dropDQM = options.get("drop_dqm", False) newDQMIO = options.get("newDQMIO", False) mergeNANO = options.get("mergeNANO", False) bypassVersionCheck = options.get("bypassVersionCheck", True) # // # // build process #// process = Process(processName) # // # // input source #// if newDQMIO: process.source = Source("DQMRootSource") process.add_(Service("DQMStore")) else: process.source = Source("PoolSource") process.source.bypassVersionCheck = CfgTypes.untracked.bool(bypassVersionCheck) if dropDQM: process.source.inputCommands = CfgTypes.untracked.vstring('keep *','drop *_EDMtoMEConverter_*_*') process.source.fileNames = CfgTypes.untracked(CfgTypes.vstring()) for entry in inputFiles: process.source.fileNames.append(str(entry)) # // # // output module #// if newDQMIO: outMod = OutputModule("DQMRootOutputModule") elif mergeNANO: import Configuration.EventContent.EventContent_cff outMod = OutputModule("NanoAODOutputModule",Configuration.EventContent.EventContent_cff.NANOAODEventContent.clone()) process.add_(Service("InitRootHandlers", EnableIMT = CfgTypes.untracked.bool(False))) else: outMod = OutputModule("PoolOutputModule") outMod.fileName = CfgTypes.untracked.string(outputFilename) if outputLFN != None: outMod.logicalFileName = CfgTypes.untracked.string(outputLFN) setattr(process, outputModLabel, outMod) process.outputPath = EndPath(outMod) return process
# // process supported options #// processName = options.get("process_name", "Merge") outputFilename = options.get("output_file", "Merged.root") outputLFN = options.get("output_lfn", None) dropDQM = options.get("drop_dqm", False) # // # // build process #// process = Process(processName) # // # // input source #// process.source = Source("PoolSource", fileNames=cms.untracked.vstring()) inputFiles = [ "lstore://cms-lstore.vampre/test/file2.root", "lstore://cms-lstore.vampire/test/file1.root" ] for entry in inputFiles: process.source.fileNames.append(str(entry)) if dropDQM: process.source.inputCommands = CfgTypes.untracked.vstring( 'keep *', 'drop *_EDMtoMEConverter_*_*') # // # // output module #// process.Merged = OutputModule("PoolOutputModule") process.Merged.fileName = CfgTypes.untracked(CfgTypes.string(outputFilename))