CMS 3D CMS Logo

HLTEventSelector.cc
Go to the documentation of this file.
2 
4 
6 
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 }
18 
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 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
bool accept() const
Has at least one path accepted the event?
Strings::size_type size() const
Definition: TriggerNames.cc:31
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
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_
unsigned int size() const
Get number of paths stored.
bool isValid() const
Definition: HandleBase.h:70
std::vector< std::string > pathNames_
trigger path names (ORed)
Definition: event.py:1
bool select(const edm::Event &) const override
decision of the selector module