CMS 3D CMS Logo

Public Member Functions | Private Attributes

triggerExpression::L1Reader Class Reference

#include <TriggerExpressionL1Reader.h>

Inheritance diagram for triggerExpression::L1Reader:
triggerExpression::Evaluator

List of all members.

Public Member Functions

void dump (std::ostream &out) const
void init (const Data &data)
 L1Reader (const std::string &pattern)
bool operator() (const Data &data) const

Private Attributes

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

Detailed Description

Definition at line 11 of file TriggerExpressionL1Reader.h.


Constructor & Destructor Documentation

triggerExpression::L1Reader::L1Reader ( const std::string &  pattern) [inline]

Definition at line 13 of file TriggerExpressionL1Reader.h.


Member Function Documentation

void triggerExpression::L1Reader::dump ( std::ostream &  out) const [virtual]

Implements triggerExpression::Evaluator.

Definition at line 33 of file TriggerExpressionL1Reader.cc.

References first, i, and m_triggers.

                                          {
  if (m_triggers.size() == 0) {
    out << "FALSE";
  } else if (m_triggers.size() == 1) {
    out << m_triggers[0].first;
  } else {
    out << "(" << m_triggers[0].first;
    for (unsigned int i = 1; i < m_triggers.size(); ++i)
      out << " OR " << m_triggers[i].first;
    out << ")";
  }
}
void triggerExpression::L1Reader::init ( const Data data) [virtual]

Reimplemented from triggerExpression::Evaluator.

Definition at line 46 of file TriggerExpressionL1Reader.cc.

References triggerExpression::Data::daqPartitions(), edm::glob2reg(), L1GtTriggerMenu::gtAlgorithmAliasMap(), L1GtTriggerMask::gtTriggerMask(), triggerExpression::Data::ignoreL1Mask(), edm::is_glob(), triggerExpression::Data::l1tAlgoMask(), triggerExpression::Data::l1tMenu(), m_pattern, m_triggers, match(), relval_steps::menu, and triggerExpression::Data::shouldThrow().

                                     {
  const L1GtTriggerMenu & menu = data.l1tMenu();
  const L1GtTriggerMask & mask = data.l1tAlgoMask();

  // clear the previous configuration
  m_triggers.clear();

  // check if the pattern has is a glob expression, or a single trigger name 
  if (not edm::is_glob(m_pattern)) {
    // no wildcard expression
    const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
    AlgorithmMap::const_iterator entry = triggerMap.find(m_pattern);
    if (entry != triggerMap.end()) {
      // single L1 bit
      m_triggers.push_back( std::make_pair(m_pattern, entry->second.algoBitNumber()) );
    } else
      // trigger not found in the current menu
      if (data.shouldThrow())
        throw cms::Exception("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
      else
        edm::LogWarning("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
  } else {
    // expand wildcards in the pattern 
    bool match = false;
    boost::regex re(edm::glob2reg(m_pattern));
    const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
    BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
      if (boost::regex_match(entry.first, re)) {
        match = true;
        if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
          m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
      }

    if (not match) {
      // m_pattern does not match any L1 bits
      if (data.shouldThrow())
        throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
      else
        edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
    }
  }

}
bool triggerExpression::L1Reader::operator() ( const Data data) const [virtual]

Implements triggerExpression::Evaluator.

Definition at line 17 of file TriggerExpressionL1Reader.cc.

References L1GlobalTriggerReadoutRecord::decisionWord(), triggerExpression::Data::hasL1T(), triggerExpression::Data::l1tResults(), and m_triggers.

                                                 {
  if (not data.hasL1T())
    return false;

  const std::vector<bool> & word = data.l1tResults().decisionWord();
  if (word.empty())
    return false;

  typedef std::pair<std::string, unsigned int> value_type;
  BOOST_FOREACH(const value_type & trigger, m_triggers)
    if (trigger.second < word.size() and word[trigger.second])
      return true;

  return false;
}

Member Data Documentation

Definition at line 25 of file TriggerExpressionL1Reader.h.

Referenced by init().

std::vector<std::pair<std::string, unsigned int> > triggerExpression::L1Reader::m_triggers [private]

Definition at line 26 of file TriggerExpressionL1Reader.h.

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