CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

trigTools::SwitchOnTriggerMatchEmbedding Class Reference

Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.

List of all members.

Public Member Functions

def __call__
def __init__
def getDefaultParameters
def toolCode

Private Attributes

 _comment
 _parameters

Static Private Attributes

tuple _defaultParameters = dicttypes.SortedKeysDict()
string _label = 'switchOnTriggerMatchEmbedding'

Detailed Description

Enables embedding of trigger matches into PAT objects
SwitchOnTriggerMatchEmbedding( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
- [cms.Process]  : the 'cms.Process'
- triggerMatchers: PAT trigger matcher module labels (list)
                   optional; default: defined in 'triggerMatchingDefaultSequence'
                   (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
- triggerProducer: PATTriggerProducer module label;
                   optional, default: 'patTrigger'
- sequence       : name of sequence to use;
                   optional, default: 'patDefaultSequence'
- hltProcess     : HLT process name;
                   optional, default: 'HLT'
- outputModule   : output module label;
                   empty label indicates no output;
                   optional, default: 'out'
- postfix        : postfix to apply to PAT module labels;
                   optional, default: ''
Using None as any argument restores its default value.

Definition at line 563 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::SwitchOnTriggerMatchEmbedding::__init__ (   self)

Definition at line 586 of file trigTools.py.

00587                         :
00588         ConfigToolBase.__init__( self )
00589         self.addParameter( self._defaultParameters, 'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
00590         self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
00591         self.addParameter( self._defaultParameters, 'sequence'       , _defaultSequence       , _defaultSequenceComment )
00592         self.addParameter( self._defaultParameters, 'hltProcess'     , _defaultHltProcess     , _defaultHltProcessComment )
00593         self.addParameter( self._defaultParameters, 'outputModule'   , _defaultOutputModule   , _defaultOutputModuleComment )
00594         self.addParameter( self._defaultParameters, 'postfix'        , _defaultPostfix        , _defaultPostfixComment )
00595         self._parameters = copy.deepcopy( self._defaultParameters )
00596         self._comment = ""


Member Function Documentation

def trigTools::SwitchOnTriggerMatchEmbedding::__call__ (   self,
  process,
  triggerMatchers = None,
  triggerProducer = None,
  sequence = None,
  hltProcess = None,
  outputModule = None,
  postfix = None 
)

Definition at line 600 of file trigTools.py.

00608                  :
00609         if triggerMatchers is None:
00610             triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
00611         if triggerProducer is None:
00612             triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
00613         if sequence is None:
00614             sequence = self._defaultParameters[ 'sequence' ].value
00615         if hltProcess is None:
00616             hltProcess = self._defaultParameters[ 'hltProcess' ].value
00617         if outputModule is None:
00618             outputModule = self._defaultParameters[ 'outputModule' ].value
00619         if postfix is None:
00620             postfix = self._defaultParameters[ 'postfix' ].value
00621         self.setParameter( 'triggerMatchers', triggerMatchers )
00622         self.setParameter( 'triggerProducer', triggerProducer )
00623         self.setParameter( 'sequence'       , sequence )
00624         self.setParameter( 'hltProcess'     , hltProcess )
00625         self.setParameter( 'outputModule'   , outputModule )
00626         self.setParameter( 'postfix'        , postfix )
00627         self.apply( process )

def trigTools::SwitchOnTriggerMatchEmbedding::getDefaultParameters (   self)

Definition at line 597 of file trigTools.py.

00598                                     :
00599         return self._defaultParameters

def trigTools::SwitchOnTriggerMatchEmbedding::toolCode (   self,
  process 
)

Definition at line 628 of file trigTools.py.

00629                                  :
00630         triggerMatchers = self._parameters[ 'triggerMatchers' ].value
00631         triggerProducer = self._parameters[ 'triggerProducer' ].value
00632         sequence        = self._parameters[ 'sequence' ].value
00633         hltProcess      = self._parameters[ 'hltProcess' ].value
00634         outputModule    = self._parameters[ 'outputModule' ].value
00635         postfix         = self._parameters[ 'postfix' ].value
00636 
00637         # Build dictionary of known input collections
00638         dictPatObjects = { 'Photons'  : 'PATTriggerMatchPhotonEmbedder'
00639                          , 'Electrons': 'PATTriggerMatchElectronEmbedder'
00640                          , 'Muons'    : 'PATTriggerMatchMuonEmbedder'
00641                          , 'Taus'     : 'PATTriggerMatchTauEmbedder'
00642                          , 'Jets'     : 'PATTriggerMatchJetEmbedder'
00643                          , 'METs'     : 'PATTriggerMatchMETEmbedder'
00644                          }
00645         listPatSteps   = [ 'pat', 'selectedPat', 'cleanPat' ]
00646         listJetAlgos   = [ 'IC5', 'SC5', 'KT4', 'KT6', 'AK5' ]
00647         listJetTypes   = [ 'Calo', 'PF', 'JPT' ]
00648         dictEmbedders  = {}
00649         for objects in dictPatObjects.keys():
00650             steps = len( listPatSteps )
00651             if objects is 'METs':
00652                 steps = 1
00653             for step in range( steps ):
00654                 coll = listPatSteps[ step ] + objects
00655                 dictEmbedders[ coll ]           = dictPatObjects[ objects ]
00656                 dictEmbedders[ coll + postfix ] = dictPatObjects[ objects ]
00657                 if objects is 'Jets':
00658                     for jetAlgo in listJetAlgos:
00659                         for jetType in listJetTypes:
00660                             jetColl = coll + jetAlgo + jetType
00661                             dictEmbedders[ jetColl ]           = dictPatObjects[ objects ]
00662                             dictEmbedders[ jetColl + postfix ] = dictPatObjects[ objects ]
00663 
00664         # Build dictionary of matchers and switch on PAT trigger matching if needed
00665         dictConfig = {}
00666         matchingOn = False
00667         for matcher in triggerMatchers:
00668             trigMchMod = getattr( process, matcher )
00669             if trigMchMod.src.value() in dictConfig:
00670                 dictConfig[ trigMchMod.src.value() ] += [ matcher ]
00671             else:
00672                 dictConfig[ trigMchMod.src.value() ] = [ matcher ]
00673             if matcher not in _modulesInSequence( process, sequence ) and not matchingOn:
00674                 print '%s():'%( self._label )
00675                 print '    PAT trigger matching switched on automatically using'
00676                 print '    switchOnTriggerMatchingStandAlone( process, %s, %s, %s, %s, %s )'%( hltProcess, triggerMatchers, triggerProducer, sequence, outputModule )
00677                 print _longLine
00678                 switchOnTriggerMatchingStandAlone( process, triggerMatchers, triggerProducer, sequence, hltProcess, '', postfix )
00679                 matchingOn = True
00680 
00681         # Maintain configurations
00682         patTriggerEventContent = []
00683         for srcInput in dictConfig.keys():
00684             if dictEmbedders.has_key( srcInput ):
00685                 # Configure embedder module
00686                 dictIndex = srcInput
00687                 srcInput += postfix
00688                 if dictEmbedders.has_key( srcInput ):
00689                     label = srcInput + 'TriggerMatch'
00690                     if label in _modulesInSequence( process, sequence ):
00691                         print '%s():'%( self._label )
00692                         print '    PAT trigger match embedder %s exists already in sequence %s'%( label, sequence )
00693                         print '    ==> entry moved to proper place'
00694                         print _longLine
00695                         removeIfInSequence( process, label, sequence + 'Trigger' )
00696                     module         = cms.EDProducer( dictEmbedders[ dictIndex ] )
00697                     module.src     = cms.InputTag( srcInput )
00698                     module.matches = cms.VInputTag( dictConfig[ dictIndex ] )
00699                     setattr( process, label, module )
00700                     trigEmbMod = getattr( process, label )
00701                     index = len( getattr( process, sequence + 'Trigger' ).moduleNames() )
00702                     getattr( process, sequence + 'Trigger' ).insert( index, trigEmbMod )
00703                     # Add event content
00704                     patTriggerEventContent += [ 'drop *_%s_*_*'%( srcInput )
00705                                               , 'keep *_%s_*_%s'%( label, process.name_() )
00706                                               ]
00707                 else:
00708                     print '%s():'%( self._label )
00709                     print '    Invalid new input source for trigger match embedding'
00710                     print '    ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ dictIndex ] )
00711                     print _longLine
00712             else:
00713                 print '%s():'%( self._label )
00714                 print '    Invalid input source for trigger match embedding'
00715                 print '    ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ srcInput ] )
00716                 print _longLine
00717         if outputModule is not '':
00718             getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )


Member Data Documentation

Definition at line 586 of file trigTools.py.

tuple trigTools::SwitchOnTriggerMatchEmbedding::_defaultParameters = dicttypes.SortedKeysDict() [static, private]

Definition at line 584 of file trigTools.py.

Definition at line 583 of file trigTools.py.

Definition at line 586 of file trigTools.py.