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::L1uGTReader Class Reference

#include <TriggerExpressionL1uGTReader.h>

Inheritance diagram for triggerExpression::L1uGTReader:
triggerExpression::Evaluator

Public Member Functions

void dump (std::ostream &out) const
 
void init (const Data &data)
 
 L1uGTReader (const std::string &pattern)
 
bool operator() (const Data &data) const
 
- 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 TriggerExpressionL1uGTReader.h.

Constructor & Destructor Documentation

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

Definition at line 13 of file TriggerExpressionL1uGTReader.h.

13  :
15  m_triggers()
16  { }
std::vector< std::pair< std::string, unsigned int > > m_triggers

Member Function Documentation

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

Implements triggerExpression::Evaluator.

Definition at line 31 of file TriggerExpressionL1uGTReader.cc.

References plotBeamSpotDB::first, i, and m_triggers.

31  {
32  if (m_triggers.size() == 0) {
33  out << "FALSE";
34  } else if (m_triggers.size() == 1) {
35  out << m_triggers[0].first;
36  } else {
37  out << "(" << m_triggers[0].first;
38  for (unsigned int i = 1; i < m_triggers.size(); ++i)
39  out << " OR " << m_triggers[i].first;
40  out << ")";
41  }
42 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::pair< std::string, unsigned int > > m_triggers
void triggerExpression::L1uGTReader::init ( const Data data)
virtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 44 of file TriggerExpressionL1uGTReader.cc.

References mps_splice::entry, L1TUtmTriggerMenu::getAlgorithmMap(), edm::glob2reg(), triggerExpression::Data::hasL1T(), edm::is_glob(), triggerExpression::Data::l1tMenu(), m_pattern, m_triggers, match(), relval_steps::menu, and triggerExpression::Data::shouldThrow().

44  {
45  if (not data.hasL1T())
46  return;
47 
48  const L1TUtmTriggerMenu & menu = data.l1tMenu();
49 
50  // clear the previous configuration
51  m_triggers.clear();
52 
53  // check if the pattern has is a glob expression, or a single trigger name
54  auto const & triggerMap = menu.getAlgorithmMap();
55  if (not edm::is_glob(m_pattern)) {
56  // no wildcard expression
57  auto entry = triggerMap.find(m_pattern);
58  if (entry != triggerMap.end()) {
59  // single L1 bit
60  m_triggers.push_back( std::make_pair(m_pattern, entry->second.getIndex()) );
61  } else
62  // trigger not found in the current menu
63  if (data.shouldThrow())
64  throw cms::Exception("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
65  else
66  edm::LogWarning("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
67  } else {
68  // expand wildcards in the pattern
69  bool match = false;
70  boost::regex re(edm::glob2reg(m_pattern));
71  for (auto const & entry: triggerMap)
72  if (boost::regex_match(entry.first, re)) {
73  match = true;
74  m_triggers.push_back( std::make_pair(entry.first, entry.second.getIndex()) );
75  }
76 
77  if (not match) {
78  // m_pattern does not match any L1 bits
79  if (data.shouldThrow())
80  throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
81  else
82  edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
83  }
84  }
85 
86 }
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:18
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:22
std::vector< std::pair< std::string, unsigned int > > m_triggers
const std::map< std::string, L1TUtmAlgorithm > & getAlgorithmMap() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
list entry
Definition: mps_splice.py:62
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
bool triggerExpression::L1uGTReader::operator() ( const Data data) const
virtual

Implements triggerExpression::Evaluator.

Definition at line 16 of file TriggerExpressionL1uGTReader.cc.

References triggerExpression::Data::hasL1T(), triggerExpression::Data::l1tResults(), and m_triggers.

16  {
17  if (not data.hasL1T())
18  return false;
19 
20  std::vector<bool> const & word = data.l1tResults();
21  if (word.empty())
22  return false;
23 
24  for (auto const & trigger: m_triggers)
25  if (trigger.second < word.size() and word[trigger.second])
26  return true;
27 
28  return false;
29 }
std::vector< std::pair< std::string, unsigned int > > m_triggers
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

std::string triggerExpression::L1uGTReader::m_pattern
private

Definition at line 25 of file TriggerExpressionL1uGTReader.h.

Referenced by init().

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

Definition at line 26 of file TriggerExpressionL1uGTReader.h.

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