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] >> 9) != 0b1000000) || ((data16[9] >> 11) != 0) ||
139 ((data16[10] >> 11) != 0) || ((data16[11] >> 11) != 0)) {
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!";
156 unsigned int mask = 0;
157 for (; length > 0; length--)
158 mask = (mask << 4) | 0xf;
162 count += (
p &
mask) == pattern;
176 std::unique_ptr<Block>
180 return std::auto_ptr<Block>(
nullptr);
182 const uint16_t * data16 =
reinterpret_cast<const uint16_t*
>(
data_);
183 const uint16_t * end16 =
reinterpret_cast<const uint16_t*
>(
end_);
191 for (
int j = 0; j < 4; ++j) {
193 pattern |= (data16[
n] >> 15) <<
n;
194 payload.push_back(data16[
n]);
197 if (
count(pattern, i + 1) == 1 and
valid(pattern))
201 if (not
valid(pattern)) {
203 return std::auto_ptr<Block>(
nullptr);
206 data_ += (i + 1) * 2;
207 return std::unique_ptr<Block>(
new Block(pattern, payload, 0,
MTF7));
212 if (not (*
data_ == 0xA110CA7E) ) {
231 unsigned blockId = 0;
236 unsigned blockSize = 192;
240 std::unique_ptr<Block>
244 LogDebug(
"L1T") <<
"Reached end of payload";
245 return std::auto_ptr<Block>();
248 edm::LogWarning(
"L1T") <<
"CTP7 with more bunch crossings than expected";
255 <<
"Expecting a block size of " <<
header.getSize()
256 <<
" but only " << (
end_ -
data_) <<
" words remaining";
257 return std::auto_ptr<Block>();
260 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