Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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