CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
triggerExpression::PathReader Class Reference

#include <TriggerExpressionPathReader.h>

Inheritance diagram for triggerExpression::PathReader:
triggerExpression::Evaluator

Public Member Functions

void dump (std::ostream &out) const override
 
void init (const Data &data) override
 
bool operator() (const Data &data) const override
 
 PathReader (const std::string &pattern)
 
- Public Member Functions inherited from triggerExpression::Evaluator
 Evaluator ()
 
virtual ~Evaluator ()
 

Private Attributes

std::string m_pattern
 
std::vector< std::pair< std::string, unsigned int > > m_triggers
 

Detailed Description

Definition at line 11 of file TriggerExpressionPathReader.h.

Constructor & Destructor Documentation

triggerExpression::PathReader::PathReader ( const std::string &  pattern)
inline

Member Function Documentation

void triggerExpression::PathReader::dump ( std::ostream &  out) const
overridevirtual

Implements triggerExpression::Evaluator.

Definition at line 25 of file TriggerExpressionPathReader.cc.

References dqmdumpme::first, mps_fire::i, and m_triggers.

Referenced by PathReader().

25  {
26  if (m_triggers.empty()) {
27  out << "FALSE";
28  } else if (m_triggers.size() == 1) {
29  out << m_triggers[0].first;
30  } else {
31  out << "(" << m_triggers[0].first;
32  for (unsigned int i = 1; i < m_triggers.size(); ++i)
33  out << " OR " << m_triggers[i].first;
34  out << ")";
35  }
36  }
std::vector< std::pair< std::string, unsigned int > > m_triggers
void triggerExpression::PathReader::init ( const Data data)
overridevirtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 39 of file TriggerExpressionPathReader.cc.

References triggerExpression::Data::hltMenu(), edm::is_glob(), m_pattern, m_triggers, match(), patCandidatesForDimuonsSequences_cff::matches, mps_check::msg, AlCaHLTBitMon_ParallelJobs::p, edm::regexMatch(), triggerExpression::Data::shouldThrow(), edm::TriggerNames::size(), edm::TriggerNames::triggerIndex(), and edm::TriggerNames::triggerNames().

Referenced by PathReader().

39  {
40  // clear the previous configuration
41  m_triggers.clear();
42 
43  // check if the pattern has is a glob expression, or a single trigger name
44  const edm::TriggerNames& hltMenu = data.hltMenu();
45  if (not edm::is_glob(m_pattern)) {
46  // no wildcard expression
47  unsigned int index = hltMenu.triggerIndex(m_pattern);
48  if (index < hltMenu.size())
49  m_triggers.push_back(std::make_pair(m_pattern, index));
50  else {
51  std::stringstream msg;
52  msg << "requested HLT path \"" << m_pattern << "\" does not exist - known paths are:";
53  if (hltMenu.triggerNames().empty())
54  msg << " (none)";
55  else
56  for (auto const& p : hltMenu.triggerNames())
57  msg << "\n\t" << p;
58  if (data.shouldThrow())
59  throw cms::Exception("Configuration") << msg.str();
60  else
61  edm::LogWarning("Configuration") << msg.str();
62  }
63  } else {
64  // expand wildcards in the pattern
65  const std::vector<std::vector<std::string>::const_iterator>& matches =
67  if (matches.empty()) {
68  // m_pattern does not match any trigger paths
69  std::stringstream msg;
70  msg << "requested pattern \"" << m_pattern << "\" does not match any HLT paths - known paths are:";
71  if (hltMenu.triggerNames().empty())
72  msg << " (none)";
73  else
74  for (auto const& p : hltMenu.triggerNames())
75  msg << "\n\t" << p;
76  if (data.shouldThrow())
77  throw cms::Exception("Configuration") << msg.str();
78  else
79  edm::LogWarning("Configuration") << msg.str();
80  } else {
81  // store indices corresponding to the matching triggers
82  for (auto const& match : matches) {
83  unsigned int index = hltMenu.triggerIndex(*match);
84  assert(index < hltMenu.size());
85  m_triggers.push_back(std::make_pair(*match, index));
86  }
87  }
88  }
89  }
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:17
Strings::size_type size() const
Definition: TriggerNames.cc:31
Strings const & triggerNames() const
Definition: TriggerNames.cc:20
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:24
tuple msg
Definition: mps_check.py:285
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const &regexp)
Definition: RegexMatch.cc:26
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
std::vector< std::pair< std::string, unsigned int > > m_triggers
bool triggerExpression::PathReader::operator() ( const Data data) const
overridevirtual

Implements triggerExpression::Evaluator.

Definition at line 14 of file TriggerExpressionPathReader.cc.

References edm::HLTGlobalStatus::accept(), triggerExpression::Data::hasHLT(), triggerExpression::Data::hltResults(), and m_triggers.

Referenced by PathReader().

14  {
15  if (not data.hasHLT())
16  return false;
17 
18  for (auto const& trigger : m_triggers)
19  if (data.hltResults().accept(trigger.second))
20  return true;
21 
22  return false;
23  }
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
std::vector< std::pair< std::string, unsigned int > > m_triggers

Member Data Documentation

std::string triggerExpression::PathReader::m_pattern
private

Definition at line 22 of file TriggerExpressionPathReader.h.

Referenced by init().

std::vector<std::pair<std::string, unsigned int> > triggerExpression::PathReader::m_triggers
private

Definition at line 23 of file TriggerExpressionPathReader.h.

Referenced by dump(), init(), and operator()().