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


Constructor & Destructor Documentation

def trigTools::SwitchOnTriggerMatchingStandAlone::__init__ (   self)

Definition at line 472 of file trigTools.py.

00473                         :
00474         ConfigToolBase.__init__( self )
00475         self.addParameter( self._defaultParameters, 'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
00476         self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
00477         self.addParameter( self._defaultParameters, 'sequence'       , _defaultSequence       , _defaultSequenceComment )
00478         self.addParameter( self._defaultParameters, 'hltProcess'     , _defaultHltProcess     , _defaultHltProcessComment )
00479         self.addParameter( self._defaultParameters, 'outputModule'   , _defaultOutputModule   , _defaultOutputModuleComment )
00480         self.addParameter( self._defaultParameters, 'postfix'        , _defaultPostfix        , _defaultPostfixComment )
00481         self._parameters = copy.deepcopy( self._defaultParameters )
00482         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 486 of file trigTools.py.

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

def trigTools::SwitchOnTriggerMatchingStandAlone::getDefaultParameters (   self)

Definition at line 483 of file trigTools.py.

00484                                     :
00485         return self._defaultParameters

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

Definition at line 514 of file trigTools.py.

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


Member Data Documentation

Definition at line 472 of file trigTools.py.

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

Definition at line 470 of file trigTools.py.

Definition at line 469 of file trigTools.py.

Definition at line 472 of file trigTools.py.