Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 nrDecWord = m_gtDecisionWord.size() / sizeW64;
0292 
0293   std::ostringstream stream64;
0294 
0295   std::vector<std::string> decWord;
0296   decWord.reserve(nrDecWord);
0297 
0298   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWord.rbegin(); ritBit != m_gtDecisionWord.rend();
0299        ++ritBit) {
0300     stream64 << (*ritBit ? '1' : '0');
0301 
0302     if ((((iBit + 1) % 16) == (sizeW64 % 16))) {
0303       stream64 << " ";
0304     }
0305 
0306     if (((iBit + 1) % sizeW64) == 0) {
0307       std::string iW = stream64.str();
0308       stream64.str("");
0309 
0310       decWord.push_back(iW);
0311     }
0312 
0313     iBit++;
0314   }
0315 
0316   int iWord = 0;
0317 
0318   for (std::vector<std::string>::reverse_iterator ritWord = decWord.rbegin(); ritWord != decWord.rend(); ++ritWord) {
0319     myCout << std::endl;
0320     myCout << "  DecisionWord (bitset style): bits " << iWord * sizeW64 + sizeW64 - 1 << " : " << iWord * sizeW64
0321            << "\n  ";
0322     myCout << *ritWord;
0323 
0324     iWord++;
0325   }
0326 }
0327 
0328 // set the GtDecisionWord value from a 64-bits word
0329 // WordA: bits 0 - 63
0330 void L1GtFdlWord::setGtDecisionWordA(const cms_uint64_t& word64) {
0331   int word64Size = sizeof(word64) * 8;  // well, it should be 64, if not...  :-)
0332   cms_uint64_t wordA = (word64 & GtDecisionWordAMask) >> GtDecisionWordAShift;
0333 
0334   cms_uint64_t one64 = 1ULL;
0335 
0336   for (int iBit = 0; iBit < word64Size; ++iBit) {
0337     m_gtDecisionWord.at(iBit) = wordA & (one64 << iBit);
0338   }
0339 }
0340 
0341 // set the GtDecisionWord value from a 64-bits word
0342 // WordB: bits 64 - 127
0343 void L1GtFdlWord::setGtDecisionWordB(const cms_uint64_t& word64) {
0344   int word64Size = sizeof(word64) * 8;
0345   cms_uint64_t wordB = (word64 & GtDecisionWordBMask) >> GtDecisionWordBShift;
0346 
0347   cms_uint64_t one64 = 1ULL;
0348 
0349   for (int iBit = 0; iBit < word64Size; ++iBit) {
0350     m_gtDecisionWord.at(iBit + word64Size) = wordB & (one64 << iBit);
0351   }
0352 }
0353 
0354 // set the GtDecisionWord value in a 64-bits word, having the index iWord
0355 // in the GTFE raw record
0356 // WordA: bits 0 - 63
0357 
0358 // a bit forced: assumes wordSize64 = 64, but also take word shift
0359 void L1GtFdlWord::setGtDecisionWordAWord64(cms_uint64_t& word64, const int iWord) {
0360   if (iWord == GtDecisionWordAWord) {
0361     int word64Size = sizeof(word64) * 8;
0362     cms_uint64_t wordA = 0x0000000000000000ULL;
0363 
0364     int iBit = 0;
0365     cms_uint64_t iDecision = 0ULL;
0366 
0367     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin(); itBit != m_gtDecisionWord.end(); ++itBit) {
0368       iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0369       wordA = wordA | (iDecision << iBit);
0370 
0371       iBit++;
0372       if (iBit >= word64Size) {
0373         break;
0374       }
0375     }
0376 
0377     word64 = word64 | (wordA << GtDecisionWordAShift);
0378   }
0379 }
0380 
0381 // set the GtDecisionWord value in a 64-bits word, having the index iWord
0382 // in the GTFE raw record
0383 // WordB: bits 64 - 127
0384 
0385 // a bit forced: assumes wordSize64 = 64, but also take word shift
0386 void L1GtFdlWord::setGtDecisionWordBWord64(cms_uint64_t& word64, const int iWord) {
0387   if (iWord == GtDecisionWordBWord) {
0388     int word64Size = sizeof(word64) * 8;
0389     cms_uint64_t wordB = 0x0000000000000000ULL;
0390 
0391     int iBit = 0;
0392     cms_uint64_t iDecision = 0ULL;
0393 
0394     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWord.begin(); itBit != m_gtDecisionWord.end(); ++itBit) {
0395       if (iBit >= word64Size) {
0396         // skip first word64Size bits, they go in wordA
0397         iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0398         wordB = wordB | (iDecision << (iBit - word64Size));
0399       }
0400 
0401       iBit++;
0402     }
0403 
0404     word64 = word64 | (wordB << GtDecisionWordBShift);
0405   }
0406 }
0407 
0408 // print GT decision word extended in bitset style
0409 //    depend on the type of DecisionWord
0410 //    this version: <vector<bool>
0411 void L1GtFdlWord::printGtDecisionWordExtended(std::ostream& myCout) const {
0412   myCout << "  DecisionWordExtended (bitset style):    \n  ";
0413 
0414   int sizeW64 = 64;  // 64 bits words
0415   int iBit = 0;
0416 
0417   for (std::vector<bool>::const_reverse_iterator ritBit = m_gtDecisionWordExtended.rbegin();
0418        ritBit != m_gtDecisionWordExtended.rend();
0419        ++ritBit) {
0420     myCout << (*ritBit ? '1' : '0');
0421 
0422     if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0423       myCout << " ";
0424     }
0425 
0426     iBit++;
0427   }
0428 }
0429 
0430 // set the GtDecisionWordExtended value from a 64-bits word
0431 void L1GtFdlWord::setGtDecisionWordExtended(const cms_uint64_t& word64) {
0432   int word64Size = sizeof(word64) * 8;
0433   cms_uint64_t wordE = (word64 & GtDecisionWordExtendedMask) >> GtDecisionWordExtendedShift;
0434 
0435   cms_uint64_t one64 = 1ULL;
0436 
0437   for (int iBit = 0; iBit < word64Size; ++iBit) {
0438     m_gtDecisionWordExtended.at(iBit) = wordE & (one64 << iBit);
0439   }
0440 }
0441 
0442 // set the GtDecisionWordExtended value in a 64-bits word, having the index iWord
0443 // in the GTFE raw record
0444 void L1GtFdlWord::setGtDecisionWordExtendedWord64(cms_uint64_t& word64, const int iWord) {
0445   if (iWord == GtDecisionWordExtendedWord) {
0446     int word64Size = sizeof(word64) * 8;
0447     cms_uint64_t wordE = 0x0000000000000000ULL;
0448 
0449     int iBit = 0;
0450     cms_uint64_t iDecision = 0ULL;
0451 
0452     for (std::vector<bool>::const_iterator itBit = m_gtDecisionWordExtended.begin();
0453          itBit != m_gtDecisionWordExtended.end();
0454          ++itBit) {
0455       iDecision = static_cast<cms_uint64_t>(*itBit);  //(*itBit ? 1 : 0);
0456       wordE = wordE | (iDecision << iBit);
0457 
0458       iBit++;
0459       if (iBit >= word64Size) {
0460         break;
0461       }
0462     }
0463 
0464     word64 = word64 | (wordE << GtDecisionWordExtendedShift);
0465   }
0466 }
0467 
0468 // set the "physics declared" bit value from a 64-bits word
0469 void L1GtFdlWord::setPhysicsDeclared(const cms_uint64_t& word64) {
0470   m_physicsDeclared = (word64 & PhysicsDeclaredMask) >> PhysicsDeclaredShift;
0471 }
0472 
0473 // set the "physics declared" bit value in a 64-bits word, having the index iWord
0474 // in the GTFE raw record
0475 void L1GtFdlWord::setPhysicsDeclaredWord64(cms_uint64_t& word64, const int iWord) {
0476   if (iWord == PhysicsDeclaredWord) {
0477     word64 = word64 | (static_cast<cms_uint64_t>(m_physicsDeclared) << PhysicsDeclaredShift);
0478   }
0479 }
0480 
0481 // set the GtPrescaleFactorIndexTech from a 64-bits word
0482 void L1GtFdlWord::setGtPrescaleFactorIndexTech(const cms_uint64_t& word64) {
0483   m_gtPrescaleFactorIndexTech = (word64 & GtPrescaleFactorIndexTechMask) >> GtPrescaleFactorIndexTechShift;
0484 }
0485 
0486 // set the GtPrescaleFactorIndexTech bits in a 64-bits word, having the index iWord
0487 // in the GTFE raw record
0488 void L1GtFdlWord::setGtPrescaleFactorIndexTechWord64(cms_uint64_t& word64, const int iWord) {
0489   if (iWord == GtPrescaleFactorIndexTechWord) {
0490     word64 = word64 | (static_cast<cms_uint64_t>(m_gtPrescaleFactorIndexTech) << GtPrescaleFactorIndexTechShift);
0491   }
0492 }
0493 
0494 // set the GtPrescaleFactorIndexAlgo from a 64-bits word
0495 void L1GtFdlWord::setGtPrescaleFactorIndexAlgo(const cms_uint64_t& word64) {
0496   m_gtPrescaleFactorIndexAlgo = (word64 & GtPrescaleFactorIndexAlgoMask) >> GtPrescaleFactorIndexAlgoShift;
0497 }
0498 
0499 // set the GtPrescaleFactorIndexAlgo bits in a 64-bits word, having the index iWord
0500 // in the GTFE raw record
0501 void L1GtFdlWord::setGtPrescaleFactorIndexAlgoWord64(cms_uint64_t& word64, const int iWord) {
0502   if (iWord == GtPrescaleFactorIndexAlgoWord) {
0503     word64 = word64 | (static_cast<cms_uint64_t>(m_gtPrescaleFactorIndexAlgo) << GtPrescaleFactorIndexAlgoShift);
0504   }
0505 }
0506 
0507 // set the NoAlgo value from a 64-bits word
0508 void L1GtFdlWord::setNoAlgo(const cms_uint64_t& word64) { m_noAlgo = (word64 & NoAlgoMask) >> NoAlgoShift; }
0509 
0510 // set the NoAlgo value in a 64-bits word, having the index iWord
0511 // in the GTFE raw record
0512 void L1GtFdlWord::setNoAlgoWord64(cms_uint64_t& word64, const int iWord) {
0513   if (iWord == NoAlgoWord) {
0514     word64 = word64 | (static_cast<cms_uint64_t>(m_noAlgo) << NoAlgoShift);
0515   }
0516 }
0517 
0518 // set the FinalOR value from a 64-bits word
0519 void L1GtFdlWord::setFinalOR(const cms_uint64_t& word64) { m_finalOR = (word64 & FinalORMask) >> FinalORShift; }
0520 
0521 // set the FinalOR value in a 64-bits word, having the index iWord
0522 // in the GTFE raw record
0523 void L1GtFdlWord::setFinalORWord64(cms_uint64_t& word64, const int iWord) {
0524   if (iWord == FinalORWord) {
0525     word64 = word64 | (static_cast<cms_uint64_t>(m_finalOR) << FinalORShift);
0526   }
0527 }
0528 
0529 // set the orbit number bits from a 64-bits word
0530 void L1GtFdlWord::setOrbitNr(const cms_uint64_t& word64) { m_orbitNr = (word64 & OrbitNrMask) >> OrbitNrShift; }
0531 
0532 // set the orbit number bits in a 64-bits word, having the index iWord
0533 // in the GTFE raw record
0534 void L1GtFdlWord::setOrbitNrWord64(cms_uint64_t& word64, const int iWord) {
0535   if (iWord == OrbitNrWord) {
0536     word64 = word64 | (static_cast<cms_uint64_t>(m_orbitNr) << OrbitNrShift);
0537   }
0538 }
0539 
0540 // set the luminosity segment number bits from a 64-bits word
0541 void L1GtFdlWord::setLumiSegmentNr(const cms_uint64_t& word64) {
0542   m_lumiSegmentNr = (word64 & LumiSegmentNrMask) >> LumiSegmentNrShift;
0543 }
0544 
0545 // set the luminosity segment number bits in a 64-bits word, having the index iWord
0546 // in the GTFE raw record
0547 void L1GtFdlWord::setLumiSegmentNrWord64(cms_uint64_t& word64, const int iWord) {
0548   if (iWord == LumiSegmentNrWord) {
0549     word64 = word64 | (static_cast<cms_uint64_t>(m_lumiSegmentNr) << LumiSegmentNrShift);
0550   }
0551 }
0552 
0553 // set the LocalBxNr value from a 64-bits word
0554 void L1GtFdlWord::setLocalBxNr(const cms_uint64_t& word64) { m_localBxNr = (word64 & LocalBxNrMask) >> LocalBxNrShift; }
0555 
0556 // set the LocalBxNr value in a 64-bits word, having the index iWord
0557 // in the GTFE raw record
0558 void L1GtFdlWord::setLocalBxNrWord64(cms_uint64_t& word64, const int iWord) {
0559   if (iWord == LocalBxNrWord) {
0560     word64 = word64 | (static_cast<cms_uint64_t>(m_localBxNr) << LocalBxNrShift);
0561   }
0562 }
0563 
0564 // reset the content of a L1GtFdlWord
0565 void L1GtFdlWord::reset() {
0566   m_boardId = 0;
0567   m_bxInEvent = 0;
0568   m_bxNr = 0;
0569   m_eventNr = 0;
0570 
0571   // technical triggers std::vector<bool>
0572   m_gtTechnicalTriggerWord.assign(L1GlobalTriggerReadoutSetup::NumberTechnicalTriggers, false);
0573 
0574   // decision word  std::vector<bool>
0575   m_gtDecisionWord.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggers, false);
0576 
0577   // extended decision word  std::vector<bool>
0578   m_gtDecisionWordExtended.assign(L1GlobalTriggerReadoutSetup::NumberPhysTriggersExtended, false);
0579 
0580   m_physicsDeclared = 0;
0581   m_gtPrescaleFactorIndexTech = 0;
0582   m_gtPrescaleFactorIndexAlgo = 0;
0583 
0584   m_noAlgo = 0;
0585   m_finalOR = 0;
0586 
0587   m_orbitNr = 0;
0588   m_lumiSegmentNr = 0;
0589   m_localBxNr = 0;
0590 }
0591 
0592 // pretty print the content of a L1GtFdlWord
0593 void L1GtFdlWord::print(std::ostream& myCout) const {
0594   myCout << "\n L1GtFdlWord::print \n" << std::endl;
0595 
0596   int iWord = 0;
0597 
0598   myCout << "\n Word " << iWord << std::endl;
0599 
0600   myCout << "  Board Id:         " << std::hex << " hex: "
0601          << "    " << std::setw(4) << std::setfill('0') << m_boardId << std::setfill(' ') << std::dec
0602          << " dec: " << m_boardId << std::endl;
0603   //
0604 
0605   int baseValue = 16;  // using hexadecimal values;
0606   int hexBxInEvent = (m_bxInEvent + baseValue) % baseValue;
0607 
0608   myCout << "  BxInEvent:        " << std::hex << " hex: "
0609          << "       " << std::setw(1) << hexBxInEvent << std::dec << " dec: " << m_bxInEvent << std::endl;
0610 
0611   myCout << "  BxNr:             " << std::hex << " hex: "
0612          << "     " << std::setw(3) << std::setfill('0') << m_bxNr << std::setfill(' ') << std::dec
0613          << " dec: " << m_bxNr << std::endl;
0614 
0615   myCout << "  EventNr:          " << std::hex << " hex: "
0616          << "  " << std::setw(6) << std::setfill('0') << m_eventNr << std::setfill(' ') << std::dec
0617          << " dec: " << m_eventNr << std::endl;
0618 
0619   // technical triggers
0620 
0621   iWord++;
0622   myCout << "\n Word " << iWord << std::endl;
0623 
0624   printGtTechnicalTriggerWord(myCout);
0625   myCout << std::endl;
0626 
0627   // physics triggers (2 words!)
0628 
0629   iWord++;
0630   myCout << "\n Word " << iWord;
0631   iWord++;
0632   myCout << " and word " << iWord;
0633 
0634   printGtDecisionWord(myCout);
0635   myCout << std::endl;
0636 
0637   // decision word extended (64 bits)
0638 
0639   iWord++;
0640   myCout << "\n Word " << iWord << std::endl;
0641 
0642   printGtDecisionWordExtended(myCout);
0643   myCout << std::endl;
0644 
0645   //
0646   iWord++;
0647   myCout << "\n Word " << iWord << std::endl;
0648 
0649   myCout << "  PhysicsDeclared:           " << std::hex << " hex: "
0650          << "    " << std::setw(4) << std::setfill('0') << m_physicsDeclared << std::setfill(' ') << std::dec
0651          << " dec: " << m_physicsDeclared << std::endl;
0652 
0653   myCout << "  GtPrescaleFactorIndexTech: " << std::hex << " hex: "
0654          << "    " << std::setw(4) << std::setfill('0') << m_gtPrescaleFactorIndexTech << std::setfill(' ') << std::dec
0655          << " dec: " << m_gtPrescaleFactorIndexTech << std::endl;
0656 
0657   myCout << "  GtPrescaleFactorIndexAlgo: " << std::hex << " hex: "
0658          << "    " << std::setw(4) << std::setfill('0') << m_gtPrescaleFactorIndexAlgo << std::setfill(' ') << std::dec
0659          << " dec: " << m_gtPrescaleFactorIndexAlgo << std::endl;
0660 
0661   myCout << "  NoAlgo:                    " << std::hex << " hex: "
0662          << "       " << std::setw(1) << std::setfill('0') << m_noAlgo << std::setfill(' ') << std::dec
0663          << " dec: " << m_noAlgo << std::endl;
0664 
0665   myCout << "  FinalOR:                   " << std::hex << " hex: "
0666          << "      " << std::setw(2) << std::setfill('0') << m_finalOR << std::setfill(' ') << std::dec
0667          << " dec: " << m_finalOR << std::endl;
0668 
0669   iWord++;
0670   myCout << "\n Word " << iWord << std::endl;
0671 
0672   myCout << "  OrbitNr:          " << std::hex << " hex: "
0673          << "" << std::setw(8) << std::setfill('0') << m_orbitNr << std::setfill(' ') << std::dec
0674          << " dec: " << m_orbitNr << std::endl;
0675 
0676   myCout << "  LumiSegmentNr:    " << std::hex << " hex: "
0677          << "    " << std::setw(4) << std::setfill('0') << m_lumiSegmentNr << std::setfill(' ') << std::dec
0678          << " dec: " << m_lumiSegmentNr << std::endl;
0679 
0680   myCout << "  LocalBxNr:        " << std::hex << " hex: "
0681          << "     " << std::setw(3) << std::setfill('0') << m_localBxNr << std::setfill(' ') << std::dec
0682          << " dec: " << m_localBxNr << std::endl;
0683 }
0684 
0685 // unpack FDL
0686 // fdlPtr pointer to the beginning of the FDL block in the raw data
0687 void L1GtFdlWord::unpack(const unsigned char* fdlPtr) {
0688   LogDebug("L1GtFdlWord") << "\nUnpacking FDL block.\n" << std::endl;
0689 
0690   const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t const*>(fdlPtr);
0691 
0692   setBoardId(payload[BoardIdWord]);
0693   setBxInEvent(payload[BxInEventWord]);
0694   setBxNr(payload[BxNrWord]);
0695   setEventNr(payload[EventNrWord]);
0696 
0697   setGtTechnicalTriggerWord(payload[GtTechnicalTriggerWordWord]);
0698 
0699   setGtDecisionWordA(payload[GtDecisionWordAWord]);
0700 
0701   setGtDecisionWordB(payload[GtDecisionWordBWord]);
0702 
0703   setGtDecisionWordExtended(payload[GtDecisionWordExtendedWord]);
0704 
0705   setPhysicsDeclared(payload[PhysicsDeclaredWord]);
0706   setGtPrescaleFactorIndexTech(payload[GtPrescaleFactorIndexTechWord]);
0707   setGtPrescaleFactorIndexAlgo(payload[GtPrescaleFactorIndexAlgoWord]);
0708   setNoAlgo(payload[NoAlgoWord]);
0709   setFinalOR(payload[FinalORWord]);
0710 
0711   setOrbitNr(payload[OrbitNrWord]);
0712   setLumiSegmentNr(payload[LumiSegmentNrWord]);
0713   setLocalBxNr(payload[LocalBxNrWord]);
0714 
0715   if (edm::isDebugEnabled()) {
0716     for (int iWord = 0; iWord < BlockSize; ++iWord) {
0717       LogTrace("L1GtFdlWord") << std::setw(4) << iWord << "  " << std::hex << std::setfill('0') << std::setw(16)
0718                               << payload[iWord] << std::dec << std::setfill(' ') << std::endl;
0719     }
0720   }
0721 }
0722 
0723 // static class members
0724 
0725 // block description in the raw GT record
0726 
0727 // block size in 64bits words (BlockSize * 64 bits)
0728 const int L1GtFdlWord::BlockSize = 7;
0729 
0730 // word 0
0731 
0732 // index of the word in the FDL block containig the variable
0733 const int L1GtFdlWord::BoardIdWord = 0;
0734 const int L1GtFdlWord::BxInEventWord = 0;
0735 const int L1GtFdlWord::BxNrWord = 0;
0736 const int L1GtFdlWord::EventNrWord = 0;
0737 
0738 // mask to get the 64-bit-value from the corresponding word in the FDL block
0739 const cms_uint64_t L1GtFdlWord::BoardIdMask = 0xFFFF000000000000ULL;
0740 const cms_uint64_t L1GtFdlWord::BxInEventMask = 0x0000F00000000000ULL;
0741 const cms_uint64_t L1GtFdlWord::BxNrMask = 0x00000FFF00000000ULL;
0742 const cms_uint64_t L1GtFdlWord::EventNrMask = 0x0000000000FFFFFFULL;
0743 
0744 // shift to the right to get the value from the "64-bit-value"
0745 const int L1GtFdlWord::BoardIdShift = 48;
0746 const int L1GtFdlWord::BxInEventShift = 44;
0747 const int L1GtFdlWord::BxNrShift = 32;
0748 const int L1GtFdlWord::EventNrShift = 0;
0749 
0750 // word 1
0751 
0752 const int L1GtFdlWord::GtTechnicalTriggerWordWord = 1;
0753 const cms_uint64_t L1GtFdlWord::GtTechnicalTriggerWordMask = 0xFFFFFFFFFFFFFFFFULL;
0754 const int L1GtFdlWord::GtTechnicalTriggerWordShift = 0;
0755 
0756 // word 2 - WordA: bits 0-63
0757 
0758 const int L1GtFdlWord::GtDecisionWordAWord = 2;
0759 const cms_uint64_t L1GtFdlWord::GtDecisionWordAMask = 0xFFFFFFFFFFFFFFFFULL;
0760 const int L1GtFdlWord::GtDecisionWordAShift = 0;
0761 
0762 // word 3 - WordB: bits 64-128
0763 
0764 const int L1GtFdlWord::GtDecisionWordBWord = 3;
0765 const cms_uint64_t L1GtFdlWord::GtDecisionWordBMask = 0xFFFFFFFFFFFFFFFFULL;
0766 const int L1GtFdlWord::GtDecisionWordBShift = 0;
0767 
0768 // word 4
0769 const int L1GtFdlWord::GtDecisionWordExtendedWord = 4;
0770 const cms_uint64_t L1GtFdlWord::GtDecisionWordExtendedMask = 0xFFFFFFFFFFFFFFFFULL;
0771 const int L1GtFdlWord::GtDecisionWordExtendedShift = 0;
0772 
0773 // word 5
0774 const int L1GtFdlWord::PhysicsDeclaredWord = 5;
0775 const int L1GtFdlWord::GtPrescaleFactorIndexTechWord = 5;
0776 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoWord = 5;
0777 const int L1GtFdlWord::NoAlgoWord = 5;
0778 const int L1GtFdlWord::FinalORWord = 5;
0779 
0780 const cms_uint64_t L1GtFdlWord::PhysicsDeclaredMask = 0x8000000000000000ULL;
0781 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexTechMask = 0x00FF000000000000ULL;
0782 const cms_uint64_t L1GtFdlWord::GtPrescaleFactorIndexAlgoMask = 0x000000FF00000000ULL;
0783 const cms_uint64_t L1GtFdlWord::NoAlgoMask = 0x0000000000000100ULL;
0784 const cms_uint64_t L1GtFdlWord::FinalORMask = 0x00000000000000FFULL;
0785 
0786 const int L1GtFdlWord::PhysicsDeclaredShift = 63;
0787 const int L1GtFdlWord::GtPrescaleFactorIndexTechShift = 48;
0788 const int L1GtFdlWord::GtPrescaleFactorIndexAlgoShift = 32;
0789 const int L1GtFdlWord::NoAlgoShift = 8;
0790 const int L1GtFdlWord::FinalORShift = 0;
0791 
0792 // word 6
0793 const int L1GtFdlWord::OrbitNrWord = 6;
0794 const int L1GtFdlWord::LumiSegmentNrWord = 6;
0795 const int L1GtFdlWord::LocalBxNrWord = 6;
0796 
0797 const cms_uint64_t L1GtFdlWord::OrbitNrMask = 0xFFFFFFFF00000000ULL;
0798 const cms_uint64_t L1GtFdlWord::LumiSegmentNrMask = 0x00000000FFFF0000ULL;
0799 const cms_uint64_t L1GtFdlWord::LocalBxNrMask = 0x0000000000000FFFULL;
0800 
0801 const int L1GtFdlWord::OrbitNrShift = 32;
0802 const int L1GtFdlWord::LumiSegmentNrShift = 16;
0803 const int L1GtFdlWord::LocalBxNrShift = 0;