CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerExpressionL1Reader.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <boost/foreach.hpp>
3 #include <boost/regex.hpp>
4 
13 
14 namespace triggerExpression {
15 
16 // define the result of the module from the L1 reults
17 bool L1Reader::operator()(const Data & data) const {
18  if (not data.hasL1T())
19  return false;
20 
21  const std::vector<bool> & word = data.l1tResults().decisionWord();
22  if (word.empty())
23  return false;
24 
25  typedef std::pair<std::string, unsigned int> value_type;
26  BOOST_FOREACH(const value_type & trigger, m_triggers)
27  if (trigger.second < word.size() and word[trigger.second])
28  return true;
29 
30  return false;
31 }
32 
33 void L1Reader::dump(std::ostream & out) const {
34  if (m_triggers.size() == 0) {
35  out << "FALSE";
36  } else if (m_triggers.size() == 1) {
37  out << m_triggers[0].first;
38  } else {
39  out << "(" << m_triggers[0].first;
40  for (unsigned int i = 1; i < m_triggers.size(); ++i)
41  out << " OR " << m_triggers[i].first;
42  out << ")";
43  }
44 }
45 
46 void L1Reader::init(const Data & data) {
47  const L1GtTriggerMenu & menu = data.l1tMenu();
48  const L1GtTriggerMask & mask = data.l1tAlgoMask();
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  if (not edm::is_glob(m_pattern)) {
55  // no wildcard expression
56  const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
57  AlgorithmMap::const_iterator 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.algoBitNumber()) );
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  const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
72  BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
73  if (boost::regex_match(entry.first, re)) {
74  match = true;
75  if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
76  m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
77  }
78 
79  if (not match) {
80  // m_pattern does not match any L1 bits
81  if (data.shouldThrow())
82  throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
83  else
84  edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
85  }
86  }
87 
88 }
89 
90 } // namespace triggerExpression
int i
Definition: DBlmapReader.cc:9
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
bool is_glob(std::string const &pattern)
Definition: RegexMatch.cc:18
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:22
bool operator()(const Data &data) const
const L1GlobalTriggerReadoutRecord & l1tResults() const
const L1GtTriggerMenu & l1tMenu() const
std::vector< std::pair< std::string, unsigned int > > m_triggers
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
bool first
Definition: L1TdeRCT.cc:94
Container::value_type value_type
const DecisionWord & decisionWord(int bxInEventValue) const
tuple out
Definition: dbtoconf.py:99
unsigned int daqPartitions() const
void dump(std::ostream &out) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
const L1GtTriggerMask & l1tAlgoMask() const