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, bool const ignoreMasks=false) const override
 
void init (const Data &data) override
 
 L1uGTReader (const std::string &pattern)
 
void mask (Evaluator const &eval) override
 
bool operator() (const Data &data) const override
 
std::vector< std::pair< std::string, unsigned int > > triggers () const override
 
std::vector< std::pair< std::string, unsigned int > > triggersAfterMasking () const
 
- Public Member Functions inherited from triggerExpression::Evaluator
virtual void disableMasks ()
 
virtual void enableMasks ()
 
 Evaluator ()=default
 
virtual bool masksEnabled () const
 
virtual std::vector< std::string > patterns () const
 
virtual ~Evaluator ()=default
 

Private Attributes

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

Detailed Description

Definition at line 8 of file TriggerExpressionL1uGTReader.h.

Constructor & Destructor Documentation

◆ L1uGTReader()

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

Member Function Documentation

◆ dump()

void triggerExpression::L1uGTReader::dump ( std::ostream &  out,
bool const  ignoreMasks = false 
) const
overridevirtual

Implements triggerExpression::Evaluator.

Definition at line 30 of file TriggerExpressionL1uGTReader.cc.

References first, mps_fire::i, m_initialised, m_triggers, m_triggersAfterMasking, triggerExpression::Evaluator::masksEnabled(), or, MillePedeFileConverter_cfg::out, and triggers().

30  {
31  if (not m_initialised) {
32  out << "Uninitialised_L1_Expression";
33  return;
34  }
35 
36  auto const& triggers = ignoreMasks or not masksEnabled() ? m_triggers : m_triggersAfterMasking;
37 
38  if (triggers.empty()) {
39  out << "FALSE";
40  } else if (triggers.size() == 1) {
41  out << triggers[0].first;
42  } else {
43  out << "(" << triggers[0].first;
44  for (unsigned int i = 1; i < triggers.size(); ++i)
45  out << " OR " << triggers[i].first;
46  out << ")";
47  }
48  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< std::pair< std::string, unsigned int > > m_triggers
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking
std::vector< std::pair< std::string, unsigned int > > triggers() const override

◆ init()

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

Reimplemented from triggerExpression::Evaluator.

Definition at line 50 of file TriggerExpressionL1uGTReader.cc.

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

50  {
51  if (not data.hasL1T())
52  return;
53 
54  const L1TUtmTriggerMenu& menu = data.l1tMenu();
55 
56  // clear the previous configuration
57  m_triggers.clear();
58 
59  // check if the pattern has is a glob expression, or a single trigger name
60  auto const& triggerMap = menu.getAlgorithmMap();
61  if (not edm::is_glob(m_pattern)) {
62  // no wildcard expression
63  auto entry = triggerMap.find(m_pattern);
64  if (entry != triggerMap.end()) {
65  // single L1 bit
66  m_triggers.push_back(std::make_pair(m_pattern, entry->second.getIndex()));
67  } else {
68  // trigger not found in the current menu
69  if (data.shouldThrow())
70  throw cms::Exception("Configuration")
71  << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
72  else
73  edm::LogWarning("Configuration")
74  << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
75  }
76  } else {
77  // expand wildcards in the pattern
78  bool match = false;
79  std::regex re(edm::glob2reg(m_pattern));
80  for (auto const& entry : triggerMap)
81  if (std::regex_match(entry.first, re)) {
82  match = true;
83  m_triggers.push_back(std::make_pair(entry.first, entry.second.getIndex()));
84  }
85 
86  if (not match) {
87  // m_pattern does not match any L1 bits
88  if (data.shouldThrow())
89  throw cms::Exception("Configuration")
90  << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
91  else
92  edm::LogWarning("Configuration")
93  << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
94  }
95  }
96 
98  m_initialised = true;
99  }
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:17
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:19
std::vector< std::pair< std::string, unsigned int > > m_triggers
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking
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
Log< level::Warning, false > LogWarning

◆ mask()

void triggerExpression::L1uGTReader::mask ( Evaluator const &  eval)
overridevirtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 101 of file TriggerExpressionL1uGTReader.cc.

References triggerExpression::Evaluator::enableMasks(), spr::find(), m_triggersAfterMasking, triggerExpression::Evaluator::patterns(), and triggerExpression::Evaluator::triggers().

101  {
102  auto const& triggersToMask = eval.triggers();
103 
104  if (triggersToMask.empty()) {
105  edm::LogInfo("NoTriggersToMask") << "\tL1uGTReader[\"" << *this << "\"]::mask(arg = \"" << eval << "\")"
106  << " failed: arg.triggers() is empty";
107  return;
108  }
109 
110  // patterns() is always empty for a L1uGTReader, and not empty for PathReader;
111  // here, PathReader evaluators are skipped as they shouldn't be used to mask a L1uGTReader
112  if (not eval.patterns().empty()) {
113  edm::LogWarning("InvalidArgumentForMasking")
114  << "\tL1uGTReader[\"" << *this << "\"]::mask(arg = \"" << eval << "\")"
115  << " failed: arg.patterns() is not empty (arg is not a L1uGTReader)";
116  return;
117  }
118 
119  enableMasks();
120 
121  // clang-format off
123  std::remove_if(
124  m_triggersAfterMasking.begin(),
126  [&triggersToMask](auto const& foo) {
127  return std::find(triggersToMask.begin(), triggersToMask.end(), foo) != triggersToMask.end();
128  }
129  ),
131  );
132  // clang-format on
133  }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking
Log< level::Info, false > LogInfo
Log< level::Warning, false > LogWarning

◆ operator()()

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

Implements triggerExpression::Evaluator.

Definition at line 13 of file TriggerExpressionL1uGTReader.cc.

References data, m_triggers, m_triggersAfterMasking, triggerExpression::Evaluator::masksEnabled(), and triggers().

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

◆ triggers()

std::vector<std::pair<std::string, unsigned int> > triggerExpression::L1uGTReader::triggers ( ) const
inlineoverridevirtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 21 of file TriggerExpressionL1uGTReader.h.

References m_triggers.

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

21 { return m_triggers; }
std::vector< std::pair< std::string, unsigned int > > m_triggers

◆ triggersAfterMasking()

std::vector<std::pair<std::string, unsigned int> > triggerExpression::L1uGTReader::triggersAfterMasking ( ) const
inline

Definition at line 22 of file TriggerExpressionL1uGTReader.h.

References m_triggersAfterMasking.

22 { return m_triggersAfterMasking; }
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking

Member Data Documentation

◆ m_initialised

bool triggerExpression::L1uGTReader::m_initialised
private

Definition at line 28 of file TriggerExpressionL1uGTReader.h.

Referenced by dump(), and init().

◆ m_pattern

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

Definition at line 25 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 26 of file TriggerExpressionL1uGTReader.h.

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

◆ m_triggersAfterMasking

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

Definition at line 27 of file TriggerExpressionL1uGTReader.h.

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