CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/HLTrigger/Configuration/python/Tools/confdb.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import sys
00004 import re
00005 import os
00006 from pipe import pipe as _pipe
00007 from options import globalTag
00008 from itertools import islice
00009 
00010 def splitter(iterator, n):
00011   i = iterator.__iter__()
00012   while True:
00013     l = list(islice(i, n))
00014     if l:
00015       yield l
00016     else:
00017       break
00018 
00019 
00020 class HLTProcess(object):
00021   # paths not supported by FastSim
00022   fastsimUnsupportedPaths = (
00023 
00024   # paths for which a recovery is not foreseen/possible
00025     "AlCa_EcalEta_v*",
00026     "AlCa_EcalPhiSym_v*",
00027     "AlCa_EcalPi0_v*",
00028     "AlCa_EcalPi0EBonly_v*",
00029     "AlCa_EcalPi0EEonly_v*",
00030     "AlCa_EcalEtaEBonly_v*",
00031     "AlCa_EcalEtaEEonly_v*",
00032     "AlCa_RPCMuonNoHits_v*",
00033     "AlCa_RPCMuonNoTriggers_v*",
00034     "AlCa_RPCMuonNormalisation_v*",
00035     "AlCa_LumiPixels_v*",
00036     "AlCa_LumiPixels_Random_v*",
00037     "AlCa_LumiPixels_ZeroBias_v*",
00038     "DQM_FEDIntegrity_v*",
00039     "DQM_HcalEmptyEvents_v*",
00040     "HLT_Calibration_v*",
00041     "HLT_EcalCalibration_v*",
00042     "HLT_HcalCalibration_v*",
00043     "HLT_TrackerCalibration_v*",
00044     "HLT_DTErrors_v*",
00045     "HLT_DTCalibration_v*",
00046     "HLT_Random_v*",
00047     "HLT_HcalNZS_v*",
00048     "HLT_HcalPhiSym_v*",
00049     "HLT_IsoTrackHB_v*",
00050     "HLT_IsoTrackHE_v*",
00051     "HLT_L1SingleMuOpen_AntiBPTX_v*",
00052     "HLT_JetE30_NoBPTX*_v*",
00053     "HLT_JetE50_NoBPTX*_v*",
00054     "HLT_JetE50_NoBPTX3BX_NoHalo_v*",
00055     "HLT_JetE70_NoBPTX3BX_NoHalo_v*",
00056     "HLT_L2Mu10_NoVertex_NoBPTX3BX_NoHalo_v*",
00057     "HLT_L2Mu20_NoVertex_NoBPTX3BX_NoHalo_v*",
00058     "HLT_L2Mu30_NoVertex_NoBPTX3BX_NoHalo_v*",
00059     "HLT_JetE30_NoBPTX3BX_v*",
00060     "HLT_JetE50_NoBPTX3BX_v*",
00061     "HLT_JetE70_NoBPTX3BX_v*",
00062     "HLT_L2Mu10_NoVertex_NoBPTX3BX_v*",
00063     "HLT_L2Mu10_NoVertex_NoBPTX3BX_v*",
00064     "HLT_L2Mu10_NoVertex_NoBPTX3BX_v*",
00065     "HLT_L2Mu20_NoVertex_NoBPTX3BX_v*",
00066     "HLT_L2Mu30_NoVertex_NoBPTX3BX_v*",
00067     "HLT_L2Mu20_NoVertex_2Cha_NoBPTX3BX_NoHalo_v*",
00068     "HLT_L2Mu30_NoVertex_2Cha_NoBPTX3BX_NoHalo_v*",
00069     "HLT_PixelTracks_Multiplicity70_v*",
00070     "HLT_PixelTracks_Multiplicity80_v*",
00071     "HLT_PixelTracks_Multiplicity90_v*",
00072     "HLT_BeamGas_HF_Beam1_v*",
00073     "HLT_BeamGas_HF_Beam2_v*",
00074     "HLT_BeamHalo_v*",
00075     "HLT_L1Tech_CASTOR_HaloMuon_v*",
00076     "HLT_L1Tech_DT_GlobalOR_v*",
00077     "HLT_GlobalRunHPDNoise_v*",
00078     "HLT_L1Tech_HBHEHO_totalOR_v*",
00079     "HLT_L1Tech_HCAL_HF_single_channel_v*",
00080     "HLT_L1TrackerCosmics_v*",
00081     "HLT_HcalUTCA_v*",
00082     
00083 # TODO: paths not supported by FastSim, but for which a recovery should be attempted
00084 
00085   
00086     )
00087 
00088   def __init__(self, configuration):
00089     self.config = configuration
00090     self.data   = None
00091     self.source = None
00092     self.parent = None
00093 
00094     self.options = {
00095       'essources' : [],
00096       'esmodules' : [],
00097       'modules'   : [],
00098       'sequences' : [],
00099       'services'  : [],
00100       'paths'     : [],
00101       'psets'     : [],
00102       'blocks'    : [],
00103     }
00104 
00105     self.labels = {}
00106     if self.config.fragment:
00107       self.labels['process'] = ''
00108       self.labels['dict']    = 'locals()'
00109     else:
00110       self.labels['process'] = 'process.'
00111       self.labels['dict']    = 'process.__dict__'
00112 
00113     if self.config.online:
00114       self.labels['connect'] = 'frontier://(proxyurl=https://localhost:3128)(serverurl=https://localhost:8000/FrontierOnProd)(serverurl=https://localhost:8000/FrontierOnProd)(retrieve-ziplevel=0)'
00115     else:
00116       self.labels['connect'] = 'frontier://FrontierProd'
00117 
00118     # get the configuration from ConfdB
00119     self.buildPathList()
00120     self.buildOptions()
00121     self.getRawConfigurationFromDB()
00122     self.customize()
00123 
00124 
00125   def _build_query(self):
00126     if self.config.menu.run:
00127       return '--runNumber %s' % self.config.menu.run
00128     else:
00129       return '--%s --configName %s' % (self.config.menu.db, self.config.menu.name)
00130 
00131   def _build_options(self):
00132     return ' '.join(['--%s %s' % (key, ','.join(vals)) for key, vals in self.options.iteritems() if vals])
00133 
00134   def _build_cmdline(self):
00135     if not self.config.fragment:
00136       return 'edmConfigFromDB       %s --noedsources %s' % (self._build_query(), self._build_options())
00137     else:
00138       return 'edmConfigFromDB --cff %s --noedsources %s' % (self._build_query(), self._build_options())
00139 
00140 
00141   def getRawConfigurationFromDB(self):
00142     cmdline = self._build_cmdline()
00143     data = _pipe(cmdline)
00144     if 'Exhausted Resultset' in data or 'CONFIG_NOT_FOUND' in data:
00145       raise ImportError('%s is not a valid HLT menu' % self.config.menuConfig.value)
00146     self.data = data
00147 
00148 
00149   def getPathList(self):
00150     cmdline = 'edmConfigFromDB --cff %s --noedsources --noes --noservices --nosequences --nomodules' % self._build_query()
00151     data = _pipe(cmdline)
00152     if 'Exhausted Resultset' in data or 'CONFIG_NOT_FOUND' in data:
00153       raise ImportError('%s is not a valid HLT menu' % self.config.menuConfig.value)
00154     filter = re.compile(r' *= *cms.(End)?Path.*')
00155     paths  = [ filter.sub('', line) for line in data.splitlines() if filter.search(line) ]
00156     return paths
00157 
00158 
00159   @staticmethod
00160   def expandWildcards(globs, collection):
00161     # expand a list of unix-style wildcards matching a given collection
00162     # wildcards with no matches are silently discarded
00163     matches = []
00164     for glob in globs:
00165       negate = ''
00166       if glob[0] == '-':
00167         negate = '-'
00168         glob   = glob[1:]
00169       # translate a unix-style glob expression into a regular expression
00170       filter = re.compile(r'^' + glob.replace('?', '.').replace('*', '.*').replace('[!', '[^') + r'$')
00171       matches.extend( negate + element for element in collection if filter.match(element) )
00172     return matches
00173 
00174 
00175   @staticmethod
00176   def consolidateNegativeList(elements):
00177     # consolidate a list of path exclusions and re-inclusions
00178     # the result is the list of paths to be removed from the dump
00179     result = set()
00180     for element in elements:
00181       if element[0] == '-':
00182         result.add( element )
00183       else:
00184         result.discard( '-' + element )
00185     return sorted( element for element in result )
00186 
00187   @staticmethod
00188   def consolidatePositiveList(elements):
00189     # consolidate a list of path selection and re-exclusions
00190     # the result is the list of paths to be included in the dump
00191     result = set()
00192     for element in elements:
00193       if element[0] == '-':
00194         result.discard( element[1:] )
00195       else:
00196         result.add( element )
00197     return sorted( element for element in result )
00198 
00199 
00200   # dump the final configuration
00201   def dump(self):
00202     return self.data % self.labels
00203 
00204 
00205   # add release-specific customizations
00206   def releaseSpecificCustomize(self):
00207     # version specific customizations
00208     self.data += """
00209 # CMSSW version specific customizations
00210 import os
00211 cmsswVersion = os.environ['CMSSW_VERSION']
00212 """
00213 
00214   # customize the configuration according to the options
00215   def customize(self):
00216 
00217     # adapt the source to the current scenario
00218     if not self.config.fragment:
00219       self.build_source()
00220 
00221     # manual override some parameters
00222     if self.config.type in ('GRun', ):
00223       self.data += """
00224 # Enable HF Noise filters in GRun menu
00225 if 'hltHfreco' in %(dict)s:
00226     %(process)shltHfreco.setNoiseFlags = cms.bool( True )
00227 """
00228     if self.config.type in ('HIon', ):
00229       self.data += """
00230 # Disable HF Noise filters in HIon menu
00231 if 'hltHfreco' in %(dict)s:
00232     %(process)shltHfreco.setNoiseFlags = cms.bool( False )
00233 """
00234 
00235 #    self.data += """
00236 ## untracked parameters with NO default in the code
00237 #if 'hltHcalDataIntegrityMonitor' in %(dict)s:
00238 #    %(process)shltHcalDataIntegrityMonitor.RawDataLabel = cms.untracked.InputTag("rawDataCollector")
00239 #if 'hltDt4DSegments' in %(dict)s:
00240 #    %(process)shltDt4DSegments.debug = cms.untracked.bool( False )
00241 #"""
00242 
00243     # if requested, override the L1 self from the GlobalTag (Xml)
00244     self.overrideL1MenuXml()
00245 
00246     # if running on MC, adapt the configuration accordingly
00247     self.fixForMC()
00248 
00249     # if requested, remove the HLT prescales
00250     self.fixPrescales()
00251 
00252     # if requested, override all ED/HLTfilters to always pass ("open" mode)
00253     self.instrumentOpenMode()
00254 
00255     # if requested, change all HLTTriggerTypeFilter EDFilters to accept only error events (SelectedTriggerType = 0)
00256     self.instrumentErrorEventType()
00257 
00258     # if requested, instrument the self with the modules and EndPath needed for timing studies
00259     self.instrumentTiming()
00260 
00261     # add version-specific customisations
00262     self.releaseSpecificCustomize()
00263 
00264     if self.config.fragment:
00265       
00266 #      self.data += """
00267 ## dummyfy hltGetConditions in cff's
00268 #if 'hltGetConditions' in %(dict)s and 'HLTriggerFirstPath' in %(dict)s :
00269 #    %(process)shltDummyConditions = cms.EDFilter( "HLTBool",
00270 #        result = cms.bool( True )
00271 #    )
00272 #    %(process)sHLTriggerFirstPath.replace(%(process)shltGetConditions,%(process)shltDummyConditions)
00273 #"""
00274 
00275       # if requested, adapt the configuration for FastSim
00276       self.fixForFastSim()
00277 
00278     else:
00279 
00280       # override the process name and adapt the relevant filters
00281       self.overrideProcessName()
00282 
00283       # override the output modules to output root files
00284       self.overrideOutput()
00285 
00286       # add global options
00287       self.addGlobalOptions()
00288 
00289       # if requested or necessary, override the GlobalTag and connection strings (incl. L1!)
00290       self.overrideGlobalTag()
00291 
00292       # if requested, run (part of) the L1 emulator
00293       self.runL1Emulator()
00294 
00295       # request summary informations from the MessageLogger
00296       self.updateMessageLogger()
00297 
00298       # load 5.2.x JECs, until they are in the GlobalTag
00299 #      self.loadAdditionalConditions('load 5.2.x JECs',
00300 #        {
00301 #          'record'  : 'JetCorrectionsRecord',
00302 #          'tag'     : 'JetCorrectorParametersCollection_AK5Calo_2012_V8_hlt_mc',
00303 #          'label'   : 'AK5CaloHLT',
00304 #          'connect' : '%(connect)s/CMS_COND_31X_PHYSICSTOOLS'
00305 #        }, {
00306 #          'record'  : 'JetCorrectionsRecord',
00307 #          'tag'     : 'JetCorrectorParametersCollection_AK5PF_2012_V8_hlt_mc',
00308 #          'label'   : 'AK5PFHLT',
00309 #          'connect' : '%(connect)s/CMS_COND_31X_PHYSICSTOOLS'
00310 #        }, {
00311 #          'record'  : 'JetCorrectionsRecord',
00312 #          'tag'     : 'JetCorrectorParametersCollection_AK5PFchs_2012_V8_hlt_mc',
00313 #          'label'   : 'AK5PFchsHLT',
00314 #          'connect' : '%(connect)s/CMS_COND_31X_PHYSICSTOOLS'
00315 #        }
00316 #      )
00317 
00318 
00319   def addGlobalOptions(self):
00320     # add global options
00321     self.data += """
00322 # limit the number of events to be processed
00323 %(process)smaxEvents = cms.untracked.PSet(
00324     input = cms.untracked.int32( 100 )
00325 )
00326 """
00327     if not self.config.profiling:
00328       self.data += """
00329 # enable the TrigReport and TimeReport
00330 %(process)soptions = cms.untracked.PSet(
00331     wantSummary = cms.untracked.bool( True )
00332 )
00333 """
00334 
00335 
00336   def _fix_parameter(self, **args):
00337     """arguments:
00338         name:     parameter name (optional)
00339         type:     parameter type (look for tracked and untracked variants)
00340         value:    original value
00341         replace:  replacement value
00342     """
00343     if 'name' in args:
00344       self.data = re.sub(
00345           r'%(name)s = cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
00346           r'%(name)s = cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
00347           self.data)
00348     else:
00349       self.data = re.sub(
00350           r'cms(?P<tracked>(?:\.untracked)?)\.%(type)s\( (?P<quote>["\']?)%(value)s(?P=quote)' % args,
00351           r'cms\g<tracked>.%(type)s( \g<quote>%(replace)s\g<quote>' % args,
00352           self.data)
00353 
00354 
00355   def fixForMC(self):
00356     if not self.config.data:
00357       # customise the HLT menu for running on MC
00358       if not self.config.fragment:
00359         self.data += """
00360 # customise the HLT menu for running on MC
00361 from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
00362 process = customizeHLTforMC(process)
00363 """
00364 
00365 
00366   def fixForFastSim(self):
00367     if self.config.fastsim:
00368       # adapt the hle configuration (fragment) to run under fastsim
00369       self.data = re.sub( r'import FWCore.ParameterSet.Config as cms', r'\g<0>\nfrom FastSimulation.HighLevelTrigger.HLTSetup_cff import *', self.data)
00370 
00371       # remove the definition of streams and datasets
00372       self.data = re.compile( r'^streams.*\n(.*\n)*?^\)\s*\n',  re.MULTILINE ).sub( '', self.data )
00373       self.data = re.compile( r'^datasets.*\n(.*\n)*?^\)\s*\n', re.MULTILINE ).sub( '', self.data )
00374 
00375       # fix the definition of module
00376       # FIXME: this should be updated to take into accout the --l1-emulator option
00377       self._fix_parameter(                               type = 'InputTag', value = 'hltL1extraParticles',  replace = 'l1extraParticles')
00378       self._fix_parameter(name = 'GMTReadoutCollection', type = 'InputTag', value = 'hltGtDigis',           replace = 'gmtDigis')
00379       self._fix_parameter(                               type = 'InputTag', value = 'hltGtDigis',           replace = 'gtDigis')
00380       self._fix_parameter(                               type = 'InputTag', value = 'hltL1GtObjectMap',     replace = 'gtDigis')
00381       self._fix_parameter(name = 'initialSeeds',         type = 'InputTag', value = 'noSeedsHere',          replace = 'globalPixelSeeds:GlobalPixel')
00382       self._fix_parameter(name = 'preFilteredSeeds',     type = 'bool',     value = 'True',                 replace = 'False')
00383       self._fix_parameter(                               type = 'InputTag', value = 'hltOfflineBeamSpot',   replace = 'offlineBeamSpot')
00384       self._fix_parameter(                               type = 'InputTag', value = 'hltOnlineBeamSpot',    replace = 'offlineBeamSpot')
00385       self._fix_parameter(                               type = 'InputTag', value = 'hltMuonCSCDigis',      replace = 'simMuonCSCDigis')
00386       self._fix_parameter(                               type = 'InputTag', value = 'hltMuonDTDigis',       replace = 'simMuonDTDigis')
00387       self._fix_parameter(                               type = 'InputTag', value = 'hltMuonRPCDigis',      replace = 'simMuonRPCDigis')
00388       self._fix_parameter(                               type = 'InputTag', value = 'hltRegionalTracksForL3MuonIsolation', replace = 'hltPixelTracks')
00389       self._fix_parameter(name = 'src',                  type = 'InputTag', value = 'hltHcalTowerNoiseCleaner', replace = 'hltTowerMakerForAll')
00390       self._fix_parameter(name = 'src',                  type = 'InputTag', value = 'hltIter4Tau3MuMerged', replace = 'hltIter4Merged')
00391 
00392       # fix the definition of sequences and paths
00393       self.data = re.sub( r'hltMuonCSCDigis', r'cms.SequencePlaceholder( "simMuonCSCDigis" )',  self.data )
00394       self.data = re.sub( r'hltMuonDTDigis',  r'cms.SequencePlaceholder( "simMuonDTDigis" )',   self.data )
00395       self.data = re.sub( r'hltMuonRPCDigis', r'cms.SequencePlaceholder( "simMuonRPCDigis" )',  self.data )
00396       self.data = re.sub( r'HLTEndSequence',  r'cms.SequencePlaceholder( "HLTEndSequence" )',   self.data )
00397       self.data = re.sub( r'hltGtDigis',      r'HLTBeginSequence',                              self.data )
00398 
00399 
00400   def fixPrescales(self):
00401     # update the PrescaleService to match the new list of paths
00402     if self.options['paths']:
00403       if self.options['paths'][0][0] == '-':
00404         # drop requested paths
00405         for minuspath in self.options['paths']:
00406           path = minuspath[1:]
00407           self.data = re.sub(r'      cms.PSet\(  pathName = cms.string\( "%s" \),\n        prescales = cms.vuint32\( .* \)\n      \),?\n' % path, '', self.data)
00408       else:
00409         # keep requested paths
00410         for path in self.all_paths:
00411           if path not in self.options['paths']:
00412             self.data = re.sub(r'      cms.PSet\(  pathName = cms.string\( "%s" \),\n        prescales = cms.vuint32\( .* \)\n      \),?\n' % path, '', self.data)
00413 
00414     if self.config.unprescale:
00415       self.data += """
00416 # remove the HLT prescales
00417 if 'PrescaleService' in %(dict)s:
00418     %(process)sPrescaleService.lvl1DefaultLabel = cms.string( '0' )
00419     %(process)sPrescaleService.lvl1Labels       = cms.vstring( '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' )
00420     %(process)sPrescaleService.prescaleTable    = cms.VPSet( )
00421 """
00422 
00423 
00424   def instrumentOpenMode(self):
00425     if self.config.open:
00426       # find all EDfilters
00427       filters = [ match[1] for match in re.findall(r'(process\.)?\b(\w+) = cms.EDFilter', self.data) ]
00428       re_sequence = re.compile( r'cms\.(Path|Sequence)\((.*)\)' )
00429       # remove existing 'cms.ingore' and '~' modifiers
00430       self.data = re_sequence.sub( lambda line: re.sub( r'cms\.ignore *\( *((process\.)?\b(\w+)) *\)', r'\1', line.group(0) ), self.data )
00431       self.data = re_sequence.sub( lambda line: re.sub( r'~', '', line.group(0) ), self.data )
00432       # wrap all EDfilters with "cms.ignore( ... )", 1000 at a time (python 2.6 complains for too-big regular expressions)
00433       for some in splitter(filters, 1000):
00434         re_filters  = re.compile( r'\b((process\.)?(' + r'|'.join(some) + r'))\b' )
00435         self.data = re_sequence.sub( lambda line: re_filters.sub( r'cms.ignore( \1 )', line.group(0) ), self.data )
00436 
00437 
00438   def instrumentErrorEventType(self):
00439     if self.config.errortype:
00440       # change all HLTTriggerTypeFilter EDFilters to accept only error events (SelectedTriggerType = 0)
00441       self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '1', replace = '0')
00442       self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '2', replace = '0')
00443       self._fix_parameter(name = 'SelectedTriggerType', type ='int32', value = '3', replace = '0')
00444 
00445 
00446   def overrideGlobalTag(self):
00447     # overwrite GlobalTag
00448     # the logic is:
00449     #   - always set the correct connection string and pfnPrefix
00450     #   - if a GlobalTag is specified on the command line:
00451     #      - override the global tag
00452     #      - if the GT is "auto:...", insert the code to read it from Configuration.AlCa.autoCond
00453     #   - if a GlobalTag is NOT  specified on the command line:
00454     #      - when running on data, do nothing, and keep the global tag in the menu
00455     #      - when running on mc, take the GT from the configuration.type
00456 
00457     # override the GlobalTag connection string and pfnPrefix
00458     text = """
00459 # override the GlobalTag, connection string and pfnPrefix
00460 if 'GlobalTag' in %%(dict)s:
00461     %%(process)sGlobalTag.connect   = '%%(connect)s/CMS_COND_31X_GLOBALTAG'
00462     %%(process)sGlobalTag.pfnPrefix = cms.untracked.string('%%(connect)s/')
00463 """
00464 
00465     # when running on MC, override the global tag even if not specified on the command line
00466     if not self.config.data and not self.config.globaltag:
00467       if self.config.type in globalTag:
00468         self.config.globaltag = globalTag[self.config.type]
00469       else:
00470         self.config.globaltag = globalTag['GRun']
00471 
00472     text += "    from Configuration.AlCa.GlobalTag import GlobalTag as customiseGlobalTag\n"
00473 
00474     # if requested, override the L1 menu from the GlobalTag (using the same connect as the GlobalTag itself)
00475     if self.config.l1.override:
00476       self.config.l1.record = 'L1GtTriggerMenuRcd'
00477       self.config.l1.label  = ''
00478       self.config.l1.tag    = self.config.l1.override
00479       if not self.config.l1.connect:
00480         self.config.l1.connect = '%(connect)s/CMS_COND_31X_L1T'
00481       self.config.l1cond = "'%(tag)s,%(record)s,%(connect)s'" % self.config.l1.__dict__
00482     else:
00483       self.config.l1cond = "None"
00484 
00485     text += "    %%(process)sGlobalTag = customiseGlobalTag(%%(process)sGlobalTag,'%(globaltag)s',%(l1cond)s)\n"
00486 
00487     self.data += text % self.config.__dict__
00488 
00489   def overrideL1MenuXml(self):
00490     # if requested, override the L1 menu from the GlobalTag (Xml file)
00491     if self.config.l1Xml.XmlFile:
00492       text = """
00493 # override the L1 menu from an Xml file
00494 %%(process)sl1GtTriggerMenuXml = cms.ESProducer("L1GtTriggerMenuXmlProducer",
00495   TriggerMenuLuminosity = cms.string('%(LumiDir)s'),
00496   DefXmlFile = cms.string('%(XmlFile)s'),
00497   VmeXmlFile = cms.string('')
00498 )
00499 %%(process)sL1GtTriggerMenuRcdSource = cms.ESSource("EmptyESSource",
00500   recordName = cms.string('L1GtTriggerMenuRcd'),
00501   iovIsRunNotTime = cms.bool(True),
00502   firstValid = cms.vuint32(1)
00503 )
00504 %%(process)ses_prefer_l1GtParameters = cms.ESPrefer('L1GtTriggerMenuXmlProducer','l1GtTriggerMenuXml') 
00505 """
00506       self.data += text % self.config.l1Xml.__dict__
00507 
00508   def runL1EmulatorGT(self):
00509     # if requested, run (part of) the L1 emulator, then repack the data into a new RAW collection, to be used by the HLT
00510     if not self.config.emulator:
00511       return
00512 
00513     if self.config.emulator != 'gt':
00514       # only the GT emulator is currently supported
00515       return
00516 
00517     # run the L1 GT emulator, then repack the data into a new RAW collection, to be used by the HLT
00518     text = """
00519 # run the L1 GT emulator, then repack the data into a new RAW collection, to be used by the HLT
00520 """
00521     if self.config.fragment:
00522       # FIXME in a cff, should also update the HLTSchedule
00523       text += "import Configuration.StandardSequences.SimL1EmulatorRepack_GT_cff\n"
00524     else:
00525       text += "process.load( 'Configuration.StandardSequences.SimL1EmulatorRepack_GT_cff' )\n"
00526 
00527     if not 'hltBoolFalse' in self.data:
00528       # add hltBoolFalse
00529       text += """
00530 %(process)shltBoolFalse = cms.EDFilter( "HLTBool",
00531     result = cms.bool( False )
00532 )
00533 """
00534     text += "process.L1Emulator = cms.Path( process.SimL1Emulator + process.hltBoolFalse )\n\n"
00535 
00536     self.data = re.sub(r'.*cms\.(End)?Path.*', text + r'\g<0>', self.data, 1)
00537 
00538 
00539   def runL1Emulator(self):
00540     # if requested, run (part of) the L1 emulator
00541     if self.config.emulator:
00542       # FIXME this fragment used "process" explicitly
00543       emulator = {
00544         'RawToDigi': '',
00545         'CustomL1T': '',
00546         'CustomHLT': ''
00547       }
00548 
00549       if self.config.data:
00550         emulator['RawToDigi'] = 'RawToDigi_Data_cff'
00551       else:
00552         emulator['RawToDigi'] = 'RawToDigi_cff'
00553 
00554       if self.config.emulator == 'gt':
00555         emulator['CustomL1T'] = 'customiseL1GtEmulatorFromRaw'
00556         emulator['CustomHLT'] = 'switchToSimGtDigis'
00557       elif self.config.emulator == 'gct,gt':
00558         emulator['CustomL1T'] = 'customiseL1CaloAndGtEmulatorsFromRaw'
00559         emulator['CustomHLT'] = 'switchToSimGctGtDigis'
00560       elif self.config.emulator == 'gmt,gt':
00561         # XXX currently unsupported
00562         emulator['CustomL1T'] = 'customiseL1MuonAndGtEmulatorsFromRaw'
00563         emulator['CustomHLT'] = 'switchToSimGmtGtDigis'
00564       elif self.config.emulator in ('gmt,gct,gt', 'gct,gmt,gt', 'all'):
00565         emulator['CustomL1T'] = 'customiseL1EmulatorFromRaw'
00566         emulator['CustomHLT'] = 'switchToSimGmtGctGtDigis'
00567       else:
00568         # unsupported argument, default to running the whole emulator
00569         emulator['CustomL1T'] = 'customiseL1EmulatorFromRaw'
00570         emulator['CustomHLT'] = 'switchToSimGmtGctGtDigis'
00571 
00572       self.data += """
00573 # customize the L1 emulator to run %(CustomL1T)s with HLT to %(CustomHLT)s
00574 process.load( 'Configuration.StandardSequences.%(RawToDigi)s' )
00575 process.load( 'Configuration.StandardSequences.SimL1Emulator_cff' )
00576 import L1Trigger.Configuration.L1Trigger_custom
00577 process = L1Trigger.Configuration.L1Trigger_custom.%(CustomL1T)s( process )
00578 process = L1Trigger.Configuration.L1Trigger_custom.customiseResetPrescalesAndMasks( process )
00579 
00580 # customize the HLT to use the emulated results
00581 import HLTrigger.Configuration.customizeHLTforL1Emulator
00582 process = HLTrigger.Configuration.customizeHLTforL1Emulator.switchToL1Emulator( process )
00583 process = HLTrigger.Configuration.customizeHLTforL1Emulator.%(CustomHLT)s( process )
00584 """ % emulator
00585 
00586 
00587   def overrideOutput(self):
00588     # override the "online" ShmStreamConsumer output modules with "offline" PoolOutputModule's
00589     self.data = re.sub(
00590       r'\b(process\.)?hltOutput(\w+) *= *cms\.OutputModule\( *"ShmStreamConsumer" *,',
00591       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    ),',
00592       self.data
00593     )
00594 
00595     if not self.config.fragment and self.config.output == 'full':
00596       # add a single "keep *" output
00597       self.data += """
00598 # add a single "keep *" output
00599 %(process)shltOutputFULL = cms.OutputModule( "PoolOutputModule",
00600     fileName = cms.untracked.string( "outputFULL.root" ),
00601     fastCloning = cms.untracked.bool( False ),
00602     dataset = cms.untracked.PSet(
00603         dataTier = cms.untracked.string( 'RECO' ),
00604         filterName = cms.untracked.string( '' )
00605     ),
00606     outputCommands = cms.untracked.vstring( 'keep *' )
00607 )
00608 %(process)sFULLOutput = cms.EndPath( %(process)shltOutputFULL )
00609 """
00610 
00611 
00612   # override the process name and adapt the relevant filters
00613   def overrideProcessName(self):
00614     if self.config.name is None:
00615       return
00616 
00617 # the following was stolen and adapted from HLTrigger.Configuration.customL1THLT_Options
00618     self.data += """
00619 # override the process name
00620 %%(process)ssetName_('%(name)s')
00621 
00622 # adapt HLT modules to the correct process name
00623 if 'hltTrigReport' in %%(dict)s:
00624     %%(process)shltTrigReport.HLTriggerResults                    = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00625 
00626 if 'hltPreExpressCosmicsOutputSmart' in %%(dict)s:
00627     %%(process)shltPreExpressCosmicsOutputSmart.TriggerResultsTag = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00628 
00629 if 'hltPreExpressOutputSmart' in %%(dict)s:
00630     %%(process)shltPreExpressOutputSmart.TriggerResultsTag        = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00631 
00632 if 'hltPreDQMForHIOutputSmart' in %%(dict)s:
00633     %%(process)shltPreDQMForHIOutputSmart.TriggerResultsTag       = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00634 
00635 if 'hltPreDQMForPPOutputSmart' in %%(dict)s:
00636     %%(process)shltPreDQMForPPOutputSmart.TriggerResultsTag       = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00637 
00638 if 'hltPreHLTDQMResultsOutputSmart' in %%(dict)s:
00639     %%(process)shltPreHLTDQMResultsOutputSmart.TriggerResultsTag  = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00640 
00641 if 'hltPreHLTDQMOutputSmart' in %%(dict)s:
00642     %%(process)shltPreHLTDQMOutputSmart.TriggerResultsTag         = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00643 
00644 if 'hltPreHLTMONOutputSmart' in %%(dict)s:
00645     %%(process)shltPreHLTMONOutputSmart.TriggerResultsTag         = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00646 
00647 if 'hltDQMHLTScalers' in %%(dict)s:
00648     %%(process)shltDQMHLTScalers.triggerResults                   = cms.InputTag( 'TriggerResults', '', '%(name)s' )
00649     %%(process)shltDQMHLTScalers.processname                      = '%(name)s'
00650 
00651 if 'hltDQML1SeedLogicScalers' in %%(dict)s:
00652     %%(process)shltDQML1SeedLogicScalers.processname              = '%(name)s'
00653 """ % self.config.__dict__
00654 
00655 
00656   def updateMessageLogger(self):
00657     # request summary informations from the MessageLogger
00658     self.data += """
00659 if 'MessageLogger' in %(dict)s:
00660     %(process)sMessageLogger.categories.append('TriggerSummaryProducerAOD')
00661     %(process)sMessageLogger.categories.append('L1GtTrigReport')
00662     %(process)sMessageLogger.categories.append('HLTrigReport')
00663 """
00664 
00665 
00666   def loadAdditionalConditions(self, comment, *conditions):
00667     # load additional conditions
00668     self.data += """
00669 # %s
00670 if 'GlobalTag' in %%(dict)s:
00671 """ % comment
00672     for condition in conditions:
00673       self.data += """    %%(process)sGlobalTag.toGet.append(
00674         cms.PSet(
00675             record  = cms.string( '%(record)s' ),
00676             tag     = cms.string( '%(tag)s' ),
00677             label   = cms.untracked.string( '%(label)s' ),
00678             connect = cms.untracked.string( '%(connect)s' )
00679         )
00680     )
00681 """ % condition
00682 
00683 
00684   def overrideParameters(self, module, parameters):
00685     # override a module's parameter if the module is present in the configuration
00686     self.data += "if '%s' in %%(dict)s:\n" % module
00687     for (parameter, value) in parameters:
00688       self.data += "    %%(process)s%s.%s = %s\n" % (module, parameter, value)
00689     self.data += "\n"
00690 
00691 
00692   def instrumentTiming(self):
00693     if self.config.profiling:
00694       # instrument the menu for profiling: remove the HLTAnalyzerEndpath, add/override the HLTriggerFirstPath, with hltGetRaw and hltGetConditions
00695       text = ''
00696 
00697       if not 'hltGetRaw' in self.data:
00698         # add hltGetRaw
00699         text += """
00700 %(process)shltGetRaw = cms.EDAnalyzer( "HLTGetRaw",
00701     RawDataCollection = cms.InputTag( "rawDataCollector" )
00702 )
00703 """
00704 
00705       if not 'hltGetConditions' in self.data:
00706         # add hltGetConditions
00707         text += """
00708 %(process)shltGetConditions = cms.EDAnalyzer( 'EventSetupRecordDataGetter',
00709     verbose = cms.untracked.bool( False ),
00710     toGet = cms.VPSet( )
00711 )
00712 """
00713 
00714       if not 'hltBoolFalse' in self.data:
00715         # add hltBoolFalse
00716         text += """
00717 %(process)shltBoolFalse = cms.EDFilter( "HLTBool",
00718     result = cms.bool( False )
00719 )
00720 """
00721 
00722       # add the definition of HLTriggerFirstPath
00723       # FIXME in a cff, should also update the HLTSchedule
00724       text += """
00725 %(process)sHLTriggerFirstPath = cms.Path( %(process)shltGetRaw + %(process)shltGetConditions + %(process)shltBoolFalse )
00726 """
00727       self.data = re.sub(r'.*cms\.(End)?Path.*', text + r'\g<0>', self.data, 1)
00728 
00729       # load additional conditions needed by hltGetConditions
00730       self.loadAdditionalConditions('add XML geometry to keep hltGetConditions happy',
00731         {
00732           'record'  : 'GeometryFileRcd',
00733           'tag'     : 'XMLFILE_Geometry_311YV1_Ideal_mc',
00734           'label'   : 'Ideal',
00735           'connect' : '%(connect)s/CMS_COND_34X_GEOMETRY'
00736         }, {
00737           'record'  : 'GeometryFileRcd',
00738           'tag'     : 'XMLFILE_Geometry_311YV1_Extended_mc',
00739           'label'   : 'Extended',
00740           'connect' : '%(connect)s/CMS_COND_34X_GEOMETRY'
00741         }
00742       )
00743 
00744     # instrument the menu with the Service, EDProducer and EndPath needed for timing studies
00745     # FIXME in a cff, should also update the HLTSchedule
00746     if self.config.timing:
00747       self.data += """
00748 # instrument the menu with the modules and EndPath needed for timing studies
00749 %(process)sPathTimerService = cms.Service( "PathTimerService",
00750 )
00751 %(process)shltTimer = cms.EDProducer( "PathTimerInserter",
00752 )
00753 %(process)shltOutputTiming = cms.OutputModule( "PoolOutputModule",
00754     fileName = cms.untracked.string( "outputTiming.root" ),
00755     fastCloning = cms.untracked.bool( False ),
00756     splitLevel = cms.untracked.int32( 0 ),
00757     dataset = cms.untracked.PSet(
00758         dataTier = cms.untracked.string( 'RECO' ),
00759         filterName = cms.untracked.string( '' )
00760     ),
00761     outputCommands = cms.untracked.vstring( 'drop *',
00762       'keep HLTPerformanceInfo_*_*_*' )
00763 )
00764 
00765 %(process)sTimingOutput = cms.EndPath( %(process)shltTimer + %(process)shltOutputTiming )
00766 """
00767 
00768   @staticmethod
00769   def dumppaths(paths):
00770     sys.stderr.write('Path selection:\n')
00771     for path in paths:
00772       sys.stderr.write('\t%s\n' % path)
00773     sys.stderr.write('\n\n')
00774 
00775   def buildPathList(self):
00776     self.all_paths = self.getPathList()
00777 
00778     if self.config.paths:
00779       # no path list was requested, dump the full table, minus unsupported / unwanted paths
00780       paths = self.config.paths.split(',')
00781     else:
00782       # dump only the requested paths, plus the eventual output endpaths
00783       paths = []
00784 
00785     if self.config.fragment or self.config.output in ('none', 'full'):
00786       # 'full' removes all outputs (same as 'none') and then adds a single "keep *" output (see the overrideOutput method)
00787       if self.config.paths:
00788         # paths are removed by default
00789         pass    
00790       else:
00791         # drop all output endpaths
00792         paths.append( "-*Output" )
00793     elif self.config.output == 'minimal':
00794       # drop all output endpaths but HLTDQMResultsOutput
00795       if self.config.paths:
00796         paths.append( "HLTDQMResultsOutput" )
00797       else:
00798         paths.append( "-*Output" )
00799         paths.append( "HLTDQMResultsOutput" )
00800     else:
00801       # keep / add back all output endpaths
00802       if self.config.paths:
00803         paths.append( "*Output" )
00804       else:
00805         pass    # paths are kepy by default
00806 
00807     # drop paths unsupported by fastsim
00808     if self.config.fastsim:
00809       paths.extend( "-%s" % path for path in self.fastsimUnsupportedPaths )
00810 
00811     # drop unwanted paths for profiling (and timing studies)
00812     if self.config.profiling:
00813       paths.append( "-HLTriggerFirstPath" )
00814       paths.append( "-HLTAnalyzerEndpath" )
00815 
00816     # this should never be in any dump (nor online menu)
00817     paths.append( "-OfflineOutput" )
00818 
00819     # expand all wildcards
00820     paths = self.expandWildcards(paths, self.all_paths)
00821 
00822     if self.config.paths:
00823       # do an "additive" consolidation
00824       self.options['paths'] = self.consolidatePositiveList(paths)
00825       if not self.options['paths']:
00826         raise RuntimeError('Error: option "--paths %s" does not select any valid paths' % self.config.paths)
00827     else:
00828       # do a "subtractive" consolidation
00829       self.options['paths'] = self.consolidateNegativeList(paths)
00830 
00831 
00832   def buildOptions(self):
00833     # common configuration for all scenarios
00834     self.options['services'].append( "-FUShmDQMOutputService" )
00835 
00836     if self.config.fragment:
00837       # extract a configuration file fragment
00838       self.options['essources'].append( "-GlobalTag" )
00839       self.options['essources'].append( "-HepPDTESSource" )
00840       self.options['essources'].append( "-XMLIdealGeometryESSource" )
00841       self.options['essources'].append( "-eegeom" )
00842       self.options['essources'].append( "-es_hardcode" )
00843       self.options['essources'].append( "-magfield" )
00844 
00845       self.options['esmodules'].append( "-AutoMagneticFieldESProducer" )
00846       self.options['esmodules'].append( "-SlaveField0" )
00847       self.options['esmodules'].append( "-SlaveField20" )
00848       self.options['esmodules'].append( "-SlaveField30" )
00849       self.options['esmodules'].append( "-SlaveField35" )
00850       self.options['esmodules'].append( "-SlaveField38" )
00851       self.options['esmodules'].append( "-SlaveField40" )
00852       self.options['esmodules'].append( "-VBF0" )
00853       self.options['esmodules'].append( "-VBF20" )
00854       self.options['esmodules'].append( "-VBF30" )
00855       self.options['esmodules'].append( "-VBF35" )
00856       self.options['esmodules'].append( "-VBF38" )
00857       self.options['esmodules'].append( "-VBF40" )
00858       self.options['esmodules'].append( "-CSCGeometryESModule" )
00859       self.options['esmodules'].append( "-CaloGeometryBuilder" )
00860       self.options['esmodules'].append( "-CaloTowerHardcodeGeometryEP" )
00861       self.options['esmodules'].append( "-CastorHardcodeGeometryEP" )
00862       self.options['esmodules'].append( "-DTGeometryESModule" )
00863       self.options['esmodules'].append( "-EcalBarrelGeometryEP" )
00864       self.options['esmodules'].append( "-EcalElectronicsMappingBuilder" )
00865       self.options['esmodules'].append( "-EcalEndcapGeometryEP" )
00866       self.options['esmodules'].append( "-EcalLaserCorrectionService" )
00867       self.options['esmodules'].append( "-EcalPreshowerGeometryEP" )
00868       self.options['esmodules'].append( "-HcalHardcodeGeometryEP" )
00869       self.options['esmodules'].append( "-HcalTopologyIdealEP" )
00870       self.options['esmodules'].append( "-MuonNumberingInitialization" )
00871       self.options['esmodules'].append( "-ParametrizedMagneticFieldProducer" )
00872       self.options['esmodules'].append( "-RPCGeometryESModule" )
00873       self.options['esmodules'].append( "-SiStripGainESProducer" )
00874       self.options['esmodules'].append( "-SiStripRecHitMatcherESProducer" )
00875       self.options['esmodules'].append( "-SiStripQualityESProducer" )
00876       self.options['esmodules'].append( "-StripCPEfromTrackAngleESProducer" )
00877       self.options['esmodules'].append( "-TrackerDigiGeometryESModule" )
00878       self.options['esmodules'].append( "-TrackerGeometricDetESModule" )
00879       self.options['esmodules'].append( "-VolumeBasedMagneticFieldESProducer" )
00880       self.options['esmodules'].append( "-ZdcHardcodeGeometryEP" )
00881       self.options['esmodules'].append( "-hcal_db_producer" )
00882       self.options['esmodules'].append( "-L1GtTriggerMaskAlgoTrigTrivialProducer" )
00883       self.options['esmodules'].append( "-L1GtTriggerMaskTechTrigTrivialProducer" )
00884       self.options['esmodules'].append( "-hltESPEcalTrigTowerConstituentsMapBuilder" )
00885       self.options['esmodules'].append( "-hltESPGlobalTrackingGeometryESProducer" )
00886       self.options['esmodules'].append( "-hltESPMuonDetLayerGeometryESProducer" )
00887       self.options['esmodules'].append( "-hltESPTrackerRecoGeometryESProducer" )
00888       if not self.config.fastsim:
00889         self.options['esmodules'].append( "-CaloTowerGeometryFromDBEP" )
00890         self.options['esmodules'].append( "-CastorGeometryFromDBEP" )
00891         self.options['esmodules'].append( "-EcalBarrelGeometryFromDBEP" )
00892         self.options['esmodules'].append( "-EcalEndcapGeometryFromDBEP" )
00893         self.options['esmodules'].append( "-EcalPreshowerGeometryFromDBEP" )
00894         self.options['esmodules'].append( "-HcalGeometryFromDBEP" )
00895         self.options['esmodules'].append( "-ZdcGeometryFromDBEP" )
00896         self.options['esmodules'].append( "-XMLFromDBSource" )
00897         self.options['esmodules'].append( "-sistripconn" )
00898 
00899       self.options['services'].append( "-PrescaleService" )
00900       self.options['services'].append( "-MessageLogger" )
00901       self.options['services'].append( "-DQM" )
00902       self.options['services'].append( "-DQMStore" )
00903       self.options['services'].append( "-MicroStateService" )
00904       self.options['services'].append( "-ModuleWebRegistry" )
00905       self.options['services'].append( "-TimeProfilerService" )
00906       self.options['services'].append( "-FastTimerService" )
00907 
00908       self.options['psets'].append( "-maxEvents" )
00909       self.options['psets'].append( "-options" )
00910 
00911     if self.config.fastsim:
00912       # remove components not supported or needed by fastsim
00913       self.options['esmodules'].append( "-navigationSchoolESProducer" )
00914       self.options['esmodules'].append( "-TransientTrackBuilderESProducer" )
00915       self.options['esmodules'].append( "-SteppingHelixPropagatorAny" )
00916       self.options['esmodules'].append( "-OppositeMaterialPropagator" )
00917       self.options['esmodules'].append( "-MaterialPropagator" )
00918       self.options['esmodules'].append( "-CaloTowerConstituentsMapBuilder" )
00919       self.options['esmodules'].append( "-CaloTopologyBuilder" )
00920 
00921       self.options['services'].append( "-UpdaterService" )
00922 
00923       self.options['modules'].append( "hltL3MuonIsolations" )
00924       self.options['modules'].append( "hltPixelVertices" )
00925       self.options['modules'].append( "-hltCkfL1SeededTrackCandidates" )
00926       self.options['modules'].append( "-hltCtfL1SeededithMaterialTracks" )
00927       self.options['modules'].append( "-hltCkf3HitL1SeededTrackCandidates" )
00928       self.options['modules'].append( "-hltCtf3HitL1SeededWithMaterialTracks" )
00929       self.options['modules'].append( "-hltCkf3HitActivityTrackCandidates" )
00930       self.options['modules'].append( "-hltCtf3HitActivityWithMaterialTracks" )
00931       self.options['modules'].append( "-hltActivityCkfTrackCandidatesForGSF" )
00932       self.options['modules'].append( "-hltL1SeededCkfTrackCandidatesForGSF" )
00933       self.options['modules'].append( "-hltMuCkfTrackCandidates" )
00934       self.options['modules'].append( "-hltMuCtfTracks" )
00935       self.options['modules'].append( "-hltTau3MuCkfTrackCandidates" )
00936       self.options['modules'].append( "-hltTau3MuCtfWithMaterialTracks" )
00937       self.options['modules'].append( "-hltMuTrackJpsiCkfTrackCandidates" )
00938       self.options['modules'].append( "-hltMuTrackJpsiCtfTracks" )
00939       self.options['modules'].append( "-hltMuTrackJpsiEffCkfTrackCandidates" )
00940       self.options['modules'].append( "-hltMuTrackJpsiEffCtfTracks" )
00941       self.options['modules'].append( "-hltJpsiTkPixelSeedFromL3Candidate" )
00942       self.options['modules'].append( "-hltCkfTrackCandidatesJpsiTk" )
00943       self.options['modules'].append( "-hltCtfWithMaterialTracksJpsiTk" )
00944       self.options['modules'].append( "-hltMuTrackCkfTrackCandidatesOnia" )
00945       self.options['modules'].append( "-hltMuTrackCtfTracksOnia" )
00946       
00947       self.options['modules'].append( "-hltESRegionalEgammaRecHit" )
00948       self.options['modules'].append( "-hltEcalRegionalJetsFEDs" )
00949       self.options['modules'].append( "-hltEcalRegionalMuonsFEDs" )
00950       self.options['modules'].append( "-hltEcalRegionalEgammaFEDs" )
00951       self.options['modules'].append( "-hltFEDSelector" )
00952       self.options['modules'].append( "-hltL3TrajSeedOIHit" )
00953       self.options['modules'].append( "-hltL3TrajSeedIOHit" )
00954       self.options['modules'].append( "-hltL3TrackCandidateFromL2OIState" )
00955       self.options['modules'].append( "-hltL3TrackCandidateFromL2OIHit" )
00956       self.options['modules'].append( "-hltL3TrackCandidateFromL2IOHit" )
00957       self.options['modules'].append( "-hltL3TrackCandidateFromL2NoVtx" )
00958       self.options['modules'].append( "-hltHcalDigis" )
00959       self.options['modules'].append( "-hltHoreco" )
00960       self.options['modules'].append( "-hltHfreco" )
00961       self.options['modules'].append( "-hltHbhereco" )
00962       self.options['modules'].append( "-hltEcalRegionalRestFEDs" )
00963       self.options['modules'].append( "-hltEcalRegionalESRestFEDs" )
00964       self.options['modules'].append( "-hltEcalRawToRecHitFacility" )
00965       self.options['modules'].append( "-hltESRawToRecHitFacility" )
00966       self.options['modules'].append( "-hltEcalRegionalJetsRecHit" )
00967       self.options['modules'].append( "-hltEcalRegionalMuonsRecHit" )
00968       self.options['modules'].append( "-hltEcalRegionalEgammaRecHit" )
00969       self.options['modules'].append( "-hltEcalRecHitAll" )
00970       self.options['modules'].append( "-hltESRecHitAll" )
00971       # === hltPF
00972       self.options['modules'].append( "-hltPFJetCkfTrackCandidates" )
00973       self.options['modules'].append( "-hltPFJetCtfWithMaterialTracks" )
00974       self.options['modules'].append( "-hltPFlowTrackSelectionHighPurity" )
00975       # === hltFastJet
00976       self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalPixelSeedGenerator" )
00977       self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalCkfTrackCandidates" )
00978       self.options['modules'].append( "-hltDisplacedHT250L1FastJetRegionalCtfWithMaterialTracks" )     
00979       self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalPixelSeedGenerator" )
00980       self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalCkfTrackCandidates" )
00981       self.options['modules'].append( "-hltDisplacedHT300L1FastJetRegionalCtfWithMaterialTracks" )     
00982       self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhiL1FastJet" )
00983       self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhiL1FastJet" )
00984       self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhiL1FastJet" )     
00985       self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorHbbVBF" )
00986       self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesHbbVBF" )
00987       self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksHbbVBF" )
00988       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20HbbL1FastJet" )
00989       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20HbbL1FastJet" )
00990       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20HbbL1FastJet" )
00991       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20HbbL1FastJet" )
00992       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20HbbL1FastJet" )
00993       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20HbbL1FastJet" )
00994       # === hltBLifetimeRegional
00995       self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorHbb" )
00996       self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesHbb" )
00997       self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksHbb" )
00998       self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhi" )
00999       self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhi" )
01000       self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhi" )
01001       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20Hbb" )
01002       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20Hbb" )
01003       self.options['modules'].append( "-hltBLifetimeBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20Hbb" )
01004       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalPixelSeedGeneratorJet20Hbb" )
01005       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCkfTrackCandidatesJet20Hbb" )
01006       self.options['modules'].append( "-hltBLifetimeDiBTagIP3D1stTrkRegionalCtfWithMaterialTracksJet20Hbb" )
01007       self.options['modules'].append( "-hltBLifetimeFastRegionalPixelSeedGeneratorHbbVBF" )
01008       self.options['modules'].append( "-hltBLifetimeFastRegionalCkfTrackCandidatesHbbVBF" )
01009       self.options['modules'].append( "-hltBLifetimeFastRegionalCtfWithMaterialTracksHbbVBF" )
01010       self.options['modules'].append( "-hltBLifetimeRegionalPixelSeedGeneratorbbPhiL1FastJetFastPV" )
01011       self.options['modules'].append( "-hltBLifetimeRegionalCkfTrackCandidatesbbPhiL1FastJetFastPV" )
01012       self.options['modules'].append( "-hltBLifetimeRegionalCtfWithMaterialTracksbbPhiL1FastJetFastPV" )
01013       self.options['modules'].append( "-hltFastPixelBLifetimeRegionalPixelSeedGeneratorHbb" )
01014       self.options['modules'].append( "-hltFastPixelBLifetimeRegionalCkfTrackCandidatesHbb" )
01015       self.options['modules'].append( "-hltFastPixelBLifetimeRegionalCtfWithMaterialTracksHbb" )
01016      
01017       self.options['modules'].append( "-hltPixelTracksForMinBias" )
01018       self.options['modules'].append( "-hltPixelTracksForHighMult" )
01019       self.options['modules'].append( "-hltRegionalPixelTracks" )
01020       self.options['modules'].append( "-hltPixelTracksReg" )
01021       self.options['modules'].append( "-hltIter4Merged" )
01022       self.options['modules'].append( "-hltFastPixelHitsVertex" )
01023       self.options['modules'].append( "-hltFastPixelTracks")
01024       self.options['modules'].append( "-hltFastPixelTracksRecover")
01025       
01026       self.options['modules'].append( "-hltFastPrimaryVertexbbPhi")
01027       self.options['modules'].append( "-hltPixelTracksFastPVbbPhi")
01028       self.options['modules'].append( "-hltPixelTracksRecoverbbPhi" )
01029       self.options['modules'].append( "-hltFastPixelHitsVertexVHbb" )
01030       self.options['modules'].append( "-hltFastPixelTracksVHbb" )
01031       self.options['modules'].append( "-hltFastPixelTracksRecoverVHbb" )
01032 
01033       self.options['modules'].append( "-hltFastPrimaryVertex")
01034       self.options['modules'].append( "-hltFastPVPixelTracks")
01035       self.options['modules'].append( "-hltFastPVPixelTracksRecover" )
01036 
01037       self.options['modules'].append( "-hltIter4Tau3MuMerged" )
01038       self.options['modules'].append( "hltPixelMatchElectronsActivity" )
01039 
01040       self.options['modules'].append( "-hltMuonCSCDigis" )
01041       self.options['modules'].append( "-hltMuonDTDigis" )
01042       self.options['modules'].append( "-hltMuonRPCDigis" )
01043       self.options['modules'].append( "-hltGtDigis" )
01044       self.options['modules'].append( "-hltL1GtTrigReport" )
01045       self.options['modules'].append( "hltCsc2DRecHits" )
01046       self.options['modules'].append( "hltDt1DRecHits" )
01047       self.options['modules'].append( "hltRpcRecHits" )
01048       self.options['modules'].append( "-hltScalersRawToDigi" )
01049 
01050       self.options['sequences'].append( "-HLTL1SeededEgammaRegionalRecoTrackerSequence" )
01051       self.options['sequences'].append( "-HLTEcalActivityEgammaRegionalRecoTrackerSequence" )
01052       self.options['sequences'].append( "-HLTPixelMatchElectronActivityTrackingSequence" )
01053       self.options['sequences'].append( "-HLTDoLocalStripSequence" )
01054       self.options['sequences'].append( "-HLTDoLocalPixelSequence" )
01055       self.options['sequences'].append( "-HLTDoLocalPixelSequenceRegL2Tau" )
01056       self.options['sequences'].append( "-hltSiPixelDigis" )
01057       self.options['sequences'].append( "-hltSiPixelClusters" )
01058       self.options['sequences'].append( "-hltSiPixelRecHits" )
01059       self.options['sequences'].append( "-HLTRecopixelvertexingSequence" )
01060       self.options['sequences'].append( "-HLTEndSequence" )
01061       self.options['sequences'].append( "-HLTBeginSequence" )
01062       self.options['sequences'].append( "-HLTBeginSequenceNZS" )
01063       self.options['sequences'].append( "-HLTBeginSequenceBPTX" )
01064       self.options['sequences'].append( "-HLTBeginSequenceAntiBPTX" )
01065       self.options['sequences'].append( "-HLTHBHENoiseSequence" )
01066       self.options['sequences'].append( "-HLTIterativeTracking" )
01067       self.options['sequences'].append( "-HLTIterativeTrackingTau3Mu" )
01068       self.options['sequences'].append( "-HLTRegionalCKFTracksForL3Isolation" )
01069       self.options['sequences'].append( "-HLTHBHENoiseCleanerSequence" )
01070 
01071       # remove HLTAnalyzerEndpath from fastsim cff's
01072       if self.config.fragment:
01073         self.options['paths'].append( "-HLTAnalyzerEndpath" )
01074 
01075 
01076   def build_source(self):
01077     if self.config.input:
01078       # if a dataset or a list of input files was given, use it
01079       if self.config.input[0:8] == 'dataset:':
01080         from dbsFileQuery import dbsFileQuery
01081         # extract the dataset name, and use DBS to fine the list of LFNs
01082         dataset = self.config.input[8:]
01083         query   = 'find file where dataset=' + dataset
01084         files   = dbsFileQuery(query)
01085         self.source = files
01086       else:
01087         # assume a list of input files
01088         self.source = self.config.input.split(',')
01089     elif self.config.online:
01090       # online we always run on data
01091       self.source = [ "file:/tmp/InputCollection.root" ]
01092     elif self.config.data:
01093       # offline we can run on data...
01094       self.source = [ "file:RelVal_Raw_%s_DATA.root" % self.config.type ]
01095     else:
01096       # ...or on mc
01097       self.source = [ "file:RelVal_Raw_%s_STARTUP.root" % self.config.type ]
01098 
01099     self.data += """
01100 %(process)ssource = cms.Source( "PoolSource",
01101     fileNames = cms.untracked.vstring(
01102 """
01103     if self.source: 
01104       for line in self.source:
01105         self.data += "        '%s',\n" % line
01106     self.data += """    ),
01107     secondaryFileNames = cms.untracked.vstring(
01108 """
01109     if self.parent: 
01110       for line in self.parent:
01111         self.data += "        '%s',\n" % line
01112     self.data += """    ),
01113     inputCommands = cms.untracked.vstring(
01114         'keep *'
01115     )
01116 )
01117 """
01118