CMS 3D CMS Logo

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 override
 
void init (const Data &data) override
 
 L1uGTReader (const std::string &pattern)
 
bool operator() (const Data &data) const override
 
- 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

◆ L1uGTReader()

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

Definition at line 13 of file TriggerExpressionL1uGTReader.h.

Member Function Documentation

◆ dump()

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

Implements triggerExpression::Evaluator.

Definition at line 30 of file TriggerExpressionL1uGTReader.cc.

30  {
31  if (m_triggers.empty()) {
32  out << "FALSE";
33  } else if (m_triggers.size() == 1) {
34  out << m_triggers[0].first;
35  } else {
36  out << "(" << m_triggers[0].first;
37  for (unsigned int i = 1; i < m_triggers.size(); ++i)
38  out << " OR " << m_triggers[i].first;
39  out << ")";
40  }
41  }

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

◆ init()

void triggerExpression::L1uGTReader::init ( const Data data)
overridevirtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 43 of file TriggerExpressionL1uGTReader.cc.

43  {
44  if (not data.hasL1T())
45  return;
46 
47  const L1TUtmTriggerMenu& menu = data.l1tMenu();
48 
49  // clear the previous configuration
50  m_triggers.clear();
51 
52  // check if the pattern has is a glob expression, or a single trigger name
53  auto const& triggerMap = menu.getAlgorithmMap();
54  if (not edm::is_glob(m_pattern)) {
55  // no wildcard expression
56  auto entry = triggerMap.find(m_pattern);
57  if (entry != triggerMap.end()) {
58  // single L1 bit
59  m_triggers.push_back(std::make_pair(m_pattern, entry->second.getIndex()));
60  } else
61  // trigger not found in the current menu
62  if (data.shouldThrow())
63  throw cms::Exception("Configuration")
64  << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
65  else
66  edm::LogWarning("Configuration") << "requested L1 trigger \"" << m_pattern
67  << "\" does not exist in the current L1 menu";
68  } else {
69  // expand wildcards in the pattern
70  bool match = false;
71  std::regex re(edm::glob2reg(m_pattern));
72  for (auto const& entry : triggerMap)
73  if (std::regex_match(entry.first, re)) {
74  match = true;
75  m_triggers.push_back(std::make_pair(entry.first, entry.second.getIndex()));
76  }
77 
78  if (not match) {
79  // m_pattern does not match any L1 bits
80  if (data.shouldThrow())
81  throw cms::Exception("Configuration")
82  << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
83  else
84  edm::LogWarning("Configuration")
85  << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
86  }
87  }
88  }

References data, mps_splice::entry, edm::glob2reg(), edm::is_glob(), m_pattern, m_triggers, match(), and optionsL1T::menu.

◆ operator()()

bool triggerExpression::L1uGTReader::operator() ( const Data data) const
overridevirtual

Implements triggerExpression::Evaluator.

Definition at line 15 of file TriggerExpressionL1uGTReader.cc.

15  {
16  if (not data.hasL1T())
17  return false;
18 
19  std::vector<bool> const& word = data.l1tResults();
20  if (word.empty())
21  return false;
22 
23  for (auto const& trigger : m_triggers)
24  if (trigger.second < word.size() and word[trigger.second])
25  return true;
26 
27  return false;
28  }

References data, and m_triggers.

Member Data Documentation

◆ m_pattern

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

Definition at line 22 of file TriggerExpressionL1uGTReader.h.

Referenced by init().

◆ m_triggers

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

Definition at line 23 of file TriggerExpressionL1uGTReader.h.

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

mps_fire.i
i
Definition: mps_fire.py:428
mps_splice.entry
entry
Definition: mps_splice.py:68
triggerExpression::L1uGTReader::m_triggers
std::vector< std::pair< std::string, unsigned int > > m_triggers
Definition: TriggerExpressionL1uGTReader.h:23
edm::is_glob
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:17
dqmdumpme.first
first
Definition: dqmdumpme.py:55
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
L1TUtmTriggerMenu
Definition: L1TUtmTriggerMenu.h:25
edm::glob2reg
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:19
optionsL1T.menu
menu
Definition: optionsL1T.py:29
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
trigger
Definition: HLTPrescaleTableCond.h:8
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::Exception
Definition: Exception.h:70
triggerExpression::L1uGTReader::m_pattern
std::string m_pattern
Definition: TriggerExpressionL1uGTReader.h:22