File indexing completed on 2024-11-28 23:10:43
0001
0002 """
0003 _AlCaNano_
0004
0005 Scenario supporting proton collisions for AlCa needs when ALCANANO is produced
0006
0007 """
0008
0009 import os
0010 import sys
0011
0012 from Configuration.DataProcessing.Scenario import *
0013 from Configuration.DataProcessing.Utils import stepALCAPRODUCER,dqmIOSource,harvestingMode,dictIO,gtNameAndConnect,addMonitoring
0014 import FWCore.ParameterSet.Config as cms
0015
0016 class AlCaNano(Scenario):
0017 def __init__(self):
0018 Scenario.__init__(self)
0019 self.recoSeq=''
0020 self.promptCustoms= [ 'Configuration/DataProcessing/RecoTLR.customisePrompt' ]
0021 self.promptModifiers = cms.ModifierChain()
0022
0023 """
0024 _AlCaNano_
0025
0026 Implement configuration building for data processing for proton
0027 collision data taking for AlCa needs when ALCANANO is produced
0028
0029 """
0030
0031 def skimsIfNotGiven(self,args,sl):
0032 if not 'skims' in args:
0033 args['skims']=sl
0034
0035 def promptReco(self, globalTag, **args):
0036 if not 'skims' in args:
0037 args['skims']=self.skims
0038 if not 'customs' in args:
0039 args['customs']= [ ]
0040 for c in self.promptCustoms:
0041 args['customs'].append(c)
0042
0043 options = Options()
0044 options.__dict__.update(defaultOptions.__dict__)
0045 options.scenario = "pp"
0046 dictIO(options,args)
0047 options.conditions = gtNameAndConnect(globalTag, args)
0048
0049 if 'customs' in args:
0050 print(args['customs'])
0051 options.customisation_file=args['customs']
0052
0053 options.step = 'RECO'
0054 options.step += self.recoSeq
0055 options.step += stepALCAPRODUCER(args['skims'])
0056
0057 process = cms.Process('RECO', cms.ModifierChain(self.eras, self.promptModifiers) )
0058 cb = ConfigBuilder(options, process = process, with_output = True)
0059
0060
0061 process.source = cms.Source("PoolSource",
0062 fileNames = cms.untracked.vstring()
0063 )
0064 cb.prepare()
0065
0066 return process
0067
0068 def alcaSkim(self, skims, **args):
0069 """
0070 _alcaSkim_
0071 AlcaReco processing & skims for proton collisions
0072 """
0073 step = ""
0074 pclWflws = [x for x in skims if "PromptCalibProd" in x]
0075 skims = [x for x in skims if x not in pclWflws]
0076
0077 if len(pclWflws):
0078 step += 'ALCA:'+('+'.join(pclWflws))
0079
0080 if len(skims) > 0:
0081 if step != "":
0082 step += ","
0083 step += "ALCAOUTPUT:"+('+'.join(skims))
0084
0085 options = Options()
0086 options.__dict__.update(defaultOptions.__dict__)
0087 options.scenario = "pp"
0088 options.step = step
0089 options.conditions = args['globaltag'] if 'globaltag' in args else 'None'
0090 if 'globalTagConnect' in args and args['globalTagConnect'] != '':
0091 options.conditions += ','+args['globalTagConnect']
0092
0093 options.triggerResultsProcess = 'RECO'
0094
0095 process = cms.Process('ALCA', self.eras)
0096 cb = ConfigBuilder(options, process=process)
0097
0098
0099 process.source = cms.Source(
0100 "PoolSource",
0101 fileNames=cms.untracked.vstring()
0102 )
0103
0104 cb.prepare()
0105
0106 for wfl in pclWflws:
0107 methodToCall = getattr(process, 'ALCARECOStream'+wfl)
0108 methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
0109
0110 return process
0111
0112
0113 def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
0114 """
0115 _dqmHarvesting_
0116 Proton collisions data taking DQM Harvesting
0117 """
0118 options = defaultOptions
0119 options.scenario = "pp"
0120 options.step = "HARVESTING:alcaHarvesting"
0121 options.name = "EDMtoMEConvert"
0122 options.conditions = gtNameAndConnect(globalTag, args)
0123
0124 process = cms.Process("HARVESTING", self.eras)
0125 process.source = dqmIOSource(args)
0126 configBuilder = ConfigBuilder(options, process = process)
0127 configBuilder.prepare()
0128
0129 harvestingMode(process,datasetName,args)
0130
0131 return process
0132
0133 def alcaHarvesting(self, globalTag, datasetName, **args):
0134 """
0135 _alcaHarvesting_
0136 Proton collisions data taking AlCa Harvesting
0137 """
0138 skims = []
0139 if 'skims' in args:
0140 skims = args['skims']
0141
0142
0143 if 'alcapromptdataset' in args:
0144 skims.append('@'+args['alcapromptdataset'])
0145
0146 if len(skims) == 0: return None
0147 options = defaultOptions
0148 options.scenario = self.cbSc if hasattr(self,'cbSc') else self.__class__.__name__
0149 options.step = "ALCAHARVEST:"+('+'.join(skims))
0150 options.name = "ALCAHARVEST"
0151 options.conditions = gtNameAndConnect(globalTag, args)
0152
0153 process = cms.Process("ALCAHARVEST", self.eras)
0154 process.source = cms.Source("PoolSource")
0155
0156 if 'customs' in args:
0157 options.customisation_file=args['customs']
0158
0159 configBuilder = ConfigBuilder(options, process = process)
0160 configBuilder.prepare()
0161
0162 process.source.processingMode = cms.untracked.string('RunsAndLumis')
0163 process.source.fileNames = cms.untracked(cms.vstring())
0164 process.maxEvents.input = -1
0165 process.dqmSaver.workflow = datasetName
0166
0167 return process
0168
0169 def expressProcessing(self, globalTag, **args):
0170 """
0171 _expressProcessing_
0172 Proton collision data taking express processing
0173 """
0174 skims = []
0175 if 'skims' in args:
0176 skims = args['skims']
0177 pclWkflws = [x for x in skims if "PromptCalibProd" in x]
0178 for wfl in pclWkflws:
0179 skims.remove(wfl)
0180
0181 options = Options()
0182 options.__dict__.update(defaultOptions.__dict__)
0183 options.scenario = "pp"
0184 options.step = stepALCAPRODUCER(skims)
0185
0186 if 'outputs' in args:
0187
0188 outputs_Raw = [x for x in args['outputs'] if x['dataTier'] == 'RAW']
0189 outputs_noRaw = [x for x in args['outputs'] if x['dataTier'] != 'RAW']
0190 if len(outputs_Raw) == 1:
0191 print('RAW data-tier requested')
0192 options.outputDefinition = outputs_noRaw.__str__()
0193
0194 options.conditions = gtNameAndConnect(globalTag, args)
0195
0196 options.filein = 'tobeoverwritten.xyz'
0197 if 'inputSource' in args:
0198 options.filetype = args['inputSource']
0199 process = cms.Process('RECO', self.eras)
0200
0201 if 'customs' in args:
0202 options.customisation_file=args['customs']
0203
0204 cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
0205
0206 cb.prepare()
0207
0208 addMonitoring(process)
0209
0210 for output in outputs_Raw:
0211 print(output)
0212 moduleLabel = output['moduleLabel']
0213 selectEvents = output.get('selectEvents', None)
0214 maxSize = output.get('maxSize', None)
0215
0216 outputModule = cms.OutputModule(
0217 "PoolOutputModule",
0218 fileName = cms.untracked.string("%s.root" % moduleLabel)
0219 )
0220
0221 outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
0222
0223 if maxSize != None:
0224 outputModule.maxSize = cms.untracked.int32(maxSize)
0225
0226 if selectEvents != None:
0227 outputModule.SelectEvents = cms.untracked.PSet(
0228 SelectEvents = cms.vstring(selectEvents)
0229 )
0230 outputModule.outputCommands = cms.untracked.vstring('drop *',
0231 'keep *_*_*_HLT')
0232
0233 setattr(process, moduleLabel, outputModule)
0234
0235 setattr(process, moduleLabel+'_step', cms.EndPath(outputModule))
0236 path = getattr(process, moduleLabel+'_step')
0237 process.schedule.append(path)
0238
0239 return process
0240