CMS 3D CMS Logo

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

Public Member Functions

def __call__ (self, process, triggerProducer=None, triggerEventProducer=None, path=None, hltProcess=None, outputModule=None)
 
def __init__ (self)
 
def getDefaultParameters (self)
 
def toolCode (self, process)
 

Private Attributes

 _comment
 
 _parameters
 

Static Private Attributes

 _defaultParameters
 
 _label
 

Detailed Description

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

Definition at line 60 of file trigTools.py.

Constructor & Destructor Documentation

def trigTools.SwitchOnTrigger.__init__ (   self)

Definition at line 80 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, trackTools.MakeTrackCandidates._defaultParameters, tauTools.AddTauCollection._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().

80  def __init__( self ):
81  ConfigToolBase.__init__( self )
82  self.addParameter( self._defaultParameters, 'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
83  self.addParameter( self._defaultParameters, 'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
84  self.addParameter( self._defaultParameters, 'path' , _defaultPath , _defaultPathComment )
85  self.addParameter( self._defaultParameters, 'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
86  self.addParameter( self._defaultParameters, 'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
87  self._parameters = copy.deepcopy( self._defaultParameters )
88  self._comment = ""
89 

Member Function Documentation

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

Definition at line 99 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, trackTools.MakeTrackCandidates._defaultParameters, tauTools.AddTauCollection._defaultParameters, jetTools.AddJetCollection._defaultParameters, jetTools.SwitchJetCollection._defaultParameters, jetTools.UpdateJetCollection._defaultParameters, jetTools.AddJetID._defaultParameters, jetTools.SetTagInfos._defaultParameters, SignedImpactParameter3D.apply(), gen::PhotosInterfaceBase.apply(), SignedTransverseImpactParameter.apply(), SurveyParameters.apply(), SignedDecayLength3D.apply(), DummyOOTPileupCorrection.apply(), MatrixReader.MatrixReader.apply, gen::PhotosppInterface.apply(), FWPSetCellEditor.apply(), gen::PhotosInterface.apply(), RigidBodyAlignmentParameters.apply(), BeamSpotAlignmentParameters.apply(), FWGUIEventFilter.apply(), DeviationsFromFileSensor2D.apply(), ConfigToolBase.ConfigToolBase.apply(), OOTPileupCorrData.apply(), BowedSurfaceAlignmentParameters.apply(), AlignmentParameters.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.apply(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ApplyTool.apply(), AbsOOTPileupCorrection.apply(), Vispa.Gui.BoxContentDialog.BoxContentDialog.apply(), TwoBowedSurfacesAlignmentParameters.apply(), reco::modules::TrackerTrackHitFilter::Rule.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(), models.RegExp.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< Num2, Len2, Dim2 >.apply(), npstat::ArrayND< Num1, Len1, Dim1 >.apply(), npstat::ArrayND< Numeric, StackLen, StackDim >.apply(), ArrayND< Numeric, Len2, Dim2 >.apply(), npstat::ArrayND< Numeric >.apply(), ArrayND< Accumulator >.apply(), ArrayND< Numeric, Len, Dim >.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.SwitchOnTrigger.getDefaultParameters().

99  ):
100  if triggerProducer is None:
101  triggerProducer = self._defaultParameters[ 'triggerProducer' ].value
102  if triggerEventProducer is None:
103  triggerEventProducer = self._defaultParameters[ 'triggerEventProducer' ].value
104  if path is None:
105  path = self._defaultParameters[ 'path' ].value
106  if hltProcess is None:
107  hltProcess = self._defaultParameters[ 'hltProcess' ].value
108  if outputModule is None:
109  outputModule = self._defaultParameters[ 'outputModule' ].value
110  self.setParameter( 'triggerProducer' , triggerProducer )
111  self.setParameter( 'triggerEventProducer', triggerEventProducer )
112  self.setParameter( 'path' , path )
113  self.setParameter( 'hltProcess' , hltProcess )
114  self.setParameter( 'outputModule' , outputModule )
115  self.apply( process )
116 
def trigTools.SwitchOnTrigger.getDefaultParameters (   self)
def trigTools.SwitchOnTrigger.toolCode (   self,
  process 
)

Definition at line 117 of file trigTools.py.

References trigTools._addEventContent(), metTools.AddMETCollection._label, heavyIonTools.ConfigureHeavyIons._label, trackTools.MakeAODTrackCandidates._label, coreTools.RunOnData._label, MagneticFieldMapESProducer._label, TrackerInteractionGeometryESProducer._label, Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigFolder._label, heavyIonTools.ProductionDefaults._label, LHECOMWeightProducer._label, cmsswVersionTools.PickRelValInputFiles._label, coreTools.RemoveMCMatching._label, trackTools.MakePATTrackCandidates._label, trigTools.SwitchOnTrigger._label, heavyIonTools.SelectionDefaults._label, heavyIonTools.DisbaleMonteCarloDeps._label, trackTools.MakeTrackCandidates._label, tauTools.AddTauCollection._label, jetTools.AddJetCollection._label, Vispa.Views.LineDecayView.DecayLine._label, jetTools.SwitchJetCollection._label, jetTools.UpdateJetCollection._label, jetTools.AddJetID._label, jetTools.SetTagInfos._label, trigTools._modulesInPath(), editorTools.UserCodeTool._parameters, heavyIonTools.ConfigureHeavyIons._parameters, trackTools.MakeAODTrackCandidates._parameters, coreTools.RunOnData._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, cmsswVersionTools.PickRelValInputFiles._parameters, coreTools.RemoveMCMatching._parameters, trackTools.MakePATTrackCandidates._parameters, trigTools.SwitchOnTrigger._parameters, heavyIonTools.SelectionDefaults._parameters, heavyIonTools.DisbaleMonteCarloDeps._parameters, trackTools.MakeTrackCandidates._parameters, tauTools.AddTauCollection._parameters, jetTools.AddJetCollection._parameters, jetTools.SwitchJetCollection._parameters, jetTools.UpdateJetCollection._parameters, jetTools.AddJetID._parameters, jetTools.SetTagInfos._parameters, helpers.addToProcessAndTask(), helpers.getPatAlgosToolsTask(), and edm.print().

117  def toolCode( self, process ):
118  triggerProducer = self._parameters[ 'triggerProducer' ].value
119  triggerEventProducer = self._parameters[ 'triggerEventProducer' ].value
120  path = self._parameters[ 'path' ].value
121  hltProcess = self._parameters[ 'hltProcess' ].value
122  outputModule = self._parameters[ 'outputModule' ].value
123 
124  task = getPatAlgosToolsTask(process)
125 
126  # Load default producers from existing config files, if needed
127  if not hasattr( process, triggerProducer ):
129  addToProcessAndTask(triggerProducer, patTrigger.clone(), process, task)
130  else:
131  print('%s():'%( self._label ))
132  print(' PATTriggerProducer module \'%s\' exists already in process'%( triggerProducer ))
133  print(' ==> entry re-used')
134  print(_longLine)
135  if not hasattr( process, triggerEventProducer ):
137  addToProcessAndTask(triggerEventProducer, patTriggerEvent.clone(), process, task)
138  else:
139  print('%s():'%( self._label ))
140  print(' PATTriggerEventProducer module \'%s\' exists already in process'%( triggerEventProducer ))
141  print(' ==> entry re-used')
142  print(_longLine)
143 
144  # Maintain configurations
145  trigProdMod = getattr( process, triggerProducer )
146  trigProdMod.processName = hltProcess
147  if trigProdMod.onlyStandAlone.value() is True:
148  trigProdMod.onlyStandAlone = False
149  print(' configuration parameter automatically changed')
150  print(' PATTriggerProducer %s.onlyStandAlone --> %s'%( triggerProducer, trigProdMod.onlyStandAlone ))
151  print(_longLine)
152  trigEvtProdMod = getattr( process, triggerEventProducer )
153  trigEvtProdMod.processName = hltProcess
154  trigEvtProdMod.patTriggerProducer = cms.InputTag( triggerProducer )
155  if not path is '':
156  if not hasattr( process, path ):
157  prodPath = cms.Path( trigProdMod + trigEvtProdMod )
158  setattr( process, path, prodPath )
159  print('%s():'%( self._label ))
160  print(' Path \'%s\' does not exist in process'%( path ))
161  print(' ==> created')
162  print(_longLine)
163  # Try to get the order right, but cannot deal with all possible cases.
164  # Simply rely on the exclusive usage of these tools without manual intervention.
165  else:
166  if not triggerProducer in _modulesInPath( process, path ):
167  prodPath = getattr( process, path )
168  prodPath += trigProdMod
169  if not triggerEventProducer in _modulesInPath( process, path ):
170  prodPath = getattr( process, path )
171  prodPath += trigEvtProdMod
172 
173  # Add event content
174  if outputModule is not '':
175  patTriggerEventContent = [ 'keep patTriggerObjects_%s_*_%s'%( triggerProducer, process.name_() )
176  , 'keep patTriggerFilters_%s_*_%s'%( triggerProducer, process.name_() )
177  , 'keep patTriggerPaths_%s_*_%s'%( triggerProducer, process.name_() )
178  , 'keep patTriggerEvent_%s_*_%s'%( triggerEventProducer, process.name_() )
179  ]
180  if ( hasattr( trigProdMod, 'addL1Algos' ) and trigProdMod.addL1Algos.value() is True ):
181  patTriggerEventContent += [ 'keep patTriggerConditions_%s_*_%s'%( triggerProducer, process.name_() )
182  , 'keep patTriggerAlgorithms_%s_*_%s'%( triggerProducer, process.name_() )
183  ]
184  if ( hasattr( trigProdMod, 'saveL1Refs' ) and trigProdMod.saveL1Refs.value() is True ):
185  patTriggerEventContent += patTriggerL1RefsEventContent
186  getattr( process, outputModule ).outputCommands = _addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
187 
def addToProcessAndTask(label, module, process, task)
Definition: helpers.py:29
def _addEventContent(outputCommands, eventContent)
Definition: trigTools.py:31
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def toolCode(self, process)
Definition: trigTools.py:117
def getPatAlgosToolsTask(process)
Definition: helpers.py:14
def _modulesInPath(process, pathLabel)
Definition: trigTools.py:27

Member Data Documentation

trigTools.SwitchOnTrigger._comment
private

Definition at line 88 of file trigTools.py.

trigTools.SwitchOnTrigger._defaultParameters
staticprivate

Definition at line 78 of file trigTools.py.

Referenced by HiCoreTools.RestrictInputToAOD.__call__(), runJetUncertainties.RunJetUncertainties.__call__(), editorTools.ChangeSource.__call__(), HiCoreTools.RemoveMCMatching.__call__(), trigTools.SwitchOnTrigger.__call__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), HiCoreTools.RemoveAllPATObjectsBut.__call__(), HiCoreTools.RemoveSpecificPATObjects.__call__(), trigTools.SwitchOnTriggerStandAlone.__call__(), trigTools.SwitchOnTriggerMatching.__call__(), HiCoreTools.RemoveCleaning.__call__(), HiCoreTools.AddCleaning.__call__(), trigTools.SwitchOnTriggerMatchingStandAlone.__call__(), trigTools.SwitchOnTriggerMatchEmbedding.__call__(), editorTools.UserCodeTool.__init__(), HiCoreTools.RestrictInputToAOD.__init__(), runJetUncertainties.RunJetUncertainties.__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool.__init__(), editorTools.ChangeSource.__init__(), HiCoreTools.RemoveMCMatching.__init__(), trigTools.SwitchOnTrigger.__init__(), HiCoreTools.RemoveAllPATObjectsBut.__init__(), HiCoreTools.RemoveSpecificPATObjects.__init__(), trigTools.SwitchOnTriggerStandAlone.__init__(), trigTools.SwitchOnTriggerMatching.__init__(), HiCoreTools.RemoveCleaning.__init__(), HiCoreTools.AddCleaning.__init__(), trigTools.SwitchOnTriggerMatchingStandAlone.__init__(), trigTools.SwitchOnTriggerMatchEmbedding.__init__(), ConfigToolBase.ConfigToolBase.dumpPython(), ConfigToolBase.ConfigToolBase.getAllowedValues(), HiCoreTools.RestrictInputToAOD.getDefaultParameters(), editorTools.ChangeSource.getDefaultParameters(), HiCoreTools.RemoveMCMatching.getDefaultParameters(), trigTools.SwitchOnTrigger.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.getDefaultParameters(), HiCoreTools.RemoveAllPATObjectsBut.getDefaultParameters(), HiCoreTools.RemoveSpecificPATObjects.getDefaultParameters(), trigTools.SwitchOnTriggerStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatching.getDefaultParameters(), HiCoreTools.RemoveCleaning.getDefaultParameters(), HiCoreTools.AddCleaning.getDefaultParameters(), trigTools.SwitchOnTriggerMatchingStandAlone.getDefaultParameters(), trigTools.SwitchOnTriggerMatchEmbedding.getDefaultParameters(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.initializeInputTag(), ConfigToolBase.ConfigToolBase.reset(), and ConfigToolBase.ConfigToolBase.setParameter().

trigTools.SwitchOnTrigger._label
staticprivate
trigTools.SwitchOnTrigger._parameters
private

Definition at line 87 of file trigTools.py.

Referenced by runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.__call__(), 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.produceMET(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.recomputeRawMetFromPfcs(), HiCoreTools.RestrictInputToAOD.toolCode(), runJetUncertainties.RunJetUncertainties.toolCode(), HiCoreTools.RemoveMCMatching.toolCode(), trigTools.SwitchOnTrigger.toolCode(), HiCoreTools.RemoveAllPATObjectsBut.toolCode(), HiCoreTools.RemoveSpecificPATObjects.toolCode(), trigTools.SwitchOnTriggerStandAlone.toolCode(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.toolCode(), HiCoreTools.RemoveCleaning.toolCode(), trigTools.SwitchOnTriggerMatching.toolCode(), HiCoreTools.AddCleaning.toolCode(), trigTools.SwitchOnTriggerMatchingStandAlone.toolCode(), trigTools.SwitchOnTriggerMatchEmbedding.toolCode(), and runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties.updateJECs().