CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerExpressionL1TechReader.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <bitset>
3 #include <boost/foreach.hpp>
4 #include <boost/regex.hpp>
5 
14 
15 namespace triggerExpression {
16 
17 // define the result of the module from the L1 reults
18 bool L1TechReader::operator()(const Data & data) const {
19  if (not data.hasL1T())
20  return false;
21 
22  typedef std::pair<std::string, unsigned int> value_type;
23  if (data.ignoreL1TechPrescales()) {
24  // select PSB#9 and bunch crossing 0
25  const L1GtPsbWord & psb = data.l1tResults().gtPsbWord(0xbb09, 0);
26  // the four 16-bit words psb.bData(1), psb.aData(1), psb.bData(0) and psb.aData(0) yield
27  // (in this sequence) the 64 technical trigger bits from most significant to least significant bit
28  uint64_t psbTriggerWord = ((uint64_t) psb.bData(1) << 48) |
29  ((uint64_t) psb.aData(1) << 32) |
30  ((uint64_t) psb.bData(0) << 16) |
31  ((uint64_t) psb.aData(0));
32  BOOST_FOREACH(const value_type & trigger, m_triggers)
33  if (psbTriggerWord & ((uint64_t) 0x01 << trigger.second))
34  return true;
35  } else {
36  const std::vector<bool> & word = data.l1tResults().technicalTriggerWord();
37  if (word.empty())
38  return false;
39 
40  BOOST_FOREACH(const value_type & trigger, m_triggers)
41  if (trigger.second < word.size() and word[trigger.second])
42  return true;
43  }
44 
45  return false;
46 }
47 
48 void L1TechReader::dump(std::ostream & out) const {
49  if (m_triggers.size() == 0) {
50  out << "FALSE";
51  } else if (m_triggers.size() == 1) {
52  out << m_triggers[0].first;
53  } else {
54  out << "(" << m_triggers[0].first;
55  for (unsigned int i = 1; i < m_triggers.size(); ++i)
56  out << " OR " << m_triggers[i].first;
57  out << ")";
58  }
59 }
60 
61 void L1TechReader::init(const Data & data) {
62  const L1GtTriggerMenu & menu = data.l1tMenu();
63  const L1GtTriggerMask & mask = data.l1tTechMask();
64 
65  // clear the previous configuration
66  m_triggers.clear();
67 
68  // L1 technical bits have a versioning suffix (".v0", ".v1", etc...)
69  // so we always go through wildcard expansion
70  bool match = false;
71  boost::regex re(edm::glob2reg(m_pattern) + "\\.v\\d");
72  const AlgorithmMap & triggerMap = menu.gtTechnicalTriggerMap();
73  BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
74  if (boost::regex_match(entry.first, re)) {
75  match = true;
76  if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
77  m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
78  }
79 
80  if (not match) {
81  // m_pattern does not match any L1 bits
82  if (data.shouldThrow())
83  throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
84  else
85  edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
86  }
87 
88 }
89 
90 } // namespace triggerExpression
const cms_uint16_t bData(int iB) const
get/set B_DATA_CH_IB
Definition: L1GtPsbWord.cc:325
int i
Definition: DBlmapReader.cc:9
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
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
const L1GtTriggerMask & l1tTechMask() const
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
std::string glob2reg(std::string const &pattern)
Definition: RegexMatch.cc:22
const L1GlobalTriggerReadoutRecord & l1tResults() const
const L1GtTriggerMenu & l1tMenu() const
const cms_uint16_t aData(int iA) const
get/set A_DATA_CH_IA
Definition: L1GtPsbWord.cc:230
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
const L1GtPsbWord gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const
get / set PSB word (record) in the GT readout record
bool first
Definition: L1TdeRCT.cc:94
Container::value_type value_type
tuple out
Definition: dbtoconf.py:99
bool operator()(const Data &data) const
unsigned long long uint64_t
Definition: Time.h:15
unsigned int daqPartitions() const
std::vector< std::pair< std::string, unsigned int > > m_triggers
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 & gtTechnicalTriggerMap() const
get / set the technical trigger map