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::HLTEventSelector ( const edm::ParameterSet pset,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 27 of file HLTEventSelector.h.

References muonDTDigis_cfi::pset, and select().

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

Definition at line 7 of file HLTEventSelector.cc.

References edm::ConsumesCollector::consumes(), edm::ParameterSet::getParameter(), pathNames_, edm::HLTGlobalStatus::size(), 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)
T getParameter(std::string const &) const
edm::InputTag triggerResults_
tag for input collection
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
unsigned int size() const
Get number of paths stored.
std::vector< std::string > pathNames_
trigger path names (ORed)
HLTEventSelector::~HLTEventSelector ( )
inlineoverride

Definition at line 31 of file HLTEventSelector.h.

31 {}

Member Function Documentation

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

decision of the selector module

Implements EventSelector.

Definition at line 20 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_.

Referenced by HLTEventSelector().

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

Member Data Documentation

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

trigger path names (ORed)

Definition at line 35 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().

edm::InputTag HLTEventSelector::triggerResults_
private

tag for input collection

Definition at line 33 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().

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

Definition at line 34 of file HLTEventSelector.h.

Referenced by HLTEventSelector(), and select().