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 }
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
HLTEventSelector::pathNames_
std::vector< std::string > pathNames_
trigger path names (ORed)
Definition: HLTEventSelector.h:35
HLTEventSelector::select
bool select(const edm::Event &) const override
decision of the selector module
Definition: HLTEventSelector.cc:19
edm::LogInfo
Definition: MessageLogger.h:254
edm::Handle< edm::TriggerResults >
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
edm::TriggerNames::triggerNames
Strings const & triggerNames() const
Definition: TriggerNames.cc:20
HLTEventSelector.h
edm::LogWarning
Definition: MessageLogger.h:141
HLTEventSelector::HLTEventSelector
HLTEventSelector(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
Definition: HLTEventSelector.h:27
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
HLTEventSelector::triggerResults_
edm::InputTag triggerResults_
tag for input collection
Definition: HLTEventSelector.h:33
TriggerNames.h
HLTEventSelector::triggerResultsToken_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Definition: HLTEventSelector.h:34
edm::TriggerNames::size
Strings::size_type size() const
Definition: TriggerNames.cc:31
edm::TriggerNames
Definition: TriggerNames.h:55
edm::HLTGlobalStatus::accept
bool accept() const
Has at least one path accepted the event?
Definition: HLTGlobalStatus.h:49
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::TriggerNames::triggerIndex
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:24
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
edm::TriggerResults
Definition: TriggerResults.h:35
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27