Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.
Public Member Functions | |
def | __call__ |
def | __init__ |
def | getDefaultParameters |
def | toolCode |
Private Attributes | |
_comment | |
_parameters | |
Static Private Attributes | |
tuple | _defaultParameters = dicttypes.SortedKeysDict() |
string | _label = 'switchOnTriggerMatching' |
Enables trigger matching in PAT SwitchOnTriggerMatching( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', 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' - triggerEventProducer: PATTriggerEventProducer module label; optional, default: 'patTriggerEvent' - 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 297 of file trigTools.py.
def trigTools::SwitchOnTriggerMatching::__init__ | ( | self | ) |
Definition at line 322 of file trigTools.py.
00323 : 00324 ConfigToolBase.__init__( self ) 00325 self.addParameter( self._defaultParameters, 'triggerMatchers' , _defaultTriggerMatchers , _defaultTriggerMatchersComment ) 00326 self.addParameter( self._defaultParameters, 'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment ) 00327 self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment ) 00328 self.addParameter( self._defaultParameters, 'sequence' , _defaultSequence , _defaultSequenceComment ) 00329 self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment ) 00330 self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment ) 00331 self.addParameter( self._defaultParameters, 'postfix' , _defaultPostfix , _defaultPostfixComment ) 00332 self._parameters = copy.deepcopy( self._defaultParameters ) 00333 self._comment = ""
def trigTools::SwitchOnTriggerMatching::__call__ | ( | self, | |
process, | |||
triggerMatchers = None , |
|||
triggerProducer = None , |
|||
triggerEventProducer = None , |
|||
sequence = None , |
|||
hltProcess = None , |
|||
outputModule = None , |
|||
postfix = None |
|||
) |
Definition at line 337 of file trigTools.py.
00346 : 00347 if triggerMatchers is None: 00348 triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value 00349 if triggerProducer is None: 00350 triggerProducer = self._defaultParameters[ 'triggerProducer' ].value 00351 if triggerEventProducer is None: 00352 triggerEventProducer = self._defaultParameters[ 'triggerEventProducer' ].value 00353 if sequence is None: 00354 sequence = self._defaultParameters[ 'sequence' ].value 00355 if hltProcess is None: 00356 hltProcess = self._defaultParameters[ 'hltProcess' ].value 00357 if outputModule is None: 00358 outputModule = self._defaultParameters[ 'outputModule' ].value 00359 if postfix is None: 00360 postfix = self._defaultParameters[ 'postfix' ].value 00361 self.setParameter( 'triggerMatchers' , triggerMatchers ) 00362 self.setParameter( 'triggerProducer' , triggerProducer ) 00363 self.setParameter( 'triggerEventProducer', triggerEventProducer ) 00364 self.setParameter( 'sequence' , sequence ) 00365 self.setParameter( 'hltProcess' , hltProcess ) 00366 self.setParameter( 'outputModule' , outputModule ) 00367 self.setParameter( 'postfix' , postfix ) 00368 self.apply( process )
def trigTools::SwitchOnTriggerMatching::getDefaultParameters | ( | self | ) |
Definition at line 334 of file trigTools.py.
def trigTools::SwitchOnTriggerMatching::toolCode | ( | self, | |
process | |||
) |
Definition at line 369 of file trigTools.py.
00370 : 00371 triggerMatchers = self._parameters[ 'triggerMatchers' ].value 00372 triggerProducer = self._parameters[ 'triggerProducer' ].value 00373 triggerEventProducer = self._parameters[ 'triggerEventProducer' ].value 00374 sequence = self._parameters[ 'sequence' ].value 00375 hltProcess = self._parameters[ 'hltProcess' ].value 00376 outputModule = self._parameters[ 'outputModule' ].value 00377 postfix = self._parameters[ 'postfix' ].value 00378 00379 # Load default producers from existing config file, if needed 00380 if not hasattr( process, 'triggerMatchingDefaultSequence' ): 00381 for matcher in triggerMatchers: 00382 if matcher in self.getDefaultParameters()[ 'triggerMatchers' ].value: 00383 process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" ) 00384 break 00385 00386 # Switch on PAT trigger information if needed 00387 if ( triggerProducer not in _modulesInSequence( process, sequence ) or triggerEventProducer not in _modulesInSequence( process, sequence ) ): 00388 print '%s():'%( self._label ) 00389 print ' PAT trigger production switched on automatically using' 00390 print ' switchOnTrigger( process, %s, %s, %s, %s, %s )'%( hltProcess, triggerProducer, triggerEventProducer, sequence, outputModule ) 00391 print _longLine 00392 switchOnTrigger( process, triggerProducer, triggerEventProducer, sequence, hltProcess, outputModule ) 00393 00394 # Maintain configurations 00395 prodSequence = getattr( process, sequence ) 00396 trigEvtProdMod = getattr( process, triggerEventProducer ) 00397 if trigEvtProdMod.patTriggerProducer.value() is not triggerProducer: 00398 print '%s():'%( self._label ) 00399 print ' Configuration conflict found' 00400 print ' triggerProducer = %s'%( triggerProducer ) 00401 print ' differs from' 00402 print ' %s.patTriggerProducer = %s'%( triggerEventProducer, trigEvtProdMod.patTriggerProducer ) 00403 print ' parameter automatically changed' 00404 print ' ==> triggerProducer --> %s'%( trigEvtProdMod.patTriggerProducer ) 00405 triggerProducer = trigEvtProdMod.patTriggerProducer 00406 for matcher in triggerMatchers: 00407 trigMchMod = getattr( process, matcher ) 00408 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix ) 00409 trigMchMod.matched = triggerProducer 00410 if matcher in _modulesInSequence( process, sequence ): 00411 print '%s():'%( self._label ) 00412 print ' PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence ) 00413 print ' ==> entry re-used' 00414 print _longLine 00415 else: 00416 # Sequence arithmetics for PAT trigger matcher modules 00417 index = len( getattr( process, sequence + 'Trigger' ).moduleNames() ) 00418 getattr( process, sequence + 'Trigger' ).insert( index, trigMchMod ) 00419 matchers = getattr( trigEvtProdMod, 'patTriggerMatches' ) 00420 if len( matchers ) > 0: 00421 print '%s():'%( self._label ) 00422 print ' PAT trigger matchers already attached to existing PATTriggerEventProducer %s'%( triggerEventProducer ) 00423 print ' configuration parameters automatically changed' 00424 for matcher in matchers: 00425 trigMchMod = getattr( process, matcher ) 00426 if trigMchMod.matched.value() is not triggerProducer: 00427 removeIfInSequence( process, matcher, sequence + 'Trigger' ) 00428 trigMchMod.matched = triggerProducer 00429 index = len( getattr( process, sequence + 'Trigger' ).moduleNames() ) 00430 getattr( process, sequence + 'Trigger' ).insert( index, trigMchMod ) 00431 print ' PAT trigger matcher %s.matched --> %s'%( matcher, trigMchMod.matched ) 00432 print _longLine 00433 else: 00434 trigEvtProdMod.patTriggerMatches = cms.VInputTag() 00435 for matcher in triggerMatchers: 00436 trigEvtProdMod.patTriggerMatches.append( cms.InputTag( matcher ) ) 00437 00438 # Add event content 00439 if outputModule is not '': 00440 patTriggerEventContent = [] 00441 for matcher in triggerMatchers: 00442 patTriggerEventContent += [ 'keep patTriggerObjectsedmAssociation_%s_%s_%s'%( triggerEventProducer, matcher, process.name_() ) 00443 , 'keep *_%s_*_*'%( getattr( process, matcher ).src.value() ) 00444 ] 00445 getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
Definition at line 322 of file trigTools.py.
tuple trigTools::SwitchOnTriggerMatching::_defaultParameters = dicttypes.SortedKeysDict() [static, private] |
Definition at line 320 of file trigTools.py.
string trigTools::SwitchOnTriggerMatching::_label = 'switchOnTriggerMatching' [static, private] |
Definition at line 319 of file trigTools.py.
Definition at line 322 of file trigTools.py.