11 const std::vector<unsigned int>
31 LogTrace(
"L1T") <<
"Writing MP7 link header";
38 LogTrace(
"L1T") <<
"Writing CTP7 link header";
48 unsigned int wordsPerBx = payloadWordsPerBx;
53 unsigned int nBxBlocks = payload_.size() / wordsPerBx;
54 for (
size_t bxCtr = 0; bxCtr < nBxBlocks; ++bxCtr) {
55 size_t startIdx = bxCtr * wordsPerBx;
56 auto startBxBlock = payload_.cbegin()+startIdx;
59 bxBlocks.emplace_back(startBxBlock, startBxBlock+wordsPerBx);
61 bxBlocks.emplace_back(bxCtr, nBxBlocks, startBxBlock, startBxBlock+wordsPerBx);
68 std::unique_ptr<Block>
71 if (
end_ - data_ < getHeaderSize()) {
72 LogDebug(
"L1T") <<
"Reached end of payload";
73 return std::auto_ptr<Block>();
76 if (data_[0] == 0xffffffff) {
77 LogDebug(
"L1T") <<
"Skipping padding word";
86 <<
"Expecting a block size of " <<
header.getSize()
87 <<
" but only " << (
end_ - data_) <<
" words remaining";
88 return std::auto_ptr<Block>();
91 LogTrace(
"L1T") <<
"Creating block with size " <<
header.getSize();
116 LogTrace(
"L1T") <<
"Getting header from " << std::hex << std::setw(8) << *
data_;
123 const uint16_t * data16 =
reinterpret_cast<const uint16_t*
>(
data);
124 const uint16_t * end16 =
reinterpret_cast<const uint16_t*
>(
end);
127 edm::LogError(
"L1T") <<
"MTF7 payload smaller than allowed!";
130 ((data16[0] >> 12) != 0x9) || ((data16[1] >> 12) != 0x9) ||
131 ((data16[2] >> 12) != 0x9) || ((data16[3] >> 12) != 0x9) ||
132 ((data16[4] >> 12) != 0xA) || ((data16[5] >> 12) != 0xA) ||
133 ((data16[6] >> 12) != 0xA) || ((data16[7] >> 12) != 0xA) ||
134 ((data16[8] >> 9) != 0b1000000) || ((data16[9] >> 11) != 0) ||
135 ((data16[10] >> 11) != 0) || ((data16[11] >> 11) != 0)) {
139 ((data16[12] >> 15) != 0) || ((data16[13] >> 15) != 1) ||
140 ((data16[14] >> 15) != 0) || ((data16[15] >> 15) != 0)) {
141 edm::LogError(
"L1T") <<
"MTF7 payload has invalid counter block!";
152 unsigned int mask = 0;
153 for (; length > 0; length--)
154 mask = (mask << 4) | 0xf;
158 count += (
p &
mask) == pattern;
172 std::unique_ptr<Block>
176 return std::auto_ptr<Block>(
nullptr);
178 const uint16_t * data16 =
reinterpret_cast<const uint16_t*
>(
data_);
179 const uint16_t * end16 =
reinterpret_cast<const uint16_t*
>(
end_);
187 for (
int j = 0; j < 4; ++j) {
189 pattern |= (data16[
n] >> 15) <<
n;
190 payload.push_back(data16[
n]);
193 if (
count(pattern, i + 1) == 1 and
valid(pattern))
197 if (not
valid(pattern)) {
199 return std::auto_ptr<Block>(
nullptr);
202 data_ += (i + 1) * 2;
203 return std::unique_ptr<Block>(
new Block(pattern, payload, 0,
MTF7));
static const unsigned int size_shift
BlockHeader getHeader() override
MP7Payload(const uint32_t *data, const uint32_t *end, bool legacy_mc=false)
std::vector< l1t::Jet >::iterator end_
static const unsigned int trailer_size
int count(unsigned int pattern, unsigned int length) const
virtual std::unique_ptr< Block > getBlock()
payload
payload postfix for testing
CTP7Payload(const uint32_t *data, const uint32_t *end)
static const unsigned int counter_size
bool valid(unsigned int pattern) const
MTF7Payload(const uint32_t *data, const uint32_t *end)
std::vector< BxBlock > BxBlocks
BlockHeader getHeader() override
static const unsigned int size_mask
BxBlocks getBxBlocks(unsigned int payloadWordsPerBx, bool bxHeader) const
char data[epos_bytes_allocation]
static const unsigned int header_size
static const unsigned int max_block_length_
static const std::vector< unsigned int > block_patterns_
std::unique_ptr< Block > getBlock() override