27 LogTrace(
"L1T") <<
"Writing MP7 link header";
31 LogTrace(
"L1T") <<
"Writing CTP7 link header";
38 LogTrace(
"L1T") <<
"Writing meaningless link header";
46 unsigned int wordsPerBx = payloadWordsPerBx;
51 unsigned int nBxBlocks =
payload_.size() / wordsPerBx;
52 for (
size_t bxCtr = 0; bxCtr < nBxBlocks; ++bxCtr) {
53 size_t startIdx = bxCtr * wordsPerBx;
54 auto startBxBlock =
payload_.cbegin() + startIdx;
57 bxBlocks.emplace_back(startBxBlock, startBxBlock + wordsPerBx);
59 bxBlocks.emplace_back(bxCtr, nBxBlocks, startBxBlock, startBxBlock + wordsPerBx);
68 LogDebug(
"L1T") <<
"Reached end of payload";
69 return std::unique_ptr<Block>();
72 if (
data_[0] == 0xffffffff) {
73 LogDebug(
"L1T") <<
"Skipping padding word";
82 <<
" words remaining";
83 return std::unique_ptr<Block>();
86 LogTrace(
"L1T") <<
"Creating block with size " <<
header.getSize();
108 LogTrace(
"L1T") <<
"Getting header from " << std::hex << std::setw(8) << *
data_;
114 const uint16_t* data16 = reinterpret_cast<const uint16_t*>(
data);
115 const uint16_t* end16 = reinterpret_cast<const uint16_t*>(
end);
118 edm::LogError(
"L1T") <<
"MTF7 payload smaller than allowed!";
121 ((data16[0] >> 12) != 0x9) || ((data16[1] >> 12) != 0x9) || ((data16[2] >> 12) != 0x9) ||
122 ((data16[3] >> 12) != 0x9) || ((data16[4] >> 12) != 0xA) || ((data16[5] >> 12) != 0xA) ||
123 ((data16[6] >> 12) != 0xA) || ((data16[7] >> 12) != 0xA) || ((data16[8] >> 15) != 0
x1) ||
124 ((data16[9] >> 15) != 0x0) || ((data16[10] >> 15) != 0x0) || ((data16[11] >> 15) != 0x0)) {
128 ((data16[12] >> 15) != 0) || ((data16[13] >> 15) != 1) || ((data16[14] >> 15) != 0) ||
129 ((data16[15] >> 15) != 0)) {
130 edm::LogError(
"L1T") <<
"MTF7 payload has invalid counter block!";
136 for (
int i = 4;
i < 1590;
i++) {
137 if (((data16[4 *
i + 0] >> 12) == 0xF) && ((data16[4 *
i + 1] >> 12) == 0xF) &&
138 ((data16[4 *
i + 2] >> 12) == 0xF) && ((data16[4 *
i + 3] >> 12) == 0xF) &&
139 ((data16[4 *
i + 4] >> 12) == 0xE) && ((data16[4 *
i + 5] >> 12) == 0xE) &&
140 ((data16[4 *
i + 6] >> 12) == 0xE) &&
141 ((data16[4 *
i + 7] >> 12) == 0xE)) {
142 algo_ = (((data16[4 *
i + 2] >> 4) & 0x3F) << 9);
143 algo_ |= (((data16[4 *
i + 2] >> 0) & 0x0F) << 5);
144 algo_ |= (((data16[4 *
i + 4] >> 0) & 0x1F) << 0);
149 edm::LogError(
"L1T") <<
"MTF7 payload has no valid EMTF firmware version!";
155 unsigned int mask = 0;
156 for (; length > 0; length--)
157 mask = (mask << 4) | 0xf;
175 return std::unique_ptr<Block>();
177 const uint16_t* data16 = reinterpret_cast<const uint16_t*>(
data_);
178 const uint16_t* end16 = reinterpret_cast<const uint16_t*>(
end_);
186 for (
int j = 0;
j < 4; ++
j) {
198 return std::unique_ptr<Block>();
207 if (not(*
data_ == 0xA110CA7E)) {
224 unsigned blockId = 0;
229 unsigned blockSize = 192;
235 LogDebug(
"L1T") <<
"Reached end of payload";
236 return std::unique_ptr<Block>();
239 edm::LogWarning(
"L1T") <<
"CTP7 with more bunch crossings than expected";
246 <<
" words remaining";
247 return std::unique_ptr<Block>();
250 LogTrace(
"L1T") <<
"Creating block with size " <<
header.getSize();