11 const std::vector<unsigned int>
31 LogTrace(
"L1T") <<
"Writing MP7 link header";
35 LogTrace(
"L1T") <<
"Writing CTP7 link header";
42 LogTrace(
"L1T") <<
"Writing meaningless link header";
52 unsigned int wordsPerBx = payloadWordsPerBx;
57 unsigned int nBxBlocks = payload_.size() / wordsPerBx;
58 for (
size_t bxCtr = 0; bxCtr < nBxBlocks; ++bxCtr) {
59 size_t startIdx = bxCtr * wordsPerBx;
60 auto startBxBlock = payload_.cbegin()+startIdx;
63 bxBlocks.emplace_back(startBxBlock, startBxBlock+wordsPerBx);
65 bxBlocks.emplace_back(bxCtr, nBxBlocks, startBxBlock, startBxBlock+wordsPerBx);
72 std::unique_ptr<Block>
75 if (
end_ - data_ < getHeaderSize()) {
76 LogDebug(
"L1T") <<
"Reached end of payload";
77 return std::auto_ptr<Block>();
80 if (data_[0] == 0xffffffff) {
81 LogDebug(
"L1T") <<
"Skipping padding word";
90 <<
"Expecting a block size of " <<
header.getSize()
91 <<
" but only " << (
end_ - data_) <<
" words remaining";
92 return std::auto_ptr<Block>();
95 LogTrace(
"L1T") <<
"Creating block with size " <<
header.getSize();
120 LogTrace(
"L1T") <<
"Getting header from " << std::hex << std::setw(8) << *
data_;
127 const uint16_t * data16 =
reinterpret_cast<const uint16_t*
>(
data);
128 const uint16_t * end16 =
reinterpret_cast<const uint16_t*
>(
end);
131 edm::LogError(
"L1T") <<
"MTF7 payload smaller than allowed!";
134 ((data16[0] >> 12) != 0x9) || ((data16[1] >> 12) != 0x9) ||
135 ((data16[2] >> 12) != 0x9) || ((data16[3] >> 12) != 0x9) ||
136 ((data16[4] >> 12) != 0xA) || ((data16[5] >> 12) != 0xA) ||
137 ((data16[6] >> 12) != 0xA) || ((data16[7] >> 12) != 0xA) ||
138 ((data16[8] >> 15) != 0
x1) || ((data16[9] >> 15) != 0x0) ||
139 ((data16[10] >> 15) != 0x0) || ((data16[11] >> 15) != 0x0)) {
143 ((data16[12] >> 15) != 0) || ((data16[13] >> 15) != 1) ||
144 ((data16[14] >> 15) != 0) || ((data16[15] >> 15) != 0)) {
145 edm::LogError(
"L1T") <<
"MTF7 payload has invalid counter block!";
151 for (
int i = 4;
i < 1590;
i++) {
152 if ( ((data16[4*
i+0] >> 12) == 0xF) && ((data16[4*
i+1] >> 12) == 0xF) &&
153 ((data16[4*
i+2] >> 12) == 0xF) && ((data16[4*
i+3] >> 12) == 0xF) &&
154 ((data16[4*
i+4] >> 12) == 0xE) && ((data16[4*
i+5] >> 12) == 0xE) &&
155 ((data16[4*
i+6] >> 12) == 0xE) && ((data16[4*
i+7] >> 12) == 0xE) ) {
156 algo_ = (((data16[4*
i+2] >> 4) & 0x3F) << 9);
157 algo_ |= (((data16[4*
i+2] >> 0) & 0x0F) << 5);
158 algo_ |= (((data16[4*
i+4] >> 0) & 0x1F) << 0);
163 edm::LogError(
"L1T") <<
"MTF7 payload has no valid EMTF firmware version!";
171 unsigned int mask = 0;
172 for (; length > 0; length--)
173 mask = (mask << 4) | 0xf;
177 count += (
p &
mask) == pattern;
191 std::unique_ptr<Block>
195 return std::auto_ptr<Block>(
nullptr);
197 const uint16_t * data16 =
reinterpret_cast<const uint16_t*
>(
data_);
198 const uint16_t * end16 =
reinterpret_cast<const uint16_t*
>(
end_);
206 for (
int j = 0; j < 4; ++j) {
208 pattern |= (data16[
n] >> 15) <<
n;
209 payload.push_back(data16[
n]);
212 if (
count(pattern, i + 1) == 1 and
valid(pattern))
216 if (not
valid(pattern)) {
218 return std::auto_ptr<Block>(
nullptr);
221 data_ += (i + 1) * 2;
222 return std::unique_ptr<Block>(
new Block(pattern, payload, 0,
MTF7));
227 if (not (*
data_ == 0xA110CA7E) ) {
246 unsigned blockId = 0;
251 unsigned blockSize = 192;
255 std::unique_ptr<Block>
259 LogDebug(
"L1T") <<
"Reached end of payload";
260 return std::auto_ptr<Block>();
263 edm::LogWarning(
"L1T") <<
"CTP7 with more bunch crossings than expected";
270 <<
"Expecting a block size of " <<
header.getSize()
271 <<
" but only " << (
end_ -
data_) <<
" words remaining";
272 return std::auto_ptr<Block>();
275 LogTrace(
"L1T") <<
"Creating block with size " <<
header.getSize();
BlockHeader getHeader() override
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
std::vector< l1t::Jet >::iterator end_
static constexpr unsigned max_block_length_
unsigned getHeaderSize() const override
static constexpr unsigned header_size
int count(unsigned int pattern, unsigned int length) const
virtual std::unique_ptr< Block > getBlock()
static constexpr unsigned counter_size
bool valid(unsigned int pattern) const
MTF7Payload(const uint32_t *data, const uint32_t *end)
std::vector< BxBlock > BxBlocks
CTP7Payload(const uint32_t *data, const uint32_t *end, amc::Header amcHeader)
BlockHeader getHeader() override
static constexpr unsigned trailer_size
BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const
char data[epos_bytes_allocation]
std::unique_ptr< Block > getBlock() override
static const std::vector< unsigned int > block_patterns_
std::unique_ptr< Block > getBlock() override