CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

trigTools::SwitchOnTrigger 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 = 'switchOnTrigger'

Detailed Description

Enables trigger information in PAT
SwitchOnTrigger( [cms.Process], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out' )
- [cms.Process]       : the 'cms.Process'
- 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'
Using None as any argument restores its default value.

Definition at line 67 of file trigTools.py.


Constructor & Destructor Documentation

def trigTools::SwitchOnTrigger::__init__ (   self)

Definition at line 87 of file trigTools.py.

00088                         :
00089         ConfigToolBase.__init__( self )
00090         self.addParameter( self._defaultParameters, 'triggerProducer'     , _defaultTriggerProducer     , _defaultTriggerProducerComment )
00091         self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
00092         self.addParameter( self._defaultParameters, 'sequence'            , _defaultSequence            , _defaultSequenceComment )
00093         self.addParameter( self._defaultParameters, 'hltProcess'          , _defaultHltProcess          , _defaultHltProcessComment )
00094         self.addParameter( self._defaultParameters, 'outputModule'        , _defaultOutputModule        , _defaultOutputModuleComment )
00095         self._parameters = copy.deepcopy( self._defaultParameters )
00096         self._comment = ""


Member Function Documentation

def trigTools::SwitchOnTrigger::__call__ (   self,
  process,
  triggerProducer = None,
  triggerEventProducer = None,
  sequence = None,
  hltProcess = None,
  outputModule = None 
)

Definition at line 100 of file trigTools.py.

00107                  :
00108         if triggerProducer is None:
00109             triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
00110         if triggerEventProducer is None:
00111             triggerEventProducer = self._defaultParameters[ 'triggerEventProducer' ].value
00112         if sequence is None:
00113             sequence = self._defaultParameters[ 'sequence' ].value
00114         if hltProcess is None:
00115             hltProcess = self._defaultParameters[ 'hltProcess' ].value
00116         if outputModule is None:
00117             outputModule = self._defaultParameters[ 'outputModule' ].value
00118         self.setParameter( 'triggerProducer'     , triggerProducer )
00119         self.setParameter( 'triggerEventProducer', triggerEventProducer )
00120         self.setParameter( 'sequence'            , sequence )
00121         self.setParameter( 'hltProcess'          , hltProcess )
00122         self.setParameter( 'outputModule'        , outputModule )
00123         self.apply( process )

def trigTools::SwitchOnTrigger::getDefaultParameters (   self)

Definition at line 97 of file trigTools.py.

00098                                     :
00099         return self._defaultParameters

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

Definition at line 124 of file trigTools.py.

00125                                  :
00126         triggerProducer      = self._parameters[ 'triggerProducer' ].value
00127         triggerEventProducer = self._parameters[ 'triggerEventProducer' ].value
00128         sequence             = self._parameters[ 'sequence' ].value
00129         hltProcess           = self._parameters[ 'hltProcess' ].value
00130         outputModule         = self._parameters[ 'outputModule' ].value
00131 
00132         # Load default producers from existing config files, if needed
00133         if not hasattr( process, triggerProducer ):
00134             if triggerProducer is self.getDefaultParameters()[ 'triggerProducer' ].value:
00135                 process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi" )
00136         if not hasattr( process, triggerEventProducer ):
00137             if triggerEventProducer is self.getDefaultParameters()[ 'triggerEventProducer' ].value:
00138                 process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerEventProducer_cfi" )
00139 
00140         # Maintain configurations
00141         prodSequence            = getattr( process, sequence )
00142         trigProdMod             = getattr( process, triggerProducer )
00143         trigProdMod.processName = hltProcess
00144         if triggerProducer in _modulesInSequence( process, sequence ):
00145             print '%s():'%( self._label )
00146             print '    PATTriggerProducer module %s exists already in sequence %s'%( triggerProducer, sequence )
00147             print '    ==> entry re-used'
00148             if trigProdMod.onlyStandAlone.value() is True:
00149                 trigProdMod.onlyStandAlone = False
00150                 print '    configuration parameter automatically changed'
00151                 print '    PATTriggerProducer %s.onlyStandAlone --> %s'%( triggerProducer, trigProdMod.onlyStandAlone )
00152             print _longLine
00153         else:
00154             # Sequence arithmetics for PATTriggerProducer module
00155             if hasattr( process, sequence + 'Trigger' ):
00156                 index = len( getattr( process, sequence + 'Trigger' ).moduleNames() )
00157                 getattr( process, sequence + 'Trigger' ).insert( index, trigProdMod )
00158             else:
00159                 patTriggerSequence = cms.Sequence( trigProdMod )
00160                 setattr( process, sequence + 'Trigger', patTriggerSequence )
00161                 prodSequence *= getattr( process, sequence + 'Trigger' )
00162         trigEvtProdMod             = getattr( process, triggerEventProducer )
00163         trigEvtProdMod.processName = hltProcess
00164         if hasattr( trigEvtProdMod, 'patTriggerProducer' ):
00165             trigEvtProdMod.patTriggerProducer = triggerProducer
00166         else:
00167             trigEvtProdMod.patTriggerProducer = cms.InputTag( triggerProducer )
00168         if triggerEventProducer in _modulesInSequence( process, sequence ):
00169             print '%s():'%( self._label )
00170             print '    PATTriggerEventProducer module %s exists already in sequence %s'%( triggerEventProducer, sequence )
00171             print '    ==> entry re-used'
00172             print _longLine
00173         else:
00174             # Sequence arithmetics for PATTriggerEventProducer module
00175             if hasattr( process, sequence + 'TriggerEvent' ):
00176                 index = len( getattr( process, sequence + 'Trigger' ).moduleNames() )
00177                 getattr( process, sequence + 'TriggerEvent' ).insert( index, trigEvtProdMod )
00178             else:
00179                 patTriggerEventSequence = cms.Sequence( trigEvtProdMod )
00180                 setattr( process, sequence + 'TriggerEvent', patTriggerEventSequence )
00181                 prodSequence *= getattr( process, sequence + 'TriggerEvent' )
00182 
00183         # Add event content
00184         if outputModule is not '':
00185             patTriggerEventContent = [ 'keep patTriggerObjects_%s_*_%s'%( triggerProducer, process.name_() )
00186                                      , 'keep patTriggerFilters_%s_*_%s'%( triggerProducer, process.name_() )
00187                                      , 'keep patTriggerPaths_%s_*_%s'%( triggerProducer, process.name_() )
00188                                      , 'keep patTriggerEvent_%s_*_%s'%( triggerEventProducer, process.name_() )
00189                                      ]
00190             if hasattr( trigProdMod, 'addL1Algos' ) and trigProdMod.addL1Algos.value() is True:
00191                 patTriggerEventContent += [ 'keep patTriggerConditions_%s_*_%s'%( triggerProducer, process.name_() )
00192                                           , 'keep patTriggerAlgorithms_%s_*_%s'%( triggerProducer, process.name_() )
00193                                           ]
00194             if hasattr( trigProdMod, 'saveL1Refs' ) and trigProdMod.saveL1Refs.value() is True:
00195                 patTriggerEventContent += patTriggerL1RefsEventContent
00196             getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )


Member Data Documentation

Definition at line 87 of file trigTools.py.

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

Definition at line 85 of file trigTools.py.

Definition at line 84 of file trigTools.py.

Definition at line 87 of file trigTools.py.