File indexing completed on 2024-04-06 12:03:32
0001
0002 """
0003 _Utils_
0004
0005 Module containing some utility tools
0006
0007 """
0008
0009 def stepALCAPRODUCER(skims):
0010 """
0011 _stepALCAPRODUCER_
0012
0013 Creates and returns the configuration string for the ALCAPRODUCER step
0014 starting from the list of AlcaReco path to be run.
0015
0016 """
0017
0018 step = ''
0019 if len(skims) >0:
0020 step = ',ALCAPRODUCER:'+('+'.join(skims))
0021 return step
0022
0023
0024 def stepSKIMPRODUCER(PhysicsSkims):
0025 """
0026 _stepSKIMPRODUCER_
0027
0028 Creates and returns the configuration string for the SKIM step
0029 starting from the list of skims to be run.
0030
0031 """
0032
0033 step = ''
0034 if len(PhysicsSkims) >0 :
0035 step = ',SKIM:'+('+'.join(PhysicsSkims))
0036 return step
0037
0038 def addMonitoring(process):
0039 """
0040 _addMonitoring_
0041
0042 Add the monitoring services to the process provided
0043 in order to write out performance summaries to the framework job report
0044 """
0045 import FWCore.ParameterSet.Config as cms
0046
0047 process.SimpleMemoryCheck = cms.Service("SimpleMemoryCheck",
0048 jobReportOutputOnly = cms.untracked.bool(True)
0049 )
0050 process.Timing = cms.Service("Timing",
0051 summaryOnly = cms.untracked.bool(True)
0052 )
0053
0054 return process
0055
0056
0057 def validateProcess(process):
0058 """
0059 _validateProcess_
0060
0061 Check attributes of process are appropriate for production
0062 This method returns nothing but will throw a RuntimeError for any issues it finds
0063 likely to cause problems in the production system
0064
0065 """
0066
0067 schedule=process.schedule_()
0068 paths=process.paths_()
0069 endpaths=process.endpaths_()
0070
0071
0072 for outputModName in process.outputModules_().keys():
0073 outputMod = getattr(process, outputModName)
0074 if not hasattr(outputMod, 'dataset'):
0075 msg = "Process contains output module without dataset PSET: %s \n" % outputModName
0076 msg += " You need to add this PSET to this module to set dataTier and filterName\n"
0077 raise RuntimeError(msg)
0078 ds=getattr(outputMod,'dataset')
0079 if not hasattr(ds, "dataTier"):
0080 msg = "Process contains output module without dataTier parameter: %s \n" % outputModName
0081 msg += " You need to add an untracked parameter to the dataset PSET of this module to set dataTier\n"
0082 raise RuntimeError(msg)
0083
0084
0085 omRun=False
0086
0087 if schedule==None:
0088 for path in paths:
0089 if outputModName in getattr(process,path).moduleNames():
0090 omRun=True
0091 for path in endpaths:
0092 if outputModName in getattr(process,path).moduleNames():
0093 omRun=True
0094 else:
0095 for path in schedule:
0096 if outputModName in path.moduleNames():
0097 omRun=True
0098 if omRun==False:
0099 msg = "Output Module %s not in endPath" % outputModName
0100 raise RuntimeError(msg)
0101
0102
0103 def dqmIOSource(args):
0104 import FWCore.ParameterSet.Config as cms
0105 if args.get('newDQMIO', False):
0106 return cms.Source("DQMRootSource",
0107 fileNames = cms.untracked(cms.vstring())
0108 )
0109 else:
0110 return cms.Source("PoolSource",
0111 fileNames = cms.untracked(cms.vstring())
0112 )
0113
0114 def harvestingMode(process, datasetName, args,rANDl=True):
0115 import FWCore.ParameterSet.Config as cms
0116 if rANDl and (not args.get('newDQMIO', False)):
0117 process.source.processingMode = cms.untracked.string('RunsAndLumis')
0118 process.dqmSaver.workflow = datasetName
0119 process.dqmSaver.saveByLumiSection = 1
0120
0121 def dictIO(options,args):
0122 if 'outputs' in args:
0123 options.outputDefinition = args['outputs'].__str__()
0124 else:
0125 writeTiers = args.get('writeTiers', [])
0126 options.eventcontent = ','.join(writeTiers)
0127 options.datatier = ','.join(writeTiers)
0128
0129 def dqmSeq(args,default):
0130 if 'dqmSeq' in args and len(args['dqmSeq'])!=0:
0131 return ':'+('+'.join(args['dqmSeq']))
0132 else:
0133 return default
0134
0135 def nanoFlavours(flavours):
0136 """
0137 _nanoFlavours_
0138
0139 Creates and returns the configuration string for the NANO flavours
0140 from the list of flavors to be run.
0141
0142 """
0143
0144 step = ''
0145 if len(flavours) >0 :
0146 step = ':'+('+'.join(flavours))
0147 return step
0148
0149 def gtNameAndConnect(globalTag, args):
0150 if 'globalTagConnect' in args and args['globalTagConnect'] != '':
0151 return globalTag + ','+args['globalTagConnect']
0152
0153 return globalTag +',frontier://PromptProd/CMS_CONDITIONS'