Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-19 01:11:56

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 # The following 2 imports are provided for backward compatibility reasons.
0004 # The functions used to be defined in this file.
0005 from FWCore.ParameterSet.MassReplace import massReplaceInputTag as MassReplaceInputTag
0006 from FWCore.ParameterSet.MassReplace import massReplaceParameter as MassReplaceParameter
0007 
0008 def ProcessName(process):
0009 #   processname modifications
0010 
0011     if 'hltTrigReport' in process.__dict__:
0012         process.hltTrigReport.HLTriggerResults = cms.InputTag( 'TriggerResults','',process.name_() )
0013 
0014     return(process)
0015 
0016 
0017 def Base(process):
0018 #   default modifications
0019 
0020     process.options.wantSummary = cms.untracked.bool(True)
0021     process.options.numberOfThreads = cms.untracked.uint32( 4 )
0022     process.options.numberOfStreams = cms.untracked.uint32( 0 )
0023     process.options.sizeOfStackForThreadsInKB = cms.untracked.uint32( 10*1024 )
0024 
0025     process.MessageLogger.TriggerSummaryProducerAOD=cms.untracked.PSet()
0026     process.MessageLogger.L1GtTrigReport=cms.untracked.PSet()
0027     process.MessageLogger.L1TGlobalSummary=cms.untracked.PSet()
0028     process.MessageLogger.HLTrigReport=cms.untracked.PSet()
0029 
0030 # No longer override - instead use GT config as provided via cmsDriver
0031 ## override the GlobalTag, connection string and pfnPrefix
0032 #    if 'GlobalTag' in process.__dict__:
0033 #        process.GlobalTag.connect   = 'frontier://FrontierProd/CMS_CONDITIONS'
0034 #        process.GlobalTag.pfnPrefix = cms.untracked.string('frontier://Frontie#rProd/')
0035 #        
0036 #   process.GlobalTag.snapshotTime = cms.string("9999-12-31 23:59:59.000")
0037 
0038     process=ProcessName(process)
0039 
0040     return(process)
0041 
0042 
0043 def L1T(process):
0044 #   modifications when running L1T only
0045 
0046     def _legacyStage1(process):
0047         labels = ['gtDigis','simGtDigis','newGtDigis','hltGtDigis']
0048         for label in labels:
0049             if label in process.__dict__:
0050                 process.load('L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi')
0051                 process.l1GtTrigReport.L1GtRecordInputTag = cms.InputTag( label )
0052                 process.L1AnalyzerEndpath = cms.EndPath( process.l1GtTrigReport )
0053                 process.schedule.append(process.L1AnalyzerEndpath)
0054 
0055     def _stage2(process):
0056         labels = ['gtStage2Digis','simGtStage2Digis','newGtStage2Digis','hltGtStage2Digis']
0057         for label in labels:
0058             if label in process.__dict__:
0059                 process.load('L1Trigger.L1TGlobal.L1TGlobalSummary_cfi')
0060                 process.L1TGlobalSummary.AlgInputTag = cms.InputTag( label )
0061                 process.L1TGlobalSummary.ExtInputTag = cms.InputTag( label )
0062                 process.L1TAnalyzerEndpath = cms.EndPath(process.L1TGlobalSummary )
0063                 process.schedule.append(process.L1TAnalyzerEndpath)
0064 
0065     from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
0066     (~stage2L1Trigger).toModify(process, _legacyStage1)
0067     stage2L1Trigger.toModify(process, _stage2)
0068 
0069     if hasattr(process,'TriggerMenu'):
0070         delattr(process,'TriggerMenu')
0071 
0072     process=Base(process)
0073 
0074     return(process)
0075 
0076 
0077 def L1THLT(process):
0078 #   modifications when running L1T+HLT
0079 
0080     if not ('HLTAnalyzerEndpath' in process.__dict__) :
0081         def _legacyStage1(process):
0082             if 'hltGtDigis' in process.__dict__:
0083                 from HLTrigger.Configuration.HLT_Fake_cff import fragment
0084                 process.hltL1GtTrigReport = fragment.hltL1GtTrigReport
0085                 process.hltTrigReport = fragment.hltTrigReport
0086                 process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtDigis + process.hltL1GtTrigReport + process.hltTrigReport)
0087                 process.schedule.append(process.HLTAnalyzerEndpath)
0088 
0089         def _stage2(process):
0090             if 'hltGtStage2ObjectMap' in process.__dict__:
0091                 from HLTrigger.Configuration.HLT_FULL_cff import fragment
0092                 process.hltL1TGlobalSummary = fragment.hltL1TGlobalSummary
0093                 process.hltTrigReport = fragment.hltTrigReport
0094                 process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtStage2Digis + process.hltL1TGlobalSummary + process.hltTrigReport)
0095                 process.schedule.append(process.HLTAnalyzerEndpath)
0096 
0097         from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
0098         (~stage2L1Trigger).toModify(process, _legacyStage1)
0099         stage2L1Trigger.toModify(process, _stage2)
0100 
0101     if hasattr(process,'TriggerMenu'):
0102         delattr(process,'TriggerMenu')
0103 
0104     process=Base(process)
0105 
0106     return(process)
0107 
0108 
0109 def HLTRECO(process):
0110     """Customisations for running HLT+RECO in the same job
0111        - remove ESSources and ESProducers from Tasks (needed to run HLT+RECO tests on GPU)
0112          - when Reconstruction_cff is loaded, it brings in Tasks that include
0113            GPU-related ES modules with the same names as they have in HLT configs
0114          - in TSG tests, these GPU-related RECO Tasks are not included in the Schedule
0115            (because the "gpu" process-modifier is not used);
0116            this causes the ES modules not to be executed, thus making them unavailable to HLT producers
0117          - this workaround removes ES modules from Tasks, making their execution independent of the content of the Schedule;
0118            with reference to https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideAboutPythonConfigFile?rev=92#Behavior_when_an_ESProducer_ESSo,
0119            this workaround avoids "Case 3" by reverting to "Case 2"
0120          - this workaround only affects Tasks of non-HLT steps, as the addition of ES modules to Tasks is not supported in ConfDB
0121            (none of the Tasks used in the HLT step can contain ES modules in the first place, modulo customisations outside ConfDB)
0122     """
0123     for taskName in process.tasks_():
0124         task = process.tasks_()[taskName]
0125         esModulesToRemove = set()
0126         for modName in task.moduleNames():
0127             module = getattr(process, modName)
0128             if isinstance(module, cms.ESSource) or isinstance(module, cms.ESProducer):
0129                 esModulesToRemove.add(module)
0130         for esModule in esModulesToRemove:
0131             task.remove(esModule)
0132 
0133     return process
0134 
0135 
0136 def customiseGlobalTagForOnlineBeamSpot(process):
0137     """Customisation of GlobalTag for Online BeamSpot
0138        - edits the GlobalTag ESSource to load the tags used to produce the HLT beamspot
0139        - these tags are not available in the Offline GT, which is the GT presently used in HLT+RECO tests
0140        - not loading these tags (i.e. not using this customisation) does not result in a runtime error,
0141          but it leads to an HLT beamspot different to the one obtained when running HLT alone
0142     """
0143     if hasattr(process, 'GlobalTag'):
0144       if not hasattr(process.GlobalTag, 'toGet'):
0145         process.GlobalTag.toGet = cms.VPSet()
0146       process.GlobalTag.toGet += [
0147         cms.PSet(
0148           record = cms.string('BeamSpotOnlineLegacyObjectsRcd'),
0149           tag = cms.string('BeamSpotOnlineLegacy')
0150         ),
0151         cms.PSet(
0152           record = cms.string('BeamSpotOnlineHLTObjectsRcd'),
0153           tag = cms.string('BeamSpotOnlineHLT')
0154         )
0155       ]
0156 
0157     return process
0158 
0159 
0160 def HLTDropPrevious(process):
0161 #   drop on input the previous HLT results
0162     process.source.inputCommands = cms.untracked.vstring (
0163         'keep *',
0164         'drop *_hltL1GtObjectMap_*_*',
0165         'drop *_TriggerResults_*_*',
0166         'drop *_hltTriggerSummaryAOD_*_*',
0167     )
0168 
0169     process=Base(process)
0170     
0171     return(process)
0172 
0173 
0174 def L1REPACK(process, sequence="Full"):
0175 
0176     from Configuration.Eras.Era_Run3_cff import Run3
0177     l1repack = cms.Process('L1REPACK', Run3)
0178     l1repack.load('Configuration.StandardSequences.SimL1EmulatorRepack_'+sequence+'_cff')
0179 
0180     for module in l1repack.es_sources_():
0181         if not hasattr(process, module):
0182             setattr(process, module, getattr(l1repack, module))
0183     for module in l1repack.es_producers_():
0184         if not hasattr(process, module):
0185             setattr(process, module, getattr(l1repack, module))
0186 
0187     for module in l1repack.SimL1Emulator.expandAndClone().moduleNames():
0188         setattr(process, module, getattr(l1repack, module))
0189     for taskName, task in l1repack.tasks_().items():
0190         if l1repack.SimL1Emulator.contains(task):
0191             setattr(process, taskName, task)
0192     for sequenceName, sequence in l1repack.sequences_().items():
0193         if l1repack.SimL1Emulator.contains(sequence):
0194             setattr(process, sequenceName, sequence)
0195 
0196     process.SimL1Emulator = l1repack.SimL1Emulator
0197 
0198     for path in process.paths_():
0199         getattr(process,path).insert(0,process.SimL1Emulator)
0200     for path in process.endpaths_():
0201         getattr(process,path).insert(0,process.SimL1Emulator)
0202 
0203     # special L1T cleanup
0204     for obj in [
0205       'hgcalTriggerGeometryESProducer',
0206     ]:
0207         if hasattr(process, obj):
0208             delattr(process, obj)
0209 
0210     return process
0211 
0212 
0213 def L1XML(process,xmlFile=None):
0214 
0215 #   xmlFile="L1Menu_Collisions2016_dev_v3.xml"
0216 
0217     if ((xmlFile is None) or (xmlFile=="")):
0218         return process
0219 
0220     process.L1TriggerMenu= cms.ESProducer("L1TUtmTriggerMenuESProducer",
0221         L1TriggerMenuFile= cms.string(xmlFile)
0222     )
0223     process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","L1TriggerMenu")
0224 
0225     return process