CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/HLTrigger/HLTcore/src/TriggerExpressionL1Reader.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <boost/foreach.hpp>
00003 #include <boost/regex.hpp>
00004 
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "FWCore/Utilities/interface/RegexMatch.h"
00007 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00008 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00009 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
00010 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00011 #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h"
00012 #include "HLTrigger/HLTcore/interface/TriggerExpressionL1Reader.h"
00013 
00014 namespace triggerExpression {
00015 
00016 // define the result of the module from the L1 reults
00017 bool L1Reader::operator()(const Data & data) const {
00018   if (not data.hasL1T())
00019     return false;
00020 
00021   const std::vector<bool> & word = data.l1tResults().decisionWord();
00022   if (word.empty())
00023     return false;
00024 
00025   typedef std::pair<std::string, unsigned int> value_type;
00026   BOOST_FOREACH(const value_type & trigger, m_triggers)
00027     if (trigger.second < word.size() and word[trigger.second])
00028       return true;
00029 
00030   return false;
00031 }
00032 
00033 void L1Reader::dump(std::ostream & out) const {
00034   if (m_triggers.size() == 0) {
00035     out << "FALSE";
00036   } else if (m_triggers.size() == 1) {
00037     out << m_triggers[0].first;
00038   } else {
00039     out << "(" << m_triggers[0].first;
00040     for (unsigned int i = 1; i < m_triggers.size(); ++i)
00041       out << " OR " << m_triggers[i].first;
00042     out << ")";
00043   }
00044 }
00045 
00046 void L1Reader::init(const Data & data) {
00047   const L1GtTriggerMenu & menu = data.l1tMenu();
00048   const L1GtTriggerMask & mask = data.l1tAlgoMask();
00049 
00050   // clear the previous configuration
00051   m_triggers.clear();
00052 
00053   // check if the pattern has is a glob expression, or a single trigger name 
00054   if (not edm::is_glob(m_pattern)) {
00055     // no wildcard expression
00056     const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
00057     AlgorithmMap::const_iterator entry = triggerMap.find(m_pattern);
00058     if (entry != triggerMap.end()) {
00059       // single L1 bit
00060       m_triggers.push_back( std::make_pair(m_pattern, entry->second.algoBitNumber()) );
00061     } else
00062       // trigger not found in the current menu
00063       if (data.shouldThrow())
00064         throw cms::Exception("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
00065       else
00066         edm::LogWarning("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
00067   } else {
00068     // expand wildcards in the pattern 
00069     bool match = false;
00070     boost::regex re(edm::glob2reg(m_pattern));
00071     const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
00072     BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
00073       if (boost::regex_match(entry.first, re)) {
00074         match = true;
00075         if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
00076           m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
00077       }
00078 
00079     if (not match) {
00080       // m_pattern does not match any L1 bits
00081       if (data.shouldThrow())
00082         throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
00083       else
00084         edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
00085     }
00086   }
00087 
00088 }
00089 
00090 } // namespace triggerExpression