CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
void init (const Data &data)
 
bool operator() (const Data &data) const
 
 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

Definition at line 13 of file TriggerExpressionPathReader.h.

13  :
15  m_triggers()
16  { }
list pattern
Definition: chain.py:104
std::vector< std::pair< std::string, unsigned int > > m_triggers

Member Function Documentation

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

Implements triggerExpression::Evaluator.

Definition at line 27 of file TriggerExpressionPathReader.cc.

References first, i, and m_triggers.

27  {
28  if (m_triggers.size() == 0) {
29  out << "FALSE";
30  } else if (m_triggers.size() == 1) {
31  out << m_triggers[0].first;
32  } else {
33  out << "(" << m_triggers[0].first;
34  for (unsigned int i = 1; i < m_triggers.size(); ++i)
35  out << " OR " << m_triggers[i].first;
36  out << ")";
37  }
38 }
int i
Definition: DBlmapReader.cc:9
bool first
Definition: L1TdeRCT.cc:75
tuple out
Definition: dbtoconf.py:99
std::vector< std::pair< std::string, unsigned int > > m_triggers
void triggerExpression::PathReader::init ( const Data data)
virtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 41 of file TriggerExpressionPathReader.cc.

References triggerExpression::Data::hltMenu(), cmsHarvester::index, edm::is_glob(), m_pattern, m_triggers, match(), producerFileCleanner::msg, AlCaHLTBitMon_ParallelJobs::p, edm::regexMatch(), triggerExpression::Data::shouldThrow(), edm::TriggerNames::size(), AlCaHLTBitMon_QueryRunRegistry::string, edm::TriggerNames::triggerIndex(), and edm::TriggerNames::triggerNames().

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

Implements triggerExpression::Evaluator.

Definition at line 15 of file TriggerExpressionPathReader.cc.

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

15  {
16  if (not data.hasHLT())
17  return false;
18 
19  typedef std::pair<std::string, unsigned int> value_type;
20  BOOST_FOREACH(const value_type & trigger, m_triggers)
21  if (data.hltResults().accept(trigger.second))
22  return true;
23 
24  return false;
25 }
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:25
return((rh^lh)&mask)
U second(std::pair< T, U > const &p)
Container::value_type value_type
volatile std::atomic< bool > shutdown_flag false
if(conf.exists("allCellsPositionCalc"))
std::vector< std::pair< std::string, unsigned int > > m_triggers

Member Data Documentation

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

Definition at line 25 of file TriggerExpressionPathReader.h.

Referenced by init().

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

Definition at line 26 of file TriggerExpressionPathReader.h.

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