Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:32

0001 /**
0002 * \class GlobalExtBlk
0003 *
0004 *
0005 * Description: see header file.
0006 *
0007 * Implementation:
0008 * <TODO: enter implementation details>
0009 *
0010 * \author: Brian Winer -- Ohio State
0011 *
0012 *
0013 */
0014 
0015 // this class header
0016 #include "DataFormats/L1TGlobal/interface/GlobalExtBlk.h"
0017 
0018 // system include files
0019 
0020 // user include files
0021 
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0024 
0025 // constructors
0026 
0027 // empty constructor, all members set to zero;
0028 GlobalExtBlk::GlobalExtBlk() {
0029   // Reserve/Clear out the decision words
0030   m_extDecision.reserve(maxExternalConditions);
0031   m_extDecision.assign(maxExternalConditions, false);
0032 }
0033 
0034 // destructor
0035 GlobalExtBlk::~GlobalExtBlk() {
0036   // empty now
0037 }
0038 
0039 /// Set decision bits
0040 void GlobalExtBlk::setExternalDecision(unsigned int bit, bool val) {
0041   if (bit < m_extDecision.size()) {
0042     m_extDecision.at(bit) = val;
0043 
0044   } else {
0045     // Need some erorr checking here.
0046     LogTrace("L1TGlobal") << "Attempting to set a external bit " << bit << " beyond limit " << m_extDecision.size();
0047   }
0048 }
0049 
0050 /// Get decision bits
0051 bool GlobalExtBlk::getExternalDecision(unsigned int bit) const {
0052   if (bit >= m_extDecision.size())
0053     return false;
0054   return m_extDecision.at(bit);
0055 }
0056 
0057 // reset the content of a GlobalExtBlk
0058 void GlobalExtBlk::reset() {
0059   // Clear out the decision words
0060   // but leave the vector intact
0061   m_extDecision.assign(maxExternalConditions, false);
0062 }
0063 
0064 // pretty print the content of a GlobalExtBlk
0065 void GlobalExtBlk::print(std::ostream& myCout) const {
0066   myCout << " GlobalExtBlk " << std::endl;
0067 
0068   // Loop through bits to create a hex word of algorithm bits.
0069   int lengthWd = m_extDecision.size();
0070   myCout << "    External Conditions   0x" << std::hex;
0071   int digit = 0;
0072   bool firstNonZero = false;
0073   for (int i = lengthWd - 1; i > -1; i--) {
0074     if (m_extDecision.at(i))
0075       digit |= (1 << (i % 4));
0076     if (digit > 0)
0077       firstNonZero = true;
0078     if ((i % 4) == 0 && firstNonZero) {
0079       myCout << std::hex << std::setw(1) << digit;
0080       digit = 0;
0081       if (i % 32 == 0 && i < lengthWd - 1)
0082         myCout << " ";
0083     }
0084   }  //end loop over algorithm bits
0085   if (!firstNonZero)
0086     myCout << "0";
0087   myCout << std::endl;
0088 }