CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 286 of file trigTools.py.

Constructor & Destructor Documentation

def trigTools.SwitchOnTriggerMatching.__init__ (   self)

Definition at line 311 of file trigTools.py.

References heavyIonTools.ConfigureHeavyIons._defaultParameters, metTools.AddMETCollection._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, tauTools.AddTauCollection._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.AddJetCollection._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.UpdateJetCollection._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(), Python11ParameterSet.addParameter(), l1t::TriggerSystem.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

312  def __init__( self ):
313  ConfigToolBase.__init__( self )
314  self.addParameter( self._defaultParameters, 'triggerMatchers' , _exampleTriggerMatchers , _defaultTriggerMatchersComment )
315  self.addParameter( self._defaultParameters, 'exampleMatchers' , False , '' )
316  self.addParameter( self._defaultParameters, 'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
317  self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
318  self.addParameter( self._defaultParameters, 'path' , _defaultPath , _defaultPathComment )
319  self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
320  self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
321  self.addParameter( self._defaultParameters, 'postfix' , _defaultPostfix , _defaultPostfixComment )
322  self._parameters = copy.deepcopy( self._defaultParameters )
323  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 335 of file trigTools.py.

References heavyIonTools.ConfigureHeavyIons._defaultParameters, metTools.AddMETCollection._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, tauTools.AddTauCollection._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.AddJetCollection._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.UpdateJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, SignedImpactParameter3D.apply(), SignedDecayLength3D.apply(), SignedTransverseImpactParameter.apply(), gen::PhotosInterfaceBase.apply(), SurveyParameters.apply(), DummyOOTPileupCorrection.apply(), MatrixReader.MatrixReader.apply, gen::PhotosppInterface.apply(), gen::PhotosInterface.apply(), FWPSetCellEditor.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), AlignmentParameters.apply(), ConfigToolBase.ConfigToolBase.apply(), BowedSurfaceAlignmentParameters.apply(), OOTPileupCorrData.apply(), AbsOOTPileupCorrection.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), models.RegExp.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric >.apply(), ArrayND< Numeric, Len, Dim >.apply(), ArrayND< Accumulator >.apply(), ArrayND< Num2, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), ArrayND< Num1, Len1, Dim1 >.apply(), Config.ProcessModifier.apply(), PedeReader.setParameter(), QIE8Simulator.setParameter(), AbsElectronicODERHS.setParameter(), SiStripLorentzAngleCalibration.setParameter(), SiPixelLorentzAngleCalibration.setParameter(), IntegratedCalibrationBase.setParameter(), SiStripBackplaneCalibration.setParameter(), fit::RootMinuit< Function >.setParameter(), and ConfigToolBase.ConfigToolBase.setParameter().

Referenced by trigTools.SwitchOnTriggerMatching.getDefaultParameters().

336  ):
337  if triggerMatchers is None:
338  triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
339  self.setParameter( 'exampleMatchers', True )
340  if triggerProducer is None:
341  triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
342  if triggerEventProducer is None:
343  triggerEventProducer = self._defaultParameters[ 'triggerEventProducer' ].value
344  if path is None:
345  path = self._defaultParameters[ 'path' ].value
346  if hltProcess is None:
347  hltProcess = self._defaultParameters[ 'hltProcess' ].value
348  if outputModule is None:
349  outputModule = self._defaultParameters[ 'outputModule' ].value
350  if postfix is None:
351  postfix = self._defaultParameters[ 'postfix' ].value
352  self.setParameter( 'triggerMatchers' , triggerMatchers )
353  self.setParameter( 'triggerProducer' , triggerProducer )
354  self.setParameter( 'triggerEventProducer', triggerEventProducer )
355  self.setParameter( 'path' , path )
356  self.setParameter( 'hltProcess' , hltProcess )
357  self.setParameter( 'outputModule' , outputModule )
358  self.setParameter( 'postfix' , postfix )
359  self.apply( process )
def trigTools.SwitchOnTriggerMatching.getDefaultParameters (   self)

Definition at line 324 of file trigTools.py.

References trigTools.SwitchOnTriggerMatching.__call__(), heavyIonTools.ConfigureHeavyIons._defaultParameters, metTools.AddMETCollection._defaultParameters, trackTools.MakeAODTrackCandidates._defaultParameters, coreTools.RunOnData._defaultParameters, heavyIonTools.ProductionDefaults._defaultParameters, cmsswVersionTools.PickRelValInputFiles._defaultParameters, coreTools.RemoveMCMatching._defaultParameters, trackTools.MakePATTrackCandidates._defaultParameters, trigTools.SwitchOnTrigger._defaultParameters, heavyIonTools.SelectionDefaults._defaultParameters, heavyIonTools.DisbaleMonteCarloDeps._defaultParameters, trigTools.SwitchOnTriggerStandAlone._defaultParameters, tauTools.AddTauCollection._defaultParameters, trackTools.MakeTrackCandidates._defaultParameters, trigTools.SwitchOnTriggerMatching._defaultParameters, jetTools.AddJetCollection._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.UpdateJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, and jetTools.SetTagInfos._defaultParameters.

325  def getDefaultParameters( self ):
326  return self._defaultParameters
def trigTools.SwitchOnTriggerMatching.toolCode (   self,
  process 
)

Definition at line 360 of file trigTools.py.

References trigTools._addEventContent(), metTools.AddMETCollection._label, trackTools.MakeAODTrackCandidates._label, heavyIonTools.ConfigureHeavyIons._label, coreTools.RunOnData._label, MagneticFieldMapESProducer._label, TrackerInteractionGeometryESProducer._label, heavyIonTools.ProductionDefaults._label, ConfigToolBase.ConfigToolBase._label, LHECOMWeightProducer._label, cmsswVersionTools.PickRelValInputFiles._label, coreTools.RemoveMCMatching._label, trackTools.MakePATTrackCandidates._label, trigTools.SwitchOnTrigger._label, heavyIonTools.SelectionDefaults._label, heavyIonTools.DisbaleMonteCarloDeps._label, trigTools.SwitchOnTriggerStandAlone._label, tauTools.AddTauCollection._label, trackTools.MakeTrackCandidates._label, trigTools.SwitchOnTriggerMatching._label, jetTools.AddJetCollection._label, jetTools.SwitchJetCollection._label, jetTools.UpdateJetCollection._label, jetTools.AddJetID._label, jetTools.SetTagInfos._label, heavyIonTools.ConfigureHeavyIons._parameters, trackTools.MakeAODTrackCandidates._parameters, coreTools.RunOnData._parameters, metTools.AddMETCollection._parameters, heavyIonTools.ProductionDefaults._parameters, ConfigToolBase.ConfigToolBase._parameters, TAbsFitConstraint._parameters, TAbsFitParticle._parameters, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, trackTools.MakePATTrackCandidates._parameters, trigTools.SwitchOnTrigger._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, trigTools.SwitchOnTriggerStandAlone._parameters, tauTools.AddTauCollection._parameters, trackTools.MakeTrackCandidates._parameters, trigTools.SwitchOnTriggerMatching._parameters, jetTools.AddJetCollection._parameters, jetTools.SwitchJetCollection._parameters, jetTools.UpdateJetCollection._parameters, jetTools.AddJetID._parameters, jetTools.SetTagInfos._parameters, helpers.getPatAlgosToolsTask(), print(), and trigTools.switchOnTrigger.

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

Member Data Documentation

trigTools.SwitchOnTriggerMatching._comment
private

Definition at line 322 of file trigTools.py.

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

Definition at line 309 of file trigTools.py.

Referenced by runJetUncertainties.RunJetUncertainties.__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), runJetUncertainties.RunJetUncertainties.__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.initializeInputTag(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

string trigTools.SwitchOnTriggerMatching._label = 'switchOnTriggerMatching'
staticprivate

Definition at line 308 of file trigTools.py.

Referenced by validation.SimpleSample.digest(), validation.SimpleSample.label(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), and trigTools.SwitchOnTriggerMatchEmbedding.toolCode().

trigTools.SwitchOnTriggerMatching._parameters
private

Definition at line 321 of file trigTools.py.

Referenced by runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.ak4JetReclustering(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createMVAMETModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.createSmearedJetModule(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.extractMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getCorrectedMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getMETUncertainties(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getUnclusteredVariationsForMVAMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getVariations(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetCleaning(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.jetConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfiguration(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.miniAODConfigurationPost(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.recomputeRawMetFromPfcs(), runJetUncertainties.RunJetUncertainties.toolCode(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.updateJECs().