CMS 3D CMS Logo

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__ (self, process, triggerMatchers=None, triggerProducer=None, triggerEventProducer=None, path=None, hltProcess=None, outputModule=None, postfix=None)
 
def __init__ (self)
 
def getDefaultParameters (self)
 
def toolCode (self, process)
 

Private Attributes

 _comment
 
 _parameters
 

Static Private Attributes

 _defaultParameters
 
 _label
 

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

◆ __init__()

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().

311  def __init__( self ):
312  ConfigToolBase.__init__( self )
313  self.addParameter( self._defaultParameters, 'triggerMatchers' , _exampleTriggerMatchers , _defaultTriggerMatchersComment )
314  self.addParameter( self._defaultParameters, 'exampleMatchers' , False , '' )
315  self.addParameter( self._defaultParameters, 'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
316  self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
317  self.addParameter( self._defaultParameters, 'path' , _defaultPath , _defaultPathComment )
318  self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
319  self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
320  self.addParameter( self._defaultParameters, 'postfix' , _defaultPostfix , _defaultPostfixComment )
321  self._parameters = copy.deepcopy( self._defaultParameters )
322  self._comment = ""
323 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __call__()

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(), SignedTransverseImpactParameter.apply(), SignedDecayLength3D.apply(), ProcessAcceleratorCUDA.ProcessAcceleratorCUDA.apply(), ProcessAcceleratorROCm.ProcessAcceleratorROCm.apply(), gen::PhotosInterfaceBase.apply(), SurveyParameters.apply(), DummyOOTPileupCorrection.apply(), MatrixReader.MatrixReader.apply, gen::PhotosppInterface.apply(), FWPSetCellEditor.apply(), BeamSpotAlignmentParameters.apply(), RigidBodyAlignmentParameters.apply(), DeviationsFromFileSensor2D.apply(), FWGUIEventFilter.apply(), AlignmentParameters.apply(), ConfigToolBase.ConfigToolBase.apply(), BowedSurfaceAlignmentParameters.apply(), OOTPileupCorrData.apply(), ProcessAcceleratorAlpaka.ProcessAcceleratorAlpaka.apply(), AbsOOTPileupCorrection.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.apply(), cmsswVersionTools.PickRelValInputFiles.apply(), models.RegExp.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), ArrayND< Num1, Len1, Dim1 >.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric >.apply(), ArrayND< Numeric, Len, Dim >.apply(), ArrayND< Accumulator >.apply(), ArrayND< Num2, Len2, Dim2 >.apply(), Config.ProcessModifier.apply(), Config.ProcessAccelerator.apply(), Config.ProcessAcceleratorTest.apply(), Config.ProcessAcceleratorTest2.apply(), HGCalCassette.setParameter(), 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().

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

◆ getDefaultParameters()

def trigTools.SwitchOnTriggerMatching.getDefaultParameters (   self)

◆ toolCode()

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, ProcessAcceleratorCUDA.ProcessAcceleratorCUDA._label, ProcessAcceleratorROCm.ProcessAcceleratorROCm._label, coreTools.RunOnData._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.

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

Member Data Documentation

◆ _comment

trigTools.SwitchOnTriggerMatching._comment
private

Definition at line 322 of file trigTools.py.

◆ _defaultParameters

trigTools.SwitchOnTriggerMatching._defaultParameters
staticprivate

◆ _label

trigTools.SwitchOnTriggerMatching._label
staticprivate

◆ _parameters

trigTools.SwitchOnTriggerMatching._parameters
private

Definition at line 321 of file trigTools.py.

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