Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:53

0001 /**
0002 * \class GlobalAlgBlk
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/GlobalAlgBlk.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 GlobalAlgBlk::GlobalAlgBlk(int orbitNr, int bxNr, int bxInEvent)
0029     : m_orbitNr(orbitNr), m_bxNr(bxNr), m_bxInEvent(bxInEvent) {
0030   //Clear out the header data
0031   m_finalOR = false;
0032   m_preScColumn = 0;
0033 
0034   // Reserve/Clear out the decision words
0035   m_algoDecisionInitial.reserve(maxPhysicsTriggers);
0036   m_algoDecisionInitial.assign(maxPhysicsTriggers, false);
0037 
0038   m_algoDecisionPreScaled.reserve(maxPhysicsTriggers);
0039   m_algoDecisionPreScaled.assign(maxPhysicsTriggers, false);
0040 
0041   m_algoDecisionFinal.reserve(maxPhysicsTriggers);
0042   m_algoDecisionFinal.assign(maxPhysicsTriggers, false);
0043 }
0044 
0045 // empty constructor, all members set to zero;
0046 GlobalAlgBlk::GlobalAlgBlk() {
0047   //Clear out the header data
0048   m_orbitNr = 0;
0049   m_bxNr = 0;
0050   m_bxInEvent = 0;
0051   m_finalOR = false;
0052   m_finalORPreVeto = false;
0053   m_finalORVeto = false;
0054   m_preScColumn = 0;
0055 
0056   // Reserve/Clear out the decision words
0057   m_algoDecisionInitial.reserve(maxPhysicsTriggers);
0058   m_algoDecisionInitial.assign(maxPhysicsTriggers, false);
0059 
0060   m_algoDecisionPreScaled.reserve(maxPhysicsTriggers);
0061   m_algoDecisionPreScaled.assign(maxPhysicsTriggers, false);
0062 
0063   m_algoDecisionFinal.reserve(maxPhysicsTriggers);
0064   m_algoDecisionFinal.assign(maxPhysicsTriggers, false);
0065 }
0066 
0067 // destructor
0068 GlobalAlgBlk::~GlobalAlgBlk() {
0069   // empty now
0070 }
0071 
0072 /// Set decision bits
0073 void GlobalAlgBlk::setAlgoDecisionInitial(unsigned int bit, bool val) {
0074   if (bit < m_algoDecisionInitial.size()) {
0075     m_algoDecisionInitial.at(bit) = val;
0076 
0077   } else {
0078     // Need some erorr checking here.
0079     LogTrace("L1TGlobal") << "Attempting to set an algorithm bit " << bit << " beyond limit "
0080                           << m_algoDecisionInitial.size();
0081   }
0082 }
0083 
0084 void GlobalAlgBlk::setAlgoDecisionInterm(unsigned int bit, bool val) {
0085   if (bit < m_algoDecisionPreScaled.size()) {
0086     m_algoDecisionPreScaled.at(bit) = val;
0087   } else {
0088     // Need some erorr checking here.
0089     LogTrace("L1TGlobal") << "Attempting to set an algorithm bit " << bit << " beyond limit "
0090                           << m_algoDecisionPreScaled.size();
0091   }
0092 }
0093 
0094 void GlobalAlgBlk::setAlgoDecisionFinal(unsigned int bit, bool val) {
0095   if (bit < m_algoDecisionFinal.size()) {
0096     m_algoDecisionFinal.at(bit) = val;
0097   } else {
0098     // Need some erorr checking here.
0099     LogTrace("L1TGlobal") << "Attempting to set an algorithm bit " << bit << " beyond limit "
0100                           << m_algoDecisionFinal.size();
0101   }
0102 }
0103 
0104 /// Get decision bits
0105 bool GlobalAlgBlk::getAlgoDecisionInitial(unsigned int bit) const {
0106   if (bit >= m_algoDecisionInitial.size())
0107     return false;
0108   return m_algoDecisionInitial.at(bit);
0109 }
0110 
0111 bool GlobalAlgBlk::getAlgoDecisionInterm(unsigned int bit) const {
0112   if (bit >= m_algoDecisionPreScaled.size())
0113     return false;
0114   return m_algoDecisionPreScaled.at(bit);
0115 }
0116 
0117 bool GlobalAlgBlk::getAlgoDecisionFinal(unsigned int bit) const {
0118   if (bit >= m_algoDecisionFinal.size())
0119     return false;
0120   return m_algoDecisionFinal.at(bit);
0121 }
0122 
0123 // reset the content of a GlobalAlgBlk
0124 void GlobalAlgBlk::reset() {
0125   //Clear out the header data
0126   m_orbitNr = 0;
0127   m_bxNr = 0;
0128   m_bxInEvent = 0;
0129   m_finalOR = false;
0130   m_finalORPreVeto = false;
0131   m_finalORVeto = false;
0132   m_preScColumn = 0;
0133 
0134   // Clear out the decision words
0135   // but leave the vector intact
0136   m_algoDecisionInitial.assign(maxPhysicsTriggers, false);
0137   m_algoDecisionPreScaled.assign(maxPhysicsTriggers, false);
0138   m_algoDecisionFinal.assign(maxPhysicsTriggers, false);
0139 }
0140 
0141 // compare the content of this GlobalAlgBlk with another one
0142 bool GlobalAlgBlk::operator==(const GlobalAlgBlk& rhs) const {
0143   // Not all variables can be compared since the prescale counters are
0144   // generally not the same when producing the collections and so the
0145   // prescaled algo decisions do not match.
0146   bool eq = m_orbitNr == rhs.getL1MenuUUID() && m_bxNr == rhs.getL1FirmwareUUID() &&
0147             m_bxInEvent == rhs.getbxInEventNr()
0148             //&& m_finalOR == rhs.getFinalOR()
0149             //&& m_finalORPreVeto == rhs.getFinalORPreVeto()
0150             //&& m_finalORVeto == rhs.getFinalORVeto()
0151             //&& m_preScColumn == rhs.getPreScColumn()
0152             && m_algoDecisionInitial == rhs.getAlgoDecisionInitial()
0153       //&& m_algoDecisionPreScaled == rhs.getAlgoDecisionInterm()
0154       //&& m_algoDecisionFinal == rhs.getAlgoDecisionFinal()
0155       ;
0156 
0157   //if (not eq) {
0158   //    std::cout << "m_orbitNr: " << m_orbitNr << " : " << rhs.getL1MenuUUID() << std::endl
0159   //              << "m_bxNr: " << m_bxNr << " : " << rhs.getL1FirmwareUUID() << std::endl
0160   //              << "m_bxInEvent: " << m_bxInEvent << " : " << rhs.getbxInEventNr() << std::endl
0161   //              << "m_finalOR: " << m_finalOR << " : " << rhs.getFinalOR() << std::endl
0162   //              << "m_finalORPreVeto: " << m_finalORPreVeto << " : " << rhs.getFinalORPreVeto() << std::endl
0163   //              << "m_finalORVeto: " << m_finalORVeto << " : " << rhs.getFinalORVeto() << std::endl
0164   //              << "m_preScColumn: " << m_preScColumn << " : " << rhs.getPreScColumn() << std::endl
0165   //              << std::endl;
0166   //    std::cout << "algoDecisions" << std::endl;
0167   //    for (size_t i = 0; i < m_algoDecisionInitial.size(); ++i) {
0168   //        std::cout << "bit " << i << ":   " << m_algoDecisionInitial.at(i) << " : " << rhs.getAlgoDecisionInitial(i)
0169   //                  << "     " << m_algoDecisionPreScaled.at(i) << " : " << rhs.getAlgoDecisionInterm(i)
0170   //                  << "     " << m_algoDecisionFinal.at(i) << " : " << rhs.getAlgoDecisionFinal(i) << std::endl;
0171   //    }
0172   //}
0173 
0174   return eq;
0175 }
0176 
0177 // pretty print the content of a GlobalAlgBlk
0178 void GlobalAlgBlk::print(std::ostream& myCout) const {
0179   myCout << " uGtGlobalAlgBlk: " << std::endl;
0180 
0181   myCout << "    L1 Menu Name (hash):  0x" << std::hex << m_orbitNr << std::endl;
0182 
0183   myCout << "    L1 firmware (hash):   0x" << std::hex << m_bxNr << std::endl;
0184 
0185   myCout << "    Local Bx (hex):      0x" << std::hex << std::setw(1) << std::setfill('0') << m_bxInEvent << std::endl;
0186 
0187   myCout << "    PreScale Column:     " << std::setw(2) << m_preScColumn << std::endl;
0188 
0189   myCout << "    Final OR Veto:       " << std::hex << std::setw(1) << std::setfill('0') << m_finalORVeto << std::endl;
0190 
0191   myCout << "    Final OR:            " << std::hex << std::setw(1) << std::setfill('0') << m_finalOR << std::endl;
0192 
0193   // Loop through bits to create a hex word of algorithm bits.
0194   int lengthWd = m_algoDecisionInitial.size();
0195   myCout << "    Decision (Initial)   0x" << std::hex;
0196   int digit = 0;
0197   for (int i = lengthWd - 1; i > -1; i--) {
0198     if (m_algoDecisionInitial.at(i))
0199       digit |= (1 << (i % 4));
0200     if ((i % 4) == 0) {
0201       myCout << std::hex << std::setw(1) << digit;
0202       digit = 0;
0203       if (i % 32 == 0 && i < lengthWd - 1)
0204         myCout << " ";
0205     }
0206   }  //end loop over algorithm bits
0207   myCout << std::endl;
0208 
0209   // Loop through bits to create a hex word of algorithm bits.
0210   lengthWd = m_algoDecisionPreScaled.size();
0211   myCout << "    Decision (Prescaled) 0x" << std::hex;
0212   digit = 0;
0213   for (int i = lengthWd - 1; i > -1; i--) {
0214     if (m_algoDecisionPreScaled.at(i))
0215       digit |= (1 << (i % 4));
0216     if ((i % 4) == 0) {
0217       myCout << std::hex << std::setw(1) << digit;
0218       digit = 0;
0219       if (i % 32 == 0 && i < lengthWd - 1)
0220         myCout << " ";
0221     }
0222   }  //end loop over algorithm bits
0223   myCout << std::endl;
0224 
0225   // Loop through bits to create a hex word of algorithm bits.
0226   lengthWd = m_algoDecisionFinal.size();
0227   myCout << "    Decision (Final)     0x" << std::hex;
0228   digit = 0;
0229   for (int i = lengthWd - 1; i > -1; i--) {
0230     if (m_algoDecisionFinal.at(i))
0231       digit |= (1 << (i % 4));
0232     if ((i % 4) == 0) {
0233       myCout << std::hex << std::setw(1) << digit;
0234       digit = 0;
0235       if (i % 32 == 0 && i < lengthWd - 1)
0236         myCout << " ";
0237     }
0238   }  //end loop over algorithm bits
0239   myCout << std::endl;
0240 }