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' )
- [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'
Using None as any argument restores its default value.

Definition at line 427 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::SwitchOnTriggerMatchingStandAlone::__init__ (   self)

Definition at line 448 of file trigTools.py.

00449                         :
00450         ConfigToolBase.__init__( self )
00451         self.addParameter( self._defaultParameters, 'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
00452         self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
00453         self.addParameter( self._defaultParameters, 'sequence'       , _defaultSequence       , _defaultSequenceComment )
00454         self.addParameter( self._defaultParameters, 'hltProcess'     , _defaultHltProcess     , _defaultHltProcessComment )
00455         self.addParameter( self._defaultParameters, 'outputModule'   , _defaultOutputModule   , _defaultOutputModuleComment )
00456         self._parameters = copy.deepcopy( self._defaultParameters )
00457         self._comment = ""


Member Function Documentation

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

Definition at line 461 of file trigTools.py.

00468                  :
00469         if triggerMatchers is None:
00470             triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
00471         if triggerProducer is None:
00472             triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
00473         if sequence is None:
00474             sequence = self._defaultParameters[ 'sequence' ].value
00475         if hltProcess is None:
00476             hltProcess = self._defaultParameters[ 'hltProcess' ].value
00477         if outputModule is None:
00478             outputModule = self._defaultParameters[ 'outputModule' ].value
00479         self.setParameter( 'triggerMatchers', triggerMatchers )
00480         self.setParameter( 'triggerProducer', triggerProducer )
00481         self.setParameter( 'sequence'       , sequence )
00482         self.setParameter( 'hltProcess'     , hltProcess )
00483         self.setParameter( 'outputModule'   , outputModule )
00484         self.apply( process )

def trigTools::SwitchOnTriggerMatchingStandAlone::getDefaultParameters (   self)

Definition at line 458 of file trigTools.py.

00459                                     :
00460         return self._defaultParameters

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

Definition at line 485 of file trigTools.py.

00486                                  :
00487         triggerMatchers = self._parameters[ 'triggerMatchers' ].value
00488         triggerProducer = self._parameters[ 'triggerProducer' ].value
00489         sequence        = self._parameters[ 'sequence' ].value
00490         hltProcess      = self._parameters[ 'hltProcess' ].value
00491         outputModule    = self._parameters[ 'outputModule' ].value
00492 
00493         # Load default producers from existing config file, if needed
00494         if not hasattr( process, 'triggerMatchingDefaultSequence' ):
00495             for matcher in triggerMatchers:
00496                 if matcher in self.getDefaultParameters()[ 'triggerMatchers' ].value:
00497                     process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" )
00498                     break
00499 
00500         # Switch on PAT trigger information if needed
00501         if triggerProducer not in _modulesInSequence( process, sequence ):
00502             print '%s():'%( self._label )
00503             print '    PAT trigger production switched on automatically using'
00504             print '    switchOnTriggerStandAlone( process, %s, %s, %s, %s )'%( hltProcess, triggerProducer, sequence, outputModule )
00505             print _longLine
00506             switchOnTriggerStandAlone( process, triggerProducer, sequence, hltProcess, outputModule )
00507 
00508         # Maintain configurations
00509         for matcher in triggerMatchers:
00510             trigMchMod         = getattr( process, matcher )
00511             trigMchMod.matched = triggerProducer
00512             if matcher in _modulesInSequence( process, sequence ):
00513                 print '%s():'%( self._label )
00514                 print '    PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence )
00515                 print '    ==> entry re-used'
00516                 print _longLine
00517             else:
00518                 # Sequence arithmetics for PAT trigger matcher modules
00519                 process.patTriggerSequence *= trigMchMod
00520 
00521         # Add event content
00522         if outputModule is not '':
00523             patTriggerEventContent = []
00524             for matcher in triggerMatchers:
00525                 patTriggerEventContent += [ 'keep patTriggerObjectStandAlonesedmAssociation_%s_*_%s'%( matcher, process.name_() )
00526                                           , 'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
00527                                           ]
00528             getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )


Member Data Documentation

Definition at line 448 of file trigTools.py.

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

Definition at line 446 of file trigTools.py.

Definition at line 445 of file trigTools.py.

Definition at line 448 of file trigTools.py.