Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-28 23:10:43

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