Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtFdlWord
0003  *
0004  *
0005  * Description: see header file.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
0017 
0018 // system include files
0019 #include <iostream>
0020 #include <iomanip>
0021 #include <vector>
0022 #include <string>
0023 
0024 // user include files
0025 
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0028 
0029 // constructors
0030 
0031 // empty constructor, all members set to zero;
0032 L1GtFdlWord::L1GtFdlWord() {
0033   m_boardId = 0;
0034   m_bxInEvent = 0;
0035   m_bxNr = 0;
0036   m_eventNr = 0;
0037 
0038   // technical triggers std::vector<bool>
0039   m_gtTechnicalTriggerWord.reserve(L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers);
0040   m_gtTechnicalTriggerWord.assign(L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers, false);
0041 
0042   // decision word  std::vector<bool>
0043   m_gtDecisionWord.reserve(L1GlobalTriggerReadoutSetup::NumberPhysTriggers);
0044   m_gtDecisionWord.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggers, false);
0045 
0046   // extended decision word  std::vector<bool>
0047   m_gtDecisionWordExtended.reserve(L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended);
0048   m_gtDecisionWordExtended.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended, false);
0049 
0050   m_physicsDeclared = 0;
0051   m_gtPrescaleFactorIndexTech = 0;
0052   m_gtPrescaleFactorIndexAlgo = 0;
0053 
0054   m_noAlgo = 0;
0055 
0056   m_finalOR = 0;
0057 
0058   m_orbitNr = 0;
0059   m_lumiSegmentNr = 0;
0060   m_localBxNr = 0;
0061 }
0062 
0063 // constructor from unpacked values;
0064 L1GtFdlWord::L1GtFdlWord(cms_uint16_t boardIdValue,
0065                          int bxInEventValue,
0066                          cms_uint16_t bxNrValue,
0067                          cms_uint32_t eventNrValue,
0068                          const TechnicalTriggerWord& gtTechnicalTriggerWordValue,
0069                          const DecisionWord& gtDecisionWordValue,
0070                          const DecisionWordExtended& gtDecisionWordExtendedValue,
0071                          cms_uint16_t gtPrescaleFactorIndexTechValue,
0072                          cms_uint16_t gtPrescaleFactorIndexAlgoValue,
0073                          cms_uint16_t noAlgoValue,
0074                          cms_uint16_t finalORValue,
0075                          cms_uint32_t orbitNrValue,
0076                          cms_uint16_t lumiSegmentNrValue,
0077                          cms_uint16_t localBxNrValue)
0078     : m_boardId(boardIdValue),
0079       m_bxInEvent(bxInEventValue),
0080       m_bxNr(bxNrValue),
0081       m_eventNr(eventNrValue),
0082       m_gtTechnicalTriggerWord(gtTechnicalTriggerWordValue),
0083       m_gtDecisionWord(gtDecisionWordValue),
0084       m_gtDecisionWordExtended(gtDecisionWordExtendedValue),
0085       m_gtPrescaleFactorIndexTech(gtPrescaleFactorIndexTechValue),
0086       m_gtPrescaleFactorIndexAlgo(gtPrescaleFactorIndexAlgoValue),
0087       m_noAlgo(noAlgoValue),
0088       m_finalOR(finalORValue),
0089       m_orbitNr(orbitNrValue),
0090       m_lumiSegmentNr(lumiSegmentNrValue),
0091       m_localBxNr(localBxNrValue)
0092 
0093 {
0094   m_physicsDeclared = 0;
0095 
0096   // the rest done in initialization list
0097 }
0098 
0099 // destructor
0100 L1GtFdlWord::~L1GtFdlWord() {
0101   // empty now
0102 }
0103 
0104 // equal operator
0105 bool L1GtFdlWord::operator==(const L1GtFdlWord& result) const {
0106   if (m_boardId != result.m_boardId) {
0107     return false;
0108   }
0109 
0110   if (m_bxInEvent != result.m_bxInEvent) {
0111     return false;
0112   }
0113 
0114   if (m_bxNr != result.m_bxNr) {
0115     return false;
0116   }
0117   if (m_eventNr != result.m_eventNr) {
0118     return false;
0119   }
0120 
0121   if (m_gtTechnicalTriggerWord != result.m_gtTechnicalTriggerWord) {
0122     return false;
0123   }
0124 
0125   if (m_gtDecisionWord != result.m_gtDecisionWord) {
0126     return false;
0127   }
0128 
0129   if (m_gtDecisionWordExtended != result.m_gtDecisionWordExtended) {
0130     return false;
0131   }
0132 
0133   if (m_physicsDeclared != result.m_physicsDeclared) {
0134     return false;
0135   }
0136 
0137   if (m_gtPrescaleFactorIndexTech != result.m_gtPrescaleFactorIndexTech) {
0138     return false;
0139   }
0140 
0141   if (m_gtPrescaleFactorIndexAlgo != result.m_gtPrescaleFactorIndexAlgo) {
0142     return false;
0143   }
0144 
0145   if (m_noAlgo != result.m_noAlgo) {
0146     return false;
0147   }
0148 
0149   if (m_finalOR != result.m_finalOR) {
0150     return false;
0151   }
0152 
0153   if (m_orbitNr != result.m_orbitNr) {
0154     return false;
0155   }
0156 
0157   if (m_lumiSegmentNr != result.m_lumiSegmentNr) {
0158     return false;
0159   }
0160 
0161   if (m_localBxNr != result.m_localBxNr) {
0162     return false;
0163   }
0164 
0165   // all members identical
0166   return true;
0167 }
0168 
0169 // unequal operator
0170 bool L1GtFdlWord::operator!=(const L1GtFdlWord& result) const { return !(result == *this); }
0171 
0172 // methods
0173 
0174 // set the BoardId value from a 64-bits word
0175 void L1GtFdlWord::setBoardId(const cms_uint64_t& word64) { m_boardId = (word64 & BoardIdMask) >> BoardIdShift; }
0176 
0177 // set the BoardId value in a 64-bits word, having the index iWord
0178 // in the GTFE raw record
0179 void L1GtFdlWord::setBoardIdWord64(cms_uint64_t& word64, const int iWord) {
0180   if (iWord == BoardIdWord) {
0181     word64 = word64 | (static_cast<cms_uint64_t>(m_boardId) << BoardIdShift);
0182   }
0183 }
0184 
0185 // set the BxInEvent value from a 64-bits word
0186 void L1GtFdlWord::setBxInEvent(const cms_uint64_t& word64) {
0187   int baseValue = 16;  // using hexadecimal values;
0188   int hexBxInEvent = (word64 & BxInEventMask) >> BxInEventShift;
0189   m_bxInEvent = (hexBxInEvent + baseValue / 2) % baseValue - baseValue / 2;
0190 }
0191 
0192 // set the BxInEvent value in a 64-bits word, having the index iWord
0193 // in the GTFE raw record
0194 void L1GtFdlWord::setBxInEventWord64(cms_uint64_t& word64, const int iWord) {
0195   if (iWord == BxInEventWord) {
0196     int baseValue = 16;  // using hexadecimal values;
0197     int hexBxInEvent = (m_bxInEvent + baseValue) % baseValue;
0198     word64 = word64 | (static_cast<cms_uint64_t>(hexBxInEvent) << BxInEventShift);
0199   }
0200 }
0201 
0202 // set the BxNr value from a 64-bits word
0203 void L1GtFdlWord::setBxNr(const cms_uint64_t& word64) { m_bxNr = (word64 & BxNrMask) >> BxNrShift; }
0204 
0205 // set the BxNr value in a 64-bits word, having the index iWord
0206 // in the GTFE raw record
0207 void L1GtFdlWord::setBxNrWord64(cms_uint64_t& word64, const int iWord) {
0208   if (iWord == BxNrWord) {
0209     word64 = word64 | (static_cast<cms_uint64_t>(m_bxNr) << BxNrShift);
0210   }
0211 }
0212 
0213 // set the EventNr value from a 64-bits word
0214 void L1GtFdlWord::setEventNr(const cms_uint64_t& word64) { m_eventNr = (word64 & EventNrMask) >> EventNrShift; }
0215 
0216 // set the EventNr value in a 64-bits word, having the index iWord
0217 // in the GTFE raw record
0218 void L1GtFdlWord::setEventNrWord64(cms_uint64_t& word64, const int iWord) {
0219   if (iWord == EventNrWord) {
0220     word64 = word64 | (static_cast<cms_uint64_t>(m_eventNr) << EventNrShift);
0221   }
0222 }
0223 
0224 // print GT technical trigger word in bitset style
0225 //    depend on the type of TechnicalTriggerWord
0226 //    this version: <vector<bool>
0227 void L1GtFdlWord::printGtTechnicalTriggerWord(std::ostream& myCout) const {
0228   myCout << "  Technical triggers (bitset style):    \n  ";
0229 
0230   int sizeW64 = 64;  // 64 bits words
0231   int iBit = 0;
0232 
0233   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtTechnicalTriggerWord.rbegin();
0234        ritBit != m_gtTechnicalTriggerWord.rend();
0235        ++ritBit) {
0236     myCout << (*ritBit ? '1' : '0');
0237 
0238     if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0239       myCout << " ";
0240     }
0241 
0242     iBit++;
0243   }
0244 }
0245 
0246 // set the GtTechnicalTriggerWord value from a 64-bits word
0247 void L1GtFdlWord::setGtTechnicalTriggerWord(const cms_uint64_t& word64) {
0248   int word64Size = sizeof(word64) * 8;
0249   cms_uint64_t wordTT = (word64 & GtTechnicalTriggerWordMask) >> GtTechnicalTriggerWordShift;
0250 
0251   cms_uint64_t one64 = 1ULL;
0252   for (int iBit = 0; iBit < word64Size; ++iBit) {
0253     m_gtTechnicalTriggerWord.at(iBit) = wordTT & (one64 << iBit);
0254   }
0255 }
0256 
0257 // set the GtTechnicalTriggerWord value in a 64-bits word, having the index iWord
0258 // in the GTFE raw record
0259 void L1GtFdlWord::setGtTechnicalTriggerWordWord64(cms_uint64_t& word64, const int iWord) {
0260   if (iWord == GtTechnicalTriggerWordWord) {
0261     int word64Size = sizeof(word64) * 8;
0262     cms_uint64_t wordTT = 0x0000000000000000ULL;
0263 
0264     int iBit = 0;
0265     cms_uint64_t iDecision = 0ULL;
0266 
0267     for (std::vector<bool>::const_iterator itBit = m_gtTechnicalTriggerWord.begin();
0268          itBit != m_gtTechnicalTriggerWord.end();
0269          ++itBit) {
0270       iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0271       wordTT = wordTT | (iDecision << iBit);
0272 
0273       iBit++;
0274       if (iBit >= word64Size) {
0275         break;
0276       }
0277     }
0278 
0279     word64 = word64 | (wordTT << GtTechnicalTriggerWordShift);
0280   }
0281 }
0282 
0283 // print GT decision word in bitset style
0284 //    depend on the type of DecisionWord
0285 //    this version: <vector<bool>
0286 void L1GtFdlWord::printGtDecisionWord(std::ostream& myCout) const {
0287   // decision word (in 64bits words)
0288   int sizeW64 = 64;  // 64 bits words
0289 
0290   int iBit = 0;
0291   int jBit = m_gtDecisionWord.size();
0292   int nrDecWord = m_gtDecisionWord.size() / sizeW64;
0293 
0294   std::ostringstream stream64;
0295 
0296   std::vector<std::string> decWord;
0297   decWord.reserve(nrDecWord);
0298 
0299   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWord.rbegin(); ritBit != m_gtDecisionWord.rend();
0300        ++ritBit) {
0301     stream64 << (*ritBit ? '1' : '0');
0302 
0303     if ((((iBit + 1) % 16) == (sizeW64 % 16))) {
0304       stream64 << " ";
0305     }
0306 
0307     if (((iBit + 1) % sizeW64) == 0) {
0308       std::string iW = stream64.str();
0309       stream64.str("");
0310 
0311       decWord.push_back(iW);
0312     }
0313 
0314     iBit++;
0315     jBit--;
0316   }
0317 
0318   int iWord = 0;
0319 
0320   for (std::vector<std::string>::reverse_iterator ritWord = decWord.rbegin(); ritWord != decWord.rend(); ++ritWord) {
0321     myCout << std::endl;
0322     myCout << "  DecisionWord (bitset style): bits " << iWord * sizeW64 + sizeW64 - 1 << " : " << iWord * sizeW64
0323            << "\n  ";
0324     myCout << *ritWord;
0325 
0326     iWord++;
0327   }
0328 }
0329 
0330 // set the GtDecisionWord value from a 64-bits word
0331 // WordA: bits 0 - 63
0332 void L1GtFdlWord::setGtDecisionWordA(const cms_uint64_t& word64) {
0333   int word64Size = sizeof(word64) * 8;  // well, it should be 64, if not...  :-)
0334   cms_uint64_t wordA = (word64 & GtDecisionWordAMask) >> GtDecisionWordAShift;
0335 
0336   cms_uint64_t one64 = 1ULL;
0337 
0338   for (int iBit = 0; iBit < word64Size; ++iBit) {
0339     m_gtDecisionWord.at(iBit) = wordA & (one64 << iBit);
0340   }
0341 }
0342 
0343 // set the GtDecisionWord value from a 64-bits word
0344 // WordB: bits 64 - 127
0345 void L1GtFdlWord::setGtDecisionWordB(const cms_uint64_t& word64) {
0346   int word64Size = sizeof(word64) * 8;
0347   cms_uint64_t wordB = (word64 & GtDecisionWordBMask) >> GtDecisionWordBShift;
0348 
0349   cms_uint64_t one64 = 1ULL;
0350 
0351   for (int iBit = 0; iBit < word64Size; ++iBit) {
0352     m_gtDecisionWord.at(iBit + word64Size) = wordB & (one64 << iBit);
0353   }
0354 }
0355 
0356 // set the GtDecisionWord value in a 64-bits word, having the index iWord
0357 // in the GTFE raw record
0358 // WordA: bits 0 - 63
0359 
0360 // a bit forced: assumes wordSize64 = 64, but also take word shift
0361 void L1GtFdlWord::setGtDecisionWordAWord64(cms_uint64_t& word64, const int iWord) {
0362   if (iWord == GtDecisionWordAWord) {
0363     int word64Size = sizeof(word64) * 8;
0364     cms_uint64_t wordA = 0x0000000000000000ULL;
0365 
0366     int iBit = 0;
0367     cms_uint64_t iDecision = 0ULL;
0368 
0369     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin(); itBit != m_gtDecisionWord.end(); ++itBit) {
0370       iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0371       wordA = wordA | (iDecision << iBit);
0372 
0373       iBit++;
0374       if (iBit >= word64Size) {
0375         break;
0376       }
0377     }
0378 
0379     word64 = word64 | (wordA << GtDecisionWordAShift);
0380   }
0381 }
0382 
0383 // set the GtDecisionWord value in a 64-bits word, having the index iWord
0384 // in the GTFE raw record
0385 // WordB: bits 64 - 127
0386 
0387 // a bit forced: assumes wordSize64 = 64, but also take word shift
0388 void L1GtFdlWord::setGtDecisionWordBWord64(cms_uint64_t& word64, const int iWord) {
0389   if (iWord == GtDecisionWordBWord) {
0390     int word64Size = sizeof(word64) * 8;
0391     cms_uint64_t wordB = 0x0000000000000000ULL;
0392 
0393     int iBit = 0;
0394     cms_uint64_t iDecision = 0ULL;
0395 
0396     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin(); itBit != m_gtDecisionWord.end(); ++itBit) {
0397       if (iBit >= word64Size) {
0398         // skip first word64Size bits, they go in wordA
0399         iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0400         wordB = wordB | (iDecision << (iBit - word64Size));
0401       }
0402 
0403       iBit++;
0404     }
0405 
0406     word64 = word64 | (wordB << GtDecisionWordBShift);
0407   }
0408 }
0409 
0410 // print GT decision word extended in bitset style
0411 //    depend on the type of DecisionWord
0412 //    this version: <vector<bool>
0413 void L1GtFdlWord::printGtDecisionWordExtended(std::ostream& myCout) const {
0414   myCout << "  DecisionWordExtended (bitset style):    \n  ";
0415 
0416   int sizeW64 = 64;  // 64 bits words
0417   int iBit = 0;
0418 
0419   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWordExtended.rbegin();
0420        ritBit != m_gtDecisionWordExtended.rend();
0421        ++ritBit) {
0422     myCout << (*ritBit ? '1' : '0');
0423 
0424     if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0425       myCout << " ";
0426     }
0427 
0428     iBit++;
0429   }
0430 }
0431 
0432 // set the GtDecisionWordExtended value from a 64-bits word
0433 void L1GtFdlWord::setGtDecisionWordExtended(const cms_uint64_t& word64) {
0434   int word64Size = sizeof(word64) * 8;
0435   cms_uint64_t wordE = (word64 & GtDecisionWordExtendedMask) >> GtDecisionWordExtendedShift;
0436 
0437   cms_uint64_t one64 = 1ULL;
0438 
0439   for (int iBit = 0; iBit < word64Size; ++iBit) {
0440     m_gtDecisionWordExtended.at(iBit) = wordE & (one64 << iBit);
0441   }
0442 }
0443 
0444 // set the GtDecisionWordExtended value in a 64-bits word, having the index iWord
0445 // in the GTFE raw record
0446 void L1GtFdlWord::setGtDecisionWordExtendedWord64(cms_uint64_t& word64, const int iWord) {
0447   if (iWord == GtDecisionWordExtendedWord) {
0448     int word64Size = sizeof(word64) * 8;
0449     cms_uint64_t wordE = 0x0000000000000000ULL;
0450 
0451     int iBit = 0;
0452     cms_uint64_t iDecision = 0ULL;
0453 
0454     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWordExtended.begin();
0455          itBit != m_gtDecisionWordExtended.end();
0456          ++itBit) {
0457       iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0458       wordE = wordE | (iDecision << iBit);
0459 
0460       iBit++;
0461       if (iBit >= word64Size) {
0462         break;
0463       }
0464     }
0465 
0466     word64 = word64 | (wordE << GtDecisionWordExtendedShift);
0467   }
0468 }
0469 
0470 // set the "physics declared" bit value from a 64-bits word
0471 void L1GtFdlWord::setPhysicsDeclared(const cms_uint64_t& word64) {
0472   m_physicsDeclared = (word64 & PhysicsDeclaredMask) >> PhysicsDeclaredShift;
0473 }
0474 
0475 // set the "physics declared" bit value in a 64-bits word, having the index iWord
0476 // in the GTFE raw record
0477 void L1GtFdlWord::setPhysicsDeclaredWord64(cms_uint64_t& word64, const int iWord) {
0478   if (iWord == PhysicsDeclaredWord) {
0479     word64 = word64 | (static_cast<cms_uint64_t>(m_physicsDeclared) << PhysicsDeclaredShift);
0480   }
0481 }
0482 
0483 // set the GtPrescaleFactorIndexTech from a 64-bits word
0484 void L1GtFdlWord::setGtPrescaleFactorIndexTech(const cms_uint64_t& word64) {
0485   m_gtPrescaleFactorIndexTech = (word64 & GtPrescaleFactorIndexTechMask) >> GtPrescaleFactorIndexTechShift;
0486 }
0487 
0488 // set the GtPrescaleFactorIndexTech bits in a 64-bits word, having the index iWord
0489 // in the GTFE raw record
0490 void L1GtFdlWord::setGtPrescaleFactorIndexTechWord64(cms_uint64_t& word64, const int iWord) {
0491   if (iWord == GtPrescaleFactorIndexTechWord) {
0492     word64 = word64 | (static_cast<cms_uint64_t>(m_gtPrescaleFactorIndexTech) << GtPrescaleFactorIndexTechShift);
0493   }
0494 }
0495 
0496 // set the GtPrescaleFactorIndexAlgo from a 64-bits word
0497 void L1GtFdlWord::setGtPrescaleFactorIndexAlgo(const cms_uint64_t& word64) {
0498   m_gtPrescaleFactorIndexAlgo = (word64 & GtPrescaleFactorIndexAlgoMask) >> GtPrescaleFactorIndexAlgoShift;
0499 }
0500 
0501 // set the GtPrescaleFactorIndexAlgo bits in a 64-bits word, having the index iWord
0502 // in the GTFE raw record
0503 void L1GtFdlWord::setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t& word64, const int iWord) {
0504   if (iWord == GtPrescaleFactorIndexAlgoWord) {
0505     word64 = word64 | (static_cast<cms_uint64_t>(m_gtPrescaleFactorIndexAlgo) << GtPrescaleFactorIndexAlgoShift);
0506   }
0507 }
0508 
0509 // set the NoAlgo value from a 64-bits word
0510 void L1GtFdlWord::setNoAlgo(const cms_uint64_t& word64) { m_noAlgo = (word64 & NoAlgoMask) >> NoAlgoShift; }
0511 
0512 // set the NoAlgo value in a 64-bits word, having the index iWord
0513 // in the GTFE raw record
0514 void L1GtFdlWord::setNoAlgoWord64(cms_uint64_t& word64, const int iWord) {
0515   if (iWord == NoAlgoWord) {
0516     word64 = word64 | (static_cast<cms_uint64_t>(m_noAlgo) << NoAlgoShift);
0517   }
0518 }
0519 
0520 // set the FinalOR value from a 64-bits word
0521 void L1GtFdlWord::setFinalOR(const cms_uint64_t& word64) { m_finalOR = (word64 & FinalORMask) >> FinalORShift; }
0522 
0523 // set the FinalOR value in a 64-bits word, having the index iWord
0524 // in the GTFE raw record
0525 void L1GtFdlWord::setFinalORWord64(cms_uint64_t& word64, const int iWord) {
0526   if (iWord == FinalORWord) {
0527     word64 = word64 | (static_cast<cms_uint64_t>(m_finalOR) << FinalORShift);
0528   }
0529 }
0530 
0531 // set the orbit number bits from a 64-bits word
0532 void L1GtFdlWord::setOrbitNr(const cms_uint64_t& word64) { m_orbitNr = (word64 & OrbitNrMask) >> OrbitNrShift; }
0533 
0534 // set the orbit number bits in a 64-bits word, having the index iWord
0535 // in the GTFE raw record
0536 void L1GtFdlWord::setOrbitNrWord64(cms_uint64_t& word64, const int iWord) {
0537   if (iWord == OrbitNrWord) {
0538     word64 = word64 | (static_cast<cms_uint64_t>(m_orbitNr) << OrbitNrShift);
0539   }
0540 }
0541 
0542 // set the luminosity segment number bits from a 64-bits word
0543 void L1GtFdlWord::setLumiSegmentNr(const cms_uint64_t& word64) {
0544   m_lumiSegmentNr = (word64 & LumiSegmentNrMask) >> LumiSegmentNrShift;
0545 }
0546 
0547 // set the luminosity segment number bits in a 64-bits word, having the index iWord
0548 // in the GTFE raw record
0549 void L1GtFdlWord::setLumiSegmentNrWord64(cms_uint64_t& word64, const int iWord) {
0550   if (iWord == LumiSegmentNrWord) {
0551     word64 = word64 | (static_cast<cms_uint64_t>(m_lumiSegmentNr) << LumiSegmentNrShift);
0552   }
0553 }
0554 
0555 // set the LocalBxNr value from a 64-bits word
0556 void L1GtFdlWord::setLocalBxNr(const cms_uint64_t& word64) { m_localBxNr = (word64 & LocalBxNrMask) >> LocalBxNrShift; }
0557 
0558 // set the LocalBxNr value in a 64-bits word, having the index iWord
0559 // in the GTFE raw record
0560 void L1GtFdlWord::setLocalBxNrWord64(cms_uint64_t& word64, const int iWord) {
0561   if (iWord == LocalBxNrWord) {
0562     word64 = word64 | (static_cast<cms_uint64_t>(m_localBxNr) << LocalBxNrShift);
0563   }
0564 }
0565 
0566 // reset the content of a L1GtFdlWord
0567 void L1GtFdlWord::reset() {
0568   m_boardId = 0;
0569   m_bxInEvent = 0;
0570   m_bxNr = 0;
0571   m_eventNr = 0;
0572 
0573   // technical triggers std::vector<bool>
0574   m_gtTechnicalTriggerWord.assign(L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers, false);
0575 
0576   // decision word  std::vector<bool>
0577   m_gtDecisionWord.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggers, false);
0578 
0579   // extended decision word  std::vector<bool>
0580   m_gtDecisionWordExtended.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended, false);
0581 
0582   m_physicsDeclared = 0;
0583   m_gtPrescaleFactorIndexTech = 0;
0584   m_gtPrescaleFactorIndexAlgo = 0;
0585 
0586   m_noAlgo = 0;
0587   m_finalOR = 0;
0588 
0589   m_orbitNr = 0;
0590   m_lumiSegmentNr = 0;
0591   m_localBxNr = 0;
0592 }
0593 
0594 // pretty print the content of a L1GtFdlWord
0595 void L1GtFdlWord::print(std::ostream& myCout) const {
0596   myCout << "\n L1GtFdlWord::print \n" << std::endl;
0597 
0598   int iWord = 0;
0599 
0600   myCout << "\n Word " << iWord << std::endl;
0601 
0602   myCout << "  Board Id:         " << std::hex << " hex: "
0603          << "    " << std::setw(4) << std::setfill('0') << m_boardId << std::setfill(' ') << std::dec
0604          << " dec: " << m_boardId << std::endl;
0605   //
0606 
0607   int baseValue = 16;  // using hexadecimal values;
0608   int hexBxInEvent = (m_bxInEvent + baseValue) % baseValue;
0609 
0610   myCout << "  BxInEvent:        " << std::hex << " hex: "
0611          << "       " << std::setw(1) << hexBxInEvent << std::dec << " dec: " << m_bxInEvent << std::endl;
0612 
0613   myCout << "  BxNr:             " << std::hex << " hex: "
0614          << "     " << std::setw(3) << std::setfill('0') << m_bxNr << std::setfill(' ') << std::dec
0615          << " dec: " << m_bxNr << std::endl;
0616 
0617   myCout << "  EventNr:          " << std::hex << " hex: "
0618          << "  " << std::setw(6) << std::setfill('0') << m_eventNr << std::setfill(' ') << std::dec
0619          << " dec: " << m_eventNr << std::endl;
0620 
0621   // technical triggers
0622 
0623   iWord++;
0624   myCout << "\n Word " << iWord << std::endl;
0625 
0626   printGtTechnicalTriggerWord(myCout);
0627   myCout << std::endl;
0628 
0629   // physics triggers (2 words!)
0630 
0631   iWord++;
0632   myCout << "\n Word " << iWord;
0633   iWord++;
0634   myCout << " and word " << iWord;
0635 
0636   printGtDecisionWord(myCout);
0637   myCout << std::endl;
0638 
0639   // decision word extended (64 bits)
0640 
0641   iWord++;
0642   myCout << "\n Word " << iWord << std::endl;
0643 
0644   printGtDecisionWordExtended(myCout);
0645   myCout << std::endl;
0646 
0647   //
0648   iWord++;
0649   myCout << "\n Word " << iWord << std::endl;
0650 
0651   myCout << "  PhysicsDeclared:           " << std::hex << " hex: "
0652          << "    " << std::setw(4) << std::setfill('0') << m_physicsDeclared << std::setfill(' ') << std::dec
0653          << " dec: " << m_physicsDeclared << std::endl;
0654 
0655   myCout << "  GtPrescaleFactorIndexTech: " << std::hex << " hex: "
0656          << "    " << std::setw(4) << std::setfill('0') << m_gtPrescaleFactorIndexTech << std::setfill(' ') << std::dec
0657          << " dec: " << m_gtPrescaleFactorIndexTech << std::endl;
0658 
0659   myCout << "  GtPrescaleFactorIndexAlgo: " << std::hex << " hex: "
0660          << "    " << std::setw(4) << std::setfill('0') << m_gtPrescaleFactorIndexAlgo << std::setfill(' ') << std::dec
0661          << " dec: " << m_gtPrescaleFactorIndexAlgo << std::endl;
0662 
0663   myCout << "  NoAlgo:                    " << std::hex << " hex: "
0664          << "       " << std::setw(1) << std::setfill('0') << m_noAlgo << std::setfill(' ') << std::dec
0665          << " dec: " << m_noAlgo << std::endl;
0666 
0667   myCout << "  FinalOR:                   " << std::hex << " hex: "
0668          << "      " << std::setw(2) << std::setfill('0') << m_finalOR << std::setfill(' ') << std::dec
0669          << " dec: " << m_finalOR << std::endl;
0670 
0671   iWord++;
0672   myCout << "\n Word " << iWord << std::endl;
0673 
0674   myCout << "  OrbitNr:          " << std::hex << " hex: "
0675          << "" << std::setw(8) << std::setfill('0') << m_orbitNr << std::setfill(' ') << std::dec
0676          << " dec: " << m_orbitNr << std::endl;
0677 
0678   myCout << "  LumiSegmentNr:    " << std::hex << " hex: "
0679          << "    " << std::setw(4) << std::setfill('0') << m_lumiSegmentNr << std::setfill(' ') << std::dec
0680          << " dec: " << m_lumiSegmentNr << std::endl;
0681 
0682   myCout << "  LocalBxNr:        " << std::hex << " hex: "
0683          << "     " << std::setw(3) << std::setfill('0') << m_localBxNr << std::setfill(' ') << std::dec
0684          << " dec: " << m_localBxNr << std::endl;
0685 }
0686 
0687 // unpack FDL
0688 // fdlPtr pointer to the beginning of the FDL block in the raw data
0689 void L1GtFdlWord::unpack(const unsigned char* fdlPtr) {
0690   LogDebug("L1GtFdlWord") << "\nUnpacking FDL block.\n" << std::endl;
0691 
0692   const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t const*>(fdlPtr);
0693 
0694   setBoardId(payload[BoardIdWord]);
0695   setBxInEvent(payload[BxInEventWord]);
0696   setBxNr(payload[BxNrWord]);
0697   setEventNr(payload[EventNrWord]);
0698 
0699   setGtTechnicalTriggerWord(payload[GtTechnicalTriggerWordWord]);
0700 
0701   setGtDecisionWordA(payload[GtDecisionWordAWord]);
0702 
0703   setGtDecisionWordB(payload[GtDecisionWordBWord]);
0704 
0705   setGtDecisionWordExtended(payload[GtDecisionWordExtendedWord]);
0706 
0707   setPhysicsDeclared(payload[PhysicsDeclaredWord]);
0708   setGtPrescaleFactorIndexTech(payload[GtPrescaleFactorIndexTechWord]);
0709   setGtPrescaleFactorIndexAlgo(payload[GtPrescaleFactorIndexAlgoWord]);
0710   setNoAlgo(payload[NoAlgoWord]);
0711   setFinalOR(payload[FinalORWord]);
0712 
0713   setOrbitNr(payload[OrbitNrWord]);
0714   setLumiSegmentNr(payload[LumiSegmentNrWord]);
0715   setLocalBxNr(payload[LocalBxNrWord]);
0716 
0717   if (edm::isDebugEnabled()) {
0718     for (int iWord = 0; iWord < BlockSize; ++iWord) {
0719       LogTrace("L1GtFdlWord") << std::setw(4) << iWord << "  " << std::hex << std::setfill('0') << std::setw(16)
0720                               << payload[iWord] << std::dec << std::setfill(' ') << std::endl;
0721     }
0722   }
0723 }
0724 
0725 // static class members
0726 
0727 // block description in the raw GT record
0728 
0729 // block size in 64bits words (BlockSize * 64 bits)
0730 const int L1GtFdlWord::BlockSize = 7;
0731 
0732 // word 0
0733 
0734 // index of the word in the FDL block containig the variable
0735 const int L1GtFdlWord::BoardIdWord = 0;
0736 const int L1GtFdlWord::BxInEventWord = 0;
0737 const int L1GtFdlWord::BxNrWord = 0;
0738 const int L1GtFdlWord::EventNrWord = 0;
0739 
0740 // mask to get the 64-bit-value from the corresponding word in the FDL block
0741 const cms_uint64_t L1GtFdlWord::BoardIdMask = 0xFFFF000000000000ULL;
0742 const cms_uint64_t L1GtFdlWord::BxInEventMask = 0x0000F00000000000ULL;
0743 const cms_uint64_t L1GtFdlWord::BxNrMask = 0x00000FFF00000000ULL;
0744 const cms_uint64_t L1GtFdlWord::EventNrMask = 0x0000000000FFFFFFULL;
0745 
0746 // shift to the right to get the value from the "64-bit-value"
0747 const int L1GtFdlWord::BoardIdShift = 48;
0748 const int L1GtFdlWord::BxInEventShift = 44;
0749 const int L1GtFdlWord::BxNrShift = 32;
0750 const int L1GtFdlWord::EventNrShift = 0;
0751 
0752 // word 1
0753 
0754 const int L1GtFdlWord::GtTechnicalTriggerWordWord = 1;
0755 const cms_uint64_t L1GtFdlWord::GtTechnicalTriggerWordMask = 0xFFFFFFFFFFFFFFFFULL;
0756 const int L1GtFdlWord::GtTechnicalTriggerWordShift = 0;
0757 
0758 // word 2 - WordA: bits 0-63
0759 
0760 const int L1GtFdlWord::GtDecisionWordAWord = 2;
0761 const cms_uint64_t L1GtFdlWord::GtDecisionWordAMask = 0xFFFFFFFFFFFFFFFFULL;
0762 const int L1GtFdlWord::GtDecisionWordAShift = 0;
0763 
0764 // word 3 - WordB: bits 64-128
0765 
0766 const int L1GtFdlWord::GtDecisionWordBWord = 3;
0767 const cms_uint64_t L1GtFdlWord::GtDecisionWordBMask = 0xFFFFFFFFFFFFFFFFULL;
0768 const int L1GtFdlWord::GtDecisionWordBShift = 0;
0769 
0770 // word 4
0771 const int L1GtFdlWord::GtDecisionWordExtendedWord = 4;
0772 const cms_uint64_t L1GtFdlWord::GtDecisionWordExtendedMask = 0xFFFFFFFFFFFFFFFFULL;
0773 const int L1GtFdlWord::GtDecisionWordExtendedShift = 0;
0774 
0775 // word 5
0776 const int L1GtFdlWord::PhysicsDeclaredWord = 5;
0777 const int L1GtFdlWord::GtPrescaleFactorIndexTechWord = 5;
0778 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoWord = 5;
0779 const int L1GtFdlWord::NoAlgoWord = 5;
0780 const int L1GtFdlWord::FinalORWord = 5;
0781 
0782 const cms_uint64_t L1GtFdlWord::PhysicsDeclaredMask = 0x8000000000000000ULL;
0783 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexTechMask = 0x00FF000000000000ULL;
0784 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexAlgoMask = 0x000000FF00000000ULL;
0785 const cms_uint64_t L1GtFdlWord::NoAlgoMask = 0x0000000000000100ULL;
0786 const cms_uint64_t L1GtFdlWord::FinalORMask = 0x00000000000000FFULL;
0787 
0788 const int L1GtFdlWord::PhysicsDeclaredShift = 63;
0789 const int L1GtFdlWord::GtPrescaleFactorIndexTechShift = 48;
0790 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoShift = 32;
0791 const int L1GtFdlWord::NoAlgoShift = 8;
0792 const int L1GtFdlWord::FinalORShift = 0;
0793 
0794 // word 6
0795 const int L1GtFdlWord::OrbitNrWord = 6;
0796 const int L1GtFdlWord::LumiSegmentNrWord = 6;
0797 const int L1GtFdlWord::LocalBxNrWord = 6;
0798 
0799 const cms_uint64_t L1GtFdlWord::OrbitNrMask = 0xFFFFFFFF00000000ULL;
0800 const cms_uint64_t L1GtFdlWord::LumiSegmentNrMask = 0x00000000FFFF0000ULL;
0801 const cms_uint64_t L1GtFdlWord::LocalBxNrMask = 0x0000000000000FFFULL;
0802 
0803 const int L1GtFdlWord::OrbitNrShift = 32;
0804 const int L1GtFdlWord::LumiSegmentNrShift = 16;
0805 const int L1GtFdlWord::LocalBxNrShift = 0;