File indexing completed on 2024-04-06 12:04:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeWord.h"
0017
0018
0019 #include <iomanip>
0020
0021
0022
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0025
0026
0027
0028
0029 L1GtfeWord::L1GtfeWord()
0030 : m_boardId(0),
0031 m_recordLength1(0),
0032 m_recordLength(0),
0033 m_bxNr(0),
0034 m_setupVersion(0),
0035 m_activeBoards(0),
0036 m_altNrBxBoard(0),
0037 m_totalTriggerNr(0) {
0038
0039 }
0040
0041
0042 L1GtfeWord::L1GtfeWord(cms_uint16_t boardIdValue,
0043 cms_uint16_t recordLength1Value,
0044 cms_uint16_t recordLengthValue,
0045 cms_uint16_t bxNrValue,
0046 cms_uint32_t setupVersionValue,
0047 cms_uint16_t activeBoardsValue,
0048 cms_uint16_t altNrBxBoardValue,
0049 cms_uint32_t totalTriggerNrValue)
0050 : m_boardId(boardIdValue),
0051 m_recordLength1(recordLength1Value),
0052 m_recordLength(recordLengthValue),
0053 m_bxNr(bxNrValue),
0054 m_setupVersion(setupVersionValue),
0055 m_activeBoards(activeBoardsValue),
0056 m_altNrBxBoard(altNrBxBoardValue),
0057 m_totalTriggerNr(totalTriggerNrValue)
0058
0059 {
0060
0061 }
0062
0063
0064 L1GtfeWord::~L1GtfeWord() {
0065
0066 }
0067
0068
0069 bool L1GtfeWord::operator==(const L1GtfeWord& result) const {
0070 if (m_boardId != result.m_boardId) {
0071 return false;
0072 }
0073
0074 if (m_recordLength1 != result.m_recordLength1) {
0075 return false;
0076 }
0077
0078 if (m_recordLength != result.m_recordLength) {
0079 return false;
0080 }
0081
0082 if (m_bxNr != result.m_bxNr) {
0083 return false;
0084 }
0085
0086 if (m_setupVersion != result.m_setupVersion) {
0087 return false;
0088 }
0089
0090 if (m_activeBoards != result.m_activeBoards) {
0091 return false;
0092 }
0093
0094 if (m_altNrBxBoard != result.m_altNrBxBoard) {
0095 return false;
0096 }
0097
0098 if (m_totalTriggerNr != result.m_totalTriggerNr) {
0099 return false;
0100 }
0101
0102
0103 return true;
0104 }
0105
0106
0107 bool L1GtfeWord::operator!=(const L1GtfeWord& result) const { return !(result == *this); }
0108
0109
0110
0111
0112 void L1GtfeWord::setBoardId(const cms_uint64_t& word64) { m_boardId = (word64 & BoardIdMask) >> BoardIdShift; }
0113
0114
0115
0116 void L1GtfeWord::setBoardIdWord64(cms_uint64_t& word64, int iWord) {
0117 if (iWord == BoardIdWord) {
0118 word64 = word64 | (static_cast<cms_uint64_t>(m_boardId) << BoardIdShift);
0119 }
0120 }
0121
0122
0123 void L1GtfeWord::setRecordLength1(const cms_uint64_t& word64) {
0124 m_recordLength1 = (word64 & RecordLength1Mask) >> RecordLength1Shift;
0125 }
0126
0127
0128
0129 void L1GtfeWord::setRecordLength1Word64(cms_uint64_t& word64, int iWord) {
0130 if (iWord == RecordLength1Word) {
0131 word64 = word64 | (static_cast<cms_uint64_t>(m_recordLength1) << RecordLength1Shift);
0132 }
0133 }
0134
0135
0136 void L1GtfeWord::setRecordLength(const cms_uint64_t& word64) {
0137 m_recordLength = (word64 & RecordLengthMask) >> RecordLengthShift;
0138 }
0139
0140
0141
0142 void L1GtfeWord::setRecordLengthWord64(cms_uint64_t& word64, int iWord) {
0143 if (iWord == RecordLengthWord) {
0144 word64 = word64 | (static_cast<cms_uint64_t>(m_recordLength) << RecordLengthShift);
0145 }
0146 }
0147
0148
0149 void L1GtfeWord::setBxNr(const cms_uint64_t& word64) { m_bxNr = (word64 & BxNrMask) >> BxNrShift; }
0150
0151
0152
0153 void L1GtfeWord::setBxNrWord64(cms_uint64_t& word64, int iWord) {
0154 if (iWord == BxNrWord) {
0155 word64 = word64 | (static_cast<cms_uint64_t>(m_bxNr) << BxNrShift);
0156 }
0157 }
0158
0159
0160 void L1GtfeWord::setSetupVersion(const cms_uint64_t& word64) {
0161 m_setupVersion = (word64 & SetupVersionMask) >> SetupVersionShift;
0162 }
0163
0164
0165
0166 void L1GtfeWord::setSetupVersionWord64(cms_uint64_t& word64, int iWord) {
0167 if (iWord == SetupVersionWord) {
0168 word64 = word64 | (static_cast<cms_uint64_t>(m_setupVersion) << SetupVersionShift);
0169 }
0170 }
0171
0172
0173 const int L1GtfeWord::bstFlag() const {
0174 int bstFlagValue = 0;
0175 bstFlagValue = static_cast<int>(m_setupVersion & BstFlagMask);
0176
0177 return bstFlagValue;
0178 }
0179
0180 void L1GtfeWord::setBstFlag(const int bstFlagValue) {
0181 m_setupVersion = m_setupVersion | (static_cast<cms_uint32_t>(bstFlagValue) & BstFlagMask);
0182 }
0183
0184
0185 void L1GtfeWord::setActiveBoards(const cms_uint64_t& word64) {
0186 m_activeBoards = (word64 & ActiveBoardsMask) >> ActiveBoardsShift;
0187 }
0188
0189
0190
0191 void L1GtfeWord::setActiveBoardsWord64(cms_uint64_t& word64, int iWord) {
0192 if (iWord == ActiveBoardsWord) {
0193 word64 = word64 | (static_cast<cms_uint64_t>(m_activeBoards) << ActiveBoardsShift);
0194 }
0195 }
0196
0197
0198
0199 void L1GtfeWord::setActiveBoardsWord64(cms_uint64_t& word64, int iWord, cms_int16_t activeBoardsValue) {
0200 if (iWord == ActiveBoardsWord) {
0201 word64 = word64 | (static_cast<cms_uint64_t>(activeBoardsValue) << ActiveBoardsShift);
0202 }
0203 }
0204
0205
0206 void L1GtfeWord::setAltNrBxBoard(const cms_uint64_t& word64) {
0207 m_altNrBxBoard = (word64 & AltNrBxBoardMask) >> AltNrBxBoardShift;
0208 }
0209
0210
0211
0212 void L1GtfeWord::setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord) {
0213 if (iWord == AltNrBxBoardWord) {
0214 word64 = word64 | (static_cast<cms_uint64_t>(m_altNrBxBoard) << AltNrBxBoardShift);
0215 }
0216 }
0217
0218
0219
0220 void L1GtfeWord::setAltNrBxBoardWord64(cms_uint64_t& word64, int iWord, cms_int16_t altNrBxBoardValue) {
0221 if (iWord == AltNrBxBoardWord) {
0222 word64 = word64 | (static_cast<cms_uint64_t>(altNrBxBoardValue) << AltNrBxBoardShift);
0223 }
0224 }
0225
0226
0227 void L1GtfeWord::setTotalTriggerNr(const cms_uint64_t& word64) {
0228 m_totalTriggerNr = (word64 & TotalTriggerNrMask) >> TotalTriggerNrShift;
0229 }
0230
0231
0232
0233 void L1GtfeWord::setTotalTriggerNrWord64(cms_uint64_t& word64, int iWord) {
0234 if (iWord == TotalTriggerNrWord) {
0235 word64 = word64 | (static_cast<cms_uint64_t>(m_totalTriggerNr) << TotalTriggerNrShift);
0236 }
0237 }
0238
0239
0240 void L1GtfeWord::reset() {
0241 m_boardId = 0;
0242 m_recordLength1 = 0;
0243 m_recordLength = 0;
0244 m_bxNr = 0;
0245 m_setupVersion = 0;
0246
0247 m_activeBoards = 0;
0248 m_altNrBxBoard = 0;
0249 m_totalTriggerNr = 0;
0250 }
0251
0252
0253 void L1GtfeWord::print(std::ostream& myCout) const {
0254 myCout << "\n L1GtfeWord::print \n" << std::endl;
0255
0256 myCout << " BoardId: " << std::hex << " hex: "
0257 << " " << std::setw(2) << std::setfill('0') << m_boardId << std::setfill(' ') << std::dec
0258 << " dec: " << m_boardId << std::endl;
0259
0260 myCout << " BX for alternative 1: " << std::hex << " hex: "
0261 << " " << std::setw(1) << m_recordLength1 << std::dec << " dec: " << m_recordLength1 << std::endl;
0262
0263 myCout << " BX for alternative 0: " << std::hex << " hex: "
0264 << " " << std::setw(1) << m_recordLength << std::dec << " dec: " << m_recordLength << std::endl;
0265
0266 myCout << " BxNr: " << std::hex << " hex: "
0267 << " " << std::setw(3) << std::setfill('0') << m_bxNr << std::setfill(' ') << std::dec
0268 << " dec: " << m_bxNr << std::endl;
0269
0270 myCout << " SetupVersion: " << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_setupVersion
0271 << std::setfill(' ') << std::dec << " dec: " << m_setupVersion << std::endl;
0272
0273
0274
0275 myCout << " ActiveBoards: " << std::hex << " hex: "
0276 << " " << std::setw(4) << std::setfill('0') << m_activeBoards << std::setfill(' ') << std::dec
0277 << " dec: " << m_activeBoards << std::endl;
0278
0279 myCout << " AltNrBxBoard: " << std::hex << " hex: "
0280 << " " << std::setw(4) << std::setfill('0') << m_altNrBxBoard << std::setfill(' ') << std::dec
0281 << " dec: " << m_altNrBxBoard << std::endl;
0282
0283 myCout << " TotalTriggerNr: " << std::hex << " hex: " << std::setw(8) << std::setfill('0') << m_totalTriggerNr
0284 << std::setfill(' ') << std::dec << " dec: " << m_totalTriggerNr << std::endl;
0285 }
0286
0287
0288
0289
0290 void L1GtfeWord::unpack(const unsigned char* gtfePtr) {
0291 LogDebug("L1GtfeWord") << "\nUnpacking GTFE block.\n" << std::endl;
0292
0293 const cms_uint64_t* payload = reinterpret_cast<cms_uint64_t const*>(gtfePtr);
0294
0295 setBoardId(payload[BoardIdWord]);
0296 setRecordLength1(payload[RecordLength1Word]);
0297 setRecordLength(payload[RecordLengthWord]);
0298 setBxNr(payload[BxNrWord]);
0299 setSetupVersion(payload[SetupVersionWord]);
0300 setActiveBoards(payload[ActiveBoardsWord]);
0301 setAltNrBxBoard(payload[AltNrBxBoardWord]);
0302 setTotalTriggerNr(payload[TotalTriggerNrWord]);
0303
0304 if (edm::isDebugEnabled()) {
0305 for (int iWord = 0; iWord < BlockSize; ++iWord) {
0306 LogTrace("L1GtfeWord") << std::setw(4) << iWord << " " << std::hex << std::setfill('0') << std::setw(16)
0307 << payload[iWord] << std::dec << std::setfill(' ') << std::endl;
0308 }
0309 }
0310 }
0311
0312
0313
0314
0315
0316
0317 const int L1GtfeWord::BlockSize = 2;
0318
0319 const int L1GtfeWord::BoardIdWord = 0;
0320 const int L1GtfeWord::RecordLength1Word = 0;
0321 const int L1GtfeWord::RecordLengthWord = 0;
0322 const int L1GtfeWord::BxNrWord = 0;
0323 const int L1GtfeWord::SetupVersionWord = 0;
0324
0325 const cms_uint64_t L1GtfeWord::BoardIdMask = 0xFF00000000000000ULL;
0326 const cms_uint64_t L1GtfeWord::RecordLength1Mask = 0x00F0000000000000ULL;
0327 const cms_uint64_t L1GtfeWord::RecordLengthMask = 0x000F000000000000ULL;
0328 const cms_uint64_t L1GtfeWord::BxNrMask = 0x00000FFF00000000ULL;
0329 const cms_uint64_t L1GtfeWord::SetupVersionMask = 0x00000000FFFFFFFFULL;
0330
0331 const cms_uint32_t L1GtfeWord::BstFlagMask = 0x0001;
0332
0333
0334 const int L1GtfeWord::BoardIdShift = 56;
0335 const int L1GtfeWord::RecordLength1Shift = 52;
0336 const int L1GtfeWord::RecordLengthShift = 48;
0337 const int L1GtfeWord::BxNrShift = 32;
0338 const int L1GtfeWord::SetupVersionShift = 0;
0339
0340
0341 const int L1GtfeWord::ActiveBoardsWord = 1;
0342 const int L1GtfeWord::AltNrBxBoardWord = 1;
0343 const int L1GtfeWord::TotalTriggerNrWord = 1;
0344
0345 const cms_uint64_t L1GtfeWord::ActiveBoardsMask = 0xFFFF000000000000ULL;
0346 const cms_uint64_t L1GtfeWord::AltNrBxBoardMask = 0x0000FFFF00000000ULL;
0347 const cms_uint64_t L1GtfeWord::TotalTriggerNrMask = 0x00000000FFFFFFFFULL;
0348
0349 const int L1GtfeWord::ActiveBoardsShift = 48;
0350 const int L1GtfeWord::AltNrBxBoardShift = 32;
0351 const int L1GtfeWord::TotalTriggerNrShift = 0;