Пример #1
0
    def toolCode(self, process):

        task = getPatAlgosToolsTask(process)

        triggerProducer = self._parameters['triggerProducer'].value
        path = self._parameters['path'].value
        hltProcess = self._parameters['hltProcess'].value
        outputModule = self._parameters['outputModule'].value

        # Load default producer from existing config file, if needed
        if not hasattr(process, triggerProducer):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
            addToProcessAndTask(triggerProducer,
                                patTrigger.clone(onlyStandAlone=True), process,
                                task)
        else:
            print('%s():' % (self._label))
            print(
                '    PATTriggerProducer module \'%s\' exists already in process'
                % (triggerProducer))
            print('    ==> entry re-used')
            print(_longLine)

        # Maintain configuration
        trigProdMod = getattr(process, triggerProducer)
        trigProdMod.processName = hltProcess
        if not path is '':
            if not hasattr(process, path):
                prodPath = cms.Path(trigProdMod)
                setattr(process, path, prodPath)
                print('%s():' % (self._label))
                print('    Path \'%s\' does not exist in process' % (path))
                print('    ==> created')
                print(_longLine)
            elif not triggerProducer in _modulesInPath(process, path):
                prodPath = getattr(process, path)
                prodPath += trigProdMod

        # Add event content
        if outputModule is not '':
            patTriggerEventContent = [
                'keep patTriggerObjectStandAlones_%s_*_%s' %
                (triggerProducer, process.name_())
            ]
            if (hasattr(trigProdMod, 'saveL1Refs')
                    and trigProdMod.saveL1Refs.value() is True):
                patTriggerEventContent += patTriggerL1RefsEventContent
            getattr(process, outputModule).outputCommands = _addEventContent(
                getattr(process, outputModule).outputCommands,
                patTriggerEventContent)
Пример #2
0
    def toolCode( self, process ):

        task = getPatAlgosToolsTask(process)

        triggerProducer = self._parameters[ 'triggerProducer' ].value
        path            = self._parameters[ 'path' ].value
        hltProcess      = self._parameters[ 'hltProcess' ].value
        outputModule    = self._parameters[ 'outputModule' ].value

        # Load default producer from existing config file, if needed
        if not hasattr( process, triggerProducer ):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
            addToProcessAndTask(triggerProducer, patTrigger.clone( onlyStandAlone = True ), process, task)
        else:
            print '%s():'%( self._label )
            print '    PATTriggerProducer module \'%s\' exists already in process'%( triggerProducer )
            print '    ==> entry re-used'
            print _longLine

        # Maintain configuration
        trigProdMod             = getattr( process, triggerProducer )
        trigProdMod.processName = hltProcess
        if not path is '':
            if not hasattr( process, path ):
                prodPath = cms.Path( trigProdMod )
                setattr( process, path, prodPath )
                print '%s():'%( self._label )
                print '    Path \'%s\' does not exist in process'%( path )
                print '    ==> created'
                print _longLine
            elif not triggerProducer in _modulesInPath( process, path ):
                prodPath = getattr( process, path )
                prodPath += trigProdMod

        # Add event content
        if outputModule is not '':
            patTriggerEventContent = [ 'keep patTriggerObjectStandAlones_%s_*_%s'%( triggerProducer, process.name_() )
                                     ]
            if ( hasattr( trigProdMod, 'saveL1Refs' ) and trigProdMod.saveL1Refs.value() is True ):
                patTriggerEventContent += patTriggerL1RefsEventContent
            getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
###

if addTriggerMatching:

  if runOnMC:
    triggerObjectSelection = triggerObjectSelectionMC
  else:
    if useRelVals:
      triggerObjectSelection = triggerObjectSelectionDataRelVals
    else:
      triggerObjectSelection = triggerObjectSelectionData
  ### Trigger matching configuration
  from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
  from TopQuarkAnalysis.Configuration.patRefSel_triggerMatching_cfi import patMuonTriggerMatch
  from PhysicsTools.PatAlgos.tools.trigTools import *
  triggerProducerPF = patTrigger.clone()
  setattr( process, 'patTrigger' + postfix, triggerProducerPF )
  triggerMatchPF = patMuonTriggerMatch.clone( matchedCuts = triggerObjectSelection )
  setattr( process, 'triggerMatch' + postfix, triggerMatchPF )
  switchOnTriggerMatchEmbedding( process
                               , triggerProducer = 'patTrigger' + postfix
                               , triggerMatchers = [ 'triggerMatch' + postfix ]
                               , sequence        = 'patPF2PATSequence' + postfix
                               , postfix         = postfix
                               )
  removeCleaningFromTriggerMatching( process
                                   , sequence = 'patPF2PATSequence' + postfix
                                   )
  getattr( process, 'intermediatePatMuons' + postfix ).src = cms.InputTag( 'selectedPatMuons' + postfix + 'TriggerMatch' )

Пример #4
0
    def toolCode( self, process ):
        triggerProducer      = self._parameters[ 'triggerProducer' ].value
        triggerEventProducer = self._parameters[ 'triggerEventProducer' ].value
        path                 = self._parameters[ 'path' ].value
        hltProcess           = self._parameters[ 'hltProcess' ].value
        outputModule         = self._parameters[ 'outputModule' ].value

        task = getPatAlgosToolsTask(process)

        # Load default producers from existing config files, if needed
        if not hasattr( process, triggerProducer ):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
            addToProcessAndTask(triggerProducer, patTrigger.clone(), process, task)
        else:
            print '%s():'%( self._label )
            print '    PATTriggerProducer module \'%s\' exists already in process'%( triggerProducer )
            print '    ==> entry re-used'
            print _longLine
        if not hasattr( process, triggerEventProducer ):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerEventProducer_cfi import patTriggerEvent
            addToProcessAndTask(triggerEventProducer, patTriggerEvent.clone(), process, task)
        else:
            print '%s():'%( self._label )
            print '    PATTriggerEventProducer module \'%s\' exists already in process'%( triggerEventProducer )
            print '    ==> entry re-used'
            print _longLine

        # Maintain configurations
        trigProdMod             = getattr( process, triggerProducer )
        trigProdMod.processName = hltProcess
        if trigProdMod.onlyStandAlone.value() is True:
            trigProdMod.onlyStandAlone = False
            print '    configuration parameter automatically changed'
            print '    PATTriggerProducer %s.onlyStandAlone --> %s'%( triggerProducer, trigProdMod.onlyStandAlone )
            print _longLine
        trigEvtProdMod                    = getattr( process, triggerEventProducer )
        trigEvtProdMod.processName        = hltProcess
        trigEvtProdMod.patTriggerProducer = cms.InputTag( triggerProducer )
        if not path is '':
            if not hasattr( process, path ):
                prodPath = cms.Path( trigProdMod + trigEvtProdMod )
                setattr( process, path, prodPath )
                print '%s():'%( self._label )
                print '    Path \'%s\' does not exist in process'%( path )
                print '    ==> created'
                print _longLine
            # Try to get the order right, but cannot deal with all possible cases.
            # Simply rely on the exclusive usage of these tools without manual intervention.
            else:
                if not triggerProducer in _modulesInPath( process, path ):
                    prodPath = getattr( process, path )
                    prodPath += trigProdMod
                if not triggerEventProducer in _modulesInPath( process, path ):
                    prodPath = getattr( process, path )
                    prodPath += trigEvtProdMod

        # Add event content
        if outputModule is not '':
            patTriggerEventContent = [ 'keep patTriggerObjects_%s_*_%s'%( triggerProducer, process.name_() )
                                     , 'keep patTriggerFilters_%s_*_%s'%( triggerProducer, process.name_() )
                                     , 'keep patTriggerPaths_%s_*_%s'%( triggerProducer, process.name_() )
                                     , 'keep patTriggerEvent_%s_*_%s'%( triggerEventProducer, process.name_() )
                                     ]
            if ( hasattr( trigProdMod, 'addL1Algos' ) and trigProdMod.addL1Algos.value() is True ):
                patTriggerEventContent += [ 'keep patTriggerConditions_%s_*_%s'%( triggerProducer, process.name_() )
                                          , 'keep patTriggerAlgorithms_%s_*_%s'%( triggerProducer, process.name_() )
                                          ]
            if ( hasattr( trigProdMod, 'saveL1Refs' ) and trigProdMod.saveL1Refs.value() is True ):
                patTriggerEventContent += patTriggerL1RefsEventContent
            getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
Пример #5
0
    def toolCode(self, process):
        triggerProducer = self._parameters['triggerProducer'].value
        triggerEventProducer = self._parameters['triggerEventProducer'].value
        path = self._parameters['path'].value
        hltProcess = self._parameters['hltProcess'].value
        outputModule = self._parameters['outputModule'].value

        # Load default producers from existing config files, if needed
        if not hasattr(process, triggerProducer):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
            setattr(process, triggerProducer, patTrigger.clone())
        else:
            print '%s():' % (self._label)
            print '    PATTriggerProducer module \'%s\' exists already in process' % (
                triggerProducer)
            print '    ==> entry re-used'
            print _longLine
        if not hasattr(process, triggerEventProducer):
            from PhysicsTools.PatAlgos.triggerLayer1.triggerEventProducer_cfi import patTriggerEvent
            setattr(process, triggerEventProducer, patTriggerEvent.clone())
        else:
            print '%s():' % (self._label)
            print '    PATTriggerEventProducer module \'%s\' exists already in process' % (
                triggerEventProducer)
            print '    ==> entry re-used'
            print _longLine

        # Maintain configurations
        trigProdMod = getattr(process, triggerProducer)
        trigProdMod.processName = hltProcess
        if trigProdMod.onlyStandAlone.value() is True:
            trigProdMod.onlyStandAlone = False
            print '    configuration parameter automatically changed'
            print '    PATTriggerProducer %s.onlyStandAlone --> %s' % (
                triggerProducer, trigProdMod.onlyStandAlone)
            print _longLine
        trigEvtProdMod = getattr(process, triggerEventProducer)
        trigEvtProdMod.processName = hltProcess
        trigEvtProdMod.patTriggerProducer = cms.InputTag(triggerProducer)
        if not path is '':
            if not hasattr(process, path):
                prodPath = cms.Path(trigProdMod + trigEvtProdMod)
                setattr(process, path, prodPath)
                print '%s():' % (self._label)
                print '    Path \'%s\' does not exist in process' % (path)
                print '    ==> created'
                print _longLine
            # Try to get the order right, but cannot deal with all possible cases.
            # Simply rely on the exclusive usage of these tools without manual intervention.
            else:
                if not triggerProducer in _modulesInPath(process, path):
                    prodPath = getattr(process, path)
                    prodPath += trigProdMod
                if not triggerEventProducer in _modulesInPath(process, path):
                    prodPath = getattr(process, path)
                    prodPath += trigEvtProdMod

        # Add event content
        if outputModule is not '':
            patTriggerEventContent = [
                'keep patTriggerObjects_%s_*_%s' %
                (triggerProducer, process.name_()),
                'keep patTriggerFilters_%s_*_%s' %
                (triggerProducer, process.name_()),
                'keep patTriggerPaths_%s_*_%s' %
                (triggerProducer, process.name_()),
                'keep patTriggerEvent_%s_*_%s' %
                (triggerEventProducer, process.name_())
            ]
            if (hasattr(trigProdMod, 'addL1Algos')
                    and trigProdMod.addL1Algos.value() is True):
                patTriggerEventContent += [
                    'keep patTriggerConditions_%s_*_%s' %
                    (triggerProducer, process.name_()),
                    'keep patTriggerAlgorithms_%s_*_%s' %
                    (triggerProducer, process.name_())
                ]
            if (hasattr(trigProdMod, 'saveL1Refs')
                    and trigProdMod.saveL1Refs.value() is True):
                patTriggerEventContent += patTriggerL1RefsEventContent
            getattr(process, outputModule).outputCommands = _addEventContent(
                getattr(process, outputModule).outputCommands,
                patTriggerEventContent)
Пример #6
0
import FWCore.ParameterSet.Config as cms

##### Config some trigger matching with the pat::Muons
from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanMuonTriggerMatchHLTMu20
from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
from PhysicsTools.PatAlgos.triggerLayer1.triggerMatchEmbedder_cfi import cleanPatMuonsTriggerMatch

patMuonTriggerResults = patTrigger.clone(processName = cms.string('*'))
patMuonTriggerMatch = cleanMuonTriggerMatchHLTMu20.clone(
                                src = cms.InputTag('selectedPatMuonsPFlow'),
                                matched = cms.InputTag( "patMuonTriggerResults" ),
                                matchedCuts = cms.string( 'path( "HLT_Mu9" ) ||'+\
                                                          'path( "HLT_Mu11" ) ||'+\
                                                          'path( "HLT_Mu13_v*" ) ||'+\
                                                          'path( "HLT_Mu15_v*" ) ||'+\
                                                          'path( "HLT_Mu17_v*" ) ||'+\
                                                          'path( "HLT_Mu19_v*" ) ||'+\
                                                          'path( "HLT_Mu20_v*" ) ||'+\
                                                          'path( "HLT_Mu21_v*" )'
                                                          )
)
triggeredPatMuons = cleanPatMuonsTriggerMatch.clone(src = patMuonTriggerMatch.src,
                                                                 matches = cms.VInputTag('patMuonTriggerMatch'))
patMuonTrigger = cms.Sequence(patMuonTriggerResults*patMuonTriggerMatch*triggeredPatMuons)
#####

Пример #7
0
import FWCore.ParameterSet.Config as cms

##### Config some trigger matching with the pat::Muons
from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi import cleanMuonTriggerMatchHLTMu20
from PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi import patTrigger
from PhysicsTools.PatAlgos.triggerLayer1.triggerMatchEmbedder_cfi import cleanPatMuonsTriggerMatch

patMuonTriggerResults = patTrigger.clone(processName=cms.string('*'))
patMuonTriggerMatch = cleanMuonTriggerMatchHLTMu20.clone(
                                src = cms.InputTag('selectedPatMuonsPFlow'),
                                matched = cms.InputTag( "patMuonTriggerResults" ),
                                matchedCuts = cms.string( 'path( "HLT_Mu9" ) ||'+\
                                                          'path( "HLT_Mu11" ) ||'+\
                                                          'path( "HLT_Mu13_v*" ) ||'+\
                                                          'path( "HLT_Mu15_v*" ) ||'+\
                                                          'path( "HLT_Mu17_v*" ) ||'+\
                                                          'path( "HLT_Mu19_v*" ) ||'+\
                                                          'path( "HLT_Mu20_v*" ) ||'+\
                                                          'path( "HLT_Mu21_v*" )'
                                                          )
)
triggeredPatMuons = cleanPatMuonsTriggerMatch.clone(
    src=patMuonTriggerMatch.src, matches=cms.VInputTag('patMuonTriggerMatch'))
patMuonTrigger = cms.Sequence(patMuonTriggerResults * patMuonTriggerMatch *
                              triggeredPatMuons)
#####