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