Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:31

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