CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
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
int i
Definition: DBlmapReader.cc:9
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.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
virtual bool select(const edm::Event &) const
decision of the selector module
std::vector< std::string > pathNames_
trigger path names (ORed)