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  if (not data.hasL1T())
63  return;
64 
65  const L1GtTriggerMenu & menu = data.l1tMenu();
66  const L1GtTriggerMask & mask = data.l1tTechMask();
67 
68  // clear the previous configuration
69  m_triggers.clear();
70 
71  // L1 technical bits have a versioning suffix (".v0", ".v1", etc...)
72  // so we always go through wildcard expansion
73  bool match = false;
74  boost::regex re(edm::glob2reg(m_pattern) + "\\.v\\d");
75  const AlgorithmMap & triggerMap = menu.gtTechnicalTriggerMap();
76  BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
77  if (boost::regex_match(entry.first, re)) {
78  match = true;
79  if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
80  m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
81  }
82 
83  if (not match) {
84  // m_pattern does not match any L1 bits
85  if (data.shouldThrow())
86  throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
87  else
88  edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern << "\" does not match any L1 trigger in the current menu";
89  }
90 
91 }
92 
93 } // namespace triggerExpression
const cms_uint16_t bData(int iB) const
get/set B_DATA_CH_IB
Definition: L1GtPsbWord.cc:323
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:228
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
const L1GtPsbWord gtPsbWord(cms_uint16_t boardIdValue, int bxInEventValue) const
get / set PSB word (record) in the GT readout record
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
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map