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 
19 bool
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)
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:39
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
edm::InputTag triggerResults_
tag for input collection
Strings const & triggerNames() const
Definition: TriggerNames.cc:24
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
unsigned int size() const
Get number of paths stored.
bool isValid() const
Definition: HandleBase.h:74
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