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