Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:38:22

0001 #!/usr/bin/env python3
0002 """
0003 _AlCaPPS_Run3_
0004 
0005 Scenario supporting proton collisions for AlCa needs for the CT-PPS detector 
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.Impl.AlCa import AlCa
0015 from Configuration.DataProcessing.Utils import stepALCAPRODUCER,dqmIOSource,harvestingMode,dictIO,gtNameAndConnect,addMonitoring
0016 from Configuration.Eras.Era_Run3_cff import Run3
0017 import FWCore.ParameterSet.Config as cms
0018 
0019 class AlCaPPS_Run3(AlCa):
0020     def __init__(self):
0021         Scenario.__init__(self)
0022         self.eras=Run3
0023         self.skims=['PPSCalMaxTracks']
0024 
0025     """
0026     _AlCaPPS_Run3_
0027 
0028     Implement configuration building for data processing for proton
0029     collision data taking for AlCa needs for the CT-PPS detector 
0030 
0031     """
0032 
0033     def skimsIfNotGiven(self,args,sl):
0034         if not 'skims' in args:
0035             args['skims']=sl
0036 
0037     def promptReco(self, globalTag, **args):
0038         if not 'skims' in args:
0039             args['skims']=self.skims
0040         if not 'customs' in args:
0041             args['customs']= [ ]
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 += stepALCAPRODUCER(args['skims'])
0054 
0055         process = cms.Process('RECO', cms.ModifierChain(self.eras) )
0056         cb = ConfigBuilder(options, process = process, with_output = True)
0057 
0058         # Input source
0059         process.source = cms.Source("PoolSource",
0060             fileNames = cms.untracked.vstring()
0061         )
0062         cb.prepare()
0063 
0064         return process
0065 
0066 
0067     def alcaSkim(self, skims, **args):
0068         """
0069         _alcaSkim_
0070 
0071         AlcaReco processing & skims for proton collisions
0072 
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         # Input source
0100         process.source = cms.Source(
0101            "PoolSource",
0102            fileNames=cms.untracked.vstring()
0103         )
0104 
0105         cb.prepare()
0106 
0107         # Tier0 needs the dataset used for ALCAHARVEST step to be a different data-tier
0108         for wfl in pclWflws:
0109             methodToCall = getattr(process, 'ALCARECOStream'+wfl)
0110             methodToCall.dataset.dataTier = cms.untracked.string('ALCAPROMPT')
0111 
0112         return process
0113 
0114     def dqmHarvesting(self, datasetName, runNumber, globalTag, **args):
0115         """
0116         _dqmHarvesting_
0117 
0118         Proton collisions data taking DQM Harvesting
0119 
0120         """
0121         options = defaultOptions
0122         options.scenario = "pp"
0123         options.step = "HARVESTING:alcaHarvesting"
0124         options.name = "EDMtoMEConvert"
0125         options.conditions = gtNameAndConnect(globalTag, args)
0126 
0127         process = cms.Process("HARVESTING", self.eras)
0128         process.source = dqmIOSource(args)
0129         configBuilder = ConfigBuilder(options, process = process)
0130         configBuilder.prepare()
0131 
0132         # customise process for particular job
0133         harvestingMode(process,datasetName,args)
0134 
0135         return process
0136 
0137     def expressProcessing(self, globalTag, **args):
0138         """
0139         _expressProcessing_
0140 
0141         Proton collision data taking express processing
0142 
0143         """
0144         skims = []
0145         if 'skims' in args:
0146             skims = args['skims']
0147             pclWkflws = [x for x in skims if "PromptCalibProd" in x]
0148             for wfl in pclWkflws:
0149                 skims.remove(wfl)
0150 
0151         options = Options()
0152         options.__dict__.update(defaultOptions.__dict__)
0153         options.scenario = "pp"
0154         options.step = stepALCAPRODUCER(skims)
0155 
0156         if 'outputs' in args:
0157             # the RAW data-tier needs a special treatment since the event-content as defined in release is not good enough
0158             outputs_Raw = [x for x in args['outputs'] if x['dataTier'] == 'RAW']
0159             outputs_noRaw = [x for x in args['outputs'] if x['dataTier'] != 'RAW']
0160             if len(outputs_Raw) == 1:
0161                 print('RAW data-tier requested')
0162             options.outputDefinition = outputs_noRaw.__str__()
0163 
0164         options.conditions = gtNameAndConnect(globalTag, args)
0165 
0166         options.filein = 'tobeoverwritten.xyz'
0167         if 'inputSource' in args:
0168             options.filetype = args['inputSource']
0169         process = cms.Process('RECO', self.eras)
0170 
0171         if 'customs' in args:
0172             options.customisation_file=args['customs']
0173 
0174         cb = ConfigBuilder(options, process = process, with_output = True, with_input = True)
0175 
0176         cb.prepare()
0177 
0178         addMonitoring(process)
0179 
0180         for output in outputs_Raw:
0181             print(output)
0182             moduleLabel = output['moduleLabel']
0183             selectEvents = output.get('selectEvents', None)
0184             maxSize = output.get('maxSize', None)
0185 
0186             outputModule = cms.OutputModule(
0187                 "PoolOutputModule",
0188                 fileName = cms.untracked.string("%s.root" % moduleLabel)
0189                 )
0190 
0191             outputModule.dataset = cms.untracked.PSet(dataTier = cms.untracked.string("RAW"))
0192 
0193             if maxSize != None:
0194                 outputModule.maxSize = cms.untracked.int32(maxSize)
0195 
0196             if selectEvents != None:
0197                 outputModule.SelectEvents = cms.untracked.PSet(
0198                     SelectEvents = cms.vstring(selectEvents)
0199                     )
0200             outputModule.outputCommands = cms.untracked.vstring('drop *',
0201                                                                 'keep  *_*_*_HLT')
0202 
0203             setattr(process, moduleLabel, outputModule)
0204             setattr(process, moduleLabel+'_step', cms.EndPath(outputModule))
0205             path = getattr(process, moduleLabel+'_step')
0206             process.schedule.append(path)
0207 
0208         return process