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() [2/2]

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

Definition at line 7 of file HLTEventSelector.cc.

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 }

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

◆ ~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.

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 }

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

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

mps_fire.i
i
Definition: mps_fire.py:428
HLTEventSelector::pathNames_
std::vector< std::string > pathNames_
trigger path names (ORed)
Definition: HLTEventSelector.h:35
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< edm::TriggerResults >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
edm::TriggerNames::triggerNames
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
HLTEventSelector::HLTEventSelector
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
Definition: HLTEventSelector.h:27
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
HLTEventSelector::triggerResults_
edm::InputTag triggerResults_
tag for input collection
Definition: HLTEventSelector.h:33
edm::TriggerNames::triggerIndex
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
HLTEventSelector::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: HLTEventSelector.h:34
edm::TriggerNames::size
std::size_t size() const
Definition: TriggerNames.cc:59
edm::TriggerNames
Definition: TriggerNames.h:55
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::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
edm::TriggerResults
Definition: TriggerResults.h:35
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27