CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

trigTools::RemoveCleaningFromTriggerMatching Class Reference

Inherits FWCore::GuiBrowsers::ConfigToolBase::ConfigToolBase.

List of all members.

Public Member Functions

def __call__
def __init__
def getDefaultParameters
def toolCode

Private Member Functions

def _renameMatchers

Private Attributes

 _comment
 _parameters

Static Private Attributes

tuple _defaultParameters = dicttypes.SortedKeysDict()
string _label = 'removeCleaningFromTriggerMatching'

Detailed Description

Removes cleaning from already existing PAT trigger matching/embedding configuration
RemoveCleaningFromTriggerMatching( [cms.Process], outputModule = 'out' )
- [cms.Process]  : the 'cms.Process'
- sequence       : name of sequence to use;
                   optional, default: 'patDefaultSequence'
- outputModule   : output module label;
                   empty label indicates no output;
                   optional, default: 'out'
Using None as any argument restores its default value.

Definition at line 722 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::RemoveCleaningFromTriggerMatching::__init__ (   self)

Definition at line 736 of file trigTools.py.

00737                         :
00738         ConfigToolBase.__init__( self )
00739         self.addParameter( self._defaultParameters, 'sequence'    , _defaultSequence    , _defaultSequenceComment )
00740         self.addParameter( self._defaultParameters, 'outputModule', _defaultOutputModule, _defaultOutputModuleComment )
00741         self._parameters = copy.deepcopy( self._defaultParameters )
00742         self._comment = ""


Member Function Documentation

def trigTools::RemoveCleaningFromTriggerMatching::__call__ (   self,
  process,
  sequence = None,
  outputModule = None 
)

Definition at line 746 of file trigTools.py.

00750                  :
00751         if sequence is None:
00752             sequence = self._defaultParameters[ 'sequence' ].value
00753         if outputModule is None:
00754             outputModule = self._defaultParameters[ 'outputModule' ].value
00755         self.setParameter( 'sequence'    , sequence )
00756         self.setParameter( 'outputModule', outputModule )
00757         self.apply( process )

def trigTools::RemoveCleaningFromTriggerMatching::_renameMatchers (   self,
  matchers,
  oldModules 
) [private]

Definition at line 823 of file trigTools.py.

00824                                                      :
00825         for matcher in range( len( matchers ) ):
00826             if matchers[ matcher ] in oldModules:
00827                 if matchers[ matcher ][ : 5 ] == 'clean':
00828                      matchers[ matcher ] = matchers[ matcher ].replace( 'clean', 'selected' )
00829         return matchers

def trigTools::RemoveCleaningFromTriggerMatching::getDefaultParameters (   self)

Definition at line 743 of file trigTools.py.

00744                                     :
00745         return self._defaultParameters

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

Definition at line 758 of file trigTools.py.

00759                                  :
00760         sequence     = self._parameters[ 'sequence' ].value
00761         outputModule = self._parameters[ 'outputModule' ].value
00762 
00763         # Maintain configurations
00764         listMatchers = [ 'PATTriggerMatcherDRLessByR'
00765                        , 'PATTriggerMatcherDRDPtLessByR'
00766                        , 'PATTriggerMatcherDRLessByPt'
00767                        , 'PATTriggerMatcherDRDPtLessByPt'
00768                        , 'PATTriggerMatcherDEtaLessByDR'
00769                        , 'PATTriggerMatcherDEtaLessByDEta'
00770                        ]
00771         listEmbedders = [ 'PATTriggerMatchPhotonEmbedder'
00772                         , 'PATTriggerMatchElectronEmbedder'
00773                         , 'PATTriggerMatchMuonEmbedder'
00774                         , 'PATTriggerMatchTauEmbedder'
00775                         , 'PATTriggerMatchJetEmbedder'
00776                         , 'PATTriggerMatchMETEmbedder'
00777                         ]
00778         modules = _modulesInSequence( process, sequence )
00779         oldModules = []
00780         oldSources = []
00781         # input source labels
00782         for module in modules:
00783             if hasattr( process, module ):
00784                 trigMod = getattr( process, module )
00785                 if trigMod.type_() in listMatchers:
00786                     if trigMod.src.value()[ : 8 ] == 'cleanPat':
00787                         trigMod.src = trigMod.src.value().replace( 'cleanPat', 'selectedPat' )
00788                         if trigMod.label()[ : 5 ] == 'clean':
00789                             oldModules += [ trigMod.label() ]
00790                             setattr( process, trigMod.label().replace( 'clean', 'selected' ), trigMod )
00791                 if trigMod.type_() in listEmbedders:
00792                     if trigMod.src.value()[ : 8 ] == 'cleanPat':
00793                         oldSources += [ trigMod.src.getModuleLabel() ]
00794                         trigMod.src = trigMod.src.value().replace( 'cleanPat', 'selectedPat' )
00795                         if trigMod.label()[ : 5 ] == 'clean':
00796                             oldModules += [ trigMod.label() ]
00797                             setattr( process, trigMod.label().replace( 'clean', 'selected' ), trigMod )
00798         # matcher labels
00799         for module in modules:
00800             if hasattr( process, module ):
00801                 trigMod = getattr( process, module )
00802                 if trigMod.type_() == 'PATTriggerEventProducer':
00803                     matchers = getattr( trigMod, 'patTriggerMatches' )
00804                     matchers = self._renameMatchers( matchers, oldModules )
00805                 elif trigMod.type_() in listEmbedders:
00806                     matchers = getattr( trigMod, 'matches' )
00807                     matchers = self._renameMatchers( matchers, oldModules )
00808 
00809         # Maintain event content
00810         if outputModule is not '':
00811             patTriggerEventContent = getattr( process, outputModule ).outputCommands
00812             for statement in range( len( patTriggerEventContent ) ):
00813                 for module in oldModules:
00814                     if module in patTriggerEventContent[ statement ]:
00815                         patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].replace( 'clean', 'selected' )
00816                 for source in oldSources:
00817                     if source in patTriggerEventContent[ statement ] and 'drop' in patTriggerEventContent[ statement ]:
00818                         patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].replace( 'clean', 'selected' )
00819         print '%s():'%( self._label )
00820         print '    Input from cleaning has been switched to input from selection;'
00821         print '    matcher and embedder modules have been renamed accordingly.'
00822         print _longLine


Member Data Documentation

Definition at line 736 of file trigTools.py.

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

Definition at line 734 of file trigTools.py.

Definition at line 733 of file trigTools.py.

Definition at line 736 of file trigTools.py.