CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Static Private Attributes
trigTools.SwitchOnTriggerMatching Class Reference
Inheritance diagram for trigTools.SwitchOnTriggerMatching:

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'
 

Detailed Description

Enables trigger matching in PAT
SwitchOnTriggerMatching( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', path = '', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
- [cms.Process]       : the 'cms.Process'
- triggerMatchers     : PAT trigger matcher module labels (list)
                        optional; default: defined in '_exampleTriggerMatchers'
                        (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcherExamples_cfi.py)
- triggerProducer     : PATTriggerProducer module label;
                        optional, default: 'patTrigger'
- triggerEventProducer: PATTriggerEventProducer module label;
                        optional, default: 'patTriggerEvent'
- path                : name of path 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 279 of file trigTools.py.

Constructor & Destructor Documentation

def trigTools.SwitchOnTriggerMatching.__init__ (   self)

Definition at line 304 of file trigTools.py.

References metTools.AddMETCollection._defaultParameters, editorTools.UserCodeTool._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, jetTools.AddJetCollection._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, tauTools.AddTauCollection._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, root::helper::RootFunctionAdapter< F, args >.addParameter(), root::helper::RootFunctionHelper< F, args, Tag >.addParameter(), ParameterMgr.addParameter(), fit::RootMinuit< Function >.addParameter(), DropBoxMetadata::Parameters.addParameter(), PythonParameterSet.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

305  def __init__( self ):
306  ConfigToolBase.__init__( self )
307  self.addParameter( self._defaultParameters, 'triggerMatchers' , _exampleTriggerMatchers , _defaultTriggerMatchersComment )
308  self.addParameter( self._defaultParameters, 'exampleMatchers' , False , '' )
309  self.addParameter( self._defaultParameters, 'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
310  self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
311  self.addParameter( self._defaultParameters, 'path' , _defaultPath , _defaultPathComment )
312  self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
313  self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
314  self.addParameter( self._defaultParameters, 'postfix' , _defaultPostfix , _defaultPostfixComment )
315  self._parameters = copy.deepcopy( self._defaultParameters )
316  self._comment = ""

Member Function Documentation

def trigTools.SwitchOnTriggerMatching.__call__ (   self,
  process,
  triggerMatchers = None,
  triggerProducer = None,
  triggerEventProducer = None,
  path = None,
  hltProcess = None,
  outputModule = None,
  postfix = None 
)

Definition at line 328 of file trigTools.py.

References metTools.AddMETCollection._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, jetTools.AddJetCollection._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, tauTools.AddTauCollection._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, SignedImpactParameter3D.apply(), gen::PhotosInterfaceBase.apply(), SignedTransverseImpactParameter.apply(), MatrixReader.MatrixReader.apply, SignedDecayLength3D.apply(), DummyOOTPileupCorrection.apply(), SurveyParameters.apply(), FWPSetCellEditor.apply(), gen::PhotosInterface.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), MatRepSparse< T, D1, D2, S, F >.apply(), ConfigToolBase.ConfigToolBase.apply(), AlignmentParameters.apply(), BowedSurfaceAlignmentParameters.apply(), OOTPileupCorrData.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool.apply(), AbsOOTPileupCorrection.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), Vispa.Gui.BoxContentDialog.BoxContentDialog.apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog.apply(), reco::Add< T >.apply(), reco::Sub< T >.apply(), reco::Mul< T >.apply(), reco::Div< T >.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), reco::And< bool >.apply(), reco::Or< bool >.apply(), reco::Less< T >.apply(), reco::LessEqual< T >.apply(), reco::More< T >.apply(), reco::MoreEqual< T >.apply(), reco::Equal< T >.apply(), ArrayND< Numeric, Len, Dim >.apply(), ArrayND< Num2, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), npstat::ArrayND< Numeric >.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), ArrayND< Accumulator >.apply(), npstat::ArrayND< Num1, Len1, Dim1 >.apply(), ora::OraMainTable.setParameter(), ora::IMainTable.setParameter(), PedeReader.setParameter(), ora::PoolMainTable.setParameter(), IntegratedCalibrationBase.setParameter(), SiStripLorentzAngleCalibration.setParameter(), SiPixelLorentzAngleCalibration.setParameter(), SiStripBackplaneCalibration.setParameter(), fit::RootMinuit< Function >.setParameter(), and ConfigToolBase.ConfigToolBase.setParameter().

Referenced by trigTools.SwitchOnTriggerMatching.getDefaultParameters().

329  ):
330  if triggerMatchers is None:
331  triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
332  self.setParameter( 'exampleMatchers', True )
333  if triggerProducer is None:
334  triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
335  if triggerEventProducer is None:
336  triggerEventProducer = self._defaultParameters[ 'triggerEventProducer' ].value
337  if path is None:
338  path = self._defaultParameters[ 'path' ].value
339  if hltProcess is None:
340  hltProcess = self._defaultParameters[ 'hltProcess' ].value
341  if outputModule is None:
342  outputModule = self._defaultParameters[ 'outputModule' ].value
343  if postfix is None:
344  postfix = self._defaultParameters[ 'postfix' ].value
345  self.setParameter( 'triggerMatchers' , triggerMatchers )
346  self.setParameter( 'triggerProducer' , triggerProducer )
347  self.setParameter( 'triggerEventProducer', triggerEventProducer )
348  self.setParameter( 'path' , path )
349  self.setParameter( 'hltProcess' , hltProcess )
350  self.setParameter( 'outputModule' , outputModule )
351  self.setParameter( 'postfix' , postfix )
352  self.apply( process )
def trigTools.SwitchOnTriggerMatching.getDefaultParameters (   self)

Definition at line 317 of file trigTools.py.

References trigTools.SwitchOnTriggerMatching.__call__(), metTools.AddMETCollection._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, editorTools.UserCodeTool._defaultParameters, heavyIonTools.ConfigureHeavyIons._defaultParameters, coreTools.RunOnData._defaultParameters, jetTools.AddJetCollection._defaultParameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, editorTools.ChangeSource._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, tauTools.AddTauCollection._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, and jetTools.SetTagInfos._defaultParameters.

318  def getDefaultParameters( self ):
319  return self._defaultParameters
def trigTools.SwitchOnTriggerMatching.toolCode (   self,
  process 
)

Definition at line 353 of file trigTools.py.

References trigTools._addEventContent(), metTools.AddMETCollection._label, trackTools.MakeAODTrackCandidates._label, editorTools.UserCodeTool._label, heavyIonTools.ConfigureHeavyIons._label, coreTools.RunOnData._label, MagneticFieldMapESProducer._label, TrackerInteractionGeometryESProducer._label, Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._label, jetTools.AddJetCollection._label, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._label, heavyIonTools.ProductionDefaults._label, ConfigToolBase.ConfigToolBase._label, editorTools.ChangeSource._label, LHECOMWeightProducer._label, cmsswVersionTools.PickRelValInputFiles._label, coreTools.RemoveMCMatching._label, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool._label, trackTools.MakePATTrackCandidates._label, trigTools.SwitchOnTrigger._label, heavyIonTools.SelectionDefaults._label, heavyIonTools.DisbaleMonteCarloDeps._label, trigTools.SwitchOnTriggerStandAlone._label, trackTools.MakeTrackCandidates._label, tauTools.AddTauCollection._label, trigTools.SwitchOnTriggerMatching._label, jetTools.SwitchJetCollection._label, jetTools.AddJetID._label, jetTools.SetTagInfos._label, Vispa.Views.LineDecayView.DecayLine._label, editorTools.UserCodeTool._parameters, heavyIonTools.ConfigureHeavyIons._parameters, coreTools.RunOnData._parameters, trackTools.MakeAODTrackCandidates._parameters, metTools.AddMETCollection._parameters, Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._parameters, Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool._parameters, heavyIonTools.ProductionDefaults._parameters, ConfigToolBase.ConfigToolBase._parameters, editorTools.ChangeSource._parameters, TAbsFitConstraint._parameters, TAbsFitParticle._parameters, jetTools.AddJetCollection._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, trackTools.MakePATTrackCandidates._parameters, trigTools.SwitchOnTrigger._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, trigTools.SwitchOnTriggerStandAlone._parameters, trackTools.MakeTrackCandidates._parameters, tauTools.AddTauCollection._parameters, trigTools.SwitchOnTriggerMatching._parameters, jetTools.SwitchJetCollection._parameters, jetTools.AddJetID._parameters, jetTools.SetTagInfos._parameters, and trigTools.switchOnTrigger.

354  def toolCode( self, process ):
355  triggerMatchers = self._parameters[ 'triggerMatchers' ].value
356  exampleMatchers = self._parameters[ 'exampleMatchers' ].value
357  triggerProducer = self._parameters[ 'triggerProducer' ].value
358  triggerEventProducer = self._parameters[ 'triggerEventProducer' ].value
359  path = self._parameters[ 'path' ].value
360  hltProcess = self._parameters[ 'hltProcess' ].value
361  outputModule = self._parameters[ 'outputModule' ].value
362  postfix = self._parameters[ 'postfix' ].value
363 
364  # Load default producers from existing config file, if needed
365  if exampleMatchers:
366  process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
367 
368  # Switch on PAT trigger information if needed
369  if not hasattr( process, triggerEventProducer ):
370  print '%s():'%( self._label )
371  print ' PAT trigger production switched on automatically using'
372  print ' switchOnTrigger( process, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerProducer, triggerEventProducer, path, outputModule )
373  print _longLine
374  switchOnTrigger( process, triggerProducer, triggerEventProducer, path, hltProcess, outputModule )
375 
376  # Maintain configurations
377  trigEvtProdMod = getattr( process, triggerEventProducer )
378  triggerMatchersKnown = []
379  for matcher in triggerMatchers:
380  if not hasattr( process, matcher ):
381  print '%s():'%( self._label )
382  print ' Matcher \'%s\' not known to process'%( matcher )
383  print ' ==> skipped'
384  print _longLine
385  continue
386  triggerMatchersKnown.append( matcher )
387  trigMchMod = getattr( process, matcher )
388  trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
389  trigMchMod.matched = triggerProducer
390  matchers = getattr( trigEvtProdMod, 'patTriggerMatches' )
391  if len( matchers ) > 0:
392  print '%s():'%( self._label )
393  print ' PAT trigger matchers already attached to existing PATTriggerEventProducer \'%s\''%( triggerEventProducer )
394  print ' configuration parameters automatically changed'
395  for matcher in matchers:
396  trigMchMod = getattr( process, matcher )
397  if trigMchMod.matched.value() is not triggerProducer:
398  trigMchMod.matched = triggerProducer
399  print ' PAT trigger matcher %s.matched --> %s'%( matcher, trigMchMod.matched )
400  print _longLine
401  else:
402  trigEvtProdMod.patTriggerMatches = cms.VInputTag()
403  for matcher in triggerMatchersKnown:
404  trigEvtProdMod.patTriggerMatches.append( cms.InputTag( matcher ) )
405 
406  # Add event content
407  if outputModule is not '':
408  patTriggerEventContent = []
409  for matcher in triggerMatchersKnown:
410  patTriggerEventContent += [ 'keep patTriggerObjectsedmAssociation_%s_%s_%s'%( triggerEventProducer, matcher, process.name_() )
411  , 'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
412  ]
413  getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
def _addEventContent
Definition: trigTools.py:29
tuple switchOnTrigger
Definition: trigTools.py:184

Member Data Documentation

trigTools.SwitchOnTriggerMatching._comment
private

Definition at line 315 of file trigTools.py.

Referenced by metUncertaintyTools.RunMEtUncertainties.__init__().

tuple trigTools.SwitchOnTriggerMatching._defaultParameters = dicttypes.SortedKeysDict()
staticprivate

Definition at line 302 of file trigTools.py.

Referenced by HiCoreTools.RestrictInputToAOD.__call__(), HiCoreTools.RemoveMCMatching.__call__(), HiCoreTools.RemoveAllPATObjectsBut.__call__(), HiCoreTools.RemoveSpecificPATObjects.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), HiCoreTools.RemoveCleaning.__call__(), HiCoreTools.AddCleaning.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), metUncertaintyTools.RunMEtUncertainties.__call__(), HiCoreTools.RestrictInputToAOD.__init__(), metUncertaintyTools.RunMEtUncertainties.__init__(), HiCoreTools.RemoveMCMatching.__init__(), HiCoreTools.RemoveAllPATObjectsBut.__init__(), HiCoreTools.RemoveSpecificPATObjects.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), HiCoreTools.RemoveCleaning.__init__(), HiCoreTools.AddCleaning.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), metUncertaintyTools.RunMEtUncertainties._initializeInputTag(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), HiCoreTools.RestrictInputToAOD.getDefaultParameters(), HiCoreTools.RemoveMCMatching.getDefaultParameters(), metUncertaintyTools.RunMEtUncertainties.getDefaultParameters(), HiCoreTools.RemoveAllPATObjectsBut.getDefaultParameters(), HiCoreTools.RemoveSpecificPATObjects.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), HiCoreTools.RemoveCleaning.getDefaultParameters(), HiCoreTools.AddCleaning.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

string trigTools.SwitchOnTriggerMatching._label = 'switchOnTriggerMatching'
staticprivate

Definition at line 301 of file trigTools.py.

Referenced by trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), and trigTools.SwitchOnTriggerMatchEmbedding.toolCode().

trigTools.SwitchOnTriggerMatching._parameters
private

Definition at line 314 of file trigTools.py.

Referenced by metUncertaintyTools.RunMEtUncertainties.__init__(), HiCoreTools.RestrictInputToAOD.toolCode(), HiCoreTools.RemoveMCMatching.toolCode(), HiCoreTools.RemoveAllPATObjectsBut.toolCode(), HiCoreTools.RemoveSpecificPATObjects.toolCode(), HiCoreTools.RemoveCleaning.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), HiCoreTools.AddCleaning.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and metUncertaintyTools.RunMEtUncertainties.toolCode().