CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
std::size_t size() const
Definition: TriggerNames.cc:59
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
unsigned int triggerIndex(std::string_view name) const
Definition: TriggerNames.cc:52
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
edm::InputTag triggerResults_
tag for input collection
Strings const & triggerNames() const
Definition: TriggerNames.cc:48
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
unsigned int size() const
Get number of paths stored.
bool select(const edm::Event &) const override
decision of the selector module
bool isValid() const
Definition: HandleBase.h:70
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Warning, false > LogWarning
std::vector< std::string > pathNames_
trigger path names (ORed)
#define LogDebug(id)