CMS 3D CMS Logo

CustomConfigs.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 # The following 2 imports are provided for backward compatibility reasons.
4 # The functions used to be defined in this file.
5 from FWCore.ParameterSet.MassReplace import massReplaceInputTag as MassReplaceInputTag
6 from FWCore.ParameterSet.MassReplace import massReplaceParameter as MassReplaceParameter
7 
8 def ProcessName(process):
9 # processname modifications
10 
11  if 'hltTrigReport' in process.__dict__:
12  process.hltTrigReport.HLTriggerResults = cms.InputTag( 'TriggerResults','',process.name_() )
13 
14  return(process)
15 
16 
17 def Base(process):
18 # default modifications
19 
20  process.options.wantSummary = True
21  process.options.numberOfThreads = 4
22  process.options.numberOfStreams = 0
23  process.options.sizeOfStackForThreadsInKB = 10*1024
24 
25  process.MessageLogger.TriggerSummaryProducerAOD = cms.untracked.PSet()
26  process.MessageLogger.L1GtTrigReport = cms.untracked.PSet()
27  process.MessageLogger.L1TGlobalSummary = cms.untracked.PSet()
28  process.MessageLogger.HLTrigReport = cms.untracked.PSet()
29 
30 # No longer override - instead use GT config as provided via cmsDriver
31 
37 
38  process=ProcessName(process)
39 
40  return(process)
41 
42 
43 def L1T(process):
44 # modifications when running L1T only
45 
46  def _legacyStage1(process):
47  labels = ['gtDigis','simGtDigis','newGtDigis','hltGtDigis']
48  for label in labels:
49  if label in process.__dict__:
50  process.load('L1Trigger.GlobalTriggerAnalyzer.l1GtTrigReport_cfi')
51  process.l1GtTrigReport.L1GtRecordInputTag = cms.InputTag( label )
52  process.L1AnalyzerEndpath = cms.EndPath( process.l1GtTrigReport )
53  process.schedule.append(process.L1AnalyzerEndpath)
54 
55  def _stage2(process):
56  labels = ['gtStage2Digis','simGtStage2Digis','newGtStage2Digis','hltGtStage2Digis']
57  for label in labels:
58  if label in process.__dict__:
59  process.load('L1Trigger.L1TGlobal.L1TGlobalSummary_cfi')
60  process.L1TGlobalSummary.AlgInputTag = cms.InputTag( label )
61  process.L1TGlobalSummary.ExtInputTag = cms.InputTag( label )
62  process.L1TAnalyzerEndpath = cms.EndPath(process.L1TGlobalSummary )
63  process.schedule.append(process.L1TAnalyzerEndpath)
64 
65  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
66  (~stage2L1Trigger).toModify(process, _legacyStage1)
67  stage2L1Trigger.toModify(process, _stage2)
68 
69  if hasattr(process,'TriggerMenu'):
70  delattr(process,'TriggerMenu')
71 
72  process=Base(process)
73 
74  return(process)
75 
76 
77 def L1THLT(process):
78 # modifications when running L1T+HLT
79 
80  if not ('HLTAnalyzerEndpath' in process.__dict__) :
81  def _legacyStage1(process):
82  if 'hltGtDigis' in process.__dict__:
83  from HLTrigger.Configuration.HLT_Fake_cff import fragment
84  process.hltL1GtTrigReport = fragment.hltL1GtTrigReport
85  process.hltTrigReport = fragment.hltTrigReport
86  process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtDigis + process.hltL1GtTrigReport + process.hltTrigReport)
87  process.schedule.append(process.HLTAnalyzerEndpath)
88 
89  def _stage2(process):
90  if 'hltGtStage2ObjectMap' in process.__dict__:
91  from HLTrigger.Configuration.HLT_FULL_cff import fragment
92  process.hltL1TGlobalSummary = fragment.hltL1TGlobalSummary
93  process.hltTrigReport = fragment.hltTrigReport
94  process.HLTAnalyzerEndpath = cms.EndPath(process.hltGtStage2Digis + process.hltL1TGlobalSummary + process.hltTrigReport)
95  process.schedule.append(process.HLTAnalyzerEndpath)
96 
97  from Configuration.Eras.Modifier_stage2L1Trigger_cff import stage2L1Trigger
98  (~stage2L1Trigger).toModify(process, _legacyStage1)
99  stage2L1Trigger.toModify(process, _stage2)
100 
101  if hasattr(process,'TriggerMenu'):
102  delattr(process,'TriggerMenu')
103 
104  process=Base(process)
105 
106  return(process)
107 
108 
109 def HLTRECO(process):
110  """Customisations for running HLT+RECO in the same job
111  - remove ESSources and ESProducers from Tasks (needed to run HLT+RECO tests on GPU)
112  - when Reconstruction_cff is loaded, it brings in Tasks that include
113  GPU-related ES modules with the same names as they have in HLT configs
114  - in TSG tests, these GPU-related RECO Tasks are not included in the Schedule
115  (because the "gpu" process-modifier is not used);
116  this causes the ES modules not to be executed, thus making them unavailable to HLT producers
117  - this workaround removes ES modules from Tasks, making their execution independent of the content of the Schedule;
118  with reference to https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideAboutPythonConfigFile?rev=92#Behavior_when_an_ESProducer_ESSo,
119  this workaround avoids "Case 3" by reverting to "Case 2"
120  - this workaround only affects Tasks of non-HLT steps, as the addition of ES modules to Tasks is not supported in ConfDB
121  (none of the Tasks used in the HLT step can contain ES modules in the first place, modulo customisations outside ConfDB)
122  """
123  for taskName in process.tasks_():
124  task = process.tasks_()[taskName]
125  esModulesToRemove = set()
126  for modName in task.moduleNames():
127  module = getattr(process, modName)
128  if isinstance(module, cms.ESSource) or isinstance(module, cms.ESProducer):
129  esModulesToRemove.add(module)
130  for esModule in esModulesToRemove:
131  task.remove(esModule)
132 
133  return process
134 
135 
137  """Customisation of GlobalTag for Online BeamSpot
138  - edits the GlobalTag ESSource to load the tags used to produce the HLT beamspot
139  - these tags are not available in the Offline GT, which is the GT presently used in HLT+RECO tests
140  - not loading these tags (i.e. not using this customisation) does not result in a runtime error,
141  but it leads to an HLT beamspot different to the one obtained when running HLT alone
142  """
143  if hasattr(process, 'GlobalTag'):
144  if not hasattr(process.GlobalTag, 'toGet'):
145  process.GlobalTag.toGet = cms.VPSet()
146  process.GlobalTag.toGet += [
147  cms.PSet(
148  record = cms.string('BeamSpotOnlineLegacyObjectsRcd'),
149  tag = cms.string('BeamSpotOnlineLegacy')
150  ),
151  cms.PSet(
152  record = cms.string('BeamSpotOnlineHLTObjectsRcd'),
153  tag = cms.string('BeamSpotOnlineHLT')
154  )
155  ]
156 
157  return process
158 
159 
160 def HLTDropPrevious(process):
161 # drop on input the previous HLT results
162  process.source.inputCommands = cms.untracked.vstring (
163  'keep *',
164  'drop *_hltL1GtObjectMap_*_*',
165  'drop *_TriggerResults_*_*',
166  'drop *_hltTriggerSummaryAOD_*_*',
167  )
168 
169  process=Base(process)
170 
171  return(process)
172 
173 
174 def L1REPACK(process, sequence="Full"):
175 
176  from Configuration.Eras.Era_Run3_cff import Run3
177  l1repack = cms.Process('L1REPACK', Run3)
178  l1repack.load('Configuration.StandardSequences.SimL1EmulatorRepack_'+sequence+'_cff')
179 
180  for module in l1repack.es_sources_():
181  if not hasattr(process, module):
182  setattr(process, module, getattr(l1repack, module))
183  for module in l1repack.es_producers_():
184  if not hasattr(process, module):
185  setattr(process, module, getattr(l1repack, module))
186 
187  for module in l1repack.SimL1Emulator.expandAndClone().moduleNames():
188  setattr(process, module, getattr(l1repack, module))
189  for taskName, task in l1repack.tasks_().items():
190  if l1repack.SimL1Emulator.contains(task):
191  setattr(process, taskName, task)
192  for sequenceName, sequence in l1repack.sequences_().items():
193  if l1repack.SimL1Emulator.contains(sequence):
194  setattr(process, sequenceName, sequence)
195 
196  process.SimL1Emulator = l1repack.SimL1Emulator
197 
198  for path in process.paths_():
199  getattr(process,path).insert(0,process.SimL1Emulator)
200  for path in process.endpaths_():
201  getattr(process,path).insert(0,process.SimL1Emulator)
202 
203  # special L1T cleanup
204  for obj in [
205  'hgcalTriggerGeometryESProducer',
206  ]:
207  if hasattr(process, obj):
208  delattr(process, obj)
209 
210  return process
211 
212 
213 def L1XML(process,xmlFile=None):
214 
215 # xmlFile="L1Menu_Collisions2016_dev_v3.xml"
216 
217  if ((xmlFile is None) or (xmlFile=="")):
218  return process
219 
220  process.L1TriggerMenu= cms.ESProducer("L1TUtmTriggerMenuESProducer",
221  L1TriggerMenuFile= cms.string(xmlFile)
222  )
223  process.ESPreferL1TXML = cms.ESPrefer("L1TUtmTriggerMenuESProducer","L1TriggerMenu")
224 
225  return process
def L1T(process)
def L1THLT(process)
return((rh ^ lh) &mask)
def Base(process)
def HLTDropPrevious(process)
def ProcessName(process)
Definition: CustomConfigs.py:8
def L1XML(process, xmlFile=None)
def L1REPACK(process, sequence="Full")
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
def customiseGlobalTagForOnlineBeamSpot(process)
def HLTRECO(process)