12 unsigned int max_block_no = 0;
14 max_block_no = (size - 1023) / 4096;
16 if (block != max_block_no)
39 }
else if (block == 0) {
59 return (size - 1023) / 4096 + 1;
75 header_(amc, board, load.
size()),
98 std::unique_ptr<uint64_t[]>
135 edm::LogInfo(
"AMC") <<
"Adding board " << board <<
" with payload size " << load.size();
150 auto block_start =
data;
155 <<
"Invalid header for AMC13 packet: "
171 unsigned int tot_size = 0;
172 unsigned int tot_nblocks = 0;
173 unsigned int maxblocks = 0;
176 tot_size +=
amc.header().getSize();
177 tot_nblocks +=
amc.header().getBlocks();
178 maxblocks =
std::max(maxblocks,
amc.header().getBlocks());
181 unsigned int words = tot_size +
187 <<
"Encountered AMC 13 packet with "
188 << size <<
" words, "
190 << words <<
" words: "
191 << tot_size <<
" payload words, "
192 << tot_nblocks <<
" AMC header words, and 2 AMC 13 header words.";
198 for (
auto&
amc: payload_) {
199 amc.addPayload(data,
amc.header().getBlockSize());
200 data +=
amc.header().getBlockSize();
202 auto block_end =
data;
206 std::string check(reinterpret_cast<const char*>(block_start), reinterpret_cast<const char*>(block_end));
215 <<
"Block trailer mismatch: "
216 <<
"expected block 0, but trailer is for block "
221 for (
unsigned int b = 1;
b < maxblocks; ++
b) {
225 std::vector<amc::Header>
headers;
230 for (
const auto&
amc: headers) {
231 payload_[
amc.getAMCNumber() - 1].addPayload(data,
amc.getBlockSize());
232 data +=
amc.getBlockSize();
239 check =
std::string(reinterpret_cast<const char*>(block_start), reinterpret_cast<const char*>(block_end));
248 <<
"Block trailer mismatch: "
249 <<
"expected block " <<
b
250 <<
", but trailer is for block " << t.
getBlock();
260 unsigned int maxblocks = 0;
271 unsigned int words = 0;
273 unsigned int maxblocks = 0;
277 blocks +=
amc.blocks();
283 return words + blocks + maxblocks * 2;
289 if (size < this->
size() * 8)
297 for (
unsigned int b = 0;
b <
blocks(); ++
b) {
300 std::vector<uint64_t> block_headers;
301 std::vector<uint64_t> block_load;
304 <<
"Considering block " <<
b
305 <<
" for payload " <<
amc.header().getBoardID()
306 <<
" with size " <<
amc.size()
307 <<
" and " <<
amc.blocks() <<
" blocks";
308 if (
amc.blocks() <
b + 1)
311 block_headers.push_back(
amc.header(
b));
312 auto words =
amc.block(
b);
313 block_load.insert(block_load.end(), words.begin(), words.end());
319 <<
"Writing header for AMC13 packet: "
320 <<
"format version " <<
h.getFormatVersion()
321 <<
", " <<
h.getNumberOfAMCs()
322 <<
" AMC packets, orbit " <<
h.getOrbitNumber();
327 block_headers.insert(block_headers.end(), block_load.begin(), block_load.end());
328 for (
const auto& word: block_headers)
331 std::string dstring(reinterpret_cast<char*>(block_start), reinterpret_cast<char*>(data));
EventNumber_t event() const
void add(unsigned int board, const std::vector< uint64_t > &load)
static const unsigned int LV1_mask
unsigned int size() const
unsigned int getCRC() const
unsigned int blocks() const
static const unsigned int CRC_mask
static const unsigned int BlkNo_mask
int bunchCrossing() const
static const unsigned int BX_mask
std::vector< uint64_t > block(unsigned int id) const
Trailer(const uint64_t *data)
void addPayload(const uint64_t *, unsigned int)
std::vector< amc::Packet > payload_
unsigned int getBlock() const
bool check(const std::string &)
static const unsigned int BX_shift
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int size) const
static const unsigned int split_block_size
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
unsigned int size() const
unsigned long long uint64_t
static const unsigned int LV1_shift
static const unsigned int BlkNo_shift
char data[epos_bytes_allocation]
std::unique_ptr< uint64_t[]> data()
bool parse(const uint64_t *, unsigned int)
static const unsigned int CRC_shift
Packet(const uint64_t *d)
tuple size
Write out results.
std::vector< uint64_t > payload_