CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HLTEventSelector Class Reference

#include <HLTEventSelector.h>

Inheritance diagram for HLTEventSelector:
EventSelector

Public Member Functions

 HLTEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
 
 HLTEventSelector (const edm::ParameterSet &pset, edm::ConsumesCollector &iC)
 
bool select (const edm::Event &) const override
 decision of the selector module More...
 
 ~HLTEventSelector () override
 
- Public Member Functions inherited from EventSelector
const std::vector< std::string > & description ()
 
 EventSelector ()
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 EventSelector (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
const std::string & name () const
 name of the module (from configuration) More...
 
virtual ~EventSelector ()
 

Private Attributes

std::vector< std::string > pathNames_
 trigger path names (ORed) More...
 
edm::InputTag triggerResults_
 tag for input collection More...
 
edm::EDGetTokenT< edm::TriggerResultstriggerResultsToken_
 

Additional Inherited Members

- Protected Attributes inherited from EventSelector
std::vector< std::string > description_
 
std::string name_
 

Detailed Description

Trivial example for a HLT selector. To be modified for analysis!

Definition at line 25 of file HLTEventSelector.h.

Constructor & Destructor Documentation

◆ HLTEventSelector() [1/2]

HLTEventSelector::HLTEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 27 of file HLTEventSelector.h.

27 : HLTEventSelector(pset, iC) {}
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)

◆ HLTEventSelector() [2/2]

HLTEventSelector::HLTEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector iC 
)

Definition at line 7 of file HLTEventSelector.cc.

References edm::ConsumesCollector::consumes(), pathNames_, muonDTDigis_cfi::pset, triggerResults_, and triggerResultsToken_.

7  {
8  // input collection
9  triggerResults_ = pset.getParameter<edm::InputTag>("triggerResults");
11  // trigger path names
12  pathNames_ = pset.getParameter<std::vector<std::string> >("pathNames");
13 
14  edm::LogInfo("HLTEventSelector") << "constructed with \n"
15  << " src = " << triggerResults_ << "\n"
16  << " #pathnames = " << pathNames_.size();
17 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::InputTag triggerResults_
tag for input collection
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Log< level::Info, false > LogInfo
std::vector< std::string > pathNames_
trigger path names (ORed)

◆ ~HLTEventSelector()

HLTEventSelector::~HLTEventSelector ( )
inlineoverride

Definition at line 30 of file HLTEventSelector.h.

30 {}

Member Function Documentation

◆ select()

bool HLTEventSelector::select ( const edm::Event ) const
overridevirtual

decision of the selector module

Implements EventSelector.

Definition at line 19 of file HLTEventSelector.cc.

References edm::HLTGlobalStatus::accept(), mps_fire::i, edm::HandleBase::isValid(), LogDebug, pathNames_, edm::TriggerNames::size(), edm::TriggerNames::triggerIndex(), edm::TriggerNames::triggerNames(), triggerResults_, and triggerResultsToken_.

19  {
20  //
21  // get the trigger results and check validity
22  //
24  event.getByToken(triggerResultsToken_, hltHandle);
25  if (!hltHandle.isValid()) {
26  edm::LogWarning("HLTEventSelector") << "No trigger results for InputTag " << triggerResults_;
27  return false;
28  }
29  //
30  // get results
31  //
32  const edm::TriggerNames& trgNames = event.triggerNames(*hltHandle);
33  unsigned int trgSize = trgNames.size();
34  // static int first(true);
35  // if ( first ) {
36  // first = false;
37  // std::cout << "Trigger menu" << std::endl;
38  // for ( unsigned int i=0; i<trgSize; ++i ) {
39  // std::cout << trgNames.triggerName(i) << std::endl;
40  // }
41  // }
42  //
43  // example for OR of all specified triggers
44  //
45  for (std::vector<std::string>::const_iterator i = pathNames_.begin(); i != pathNames_.end(); ++i) {
46  // get index
47  unsigned int index = trgNames.triggerIndex(*i);
48  if (index == trgSize) {
49  edm::LogWarning("HLTEventSelector") << "Unknown trigger name " << *i;
50  // return false;
51  continue;
52  }
53  // if ( !hltHandle->accept(index) ) return false;
54  if (hltHandle->accept(index)) {
55  LogDebug("HLTEventSelector") << "Event selected by " << *i;
56  return true;
57  }
58  }
59  // return true;
60  LogDebug("HLTEventSelector") << "Event rejected";
61  return false;
62 }
bool accept() const
Has at least one path accepted the event?
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
edm::InputTag triggerResults_
tag for input collection
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
std::size_t size() const
Definition: TriggerNames.cc:59
bool isValid() const
Definition: HandleBase.h:70
Log< level::Warning, false > LogWarning
std::vector< std::string > pathNames_
trigger path names (ORed)
#define LogDebug(id)

Member Data Documentation

◆ pathNames_

std::vector<std::string> HLTEventSelector::pathNames_
private

trigger path names (ORed)

Definition at line 35 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().

◆ triggerResults_

edm::InputTag HLTEventSelector::triggerResults_
private

tag for input collection

Definition at line 33 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().

◆ triggerResultsToken_

edm::EDGetTokenT<edm::TriggerResults> HLTEventSelector::triggerResultsToken_
private

Definition at line 34 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().