CMS 3D CMS Logo

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