CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TriggerMatchProducer< object > Class Template Reference

#include <TriggerMatchProducer.h>

Inheritance diagram for TriggerMatchProducer< object >:
edm::stream::EDProducer<>

Public Member Functions

 TriggerMatchProducer (const edm::ParameterSet &)
 
 ~TriggerMatchProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void beginRun (edm::Run const &iRun, edm::EventSetup const &iSetup) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

edm::InputTag _inputProducer
 
edm::EDGetTokenT< edm::View< object > > _inputProducerToken
 
bool changed_
 
double delRMatchingCut_
 
std::string filterName_
 
HLTPrescaleProvider hltPrescaleProvider_
 
std::string hltTag_
 
bool storeRefCollection_
 
edm::InputTag triggerEventTag_
 
edm::EDGetTokenT< trigger::TriggerEventtriggerEventToken_
 
edm::InputTag triggerResultsTag_
 
edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

template<class object>
class TriggerMatchProducer< object >

Definition at line 30 of file TriggerMatchProducer.h.

Constructor & Destructor Documentation

◆ TriggerMatchProducer()

template<class object >
TriggerMatchProducer< object >::TriggerMatchProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file TriggerMatchProducer.h.

59  : hltPrescaleProvider_(iConfig, consumesCollector(), *this) {
60  _inputProducer = iConfig.template getParameter<edm::InputTag>("InputProducer");
61  _inputProducerToken = consumes<edm::View<object> >(_inputProducer);
62 
63  // **************** Trigger ******************* //
64  const edm::InputTag dTriggerEventTag("hltTriggerSummaryAOD", "", "HLT");
65  triggerEventTag_ = iConfig.getUntrackedParameter<edm::InputTag>("triggerEventTag", dTriggerEventTag);
66  triggerEventToken_ = consumes<trigger::TriggerEvent>(triggerEventTag_);
67 
68  const edm::InputTag dTriggerResults("TriggerResults", "", "HLT");
69  // By default, trigger results are labeled "TriggerResults" with process name "HLT" in the event.
70  triggerResultsTag_ = iConfig.getUntrackedParameter<edm::InputTag>("triggerResultsTag", dTriggerResults);
71  triggerResultsToken_ = consumes<edm::TriggerResults>(triggerResultsTag_);
72 
73  // const edm::InputTag dHLTTag("HLT_Ele15_LW_L1R", "","HLT8E29");
74  hltTag_ = iConfig.getUntrackedParameter<std::string>("hltTag", "HLT_Ele*");
75 
76  delRMatchingCut_ = iConfig.getUntrackedParameter<double>("triggerDelRMatch", 0.30);
77  // ******************************************** //
78  //Trigger path VS l1 trigger filter. Trigger Path is default.
79  // isFilter_ = iConfig.getUntrackedParameter<bool>("isTriggerFilter",false);
80  // printIndex_ = iConfig.getUntrackedParameter<bool>("verbose",false);
81 
82  produces<edm::PtrVector<object> >();
83  produces<edm::RefToBaseVector<object> >("R");
84 
85  filterName_ = "";
86 }

References TriggerMatchProducer< object >::_inputProducer, TriggerMatchProducer< object >::_inputProducerToken, TriggerMatchProducer< object >::delRMatchingCut_, TriggerMatchProducer< object >::filterName_, edm::ParameterSet::getUntrackedParameter(), TriggerMatchProducer< object >::hltTag_, AlCaHLTBitMon_QueryRunRegistry::string, TriggerMatchProducer< object >::triggerEventTag_, TriggerMatchProducer< object >::triggerEventToken_, TriggerMatchProducer< object >::triggerResultsTag_, and TriggerMatchProducer< object >::triggerResultsToken_.

◆ ~TriggerMatchProducer()

template<class object >
TriggerMatchProducer< object >::~TriggerMatchProducer ( )
override

Definition at line 89 of file TriggerMatchProducer.h.

89 {}

Member Function Documentation

◆ beginRun()

template<class object >
void TriggerMatchProducer< object >::beginRun ( edm::Run const &  iRun,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 241 of file TriggerMatchProducer.h.

241  {
242  // std::cout << "calling init(" << "iRun" << ", " << "iSetup" << ", " << triggerEventTag_.process() << ", " << "changed_" << ") in beginRun()" << std::endl;
243  if (!hltPrescaleProvider_.init(iRun, iSetup, triggerEventTag_.process(), changed_)) {
244  edm::LogError("TriggerMatchProducer") << "Error! Can't initialize HLTConfigProvider";
245  throw cms::Exception("HLTConfigProvider::init() returned non 0");
246  }
247  // HLTConfigProvider const& hltConfig = hltPrescaleProvider_.hltConfigProvider();
248  // if(printIndex_ && changed_)
249  // std::cout << "HLT configuration changed !" << std::endl;
250  // std::vector<std::string> filters = hltConfig.moduleLabels( hltTag_.label() );
251 }

References Exception.

◆ produce()

template<class object >
void TriggerMatchProducer< object >::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
overrideprivate

Definition at line 97 of file TriggerMatchProducer.h.

97  {
98  using namespace std;
99  using namespace edm;
100  using namespace reco;
101  using namespace trigger;
102 
104 
105  // Create the output collection
106  std::unique_ptr<edm::RefToBaseVector<object> > outColRef(new edm::RefToBaseVector<object>);
107  std::unique_ptr<edm::PtrVector<object> > outColPtr(new edm::PtrVector<object>);
108 
109  // Get the input collection
110  edm::Handle<edm::View<object> > candHandle;
111  try {
112  event.getByToken(_inputProducerToken, candHandle);
113  } catch (cms::Exception& ex) {
114  edm::LogError("TriggerMatchProducer") << "Error! Can't get collection: " << _inputProducer;
115  throw ex;
116  }
117 
118  // Trigger Info
120  event.getByToken(triggerEventToken_, trgEvent);
122  event.getByToken(triggerResultsToken_, pTrgResults);
123 
124  //gracefully choose the single appropriate HLT path from the list of desired paths
125  std::vector<std::string> activeHLTPathsInThisEvent = hltConfig.triggerNames();
126  std::map<std::string, bool> triggerInMenu;
127  std::map<std::string, bool> triggerUnprescaled;
128  // for (std::vector<edm::InputTag>::const_iterator iMyHLT = hltTags_.begin();
129  // iMyHLT != hltTags_.end(); ++iMyHLT) {
130  // if ( triggerInMenu.find((*iMyHLT).label()) == triggerInMenu.end() )
131  // triggerInMenu[(*iMyHLT).label()] = false;
132  // if ( triggerUnprescaled.find((*iMyHLT).label()) == triggerUnprescaled.end() )
133  // triggerUnprescaled[(*iMyHLT).label()] = false;
134  // }
135  for (std::vector<std::string>::const_iterator iHLT = activeHLTPathsInThisEvent.begin();
136  iHLT != activeHLTPathsInThisEvent.end();
137  ++iHLT) {
138  // cout << "######## " << *iHLT << endl;
139 
140  if (TString(*iHLT).Contains(TRegexp(hltTag_))) {
141  triggerInMenu[*iHLT] = true;
142  if (hltPrescaleProvider_.prescaleValue(event, eventSetup, *iHLT) == 1)
143  triggerUnprescaled[*iHLT] = true;
144  }
145  }
146 
147  // Some sanity checks
148  if (not trgEvent.isValid()) {
149  edm::LogInfo("info") << "******** Following Trigger Summary Object Not Found: " << triggerEventTag_;
150 
151  event.put(std::move(outColRef), "R");
152  event.put(std::move(outColPtr));
153  return;
154  }
155 
156  //---------------------------------------------------------------------------
157 
158  edm::InputTag filterTag;
159  // loop over these objects to see whether they match
160  const trigger::TriggerObjectCollection& TOC(trgEvent->getObjects());
161 
162  std::vector<int> index;
163  std::vector<std::string> filters;
164  // if(isFilter_){
165  //-----------------------------------------------------------------------
166  for (std::map<std::string, bool>::const_iterator iMyHLT = triggerInMenu.begin(); iMyHLT != triggerInMenu.end();
167  ++iMyHLT) {
168  if (!(iMyHLT->second && triggerUnprescaled[iMyHLT->first]))
169  continue;
170 
171  int triggerIndex = -1;
172  edm::InputTag filterTag;
173  try {
174  filters = hltConfig.moduleLabels(iMyHLT->first);
175  triggerIndex = hltConfig.triggerIndex(iMyHLT->first);
176  } catch (std::exception const&) {
177  cout << "bad trigger\n";
178  }
179  // Results from TriggerResults product
180  if (triggerIndex == -1 || !(pTrgResults->wasrun(triggerIndex)) || !(pTrgResults->accept(triggerIndex)) ||
181  (pTrgResults->error(triggerIndex))) {
182  continue;
183  }
184 
185  for (std::vector<std::string>::iterator filter = filters.begin(); filter != filters.end(); ++filter) {
186  edm::InputTag testTag(*filter, "", triggerEventTag_.process());
187  int testindex = trgEvent->filterIndex(testTag);
188  if (!(testindex >= trgEvent->sizeFilters())) {
189  filterName_ = *filter;
190  filterTag = testTag;
191  }
192  }
193 
194  //using last filter tag
195  index.push_back(trgEvent->filterIndex(filterTag));
196  // std::cout << "TrgPath" << iMyHLT->first << "hltTag_.label() " <<
197  // filterTag.label() << " filter name " <<
198  // filterName_ << " sizeFilters " <<
199  // trgEvent->sizeFilters() << std::endl;
200  }
201 
202  // Loop over the candidate collection
203  edm::PtrVector<object> ptrVect;
205  for (size_t i = 0; i < candHandle->size(); ++i) {
206  ptrVect.push_back(candHandle->ptrAt(i));
207  refs.push_back(candHandle->refAt(i));
208  }
209  // find how many objects there are
210  unsigned int counter = 0;
211  for (typename edm::View<object>::const_iterator j = candHandle->begin(); j != candHandle->end(); ++j, ++counter) {
212  bool hltTrigger = false;
213  for (unsigned int idx = 0; idx < index.size(); ++idx) {
214  if (hltTrigger)
215  continue;
216  const trigger::Keys& KEYS(trgEvent->filterKeys(index[idx]));
217  const size_type nK(KEYS.size());
218  // Get cut decision for each candidate
219  // Did this candidate cause a HLT trigger?
220 
221  for (int ipart = 0; ipart != nK; ++ipart) {
222  const trigger::TriggerObject& TO = TOC[KEYS[ipart]];
223  double dRval = deltaR(j->eta(), j->phi(), TO.eta(), TO.phi());
224  hltTrigger = dRval < delRMatchingCut_;
225  if (hltTrigger)
226  break;
227  }
228  }
229 
230  if (hltTrigger) {
231  outColRef->push_back(refs[counter]);
232  outColPtr->push_back(ptrVect[counter]);
233  }
234  }
235  event.put(std::move(outColRef), "R");
236  event.put(std::move(outColPtr));
237 }

References edm::HLTGlobalStatus::accept(), counter, gather_cfg::cout, PbPb_ZMuSkimMuonDPG_cff::deltaR, edm::HLTGlobalStatus::error(), trigger::TriggerObject::eta(), cppFunctionSkipper::exception, ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), filters, trigger::TriggerEvent::getObjects(), HltComparatorCreateWorkflow::hltConfig, mps_fire::i, heavyIonCSV_trainingSettings::idx, edm::HandleBase::isValid(), dqmiolumiharvest::j, eostools::move(), trigger::TriggerObject::phi(), edm::RefToBaseVector< T >::push_back(), edm::PtrVector< T >::push_back(), trigger::TriggerEvent::sizeFilters(), and edm::HLTGlobalStatus::wasrun().

Member Data Documentation

◆ _inputProducer

template<class object >
edm::InputTag TriggerMatchProducer< object >::_inputProducer
private

◆ _inputProducerToken

template<class object >
edm::EDGetTokenT<edm::View<object> > TriggerMatchProducer< object >::_inputProducerToken
private

◆ changed_

template<class object >
bool TriggerMatchProducer< object >::changed_
private

Definition at line 53 of file TriggerMatchProducer.h.

◆ delRMatchingCut_

template<class object >
double TriggerMatchProducer< object >::delRMatchingCut_
private

◆ filterName_

template<class object >
std::string TriggerMatchProducer< object >::filterName_
private

◆ hltPrescaleProvider_

template<class object >
HLTPrescaleProvider TriggerMatchProducer< object >::hltPrescaleProvider_
private

Definition at line 54 of file TriggerMatchProducer.h.

◆ hltTag_

template<class object >
std::string TriggerMatchProducer< object >::hltTag_
private

◆ storeRefCollection_

template<class object >
bool TriggerMatchProducer< object >::storeRefCollection_
private

Definition at line 50 of file TriggerMatchProducer.h.

◆ triggerEventTag_

template<class object >
edm::InputTag TriggerMatchProducer< object >::triggerEventTag_
private

◆ triggerEventToken_

template<class object >
edm::EDGetTokenT<trigger::TriggerEvent> TriggerMatchProducer< object >::triggerEventToken_
private

◆ triggerResultsTag_

template<class object >
edm::InputTag TriggerMatchProducer< object >::triggerResultsTag_
private

◆ triggerResultsToken_

template<class object >
edm::EDGetTokenT<edm::TriggerResults> TriggerMatchProducer< object >::triggerResultsToken_
private
trigger::TriggerObject::phi
float phi() const
Definition: TriggerObject.h:54
counter
Definition: counter.py:1
TriggerMatchProducer::triggerEventTag_
edm::InputTag triggerEventTag_
Definition: TriggerMatchProducer.h:43
trigger::TriggerEvent::sizeFilters
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:146
mps_fire.i
i
Definition: mps_fire.py:428
filters
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
HLTPrescaleProvider::hltConfigProvider
HLTConfigProvider const & hltConfigProvider() const
Definition: HLTPrescaleProvider.h:52
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::HLTGlobalStatus::wasrun
bool wasrun() const
Was at least one path run?
Definition: HLTGlobalStatus.h:47
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
edm::HLTGlobalStatus::error
bool error() const
Has any path encountered an error (exception)
Definition: HLTGlobalStatus.h:51
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
edm::RefToBaseVector::push_back
void push_back(const RefToBase< T > &)
Definition: RefToBaseVector.h:217
edm::PtrVector
Definition: PtrVector.h:36
TriggerMatchProducer::filterName_
std::string filterName_
Definition: TriggerMatchProducer.h:49
TriggerMatchProducer::hltPrescaleProvider_
HLTPrescaleProvider hltPrescaleProvider_
Definition: TriggerMatchProducer.h:54
TriggerMatchProducer::changed_
bool changed_
Definition: TriggerMatchProducer.h:53
TriggerMatchProducer::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: TriggerMatchProducer.h:46
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
trigger::TriggerObject
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
TriggerMatchProducer::triggerEventToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
Definition: TriggerMatchProducer.h:44
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
TriggerMatchProducer::_inputProducer
edm::InputTag _inputProducer
Definition: TriggerMatchProducer.h:41
TriggerMatchProducer::hltTag_
std::string hltTag_
Definition: TriggerMatchProducer.h:47
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
TriggerMatchProducer::triggerResultsTag_
edm::InputTag triggerResultsTag_
Definition: TriggerMatchProducer.h:45
trigger::TriggerEvent::filterIndex
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
TriggerMatchProducer::delRMatchingCut_
double delRMatchingCut_
Definition: TriggerMatchProducer.h:48
trigger::TriggerObject::eta
float eta() const
Definition: TriggerObject.h:53
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
edm::RefToBaseVector
Definition: EDProductfwd.h:29
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
HLTPrescaleProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
Definition: HLTPrescaleProvider.cc:21
HLTPrescaleProvider::prescaleValue
T prescaleValue(const edm::Event &iEvent, const edm::EventSetup &iSetup, const std::string &trigger)
combining the two methods above
Definition: HLTPrescaleProvider.h:63
HLTConfigProvider
Definition: HLTConfigProvider.h:29
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:245
TriggerMatchProducer::_inputProducerToken
edm::EDGetTokenT< edm::View< object > > _inputProducerToken
Definition: TriggerMatchProducer.h:42
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
trigger
Definition: HLTPrescaleTableCond.h:8
cms::Exception
Definition: Exception.h:70
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::InputTag
Definition: InputTag.h:15