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, bool const ignoreMasks=false) const override
 
void init (const Data &data) override
 
void mask (Evaluator const &eval) override
 
bool operator() (const Data &data) const override
 
 PathReader (const std::string &pattern)
 
std::vector< std::string > patterns () 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 ~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 TriggerExpressionPathReader.h.

Constructor & Destructor Documentation

◆ PathReader()

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

Member Function Documentation

◆ dump()

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

Implements triggerExpression::Evaluator.

Definition at line 25 of file TriggerExpressionPathReader.cc.

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

25  {
26  if (not m_initialised) {
27  out << "Uninitialised_Path_Expression";
28  return;
29  }
30 
31  auto const& triggers = ignoreMasks or not masksEnabled() ? m_triggers : m_triggersAfterMasking;
32 
33  if (triggers.empty()) {
34  out << "FALSE";
35  } else if (triggers.size() == 1) {
36  out << triggers[0].first;
37  } else {
38  out << "(" << triggers[0].first;
39  for (unsigned int i = 1; i < triggers.size(); ++i)
40  out << " OR " << triggers[i].first;
41  out << ")";
42  }
43  }
std::vector< std::pair< std::string, unsigned int > > triggers() const override
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking
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

◆ init()

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

Reimplemented from triggerExpression::Evaluator.

Definition at line 46 of file TriggerExpressionPathReader.cc.

References cms::cuda::assert(), data, edm::is_glob(), m_initialised, m_pattern, m_triggers, m_triggersAfterMasking, oniaPATMuonsWithTrigger_cff::matches, mps_check::msg, AlCaHLTBitMon_ParallelJobs::p, and edm::regexMatch().

46  {
47  // clear the previous configuration
48  m_triggers.clear();
49 
50  // check if the pattern has is a glob expression, or a single trigger name
51  if (not edm::is_glob(m_pattern)) {
52  // no wildcard expression
53  auto index = data.triggerIndex(m_pattern);
54  if (index >= 0)
55  m_triggers.push_back(std::make_pair(m_pattern, index));
56  else {
57  std::stringstream msg;
58  msg << "requested HLT path \"" << m_pattern << "\" does not exist - known paths are:";
59  if (data.triggerNames().empty())
60  msg << " (none)";
61  else
62  for (auto const& p : data.triggerNames())
63  msg << "\n\t" << p;
64  if (data.shouldThrow())
65  throw cms::Exception("Configuration") << msg.str();
66  else
67  edm::LogWarning("Configuration") << msg.str();
68  }
69  } else {
70  // expand wildcards in the pattern
71  const std::vector<std::vector<std::string>::const_iterator>& matches =
72  edm::regexMatch(data.triggerNames(), m_pattern);
73  if (matches.empty()) {
74  // m_pattern does not match any trigger paths
75  std::stringstream msg;
76  msg << "requested pattern \"" << m_pattern << "\" does not match any HLT paths - known paths are:";
77  if (data.triggerNames().empty())
78  msg << " (none)";
79  else
80  for (auto const& p : data.triggerNames())
81  msg << "\n\t" << p;
82  if (data.shouldThrow())
83  throw cms::Exception("Configuration") << msg.str();
84  else
85  edm::LogWarning("Configuration") << msg.str();
86  } else {
87  // store indices corresponding to the matching triggers
88  for (auto const& match : matches) {
89  auto index = data.triggerIndex(*match);
90  assert(index >= 0);
91  m_triggers.push_back(std::make_pair(*match, index));
92  }
93  }
94  }
95 
97  m_initialised = true;
98  }
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:17
assert(be >=bs)
std::vector< std::pair< std::string, unsigned int > > m_triggersAfterMasking
tuple msg
Definition: mps_check.py:286
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
Log< level::Warning, false > LogWarning
std::vector< std::pair< std::string, unsigned int > > m_triggers

◆ mask()

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

Reimplemented from triggerExpression::Evaluator.

Definition at line 100 of file TriggerExpressionPathReader.cc.

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

100  {
101  auto const& triggersToMask = eval.triggers();
102 
103  if (triggersToMask.empty()) {
104  edm::LogInfo("NoTriggersToMask") << "\tPathReader[\"" << *this << "\"]::mask(arg = \"" << eval << "\")"
105  << " failed: arg.triggers() is empty";
106  return;
107  }
108 
109  // patterns() is always empty for a L1uGTReader, and not empty for PathReader;
110  // here, L1uGTReader evaluators are skipped as they shouldn't be used to mask a PathReader
111  if (eval.patterns().empty()) {
112  edm::LogWarning("InvalidArgumentForMasking")
113  << "\tPathReader[\"" << *this << "\"]::mask(arg = \"" << eval << "\")"
114  << " failed: arg.patterns() is empty (arg is not a PathReader)";
115  return;
116  }
117 
118  enableMasks();
119 
120  // clang-format off
122  std::remove_if(
123  m_triggersAfterMasking.begin(),
125  [&triggersToMask](auto const& foo) {
126  return std::find(triggersToMask.begin(), triggersToMask.end(), foo) != triggersToMask.end();
127  }
128  ),
130  );
131  // clang-format on
132  }
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::PathReader::operator() ( const Data data) const
overridevirtual

Implements triggerExpression::Evaluator.

Definition at line 12 of file TriggerExpressionPathReader.cc.

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

12  {
13  if (not data.hasHLT() && not data.usePathStatus())
14  return false;
15 
17 
18  for (auto const& trigger : triggers)
19  if (data.passHLT(trigger.second))
20  return true;
21 
22  return false;
23  }
std::vector< std::pair< std::string, unsigned int > > triggers() const override
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 > > m_triggers

◆ patterns()

std::vector<std::string> triggerExpression::PathReader::patterns ( ) const
inlineoverridevirtual

Reimplemented from triggerExpression::Evaluator.

Definition at line 17 of file TriggerExpressionPathReader.h.

References m_pattern.

◆ triggers()

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

Reimplemented from triggerExpression::Evaluator.

Definition at line 23 of file TriggerExpressionPathReader.h.

References m_triggers.

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

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

◆ triggersAfterMasking()

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

Definition at line 24 of file TriggerExpressionPathReader.h.

References m_triggersAfterMasking.

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

Member Data Documentation

◆ m_initialised

bool triggerExpression::PathReader::m_initialised
private

Definition at line 30 of file TriggerExpressionPathReader.h.

Referenced by dump(), and init().

◆ m_pattern

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

Definition at line 27 of file TriggerExpressionPathReader.h.

Referenced by init(), and patterns().

◆ m_triggers

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

Definition at line 28 of file TriggerExpressionPathReader.h.

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

◆ m_triggersAfterMasking

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

Definition at line 29 of file TriggerExpressionPathReader.h.

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