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 564 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::SwitchOnTriggerMatchEmbedding::__init__ (   self)

Definition at line 587 of file trigTools.py.

00588                         :
00589         ConfigToolBase.__init__( self )
00590         self.addParameter( self._defaultParameters, 'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
00591         self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
00592         self.addParameter( self._defaultParameters, 'sequence'       , _defaultSequence       , _defaultSequenceComment )
00593         self.addParameter( self._defaultParameters, 'hltProcess'     , _defaultHltProcess     , _defaultHltProcessComment )
00594         self.addParameter( self._defaultParameters, 'outputModule'   , _defaultOutputModule   , _defaultOutputModuleComment )
00595         self.addParameter( self._defaultParameters, 'postfix'        , _defaultPostfix        , _defaultPostfixComment )
00596         self._parameters = copy.deepcopy( self._defaultParameters )
00597         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 601 of file trigTools.py.

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

def trigTools::SwitchOnTriggerMatchEmbedding::getDefaultParameters (   self)

Definition at line 598 of file trigTools.py.

00599                                     :
00600         return self._defaultParameters

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

Definition at line 629 of file trigTools.py.

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


Member Data Documentation

Definition at line 587 of file trigTools.py.

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

Definition at line 585 of file trigTools.py.

Definition at line 584 of file trigTools.py.

Definition at line 587 of file trigTools.py.