CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

trigTools::SwitchOnTriggerMatchingStandAlone 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 = 'switchOnTriggerMatchingStandAlone'

Detailed Description

Enables trigger matching in PAT
SwitchOnTriggerMatchingStandAlone( [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 448 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::SwitchOnTriggerMatchingStandAlone::__init__ (   self)

Definition at line 471 of file trigTools.py.

00472                         :
00473         ConfigToolBase.__init__( self )
00474         self.addParameter( self._defaultParameters, 'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
00475         self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
00476         self.addParameter( self._defaultParameters, 'sequence'       , _defaultSequence       , _defaultSequenceComment )
00477         self.addParameter( self._defaultParameters, 'hltProcess'     , _defaultHltProcess     , _defaultHltProcessComment )
00478         self.addParameter( self._defaultParameters, 'outputModule'   , _defaultOutputModule   , _defaultOutputModuleComment )
00479         self.addParameter( self._defaultParameters, 'postfix'        , _defaultPostfix        , _defaultPostfixComment )
00480         self._parameters = copy.deepcopy( self._defaultParameters )
00481         self._comment = ""


Member Function Documentation

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

Definition at line 485 of file trigTools.py.

00493                  :
00494         if triggerMatchers is None:
00495             triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
00496         if triggerProducer is None:
00497             triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
00498         if sequence is None:
00499             sequence = self._defaultParameters[ 'sequence' ].value
00500         if hltProcess is None:
00501             hltProcess = self._defaultParameters[ 'hltProcess' ].value
00502         if outputModule is None:
00503             outputModule = self._defaultParameters[ 'outputModule' ].value
00504         if postfix is None:
00505             postfix = self._defaultParameters[ 'postfix' ].value
00506         self.setParameter( 'triggerMatchers', triggerMatchers )
00507         self.setParameter( 'triggerProducer', triggerProducer )
00508         self.setParameter( 'sequence'       , sequence )
00509         self.setParameter( 'hltProcess'     , hltProcess )
00510         self.setParameter( 'outputModule'   , outputModule )
00511         self.setParameter( 'postfix'        , postfix )
00512         self.apply( process )

def trigTools::SwitchOnTriggerMatchingStandAlone::getDefaultParameters (   self)

Definition at line 482 of file trigTools.py.

00483                                     :
00484         return self._defaultParameters

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

Definition at line 513 of file trigTools.py.

00514                                  :
00515         triggerMatchers = self._parameters[ 'triggerMatchers' ].value
00516         triggerProducer = self._parameters[ 'triggerProducer' ].value
00517         sequence        = self._parameters[ 'sequence' ].value
00518         hltProcess      = self._parameters[ 'hltProcess' ].value
00519         outputModule    = self._parameters[ 'outputModule' ].value
00520         postfix         = self._parameters[ 'postfix' ].value
00521 
00522         # Load default producers from existing config file, if needed
00523         if not hasattr( process, 'triggerMatchingDefaultSequence' ):
00524             for matcher in triggerMatchers:
00525                 if matcher in self.getDefaultParameters()[ 'triggerMatchers' ].value:
00526                     process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" )
00527                     break
00528 
00529         # Switch on PAT trigger information if needed
00530         if triggerProducer not in _modulesInSequence( process, sequence ):
00531             print '%s():'%( self._label )
00532             print '    PAT trigger production switched on automatically using'
00533             print '    switchOnTriggerStandAlone( process, %s, %s, %s, %s )'%( hltProcess, triggerProducer, sequence, outputModule )
00534             print _longLine
00535             switchOnTriggerStandAlone( process, triggerProducer, sequence, hltProcess, outputModule )
00536 
00537         # Maintain configurations
00538         for matcher in triggerMatchers:
00539             trigMchMod         = getattr( process, matcher )
00540             trigMchMod.src     = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
00541             trigMchMod.matched = triggerProducer
00542             if matcher in _modulesInSequence( process, sequence ):
00543                 print '%s():'%( self._label )
00544                 print '    PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence )
00545                 print '    ==> entry re-used'
00546                 print _longLine
00547             else:
00548                 # Sequence arithmetics for PAT trigger matcher modules
00549                 index = len( getattr( process, sequence + 'Trigger' ).moduleNames() )
00550                 getattr( process, sequence + 'Trigger' ).insert( index, trigMchMod )
00551 
00552         # Add event content
00553         if outputModule is not '':
00554             patTriggerEventContent = []
00555             for matcher in triggerMatchers:
00556                 patTriggerEventContent += [ 'keep patTriggerObjectStandAlonesedmAssociation_%s_*_%s'%( matcher, process.name_() )
00557                                           , 'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
00558                                           ]
00559             getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )


Member Data Documentation

Definition at line 471 of file trigTools.py.

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

Definition at line 469 of file trigTools.py.

Definition at line 468 of file trigTools.py.

Definition at line 471 of file trigTools.py.