CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
confdb.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import sys
4 import re
5 import os
6 import urllib, urllib2
7 from pipe import pipe as _pipe
8 from options import globalTag
9 from itertools import islice
10 
11 def splitter(iterator, n):
12  i = iterator.__iter__()
13  while True:
14  l = list(islice(i, n))
15  if l:
16  yield l
17  else:
18  break
19 
20 
22  # paths not supported by FastSim
23  fastsimUnsupportedPaths = (
24 
25  # paths for which a recovery is not foreseen/possible
26  "AlCa_*_v*",
27  "DQM_*_v*",
28  "HLT_*Calibration_v*",
29  "HLT_DTErrors_v*",
30  "HLT_Random_v*",
31  "HLT_HcalNZS_v*",
32  "HLT_HcalPhiSym_v*",
33  "HLT_Activity_Ecal*_v*",
34  "HLT_IsoTrackHB_v*",
35  "HLT_IsoTrackHE_v*",
36  "HLT_L1SingleMuOpen_AntiBPTX_v*",
37  "HLT_JetE*_NoBPTX*_v*",
38  "HLT_L2Mu*_NoBPTX*_v*",
39  "HLT_PixelTracks_Multiplicity70_v*",
40  "HLT_PixelTracks_Multiplicity80_v*",
41  "HLT_PixelTracks_Multiplicity90_v*",
42  "HLT_Beam*_v*",
43  #"HLT_L1Tech_*_v*",
44  "HLT_GlobalRunHPDNoise_v*",
45  "HLT_L1TrackerCosmics_v*",
46  "HLT_HcalUTCA_v*",
47 
48  # TODO: paths not supported by FastSim, but for which a recovery should be attempted
49  "HLT_DoubleMu33NoFiltersNoVtx_v*",
50  "HLT_DoubleMu38NoFiltersNoVtx_v*",
51  "HLT_Mu38NoFiltersNoVtx_Photon38_CaloIdL_v*",
52  "HLT_Mu42NoFiltersNoVtx_Photon42_CaloIdL_v*",
53  "HLT_DoubleMu23NoFiltersNoVtxDisplaced_v*",
54  "HLT_DoubleMu28NoFiltersNoVtxDisplaced_v*",
55  "HLT_Mu28NoFiltersNoVtxDisplaced_Photon28_CaloIdL_v*",
56  "HLT_Mu33NoFiltersNoVtxDisplaced_Photon33_CaloIdL_v*",
57  "HLT_HT350_DisplacedDijet80_Tight_DisplacedTrack_v*",
58  "HLT_HT350_DisplacedDijet80_DisplacedTrack_v*",
59  "HLT_HT500_DisplacedDijet40_Inclusive_v*",
60  "HLT_HT350_DisplacedDijet40_DisplacedTrack_v*",
61  "HLT_VBF_DisplacedJet40_DisplacedTrack_v*",
62  "HLT_VBF_DisplacedJet40_Hadronic_v*",
63  "HLT_HT550_DisplacedDijet40_Inclusive_v*",
64  "HLT_HT350_DisplacedDijet80_DisplacedTrack_v*",
65  "HLT_VBF_DisplacedJet40_TightID_DisplacedTrack_v*",
66  "HLT_VBF_DisplacedJet40_TightID_Hadronic_v*",
67  "HLT_TrkMu15_DoubleTrkMu5NoFiltersNoVtx_v*",
68  "HLT_TrkMu17_DoubleTrkMu8NoFiltersNoVtx_v*",
69  )
70 
71  def __init__(self, configuration):
72  self.config = configuration
73  self.data = None
74  self.source = []
75  self.parent = []
76 
77  self.options = {
78  'essources' : [],
79  'esmodules' : [],
80  'modules' : [],
81  'sequences' : [],
82  'services' : [],
83  'paths' : [],
84  'psets' : [],
85  'blocks' : [],
86  }
87 
88  self.labels = {}
89  if self.config.fragment:
90  self.labels['process'] = 'fragment.'
91  self.labels['dict'] = 'fragment.__dict__'
92  else:
93  self.labels['process'] = 'process.'
94  self.labels['dict'] = 'process.__dict__'
95 
96  if self.config.online:
97  self.labels['connect'] = 'frontier://(proxyurl=http://localhost:3128)(serverurl=http://localhost:8000/FrontierOnProd)(serverurl=http://localhost:8000/FrontierOnProd)(retrieve-ziplevel=0)'
98  else:
99  self.labels['connect'] = 'frontier://FrontierProd'
100 
101  if self.config.prescale and (self.config.prescale.lower() != 'none'):
102  self.labels['prescale'] = self.config.prescale
103 
104  # get the configuration from ConfdB
105  from confdbOfflineConverter import OfflineConverter
106  self.converter = OfflineConverter(database = self.config.menu.db)
107  self.buildPathList()
108  self.buildOptions()
110  self.customize()
111 
112 
114  if self.config.menu.run:
115  args = ['--runNumber', self.config.menu.run]
116  else:
117  args = ['--configName', self.config.menu.name ]
118  args.append('--noedsources')
119  for key, vals in self.options.iteritems():
120  if vals:
121  args.extend(('--'+key, ','.join(vals)))
122 
123  data, err = self.converter.query( *args )
124  if 'ERROR' in err or 'Exhausted Resultset' in err or 'CONFIG_NOT_FOUND' in err:
125  print "%s: error while retriving the HLT menu" % os.path.basename(sys.argv[0])
126  print
127  print err
128  print
129  sys.exit(1)
130  self.data = data
131 
132 
133  def getPathList(self):
134  if self.config.menu.run:
135  args = ['--runNumber', self.config.menu.run]
136  else:
137  args = ['--configName', self.config.menu.name]
138  args.extend( (
139  '--cff',
140  '--noedsources',
141  '--noes',
142  '--noservices',
143  '--nosequences',
144  '--nomodules'
145  ) )
146 
147  data, err = self.converter.query( *args )
148  if 'ERROR' in err or 'Exhausted Resultset' in err or 'CONFIG_NOT_FOUND' in err:
149  print "%s: error while retriving the list of paths from the HLT menu" % os.path.basename(sys.argv[0])
150  print
151  print err
152  print
153  sys.exit(1)
154  filter = re.compile(r' *= *cms.(End)?Path.*')
155  paths = [ filter.sub('', line) for line in data.splitlines() if filter.search(line) ]
156  return paths
157 
158 
159  @staticmethod
160  def expandWildcards(globs, collection):
161  # expand a list of unix-style wildcards matching a given collection
162  # wildcards with no matches are silently discarded
163  matches = []
164  for glob in globs:
165  negate = ''
166  if glob[0] == '-':
167  negate = '-'
168  glob = glob[1:]
169  # translate a unix-style glob expression into a regular expression
170  filter = re.compile(r'^' + glob.replace('?', '.').replace('*', '.*').replace('[!', '[^') + r'$')
171  matches.extend( negate + element for element in collection if filter.match(element) )
172  return matches
173 
174 
175  @staticmethod
176  def consolidateNegativeList(elements):
177  # consolidate a list of path exclusions and re-inclusions
178  # the result is the list of paths to be removed from the dump
179  result = set()
180  for element in elements:
181  if element[0] == '-':
182  result.add( element )
183  else:
184  result.discard( '-' + element )
185  return sorted( element for element in result )
186 
187  @staticmethod
188  def consolidatePositiveList(elements):
189  # consolidate a list of path selection and re-exclusions
190  # the result is the list of paths to be included in the dump
191  result = set()
192  for element in elements:
193  if element[0] == '-':
194  result.discard( element[1:] )
195  else:
196  result.add( element )
197  return sorted( element for element in result )
198 
199 
200  # dump the final configuration
201  def dump(self):
202  self.data = self.data % self.labels
203  if self.config.fragment:
204  self.data = re.sub( r'\bprocess\b', 'fragment', self.data )
205  self.data = re.sub( r'\bProcess\b', 'ProcessFragment', self.data )
206  return self.data
207 
208 
209  # add release-specific customizations
211  # release-specific customizations now live in HLTrigger.Configuration.customizeHLTforCMSSW.customiseHLTforCMSSW(.,.)
212  self.data += """
213 # add release-specific customizations
214 from HLTrigger.Configuration.customizeHLTforCMSSW import customiseHLTforCMSSW
215 process = customiseHLTforCMSSW(process,menuType="%s",fastSim=%s)
216 """ % (self.config.type,self.config.fastsim)
217 
218  # customize the configuration according to the options
219  def customize(self):
220 
221  # adapt the source to the current scenario
222  if not self.config.fragment:
223  self.build_source()
224 
225  # manual override some parameters
226  if self.config.type in ('HIon', ):
227  if self.config.data:
228  if not self.config.fragment:
229  self._fix_parameter( type = 'InputTag', value = 'rawDataCollector', replace = 'rawDataRepacker')
230 
231 # if self.config.type in ('HIon', ):
232 # self.data += """
233 ## Disable HF Noise filters in HIon menu
234 #if 'hltHfreco' in %(dict)s:
235 # %(process)shltHfreco.setNoiseFlags = cms.bool( False )
236 #"""
237 # else:
238 # self.data += """
239 ## Enable HF Noise filters in non-HIon menu
240 #if 'hltHfreco' in %(dict)s:
241 # %(process)shltHfreco.setNoiseFlags = cms.bool( True )
242 #"""
243 
244 # self.data += """
245 ## untracked parameters with NO default in the code
246 #if 'hltHcalDataIntegrityMonitor' in %(dict)s:
247 # %(process)shltHcalDataIntegrityMonitor.RawDataLabel = cms.untracked.InputTag("rawDataCollector")
248 #if 'hltDt4DSegments' in %(dict)s:
249 # %(process)shltDt4DSegments.debug = cms.untracked.bool( False )
250 #"""
251 
252  # if running on MC, adapt the configuration accordingly
253  self.fixForMC()
254 
255  # if requested, remove the HLT prescales
256  self.fixPrescales()
257 
258  # if requested, override all ED/HLTfilters to always pass ("open" mode)
259  self.instrumentOpenMode()
260 
261  # if requested, change all HLTTriggerTypeFilter EDFilters to accept only error events (SelectedTriggerType = 0)
262  self.instrumentErrorEventType()
263 
264  # if requested, instrument the self with the modules and EndPath needed for timing studies
265  self.instrumentTiming()
266 
267  # add version-specific customisations
269 
270  if self.config.fragment:
271  self.data += """
272 # dummyfy hltGetConditions in cff's
273 if 'hltGetConditions' in %(dict)s and 'HLTriggerFirstPath' in %(dict)s :
274  %(process)shltDummyConditions = cms.EDFilter( "HLTBool",
275  result = cms.bool( True )
276  )
277  %(process)sHLTriggerFirstPath.replace(%(process)shltGetConditions,%(process)shltDummyConditions)
278 """
279 
280  # if requested, adapt the configuration for FastSim
281  self.fixForFastSim()
282 
283  else:
284 
285  if self.config.type not in ('Fake',) :
286  if '50ns' in self.config.type :
287  self.data += """
288 # load 2015 Run-2 L1 Menu for 50ns
289 from L1Trigger.Configuration.customise_overwriteL1Menu import L1Menu_Collisions2015_50ns_v1 as loadL1Menu
290 process = loadL1Menu(process)
291 """
292  elif 'HIon' in self.config.type :
293  self.data += """
294 # load 2015 Run-2 L1 Menu for HIon
295 from L1Trigger.Configuration.customise_overwriteL1Menu import L1Menu_CollisionsHeavyIons2015_v0 as loadL1Menu
296 process = loadL1Menu(process)
297 """
298  else :
299  self.data += """
300 # load 2015 Run-2 L1 Menu for 25ns (default for GRun, PIon)
301 from L1Trigger.Configuration.customise_overwriteL1Menu import L1Menu_Collisions2015_25ns_v2 as loadL1menu
302 process = loadL1menu(process)
303 """
304 
305  # override the process name and adapt the relevant filters
306  self.overrideProcessName()
307 
308  # override the output modules to output root files
309  self.overrideOutput()
310 
311  # add global options
312  self.addGlobalOptions()
313 
314  # if requested or necessary, override the GlobalTag and connection strings (incl. L1!)
315  self.overrideGlobalTag()
316 
317  # if requested, override the L1 self from the GlobalTag (Xml)
318  self.overrideL1MenuXml()
319 
320  # if requested, add snippet to run on new L1 skim
321  self.switchToNewL1Skim()
322 
323  # if requested, run (part of) the L1 emulator
324  self.runL1Emulator()
325 
326  # request summary informations from the MessageLogger
327  self.updateMessageLogger()
328 
329  # replace DQMStore and DQMRootOutputModule with a configuration suitable for running offline
330  self.instrumentDQM()
331 
332  # load 5.2.x JECs, until they are in the GlobalTag
333 # self.loadAdditionalConditions('load 5.2.x JECs',
334 # {
335 # 'record' : 'JetCorrectionsRecord',
336 # 'tag' : 'JetCorrectorParametersCollection_AK5Calo_2012_V8_hlt_mc',
337 # 'label' : 'AK5CaloHLT',
338 # 'connect' : '%(connect)s/CMS_CONDITIONS'
339 # }, {
340 # 'record' : 'JetCorrectionsRecord',
341 # 'tag' : 'JetCorrectorParametersCollection_AK5PF_2012_V8_hlt_mc',
342 # 'label' : 'AK5PFHLT',
343 # 'connect' : '%(connect)s/CMS_CONDITIONS'
344 # }, {
345 # 'record' : 'JetCorrectionsRecord',
346 # 'tag' : 'JetCorrectorParametersCollection_AK5PFchs_2012_V8_hlt_mc',
347 # 'label' : 'AK5PFchsHLT',
348 # 'connect' : '%(connect)s/CMS_CONDITIONS'
349 # }
350 # )
351 
352 
353  def addGlobalOptions(self):
354  # add global options
355  self.data += """
356 # limit the number of events to be processed
357 %%(process)smaxEvents = cms.untracked.PSet(
358  input = cms.untracked.int32( %d )
359 )
360 """ % self.config.events
361 
362  if not self.config.profiling:
363  self.data += """
364 # enable the TrigReport and TimeReport
365 %(process)soptions = cms.untracked.PSet(
366  wantSummary = cms.untracked.bool( True )
367 )
368 """
369 
370 
371  def _fix_parameter(self, **args):
372  """arguments:
373  name: parameter name (optional)
374  type: parameter type (look for tracked and untracked variants)
375  value: original value
376  replace: replacement value
377  """
378  if 'name' in args:
379  self.data = re.sub(
380  r'%(name)s = cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
381  r'%(name)s = cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
382  self.data)
383  else:
384  self.data = re.sub(
385  r'cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
386  r'cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
387  self.data)
388 
389 
390  def fixForMC(self):
391  if not self.config.data:
392  # customise the HLT menu for running on MC
393  if not self.config.fragment:
394  self.data += """
395 # customise the HLT menu for running on MC
396 from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
397 process = customizeHLTforMC(process)
398 """
399 
400 
401  def fixForFastSim(self):
402  if self.config.fastsim:
403  # adapt the the configuration fragment to run under fastsim
404  self.data = re.compile( r'process = cms\.Process.*$', re.MULTILINE ).sub( r'\g<0>\n\nprocess.load( "FastSimulation.HighLevelTrigger.HLTSetup_cff" )', self.data)
405 
406  # remove the definition of streams and datasets
407  self.data = re.compile( r'^process\.streams.*\n(.*\n)*?^\)\s*\n', re.MULTILINE ).sub( '', self.data )
408  self.data = re.compile( r'^process\.datasets.*\n(.*\n)*?^\)\s*\n', re.MULTILINE ).sub( '', self.data )
409 
410  # fix the definition of some modules
411  # FIXME: this should be updated to take into accout the --l1-emulator option
412  self._fix_parameter( type = 'InputTag', value = 'hltL1extraParticles', replace = 'l1extraParticles')
413  self._fix_parameter(name = 'GMTReadoutCollection', type = 'InputTag', value = 'hltGtDigis', replace = 'simGmtDigis')
414  self._fix_parameter( type = 'InputTag', value = 'hltGtDigis', replace = 'simGtDigis')
415  self._fix_parameter( type = 'InputTag', value = 'hltL1GtObjectMap', replace = 'simGtDigis')
416  self._fix_parameter(name = 'initialSeeds', type = 'InputTag', value = 'noSeedsHere', replace = 'globalPixelSeeds:GlobalPixel')
417  self._fix_parameter(name = 'preFilteredSeeds', type = 'bool', value = 'True', replace = 'False')
418  self._fix_parameter( type = 'InputTag', value = 'hltOfflineBeamSpot', replace = 'offlineBeamSpot')
419  self._fix_parameter( type = 'InputTag', value = 'hltOnlineBeamSpot', replace = 'offlineBeamSpot')
420  self._fix_parameter( type = 'InputTag', value = 'hltMuonCSCDigis', replace = 'simMuonCSCDigis')
421  self._fix_parameter( type = 'InputTag', value = 'hltMuonDTDigis', replace = 'simMuonDTDigis')
422  self._fix_parameter( type = 'InputTag', value = 'hltMuonRPCDigis', replace = 'simMuonRPCDigis')
423  self._fix_parameter( type = 'InputTag', value = 'hltRegionalTracksForL3MuonIsolation', replace = 'hltPixelTracks')
424  self._fix_parameter(name = 'src', type = 'InputTag', value = 'hltHcalTowerNoiseCleaner', replace = 'hltTowerMakerForAll')
425  self._fix_parameter(name = 'src', type = 'InputTag', value = 'hltIter4Tau3MuMerged', replace = 'hltIter4Merged')
426 
427  # MeasurementTrackerEvent
428  self._fix_parameter( type = 'InputTag', value = 'hltSiStripClusters', replace = 'MeasurementTrackerEvent')
429 
430  # fix the definition of sequences and paths
431  self.data = re.sub( r'process.hltMuonCSCDigis', r'cms.SequencePlaceholder( "simMuonCSCDigis" )', self.data )
432  self.data = re.sub( r'process.hltMuonDTDigis', r'cms.SequencePlaceholder( "simMuonDTDigis" )', self.data )
433  self.data = re.sub( r'process.hltMuonRPCDigis', r'cms.SequencePlaceholder( "simMuonRPCDigis" )', self.data )
434  self.data = re.sub( r'process.HLTEndSequence', r'cms.SequencePlaceholder( "HLTEndSequence" )', self.data )
435  self.data = re.sub( r'hltGtDigis', r'HLTBeginSequence', self.data )
436 
437 
438  def fixPrescales(self):
439  # update the PrescaleService to match the new list of paths
440  if self.options['paths']:
441  if self.options['paths'][0][0] == '-':
442  # drop requested paths
443  for minuspath in self.options['paths']:
444  path = minuspath[1:]
445  self.data = re.sub(r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path, '', self.data)
446  else:
447  # keep requested paths
448  for path in self.all_paths:
449  if path not in self.options['paths']:
450  self.data = re.sub(r' cms.PSet\( pathName = cms.string\( "%s" \),\n prescales = cms.vuint32\( .* \)\n \),?\n' % path, '', self.data)
451 
452  if self.config.prescale and (self.config.prescale.lower() != 'none'):
453  # TO DO: check that the requested prescale column is valid
454  self.data += """
455 # force the use of a specific HLT prescale column
456 if 'PrescaleService' in %(dict)s:
457  %(process)sPrescaleService.forceDefault = True
458  %(process)sPrescaleService.lvl1DefaultLabel = '%(prescale)s'
459 """
460 
461 
463  if self.config.open:
464  # find all EDfilters
465  filters = [ match[1] for match in re.findall(r'(process\.)?\b(\w+) = cms.EDFilter', self.data) ]
466  re_sequence = re.compile( r'cms\.(Path|Sequence)\((.*)\)' )
467  # remove existing 'cms.ignore' and '~' modifiers
468  self.data = re_sequence.sub( lambda line: re.sub( r'cms\.ignore *\( *((process\.)?\b(\w+)) *\)', r'\1', line.group(0) ), self.data )
469  self.data = re_sequence.sub( lambda line: re.sub( r'~', '', line.group(0) ), self.data )
470  # wrap all EDfilters with "cms.ignore( ... )", 1000 at a time (python 2.6 complains for too-big regular expressions)
471  for some in splitter(filters, 1000):
472  re_filters = re.compile( r'\b((process\.)?(' + r'|'.join(some) + r'))\b' )
473  self.data = re_sequence.sub( lambda line: re_filters.sub( r'cms.ignore( \1 )', line.group(0) ), self.data )
474 
475 
477  if self.config.errortype:
478  # change all HLTTriggerTypeFilter EDFilters to accept only error events (SelectedTriggerType = 0)
479  self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '1', replace = '0')
480  self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '2', replace = '0')
481  self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '3', replace = '0')
482 
483 
484  def overrideGlobalTag(self):
485  # overwrite GlobalTag
486  # the logic is:
487  # - always set the correct connection string and pfnPrefix
488  # - if a GlobalTag is specified on the command line:
489  # - override the global tag
490  # - if the GT is "auto:...", insert the code to read it from Configuration.AlCa.autoCond
491  # - if a GlobalTag is NOT specified on the command line:
492  # - when running on data, do nothing, and keep the global tag in the menu
493  # - when running on mc, take the GT from the configuration.type
494 
495  # override the GlobalTag connection string and pfnPrefix
496  text = """
497 # override the GlobalTag, connection string and pfnPrefix
498 if 'GlobalTag' in %(dict)s:
499 """
500 
501  # when running on MC, override the global tag even if not specified on the command line
502  if not self.config.data and not self.config.globaltag:
503  if self.config.type in globalTag:
504  self.config.globaltag = globalTag[self.config.type]
505  else:
506  self.config.globaltag = globalTag['GRun']
507 
508  # if requested, override the L1 menu from the GlobalTag (using the same connect as the GlobalTag itself)
509  if self.config.l1.override:
510  self.config.l1.record = 'L1GtTriggerMenuRcd'
511  self.config.l1.label = ''
512  self.config.l1.tag = self.config.l1.override
513  if not self.config.l1.connect:
514  self.config.l1.connect = '%(connect)s/CMS_CONDITIONS'
515  self.config.l1cond = '%(tag)s,%(record)s,%(connect)s' % self.config.l1.__dict__
516  else:
517  self.config.l1cond = None
518 
519  if self.config.globaltag or self.config.l1cond:
520  text += " from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag as customiseGlobalTag\n"
521  text += " %(process)sGlobalTag = customiseGlobalTag(%(process)sGlobalTag"
522  if self.config.globaltag:
523  text += ", globaltag = %s" % repr(self.config.globaltag)
524  if self.config.l1cond:
525  text += ", conditions = %s" % repr(self.config.l1cond)
526  text += ")\n"
527 
528  text += """ %(process)sGlobalTag.connect = '%(connect)s/CMS_CONDITIONS'
529  %(process)sGlobalTag.pfnPrefix = cms.untracked.string('%(connect)s/')
530  for pset in process.GlobalTag.toGet.value():
531  pset.connect = pset.connect.value().replace('frontier://FrontierProd/', '%(connect)s/')
532  # fix for multi-run processing
533  %(process)sGlobalTag.RefreshEachRun = cms.untracked.bool( False )
534  %(process)sGlobalTag.ReconnectEachRun = cms.untracked.bool( False )
535 """
536  self.data += text
537 
538  def overrideL1MenuXml(self):
539  # if requested, override the L1 menu from the GlobalTag (Xml file)
540  if self.config.l1Xml.XmlFile:
541  text = """
542 # override the L1 menu from an Xml file
543 %%(process)sl1GtTriggerMenuXml = cms.ESProducer("L1GtTriggerMenuXmlProducer",
544  TriggerMenuLuminosity = cms.string('%(LumiDir)s'),
545  DefXmlFile = cms.string('%(XmlFile)s'),
546  VmeXmlFile = cms.string('')
547 )
548 %%(process)sL1GtTriggerMenuRcdSource = cms.ESSource("EmptyESSource",
549  recordName = cms.string('L1GtTriggerMenuRcd'),
550  iovIsRunNotTime = cms.bool(True),
551  firstValid = cms.vuint32(1)
552 )
553 %%(process)ses_prefer_l1GtParameters = cms.ESPrefer('L1GtTriggerMenuXmlProducer','l1GtTriggerMenuXml')
554 """
555  self.data += text % self.config.l1Xml.__dict__
556 
557  def runL1EmulatorGT(self):
558  # if requested, run (part of) the L1 emulator, then repack the data into a new RAW collection, to be used by the HLT
559  if not self.config.emulator:
560  return
561 
562  if self.config.emulator != 'gt':
563  # only the GT emulator is currently supported
564  return
565 
566  # run the L1 GT emulator, then repack the data into a new RAW collection, to be used by the HLT
567  text = """
568 # run the L1 GT emulator, then repack the data into a new RAW collection, to be used by the HLT
569 """
570  if self.config.fragment:
571  # FIXME in a cff, should also update the HLTSchedule
572  text += "import Configuration.StandardSequences.SimL1EmulatorRepack_GT_cff\n"
573  else:
574  text += "process.load( 'Configuration.StandardSequences.SimL1EmulatorRepack_GT_cff' )\n"
575 
576  if not 'hltBoolFalse' in self.data:
577  # add hltBoolFalse
578  text += """
579 %(process)shltBoolFalse = cms.EDFilter( "HLTBool",
580  result = cms.bool( False )
581 )
582 """
583  text += "process.L1Emulator = cms.Path( process.SimL1Emulator + process.hltBoolFalse )\n\n"
584 
585  self.data = re.sub(r'.*cms\.(End)?Path.*', text + r'\g<0>', self.data, 1)
586 
587 
588  def runL1Emulator(self):
589  # if requested, run (part of) the L1 emulator
590  if self.config.emulator:
591  # FIXME this fragment used "process" explicitly
592  emulator = {
593  'RawToDigi': '',
594  'CustomL1T': '',
595  'CustomHLT': ''
596  }
597 
598  if self.config.data:
599  emulator['RawToDigi'] = 'RawToDigi_Data_cff'
600  else:
601  emulator['RawToDigi'] = 'RawToDigi_cff'
602 
603  if self.config.emulator == 'gt':
604  emulator['CustomL1T'] = 'customiseL1GtEmulatorFromRaw'
605  emulator['CustomHLT'] = 'switchToSimGtDigis'
606  elif self.config.emulator == 'gct,gt':
607  emulator['CustomL1T'] = 'customiseL1CaloAndGtEmulatorsFromRaw'
608  emulator['CustomHLT'] = 'switchToSimGctGtDigis'
609  elif self.config.emulator == 'gmt,gt':
610  # XXX currently unsupported
611  emulator['CustomL1T'] = 'customiseL1MuonAndGtEmulatorsFromRaw'
612  emulator['CustomHLT'] = 'switchToSimGmtGtDigis'
613  elif self.config.emulator in ('gmt,gct,gt', 'gct,gmt,gt', 'all'):
614  emulator['CustomL1T'] = 'customiseL1EmulatorFromRaw'
615  emulator['CustomHLT'] = 'switchToSimGmtGctGtDigis'
616  elif self.config.emulator in ('stage1,gt'):
617  emulator['CustomL1T'] = 'customiseL1EmulatorFromRaw'
618  emulator['CustomHLT'] = 'switchToSimStage1Digis'
619  else:
620  # unsupported argument, default to running the whole emulator
621  emulator['CustomL1T'] = 'customiseL1EmulatorFromRaw'
622  emulator['CustomHLT'] = 'switchToSimGmtGctGtDigis'
623 
624  self.data += """
625 # customize the L1 emulator to run %(CustomL1T)s with HLT to %(CustomHLT)s
626 process.load( 'Configuration.StandardSequences.%(RawToDigi)s' )
627 process.load( 'Configuration.StandardSequences.SimL1Emulator_cff' )
628 import L1Trigger.Configuration.L1Trigger_custom
629 #
630 """ % emulator
631 
632  if (self.config.emulator).find("stage1")>-1:
633  self.data += """
634 # 2015 Run2 emulator
635 import L1Trigger.L1TCalorimeter.L1TCaloStage1_customForHLT
636 process = L1Trigger.L1TCalorimeter.L1TCaloStage1_customForHLT.%(CustomL1T)s( process )
637 """ % emulator
638  else:
639  self.data += """
640 # Run1 Emulator
641 process = L1Trigger.Configuration.L1Trigger_custom.%(CustomL1T)s( process )
642 """ % emulator
643 
644  self.data += """
645 #
646 process = L1Trigger.Configuration.L1Trigger_custom.customiseResetPrescalesAndMasks( process )
647 # customize the HLT to use the emulated results
648 import HLTrigger.Configuration.customizeHLTforL1Emulator
649 process = HLTrigger.Configuration.customizeHLTforL1Emulator.switchToL1Emulator( process )
650 process = HLTrigger.Configuration.customizeHLTforL1Emulator.%(CustomHLT)s( process )
651 """ % emulator
652 
653  def switchToNewL1Skim(self):
654  # add snippet to switch to new L1 skim files
655  if self.config.l1skim:
656  self.data += """
657 # Customize the menu to use information from new L1 emulator in the L1 skim files
658 process.hltL2MuonSeeds.GMTReadoutCollection = cms.InputTag("simGmtDigis::L1SKIM" )
659 process.hltL1extraParticles.muonSource = cms.InputTag("simGmtDigis::L1SKIM" )
660 for module in process.__dict__.itervalues():
661  if isinstance(module, cms._Module):
662  for parameter in module.__dict__.itervalues():
663  if isinstance(parameter, cms.InputTag):
664  if parameter.moduleLabel == 'hltGtDigis':
665  parameter.moduleLabel = "gtDigisFromSkim"
666  elif parameter.moduleLabel == 'hltL1GtObjectMap':
667  parameter.moduleLabel = "gtDigisFromSkim"
668  elif parameter.moduleLabel == 'hltGctDigis':
669  parameter.moduleLabel ="simCaloStage1LegacyFormatDigis"
670 """
671 
672  def overrideOutput(self):
673  # override the "online" ShmStreamConsumer output modules with "offline" PoolOutputModule's
674  self.data = re.sub(
675  r'\b(process\.)?hltOutput(\w+) *= *cms\.OutputModule\( *"ShmStreamConsumer" *,',
676  r'%(process)shltOutput\2 = cms.OutputModule( "PoolOutputModule",\n fileName = cms.untracked.string( "output\2.root" ),\n fastCloning = cms.untracked.bool( False ),\n dataset = cms.untracked.PSet(\n filterName = cms.untracked.string( "" ),\n dataTier = cms.untracked.string( "RAW" )\n ),',
677  self.data
678  )
679 
680  if not self.config.fragment and self.config.output == 'full':
681  # add a single "keep *" output
682  self.data += """
683 # add a single "keep *" output
684 %(process)shltOutputFULL = cms.OutputModule( "PoolOutputModule",
685  fileName = cms.untracked.string( "outputFULL.root" ),
686  fastCloning = cms.untracked.bool( False ),
687  dataset = cms.untracked.PSet(
688  dataTier = cms.untracked.string( 'RECO' ),
689  filterName = cms.untracked.string( '' )
690  ),
691  outputCommands = cms.untracked.vstring( 'keep *' )
692 )
693 %(process)sFULLOutput = cms.EndPath( %(process)shltOutputFULL )
694 """
695 
696 
697  # override the process name and adapt the relevant filters
699  if self.config.name is None:
700  return
701 
702  # sanitise process name
703  self.config.name = self.config.name.replace("_","")
704  # override the process name
705  quote = '[\'\"]'
706  self.data = re.compile(r'^(process\s*=\s*cms\.Process\(\s*' + quote + r')\w+(' + quote + r'\s*\).*)$', re.MULTILINE).sub(r'\1%s\2' % self.config.name, self.data, 1)
707 
708  # the following was stolen and adapted from HLTrigger.Configuration.customL1THLT_Options
709  self.data += """
710 # adapt HLT modules to the correct process name
711 if 'hltTrigReport' in %%(dict)s:
712  %%(process)shltTrigReport.HLTriggerResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
713 
714 if 'hltPreExpressCosmicsOutputSmart' in %%(dict)s:
715  %%(process)shltPreExpressCosmicsOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
716 
717 if 'hltPreExpressOutputSmart' in %%(dict)s:
718  %%(process)shltPreExpressOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
719 
720 if 'hltPreDQMForHIOutputSmart' in %%(dict)s:
721  %%(process)shltPreDQMForHIOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
722 
723 if 'hltPreDQMForPPOutputSmart' in %%(dict)s:
724  %%(process)shltPreDQMForPPOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
725 
726 if 'hltPreHLTDQMResultsOutputSmart' in %%(dict)s:
727  %%(process)shltPreHLTDQMResultsOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
728 
729 if 'hltPreHLTDQMOutputSmart' in %%(dict)s:
730  %%(process)shltPreHLTDQMOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
731 
732 if 'hltPreHLTMONOutputSmart' in %%(dict)s:
733  %%(process)shltPreHLTMONOutputSmart.hltResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
734 
735 if 'hltDQMHLTScalers' in %%(dict)s:
736  %%(process)shltDQMHLTScalers.triggerResults = cms.InputTag( 'TriggerResults', '', '%(name)s' )
737  %%(process)shltDQMHLTScalers.processname = '%(name)s'
738 
739 if 'hltDQML1SeedLogicScalers' in %%(dict)s:
740  %%(process)shltDQML1SeedLogicScalers.processname = '%(name)s'
741 """ % self.config.__dict__
742 
743 
745  # request summary informations from the MessageLogger
746  self.data += """
747 if 'MessageLogger' in %(dict)s:
748  %(process)sMessageLogger.categories.append('TriggerSummaryProducerAOD')
749  %(process)sMessageLogger.categories.append('L1GtTrigReport')
750  %(process)sMessageLogger.categories.append('HLTrigReport')
751  %(process)sMessageLogger.categories.append('FastReport')
752 """
753 
754 
755  def loadAdditionalConditions(self, comment, *conditions):
756  # load additional conditions
757  self.data += """
758 # %s
759 if 'GlobalTag' in %%(dict)s:
760 """ % comment
761  for condition in conditions:
762  self.data += """ %%(process)sGlobalTag.toGet.append(
763  cms.PSet(
764  record = cms.string( '%(record)s' ),
765  tag = cms.string( '%(tag)s' ),
766  label = cms.untracked.string( '%(label)s' ),
767  connect = cms.untracked.string( '%(connect)s' )
768  )
769  )
770 """ % condition
771 
772 
773  def loadCffCommand(self, module):
774  # load a cfi or cff module
775  if self.config.fragment:
776  return 'from %s import *\n' % module
777  else:
778  return 'process.load( "%s" )\n' % module
779 
780  def loadCff(self, module):
781  self.data += self.loadCffCommand(module)
782 
783 
784  def overrideParameters(self, module, parameters):
785  # override a module's parameter if the module is present in the configuration
786  self.data += "if '%s' in %%(dict)s:\n" % module
787  for (parameter, value) in parameters:
788  self.data += " %%(process)s%s.%s = %s\n" % (module, parameter, value)
789  self.data += "\n"
790 
791 
792  def instrumentTiming(self):
793  if self.config.profiling:
794  # instrument the menu for profiling: remove the HLTAnalyzerEndpath, add/override the HLTriggerFirstPath, with hltGetRaw and hltGetConditions
795  text = ''
796 
797  if not 'hltGetRaw' in self.data:
798  # add hltGetRaw
799  text += """
800 %(process)shltGetRaw = cms.EDAnalyzer( "HLTGetRaw",
801  RawDataCollection = cms.InputTag( "rawDataCollector" )
802 )
803 """
804 
805  if not 'hltGetConditions' in self.data:
806  # add hltGetConditions
807  text += """
808 %(process)shltGetConditions = cms.EDAnalyzer( 'EventSetupRecordDataGetter',
809  verbose = cms.untracked.bool( False ),
810  toGet = cms.VPSet( )
811 )
812 """
813 
814  if not 'hltBoolFalse' in self.data:
815  # add hltBoolFalse
816  text += """
817 %(process)shltBoolFalse = cms.EDFilter( "HLTBool",
818  result = cms.bool( False )
819 )
820 """
821 
822  # add the definition of HLTriggerFirstPath
823  # FIXME in a cff, should also update the HLTSchedule
824  text += """
825 %(process)sHLTriggerFirstPath = cms.Path( %(process)shltGetRaw + %(process)shltGetConditions + %(process)shltBoolFalse )
826 """
827  self.data = re.sub(r'.*cms\.(End)?Path.*', text + r'\g<0>', self.data, 1)
828 
829 
830  # instrument the menu with the Service, EDProducer and EndPath needed for timing studies
831  # FIXME in a cff, should also update the HLTSchedule
832  if self.config.timing:
833  self.data += """
834 # instrument the menu with the modules and EndPath needed for timing studies
835 """
836 
837  if not 'FastTimerService' in self.data:
838  self.data += '\n# configure the FastTimerService\n'
839  self.loadCff('HLTrigger.Timer.FastTimerService_cfi')
840  else:
841  self.data += '\n# configure the FastTimerService\n'
842 
843  self.data += """# this is currently ignored in CMSSW 7.x, always using the real time clock
844 %(process)sFastTimerService.useRealTimeClock = True
845 # enable specific features
846 %(process)sFastTimerService.enableTimingPaths = True
847 %(process)sFastTimerService.enableTimingModules = True
848 %(process)sFastTimerService.enableTimingExclusive = True
849 # print a text summary at the end of the job
850 %(process)sFastTimerService.enableTimingSummary = True
851 # skip the first path (disregard the time spent loading event and conditions data)
852 %(process)sFastTimerService.skipFirstPath = True
853 # enable DQM plots
854 %(process)sFastTimerService.enableDQM = True
855 # enable most per-path DQM plots
856 %(process)sFastTimerService.enableDQMbyPathActive = True
857 %(process)sFastTimerService.enableDQMbyPathTotal = True
858 %(process)sFastTimerService.enableDQMbyPathOverhead = False
859 %(process)sFastTimerService.enableDQMbyPathDetails = True
860 %(process)sFastTimerService.enableDQMbyPathCounters = True
861 %(process)sFastTimerService.enableDQMbyPathExclusive = True
862 # disable per-module DQM plots
863 %(process)sFastTimerService.enableDQMbyModule = False
864 %(process)sFastTimerService.enableDQMbyModuleType = False
865 # enable per-event DQM sumary plots
866 %(process)sFastTimerService.enableDQMSummary = True
867 # enable per-event DQM plots by lumisection
868 %(process)sFastTimerService.enableDQMbyLumiSection = True
869 %(process)sFastTimerService.dqmLumiSectionsRange = 2500
870 # set the time resolution of the DQM plots
871 %(process)sFastTimerService.dqmTimeRange = 1000.
872 %(process)sFastTimerService.dqmTimeResolution = 5.
873 %(process)sFastTimerService.dqmPathTimeRange = 100.
874 %(process)sFastTimerService.dqmPathTimeResolution = 0.5
875 %(process)sFastTimerService.dqmModuleTimeRange = 40.
876 %(process)sFastTimerService.dqmModuleTimeResolution = 0.2
877 # set the base DQM folder for the plots
878 %(process)sFastTimerService.dqmPath = 'HLT/TimerService'
879 %(process)sFastTimerService.enableDQMbyProcesses = True
880 """
881 
882 
883  def instrumentDQM(self):
884  if not self.config.hilton:
885  # remove any reference to the hltDQMFileSaver
886  if 'hltDQMFileSaver' in self.data:
887  self.data = re.sub(r'\b(process\.)?hltDQMFileSaver \+ ', '', self.data)
888  self.data = re.sub(r' \+ \b(process\.)?hltDQMFileSaver', '', self.data)
889  self.data = re.sub(r'\b(process\.)?hltDQMFileSaver', '', self.data)
890 
891  # instrument the HLT menu with DQMStore and DQMRootOutputModule suitable for running offline
892  dqmstore = "\n# load the DQMStore and DQMRootOutputModule\n"
893  dqmstore += self.loadCffCommand('DQMServices.Core.DQMStore_cfi')
894  dqmstore += "%(process)sDQMStore.enableMultiThread = True\n"
895  dqmstore += """
896 %(process)sdqmOutput = cms.OutputModule("DQMRootOutputModule",
897  fileName = cms.untracked.string("DQMIO.root")
898 )
899 """
900 
901  empty_path = re.compile(r'.*\b(process\.)?DQMOutput = cms\.EndPath\( *\).*')
902  other_path = re.compile(r'(.*\b(process\.)?DQMOutput = cms\.EndPath\()(.*)')
903  if empty_path.search(self.data):
904  # replace an empty DQMOutput path
905  self.data = empty_path.sub(dqmstore + '\n%(process)sDQMOutput = cms.EndPath( %(process)sdqmOutput )\n', self.data)
906  elif other_path.search(self.data):
907  # prepend the dqmOutput to the DQMOutput path
908  self.data = other_path.sub(dqmstore + r'\g<1> %(process)sdqmOutput +\g<3>', self.data)
909  else:
910  # ceate a new DQMOutput path with the dqmOutput module
911  self.data += dqmstore
912  self.data += '\n%(process)sDQMOutput = cms.EndPath( %(process)sdqmOutput )\n'
913 
914 
915  @staticmethod
916  def dumppaths(paths):
917  sys.stderr.write('Path selection:\n')
918  for path in paths:
919  sys.stderr.write('\t%s\n' % path)
920  sys.stderr.write('\n\n')
921 
922  def buildPathList(self):
923  self.all_paths = self.getPathList()
924 
925  if self.config.paths:
926  # no path list was requested, dump the full table, minus unsupported / unwanted paths
927  paths = self.config.paths.split(',')
928  else:
929  # dump only the requested paths, plus the eventual output endpaths
930  paths = []
931 
932  if self.config.fragment or self.config.output in ('none', 'full'):
933  # 'full' removes all outputs (same as 'none') and then adds a single "keep *" output (see the overrideOutput method)
934  if self.config.paths:
935  # paths are removed by default
936  pass
937  else:
938  # drop all output endpaths
939  paths.append( "-*Output" )
940  elif self.config.output == 'minimal':
941  # drop all output endpaths but HLTDQMResultsOutput
942  if self.config.paths:
943  paths.append( "HLTDQMResultsOutput" )
944  else:
945  paths.append( "-*Output" )
946  paths.append( "HLTDQMResultsOutput" )
947  else:
948  # keep / add back all output endpaths
949  if self.config.paths:
950  paths.append( "*Output" )
951  else:
952  pass # paths are kepy by default
953 
954  # drop paths unsupported by fastsim
955  if self.config.fastsim:
956  paths.extend( "-%s" % path for path in self.fastsimUnsupportedPaths )
957 
958  # drop unwanted paths for profiling (and timing studies)
959  if self.config.profiling:
960  paths.append( "-HLTriggerFirstPath" )
961  paths.append( "-HLTAnalyzerEndpath" )
962 
963  # this should never be in any dump (nor online menu)
964  paths.append( "-OfflineOutput" )
965 
966  # expand all wildcards
967  paths = self.expandWildcards(paths, self.all_paths)
968 
969  if self.config.paths:
970  # do an "additive" consolidation
971  self.options['paths'] = self.consolidatePositiveList(paths)
972  if not self.options['paths']:
973  raise RuntimeError('Error: option "--paths %s" does not select any valid paths' % self.config.paths)
974  else:
975  # do a "subtractive" consolidation
976  self.options['paths'] = self.consolidateNegativeList(paths)
977 
978 
979  def buildOptions(self):
980  # common configuration for all scenarios
981  self.options['services'].append( "-DQM" )
982  self.options['services'].append( "-FUShmDQMOutputService" )
983  self.options['services'].append( "-MicroStateService" )
984  self.options['services'].append( "-ModuleWebRegistry" )
985  self.options['services'].append( "-TimeProfilerService" )
986 
987  # remove the DAQ modules and the online definition of the DQMStore and DQMFileSaver
988  # unless a hilton-like configuration has been requested
989  if not self.config.hilton:
990  self.options['services'].append( "-EvFDaqDirector" )
991  self.options['services'].append( "-FastMonitoringService" )
992  self.options['services'].append( "-DQMStore" )
993  self.options['modules'].append( "-hltDQMFileSaver" )
994 
995  if self.config.fragment:
996  # extract a configuration file fragment
997  self.options['essources'].append( "-GlobalTag" )
998  self.options['essources'].append( "-HepPDTESSource" )
999  self.options['essources'].append( "-XMLIdealGeometryESSource" )
1000  self.options['essources'].append( "-eegeom" )
1001  self.options['essources'].append( "-es_hardcode" )
1002  self.options['essources'].append( "-magfield" )
1003 
1004  self.options['esmodules'].append( "-AutoMagneticFieldESProducer" )
1005  self.options['esmodules'].append( "-SlaveField0" )
1006  self.options['esmodules'].append( "-SlaveField20" )
1007  self.options['esmodules'].append( "-SlaveField30" )
1008  self.options['esmodules'].append( "-SlaveField35" )
1009  self.options['esmodules'].append( "-SlaveField38" )
1010  self.options['esmodules'].append( "-SlaveField40" )
1011  self.options['esmodules'].append( "-VBF0" )
1012  self.options['esmodules'].append( "-VBF20" )
1013  self.options['esmodules'].append( "-VBF30" )
1014  self.options['esmodules'].append( "-VBF35" )
1015  self.options['esmodules'].append( "-VBF38" )
1016  self.options['esmodules'].append( "-VBF40" )
1017  self.options['esmodules'].append( "-CSCGeometryESModule" )
1018  self.options['esmodules'].append( "-CaloGeometryBuilder" )
1019  self.options['esmodules'].append( "-CaloTowerHardcodeGeometryEP" )
1020  self.options['esmodules'].append( "-CastorHardcodeGeometryEP" )
1021  self.options['esmodules'].append( "-DTGeometryESModule" )
1022  self.options['esmodules'].append( "-EcalBarrelGeometryEP" )
1023  self.options['esmodules'].append( "-EcalElectronicsMappingBuilder" )
1024  self.options['esmodules'].append( "-EcalEndcapGeometryEP" )
1025  self.options['esmodules'].append( "-EcalLaserCorrectionService" )
1026  self.options['esmodules'].append( "-EcalPreshowerGeometryEP" )
1027  self.options['esmodules'].append( "-HcalHardcodeGeometryEP" )
1028  self.options['esmodules'].append( "-HcalTopologyIdealEP" )
1029  self.options['esmodules'].append( "-MuonNumberingInitialization" )
1030  self.options['esmodules'].append( "-ParametrizedMagneticFieldProducer" )
1031  self.options['esmodules'].append( "-RPCGeometryESModule" )
1032  self.options['esmodules'].append( "-SiStripGainESProducer" )
1033  self.options['esmodules'].append( "-SiStripRecHitMatcherESProducer" )
1034  self.options['esmodules'].append( "-SiStripQualityESProducer" )
1035  self.options['esmodules'].append( "-StripCPEfromTrackAngleESProducer" )
1036  self.options['esmodules'].append( "-TrackerDigiGeometryESModule" )
1037  self.options['esmodules'].append( "-TrackerGeometricDetESModule" )
1038  self.options['esmodules'].append( "-VolumeBasedMagneticFieldESProducer" )
1039  self.options['esmodules'].append( "-ZdcHardcodeGeometryEP" )
1040  self.options['esmodules'].append( "-hcal_db_producer" )
1041  self.options['esmodules'].append( "-L1GtTriggerMaskAlgoTrigTrivialProducer" )
1042  self.options['esmodules'].append( "-L1GtTriggerMaskTechTrigTrivialProducer" )
1043  self.options['esmodules'].append( "-hltESPEcalTrigTowerConstituentsMapBuilder" )
1044  self.options['esmodules'].append( "-hltESPGlobalTrackingGeometryESProducer" )
1045  self.options['esmodules'].append( "-hltESPMuonDetLayerGeometryESProducer" )
1046  self.options['esmodules'].append( "-hltESPTrackerRecoGeometryESProducer" )
1047  self.options['esmodules'].append( "-trackerTopology" )
1048 
1049  if not self.config.fastsim:
1050  self.options['esmodules'].append( "-CaloTowerGeometryFromDBEP" )
1051  self.options['esmodules'].append( "-CastorGeometryFromDBEP" )
1052  self.options['esmodules'].append( "-EcalBarrelGeometryFromDBEP" )
1053  self.options['esmodules'].append( "-EcalEndcapGeometryFromDBEP" )
1054  self.options['esmodules'].append( "-EcalPreshowerGeometryFromDBEP" )
1055  self.options['esmodules'].append( "-HcalGeometryFromDBEP" )
1056  self.options['esmodules'].append( "-ZdcGeometryFromDBEP" )
1057  self.options['esmodules'].append( "-XMLFromDBSource" )
1058  self.options['esmodules'].append( "-sistripconn" )
1059 
1060  self.options['services'].append( "-MessageLogger" )
1061 
1062  self.options['psets'].append( "-maxEvents" )
1063  self.options['psets'].append( "-options" )
1064 
1065  if self.config.fragment or (self.config.prescale and (self.config.prescale.lower() == 'none')):
1066  self.options['services'].append( "-PrescaleService" )
1067 
1068  if self.config.fragment or self.config.timing:
1069  self.options['services'].append( "-FastTimerService" )
1070 
1071  if self.config.fastsim:
1072  # remove components not supported or needed by fastsim
1073  self.options['esmodules'].append( "-navigationSchoolESProducer" )
1074  self.options['esmodules'].append( "-TransientTrackBuilderESProducer" )
1075  self.options['esmodules'].append( "-SteppingHelixPropagatorAny" )
1076  self.options['esmodules'].append( "-OppositeMaterialPropagator" )
1077  self.options['esmodules'].append( "-MaterialPropagator" )
1078  self.options['esmodules'].append( "-CaloTowerConstituentsMapBuilder" )
1079  self.options['esmodules'].append( "-CaloTopologyBuilder" )
1080 
1081  self.options['modules'].append( "hltL3MuonIsolations" )
1082  self.options['modules'].append( "hltPixelVertices" )
1083  self.options['modules'].append( "-hltCkfL1SeededTrackCandidates" )
1084  self.options['modules'].append( "-hltCtfL1SeededithMaterialTracks" )
1085  self.options['modules'].append( "-hltCkf3HitL1SeededTrackCandidates" )
1086  self.options['modules'].append( "-hltCtf3HitL1SeededWithMaterialTracks" )
1087  self.options['modules'].append( "-hltCkf3HitActivityTrackCandidates" )
1088  self.options['modules'].append( "-hltCtf3HitActivityWithMaterialTracks" )
1089  self.options['modules'].append( "-hltActivityCkfTrackCandidatesForGSF" )
1090  self.options['modules'].append( "-hltL1SeededCkfTrackCandidatesForGSF" )
1091  self.options['modules'].append( "-hltMuCkfTrackCandidates" )
1092  self.options['modules'].append( "-hltMuCtfTracks" )
1093  self.options['modules'].append( "-hltTau3MuCkfTrackCandidates" )
1094  self.options['modules'].append( "-hltTau3MuCtfWithMaterialTracks" )
1095  self.options['modules'].append( "-hltMuTrackJpsiCkfTrackCandidates" )
1096  self.options['modules'].append( "-hltMuTrackJpsiCtfTracks" )
1097  self.options['modules'].append( "-hltMuTrackJpsiEffCkfTrackCandidates" )
1098  self.options['modules'].append( "-hltMuTrackJpsiEffCtfTracks" )
1099  self.options['modules'].append( "-hltJpsiTkPixelSeedFromL3Candidate" )
1100  self.options['modules'].append( "-hltCkfTrackCandidatesJpsiTk" )
1101  self.options['modules'].append( "-hltCtfWithMaterialTracksJpsiTk" )
1102  self.options['modules'].append( "-hltMuTrackCkfTrackCandidatesOnia" )
1103  self.options['modules'].append( "-hltMuTrackCtfTracksOnia" )
1104 
1105  self.options['modules'].append( "-hltFEDSelector" )
1106  self.options['modules'].append( "-hltL3TrajSeedOIHit" )
1107  self.options['modules'].append( "-hltL3TrajSeedIOHit" )
1108  self.options['modules'].append( "-hltL3NoFiltersTrajSeedOIHit" )
1109  self.options['modules'].append( "-hltL3NoFiltersTrajSeedIOHit" )
1110  self.options['modules'].append( "-hltL3TrackCandidateFromL2OIState" )
1111  self.options['modules'].append( "-hltL3TrackCandidateFromL2OIHit" )
1112  self.options['modules'].append( "-hltL3TrackCandidateFromL2IOHit" )
1113  self.options['modules'].append( "-hltL3TrackCandidateFromL2NoVtx" )
1114  self.options['modules'].append( "-hltHcalDigis" )
1115  self.options['modules'].append( "-hltHoreco" )
1116  self.options['modules'].append( "-hltHfreco" )
1117  self.options['modules'].append( "-hltHbhereco" )
1118  self.options['modules'].append( "-hltESRawToRecHitFacility" )
1119  self.options['modules'].append( "-hltEcalRecHitAll" )
1120  self.options['modules'].append( "-hltESRecHitAll" )
1121  # === eGamma
1122  self.options['modules'].append( "-hltEgammaCkfTrackCandidatesForGSF" )
1123  self.options['modules'].append( "-hltEgammaGsfTracks" )
1124  self.options['modules'].append( "-hltEgammaCkfTrackCandidatesForGSFUnseeded" )
1125  self.options['modules'].append( "-hltEgammaGsfTracksUnseeded" )
1126  # === hltPF
1127  self.options['modules'].append( "-hltPFJetCkfTrackCandidates" )
1128  self.options['modules'].append( "-hltPFJetCtfWithMaterialTracks" )
1129  self.options['modules'].append( "-hltPFlowTrackSelectionHighPurity" )
1130  # === hltFastJet
1131  self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalPixelSeedGenerator" )
1132  self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalCkfTrackCandidates" )
1133  self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalCtfWithMaterialTracks" )
1134  self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalPixelSeedGenerator" )
1135  self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalCkfTrackCandidates" )
1136  self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalCtfWithMaterialTracks" )
1137  self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhiL1FastJet" )
1138  self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhiL1FastJet" )
1139  self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhiL1FastJet" )
1140  self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorHbbVBF" )
1141  self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesHbbVBF" )
1142  self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksHbbVBF" )
1143  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20HbbL1FastJet" )
1144  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20HbbL1FastJet" )
1145  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20HbbL1FastJet" )
1146  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20HbbL1FastJet" )
1147  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20HbbL1FastJet" )
1148  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20HbbL1FastJet" )
1149  # === hltBLifetimeRegional
1150  self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorHbb" )
1151  self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesHbb" )
1152  self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksHbb" )
1153  self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhi" )
1154  self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhi" )
1155  self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhi" )
1156  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20Hbb" )
1157  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20Hbb" )
1158  self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20Hbb" )
1159  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20Hbb" )
1160  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20Hbb" )
1161  self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20Hbb" )
1162  self.options['modules'].append( "-hltBLifetimeFastRegionalPixelSeedGeneratorHbbVBF" )
1163  self.options['modules'].append( "-hltBLifetimeFastRegionalCkfTrackCandidatesHbbVBF" )
1164  self.options['modules'].append( "-hltBLifetimeFastRegionalCtfWithMaterialTracksHbbVBF" )
1165  self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhiL1FastJetFastPV" )
1166  self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhiL1FastJetFastPV" )
1167  self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhiL1FastJetFastPV" )
1168  self.options['modules'].append( "-hltFastPixelBLifetimeRegionalPixelSeedGeneratorHbb" )
1169  self.options['modules'].append( "-hltFastPixelBLifetimeRegionalCkfTrackCandidatesHbb" )
1170  self.options['modules'].append( "-hltFastPixelBLifetimeRegionalCtfWithMaterialTracksHbb" )
1171 
1172  self.options['modules'].append( "-hltPixelTracksForMinBias" )
1173  self.options['modules'].append( "-hltPixelTracksForHighMult" )
1174  self.options['modules'].append( "-hltRegionalPixelTracks" )
1175  self.options['modules'].append( "-hltPixelTracksReg" )
1176  self.options['modules'].append( "-hltPixelTracksL3Muon" )
1177  self.options['modules'].append( "-hltPixelTracksGlbTrkMuon" )
1178  self.options['modules'].append( "-hltPixelTracksHighPtTkMuIso" )
1179  self.options['modules'].append( "-hltPixelTracksHybrid" )
1180  self.options['modules'].append( "-hltPixelTracksForPhotons" )
1181  self.options['modules'].append( "-hltPixelTracksForEgamma" )
1182  self.options['modules'].append( "-hltPixelTracksElectrons" )
1183  self.options['modules'].append( "-hltPixelTracksForNoPU" )
1184 
1185  self.options['modules'].append( "-hltFastPixelHitsVertex" )
1186  self.options['modules'].append( "-hltFastPixelTracks")
1187  self.options['modules'].append( "-hltFastPixelTracksRecover")
1188 
1189  self.options['modules'].append( "-hltPixelLayerPairs" )
1190  self.options['modules'].append( "-hltPixelLayerTriplets" )
1191  self.options['modules'].append( "-hltPixelLayerTripletsReg" )
1192  self.options['modules'].append( "-hltPixelLayerTripletsHITHB" )
1193  self.options['modules'].append( "-hltPixelLayerTripletsHITHE" )
1194  self.options['modules'].append( "-hltMixedLayerPairs" )
1195 
1196  self.options['modules'].append( "-hltFastPrimaryVertexbbPhi")
1197  self.options['modules'].append( "-hltPixelTracksFastPVbbPhi")
1198  self.options['modules'].append( "-hltPixelTracksRecoverbbPhi" )
1199  self.options['modules'].append( "-hltFastPixelHitsVertexVHbb" )
1200  self.options['modules'].append( "-hltFastPixelTracksVHbb" )
1201  self.options['modules'].append( "-hltFastPixelTracksRecoverVHbb" )
1202 
1203  self.options['modules'].append( "-hltFastPrimaryVertex")
1204  self.options['modules'].append( "-hltFastPVPixelVertexFilter")
1205  self.options['modules'].append( "-hltFastPVPixelTracks")
1206  self.options['modules'].append( "-hltFastPVPixelTracksRecover" )
1207 
1208  self.options['modules'].append( "hltPixelMatchElectronsActivity" )
1209 
1210  self.options['modules'].append( "-hltMuonCSCDigis" )
1211  self.options['modules'].append( "-hltMuonDTDigis" )
1212  self.options['modules'].append( "-hltMuonRPCDigis" )
1213  self.options['modules'].append( "-hltGtDigis" )
1214  self.options['modules'].append( "-hltL1GtTrigReport" )
1215  self.options['modules'].append( "hltCsc2DRecHits" )
1216  self.options['modules'].append( "hltDt1DRecHits" )
1217  self.options['modules'].append( "hltRpcRecHits" )
1218  self.options['modules'].append( "-hltScalersRawToDigi" )
1219 
1220  self.options['sequences'].append( "-HLTL1SeededEgammaRegionalRecoTrackerSequence" )
1221  self.options['sequences'].append( "-HLTEcalActivityEgammaRegionalRecoTrackerSequence" )
1222  self.options['sequences'].append( "-HLTPixelMatchElectronActivityTrackingSequence" )
1223  self.options['sequences'].append( "-HLTDoLocalStripSequence" )
1224  self.options['sequences'].append( "-HLTDoLocalPixelSequence" )
1225  self.options['sequences'].append( "-HLTDoLocalPixelSequenceRegL2Tau" )
1226  self.options['sequences'].append( "-HLTDoLocalStripSequenceReg" )
1227  self.options['sequences'].append( "-HLTDoLocalPixelSequenceReg" )
1228  self.options['sequences'].append( "-HLTDoLocalStripSequenceRegForBTag" )
1229  self.options['sequences'].append( "-HLTDoLocalPixelSequenceRegForBTag" )
1230  self.options['sequences'].append( "-HLTDoLocalPixelSequenceRegForNoPU" )
1231  self.options['sequences'].append( "-hltSiPixelDigis" )
1232  self.options['sequences'].append( "-hltSiPixelClusters" )
1233  self.options['sequences'].append( "-hltSiPixelRecHits" )
1234  self.options['sequences'].append( "-HLTRecopixelvertexingSequence" )
1235  self.options['sequences'].append( "-HLTEndSequence" )
1236  self.options['sequences'].append( "-HLTBeginSequence" )
1237  self.options['sequences'].append( "-HLTBeginSequenceNZS" )
1238  self.options['sequences'].append( "-HLTBeginSequenceBPTX" )
1239  self.options['sequences'].append( "-HLTBeginSequenceAntiBPTX" )
1240  self.options['sequences'].append( "-HLTHBHENoiseSequence" )
1241  self.options['sequences'].append( "-HLTIterativeTrackingIter04" )
1242  self.options['sequences'].append( "-HLTIterativeTrackingIter02" )
1243  self.options['sequences'].append( "-HLTIterativeTracking" )
1244  self.options['sequences'].append( "-HLTIterativeTrackingTau3Mu" )
1245  self.options['sequences'].append( "-HLTIterativeTrackingReg" )
1246  self.options['sequences'].append( "-HLTIterativeTrackingForElectronIter02" )
1247  self.options['sequences'].append( "-HLTIterativeTrackingForPhotonsIter02" )
1248  self.options['sequences'].append( "-HLTIterativeTrackingL3MuonIter02" )
1249  self.options['sequences'].append( "-HLTIterativeTrackingGlbTrkMuonIter02" )
1250  self.options['sequences'].append( "-HLTIterativeTrackingL3MuonRegIter02" )
1251  self.options['sequences'].append( "-HLTIterativeTrackingHighPtTkMu" )
1252  self.options['sequences'].append( "-HLTIterativeTrackingHighPtTkMuIsoIter02" )
1253  self.options['sequences'].append( "-HLTIterativeTrackingForBTagIter02" )
1254  self.options['sequences'].append( "-HLTIterativeTrackingForBTagIter12" )
1255  self.options['sequences'].append( "-HLTIterativeTrackingForTauIter04" )
1256  self.options['sequences'].append( "-HLTIterativeTrackingForTauIter02" )
1257  self.options['sequences'].append( "-HLTIterativeTrackingDisplacedJpsiIter02" )
1258  self.options['sequences'].append( "-HLTIterativeTrackingDisplacedPsiPrimeIter02" )
1259  self.options['sequences'].append( "-HLTIterativeTrackingDisplacedNRMuMuIter02" )
1260  self.options['sequences'].append( "-HLTIterativeTrackingForBTagIteration0" )
1261  self.options['sequences'].append( "-HLTIterativeTrackingIteration4DisplacedJets" )
1262  self.options['sequences'].append( "-HLTRegionalCKFTracksForL3Isolation" )
1263  self.options['sequences'].append( "-HLTHBHENoiseCleanerSequence" )
1264 
1265  # remove HLTAnalyzerEndpath from fastsim cff's
1266  if self.config.fragment:
1267  self.options['paths'].append( "-HLTAnalyzerEndpath" )
1268 
1269 
1270  def append_filenames(self, name, filenames):
1271  if len(filenames) > 255:
1272  token_open = "( *("
1273  token_close = ") )"
1274  else:
1275  token_open = "("
1276  token_close = ")"
1277 
1278  self.data += " %s = cms.untracked.vstring%s\n" % (name, token_open)
1279  for line in filenames:
1280  self.data += " '%s',\n" % line
1281  self.data += " %s,\n" % (token_close)
1282 
1283 
1284  def expand_filenames(self, input):
1285  # check if the input is a dataset or a list of files
1286  if input[0:8] == 'dataset:':
1287  from dasFileQuery import dasFileQuery
1288  # extract the dataset name, and use DAS to fine the list of LFNs
1289  dataset = input[8:]
1290  files = dasFileQuery(dataset)
1291  else:
1292  # assume a comma-separated list of input files
1293  files = self.config.input.split(',')
1294  return files
1295 
1296  def build_source(self):
1297  if self.config.input:
1298  # if a dataset or a list of input files was given, use it
1299  self.source = self.expand_filenames(self.config.input)
1300  elif self.config.online:
1301  # online we always run on data
1302  self.source = [ "file:/tmp/InputCollection.root" ]
1303  elif self.config.data:
1304  # offline we can run on data...
1305  self.source = [ "file:RelVal_Raw_%s_DATA.root" % self.config.type ]
1306  else:
1307  # ...or on mc
1308  self.source = [ "file:RelVal_Raw_%s_MC.root" % self.config.type ]
1309 
1310  if self.config.parent:
1311  # if a dataset or a list of input files was given for the parent data, use it
1312  self.parent = self.expand_filenames(self.config.parent)
1313 
1314  self.data += """
1315 %(process)ssource = cms.Source( "PoolSource",
1316 """
1317  self.append_filenames("fileNames", self.source)
1318  if (self.parent):
1319  self.append_filenames("secondaryFileNames", self.parent)
1320  self.data += """\
1321  inputCommands = cms.untracked.vstring(
1322  'keep *'
1323  )
1324 )
1325 """
def _fix_parameter
Definition: confdb.py:371
def build_source
Definition: confdb.py:1296
def loadAdditionalConditions
Definition: confdb.py:755
def loadCff
Definition: confdb.py:780
def fixForMC
Definition: confdb.py:390
def buildPathList
Definition: confdb.py:922
def instrumentTiming
Definition: confdb.py:792
def runL1Emulator
Definition: confdb.py:588
def instrumentErrorEventType
Definition: confdb.py:476
def switchToNewL1Skim
Definition: confdb.py:653
def expand_filenames
Definition: confdb.py:1284
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
def instrumentDQM
Definition: confdb.py:883
def splitter
Definition: confdb.py:11
def overrideGlobalTag
Definition: confdb.py:484
def fixPrescales
Definition: confdb.py:438
def releaseSpecificCustomize
Definition: confdb.py:210
def consolidateNegativeList
Definition: confdb.py:176
def dumppaths
Definition: confdb.py:916
def loadCffCommand
Definition: confdb.py:773
def runL1EmulatorGT
Definition: confdb.py:557
def consolidatePositiveList
Definition: confdb.py:188
def expandWildcards
Definition: confdb.py:160
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def getRawConfigurationFromDB
Definition: confdb.py:113
def fixForFastSim
Definition: confdb.py:401
list object
Definition: dbtoconf.py:77
def buildOptions
Definition: confdb.py:979
def overrideProcessName
Definition: confdb.py:698
def overrideL1MenuXml
Definition: confdb.py:538
def append_filenames
Definition: confdb.py:1270
def addGlobalOptions
Disable HF Noise filters in HIon menu if &#39;hltHfreco&#39; in %(dict)s: %(process)shltHfreco.setNoiseFlags = cms.bool( False ) &quot;&quot;" else: self.data += &quot;&quot;" Enable HF Noise filters in non-HIon menu if &#39;hltHfreco&#39; in %(dict)s: %(process)shltHfreco.setNoiseFlags = cms.bool( True ) &quot;&quot;".
Definition: confdb.py:353
def instrumentOpenMode
Definition: confdb.py:462
def overrideOutput
Definition: confdb.py:672
def overrideParameters
Definition: confdb.py:784
def updateMessageLogger
Definition: confdb.py:744
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run