CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/HLTrigger/HLTcore/src/TriggerExpressionL1TechReader.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <bitset>
00003 #include <boost/foreach.hpp>
00004 #include <boost/regex.hpp>
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include "FWCore/Utilities/interface/RegexMatch.h"
00008 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00009 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00010 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
00011 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00012 #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h"
00013 #include "HLTrigger/HLTcore/interface/TriggerExpressionL1TechReader.h"
00014 
00015 namespace triggerExpression {
00016 
00017 // define the result of the module from the L1 reults
00018 bool L1TechReader::operator()(const Data & data) const {
00019   if (not data.hasL1T())
00020     return false;
00021 
00022   typedef std::pair<std::string, unsigned int> value_type;
00023   if (data.ignoreL1TechPrescales()) {
00024     // select PSB#9 and bunch crossing 0
00025     const L1GtPsbWord & psb = data.l1tResults().gtPsbWord(0xbb09, 0);
00026     // the four 16-bit words psb.bData(1), psb.aData(1), psb.bData(0) and psb.aData(0) yield
00027     // (in this sequence) the 64 technical trigger bits from most significant to least significant bit
00028     uint64_t psbTriggerWord = ((uint64_t) psb.bData(1) << 48) | 
00029                               ((uint64_t) psb.aData(1) << 32) | 
00030                               ((uint64_t) psb.bData(0) << 16) | 
00031                               ((uint64_t) psb.aData(0));
00032     BOOST_FOREACH(const value_type & trigger, m_triggers)
00033       if (psbTriggerWord & ((uint64_t) 0x01 << trigger.second))
00034         return true;
00035   } else {
00036     const std::vector<bool> & word = data.l1tResults().technicalTriggerWord();
00037     if (word.empty())
00038       return false;
00039 
00040     BOOST_FOREACH(const value_type & trigger, m_triggers)
00041       if (trigger.second < word.size() and word[trigger.second])
00042         return true;
00043   }
00044 
00045   return false;
00046 }
00047 
00048 void L1TechReader::dump(std::ostream & out) const {
00049   if (m_triggers.size() == 0) {
00050     out << "FALSE";
00051   } else if (m_triggers.size() == 1) {
00052     out << m_triggers[0].first;
00053   } else {
00054     out << "(" << m_triggers[0].first;
00055     for (unsigned int i = 1; i < m_triggers.size(); ++i)
00056       out << " OR " << m_triggers[i].first;
00057     out << ")";
00058   }
00059 }
00060 
00061 void L1TechReader::init(const Data & data) {
00062   const L1GtTriggerMenu & menu = data.l1tMenu();
00063   const L1GtTriggerMask & mask = data.l1tTechMask();
00064 
00065   // clear the previous configuration
00066   m_triggers.clear();
00067 
00068   // L1 technical bits have a versioning suffix (".v0", ".v1", etc...)
00069   // so we always go through wildcard expansion
00070   bool match = false;
00071   boost::regex re(edm::glob2reg(m_pattern) + "\\.v\\d");
00072   const AlgorithmMap & triggerMap = menu.gtTechnicalTriggerMap();
00073   BOOST_FOREACH(const AlgorithmMap::value_type & entry, triggerMap)
00074     if (boost::regex_match(entry.first, re)) {
00075       match = true;
00076       if (data.ignoreL1Mask() or (mask.gtTriggerMask()[entry.second.algoBitNumber()] & data.daqPartitions()) != data.daqPartitions()) // unmasked in one or more partitions
00077         m_triggers.push_back( std::make_pair(entry.first, entry.second.algoBitNumber()) );
00078     }
00079 
00080   if (not match) {
00081     // m_pattern does not match any L1 bits
00082     if (data.shouldThrow())
00083       throw cms::Exception("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
00084     else
00085       edm::LogWarning("Configuration") << "requested pattern \"" << m_pattern <<  "\" does not match any L1 trigger in the current menu";
00086   }
00087 
00088 }
00089 
00090 } // namespace triggerExpression