CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
trigTools.SwitchOnTriggerMatchEmbedding Class Reference
Inheritance diagram for trigTools.SwitchOnTriggerMatchEmbedding:

Public Member Functions

def __call__ (self, process, triggerMatchers=None, triggerProducer=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 embedding of trigger matches into PAT objects
SwitchOnTriggerMatchEmbedding( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', path = '', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
- [cms.Process]  : the 'cms.Process'
- triggerMatchers: PAT trigger matcher module labels (list)
                   optional; default: defined in 'triggerMatchingDefaultSequence'
                   (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcherExamples_cfi.py)
- triggerProducer: PATTriggerProducer module label;
                   optional, default: 'patTrigger'
- path           : name of path to use;
                   optional, default: ''
- 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 541 of file trigTools.py.

Constructor & Destructor Documentation

◆ __init__()

def trigTools.SwitchOnTriggerMatchEmbedding.__init__ (   self)

Definition at line 564 of file trigTools.py.

564  def __init__( self ):
565  ConfigToolBase.__init__( self )
566  self.addParameter( self._defaultParameters, 'triggerMatchers', _exampleTriggerMatchers, _defaultTriggerMatchersComment )
567  self.addParameter( self._defaultParameters, 'exampleMatchers', False , '' )
568  self.addParameter( self._defaultParameters, 'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
569  self.addParameter( self._defaultParameters, 'path' , _defaultPath , _defaultPathComment )
570  self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
571  self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
572  self.addParameter( self._defaultParameters, 'postfix' , _defaultPostfix , _defaultPostfixComment )
573  self._parameters = copy.deepcopy( self._defaultParameters )
574  self._comment = ""
575 

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, trigTools.SwitchOnTriggerMatchingStandAlone._defaultParameters, trigTools.SwitchOnTriggerMatchEmbedding._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(), cmspython3::Python11ParameterSet.addParameter(), l1t::TriggerSystem.addParameter(), LutXml.addParameter(), ConfigToolBase.ConfigToolBase.addParameter(), and edm::ParameterSet.addParameter().

Member Function Documentation

◆ __call__()

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

Definition at line 579 of file trigTools.py.

579  def __call__( self, process
580  , triggerMatchers = None
581  , triggerProducer = None
582  , path = None
583  , hltProcess = None
584  , outputModule = None
585  , postfix = None
586  ):
587  if triggerMatchers is None:
588  triggerMatchers = self._defaultParameters[ 'triggerMatchers' ].value
589  self.setParameter( 'exampleMatchers', True )
590  if triggerProducer is None:
591  triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
592  if path is None:
593  path = self._defaultParameters[ 'path' ].value
594  if hltProcess is None:
595  hltProcess = self._defaultParameters[ 'hltProcess' ].value
596  if outputModule is None:
597  outputModule = self._defaultParameters[ 'outputModule' ].value
598  if postfix is None:
599  postfix = self._defaultParameters[ 'postfix' ].value
600  self.setParameter( 'triggerMatchers', triggerMatchers )
601  self.setParameter( 'triggerProducer', triggerProducer )
602  self.setParameter( 'path' , path )
603  self.setParameter( 'hltProcess' , hltProcess )
604  self.setParameter( 'outputModule' , outputModule )
605  self.setParameter( 'postfix' , postfix )
606  self.apply( process )
607 

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, trigTools.SwitchOnTriggerMatchingStandAlone._defaultParameters, trigTools.SwitchOnTriggerMatchEmbedding._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(), DeviationsFromFileSensor2D.apply(), FWGUIEventFilter.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, Len, Dim >.apply(), ArrayND< Accumulator >.apply(), ArrayND< Num2, Len2, Dim2 >.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric >.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), npstat::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().

◆ getDefaultParameters()

def trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters (   self)

◆ toolCode()

def trigTools.SwitchOnTriggerMatchEmbedding.toolCode (   self,
  process 
)

Definition at line 608 of file trigTools.py.

608  def toolCode( self, process ):
609  triggerMatchers = self._parameters[ 'triggerMatchers' ].value
610  exampleMatchers = self._parameters[ 'exampleMatchers' ].value
611  triggerProducer = self._parameters[ 'triggerProducer' ].value
612  path = self._parameters[ 'path' ].value
613  hltProcess = self._parameters[ 'hltProcess' ].value
614  outputModule = self._parameters[ 'outputModule' ].value
615  postfix = self._parameters[ 'postfix' ].value
616 
617  # Load default producers from existing config file, if needed
618  task = getPatAlgosToolsTask(process)
619  if exampleMatchers:
620  process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
621  task.add(process.triggerMatcherExamplesTask)
622 
623  # Build dictionary of allowed input producers
624  dictPatProducers = { 'PATPhotonCleaner' : 'PATTriggerMatchPhotonEmbedder'
625  , 'PATElectronCleaner': 'PATTriggerMatchElectronEmbedder'
626  , 'PATMuonCleaner' : 'PATTriggerMatchMuonEmbedder'
627  , 'PATTauCleaner' : 'PATTriggerMatchTauEmbedder'
628  , 'PATJetCleaner' : 'PATTriggerMatchJetEmbedder'
629  , 'PATMETCleaner' : 'PATTriggerMatchMETEmbedder'
630 # , 'PATGenericParticleCleaner' : ''
631 # , 'PATPFParticleCleaner' : ''
632  , 'PATPhotonSelector' : 'PATTriggerMatchPhotonEmbedder'
633  , 'PATElectronSelector': 'PATTriggerMatchElectronEmbedder'
634  , 'PATMuonSelector' : 'PATTriggerMatchMuonEmbedder'
635  , 'PATTauSelector' : 'PATTriggerMatchTauEmbedder'
636  , 'PATJetSelector' : 'PATTriggerMatchJetEmbedder'
637  , 'PATMETSelector' : 'PATTriggerMatchMETEmbedder'
638 # , 'PATGenericParticleSelector' : ''
639 # , 'PATPFParticleSelector' : ''
640 # , 'PATCompositeCandidateSelector' : ''
641  , 'PATPhotonRefSelector' : 'PATTriggerMatchPhotonEmbedder'
642  , 'PATElectronRefSelector': 'PATTriggerMatchElectronEmbedder'
643  , 'PATMuonRefSelector' : 'PATTriggerMatchMuonEmbedder'
644  , 'PATTauRefSelector' : 'PATTriggerMatchTauEmbedder'
645  , 'PATJetRefSelector' : 'PATTriggerMatchJetEmbedder'
646  , 'PATMETRefSelector' : 'PATTriggerMatchMETEmbedder'
647 # , 'PATGenericParticleRefSelector' : ''
648 # , 'PATPFParticleRefSelector' : ''
649 # , 'PATCompositeCandidateRefSelector' : ''
650  , 'PATPhotonProducer' : 'PATTriggerMatchPhotonEmbedder'
651  , 'PATElectronProducer': 'PATTriggerMatchElectronEmbedder'
652  , 'PATMuonProducer' : 'PATTriggerMatchMuonEmbedder'
653  , 'PATTauProducer' : 'PATTriggerMatchTauEmbedder'
654  , 'PATJetProducer' : 'PATTriggerMatchJetEmbedder'
655  , 'PATMETProducer' : 'PATTriggerMatchMETEmbedder'
656 # , 'PATGenericParticleProducer' : ''
657 # , 'PATPFParticleProducer' : ''
658 # , 'PATCompositeCandidateProducer' : ''
659  , 'MuonSelectorVertex': 'PATTriggerMatchMuonEmbedder'
660  }
661 
662  # Switch on PAT trigger matching if needed
663  dictConfig = {}
664  if not hasattr( process, triggerProducer ):
665  if exampleMatchers:
666  print('%s():'%( self._label ))
667  print(' PAT trigger matching switched on automatically using')
668  print(' switchOnTriggerMatchingStandAlone( process, \'%s\', None, \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerProducer, path, outputModule, postfix ))
669  print(_longLine)
670  switchOnTriggerMatchingStandAlone( process, None, triggerProducer, path, hltProcess, '', postfix ) # Do not store intermediate output collections.
671  else:
672  print('%s():'%( self._label ))
673  print(' PAT trigger matching switched on automatically using')
674  print(' switchOnTriggerMatchingStandAlone( process, \'%s\', %s, \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerMatchers, triggerProducer, path, outputModule, postfix ))
675  print(_longLine)
676  switchOnTriggerMatchingStandAlone( process, triggerMatchers, triggerProducer, path, hltProcess, '', postfix ) # Do not store intermediate output collections.
677  elif exampleMatchers:
678  process.load( "PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
679  task.add(process.triggerMatcherExamplesTask)
680 
681  # Build dictionary of matchers
682  for matcher in triggerMatchers:
683  if not hasattr( process, matcher ):
684  print('%s():'%( self._label ))
685  print(' PAT trigger matcher \'%s\' not known to process'%( matcher ))
686  print(' ==> skipped')
687  print(_longLine)
688  continue
689  trigMchMod = getattr( process, matcher )
690  patObjProd = getattr( process, trigMchMod.src.value() + postfix )
691  if trigMchMod.src.value() in dictConfig:
692  dictConfig[ patObjProd.type_() ] += [ matcher ]
693  else:
694  dictConfig[ patObjProd.type_() ] = [ matcher ]
695 
696  # Maintain configurations
697  patTriggerEventContent = []
698  for patObjProdType in dictConfig.keys():
699  if patObjProdType in dictPatProducers:
700  for matcher in dictConfig[ patObjProdType ]:
701  trigMchMod = getattr( process, matcher )
702  patObjProd = getattr( process, trigMchMod.src.value() + postfix )
703  # Configure embedder module
704  label = patObjProd.label_() + 'TriggerMatch' # hardcoded default
705  if hasattr( process, label ):
706  print('%s():'%( self._label ))
707  print(' PAT trigger match embedder \'%s\' exists already in process'%( label ))
708  print(' ==> entry re-used')
709  print(_longLine)
710  module = getattr( process, label )
711  if not module.type_() is dictPatProducers[ patObjProdType ]:
712  print('%s():'%( self._label ))
713  print(' Configuration conflict for PAT trigger match embedder \'%s\''%( label ))
714  print(' - exists as %s'%( module.type_() ))
715  print(' - requested as %s by \'%s\''%( dictPatProducers[ patObjProdType ], matcher ))
716  print(' ==> skipped')
717  print(_longLine)
718  continue
719  if not module.src.value() is trigMchMod.src.value() + postfix:
720  print('%s():'%( self._label ))
721  print(' Configuration conflict for PAT trigger match embedder \'%s\''%( label ))
722  print(' - exists for input %s'%( module.src.value() ))
723  print(' - requested for input %s by \'%s\''%( trigMchMod.src.value() + postfix, matcher ))
724  print(' ==> skipped')
725  print(_longLine)
726  continue
727  module.matches.append( cms.InputTag( matcher ) )
728  else:
729  module = cms.EDProducer( dictPatProducers[ patObjProdType ] )
730  module.src = cms.InputTag( patObjProd.label_() )
731  module.matches = cms.VInputTag( matcher )
732  addToProcessAndTask(label, module, process, task)
733  # Add event content
734  patTriggerEventContent += [ 'drop *_%s_*_*'%( patObjProd.label_() )
735  , 'keep *_%s_*_%s'%( label, process.name_() )
736  ]
737  else:
738  print('%s():'%( self._label ))
739  print(' Invalid input source for trigger match embedding')
740  print(' ==> %s with matchers \'%s\' is skipped'%( patObjProdType, dictConfig[ patObjProdType ] ))
741  print(_longLine)
742  if outputModule is not '':
743  getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
744 

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, trigTools.SwitchOnTriggerMatchingStandAlone._label, trigTools.SwitchOnTriggerMatchEmbedding._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, trigTools.SwitchOnTriggerMatchingStandAlone._parameters, trigTools.SwitchOnTriggerMatchEmbedding._parameters, jetTools.AddJetCollection._parameters, jetTools.SwitchJetCollection._parameters, jetTools.UpdateJetCollection._parameters, jetTools.AddJetID._parameters, jetTools.SetTagInfos._parameters, helpers.addToProcessAndTask(), helpers.getPatAlgosToolsTask(), edm.print(), and trigTools.switchOnTriggerMatchingStandAlone.

Member Data Documentation

◆ _comment

trigTools.SwitchOnTriggerMatchEmbedding._comment
private

Definition at line 574 of file trigTools.py.

◆ _defaultParameters

trigTools.SwitchOnTriggerMatchEmbedding._defaultParameters
staticprivate

◆ _label

trigTools.SwitchOnTriggerMatchEmbedding._label
staticprivate

◆ _parameters

trigTools.SwitchOnTriggerMatchEmbedding._parameters
private

Definition at line 573 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.SwitchOnTriggerMatchEmbedding.toolCode(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.updateJECs().

helpers.getPatAlgosToolsTask
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
trigTools.switchOnTriggerMatchingStandAlone
switchOnTriggerMatchingStandAlone
Definition: trigTools.py:538
trigTools._addEventContent
def _addEventContent(outputCommands, eventContent)
Definition: trigTools.py:31
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
helpers.addToProcessAndTask
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29