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[]>
133 Packet::add(
unsigned int amc_no,
unsigned int board,
const std::vector<uint64_t>&
load)
135 edm::LogInfo(
"AMC") <<
"Adding board " << board <<
" with payload size " << load.size()
136 <<
" as payload #" << amc_no;
151 auto block_start =
data;
156 <<
"Invalid header for AMC13 packet: "
172 unsigned int tot_size = 0;
173 unsigned int tot_nblocks = 0;
174 unsigned int maxblocks = 0;
177 tot_size +=
amc.header().getSize();
178 tot_nblocks +=
amc.header().getBlocks();
179 maxblocks =
std::max(maxblocks,
amc.header().getBlocks());
182 unsigned int words = tot_size +
188 <<
"Encountered AMC 13 packet with "
189 << size <<
" words, "
191 << words <<
" words: "
192 << tot_size <<
" payload words, "
193 << tot_nblocks <<
" AMC header words, and 2 AMC 13 header words.";
199 for (
auto&
amc: payload_) {
200 amc.addPayload(data,
amc.header().getBlockSize());
201 data +=
amc.header().getBlockSize();
203 auto block_end =
data;
207 std::string check(reinterpret_cast<const char*>(block_start), reinterpret_cast<const char*>(block_end));
216 <<
"Block trailer mismatch: "
217 <<
"expected block 0, but trailer is for block "
222 for (
unsigned int b = 1;
b < maxblocks; ++
b) {
226 std::vector<amc::Header>
headers;
231 for (
const auto&
amc: headers) {
232 payload_[
amc.getAMCNumber() - 1].addPayload(data,
amc.getBlockSize());
233 data +=
amc.getBlockSize();
240 check =
std::string(reinterpret_cast<const char*>(block_start), reinterpret_cast<const char*>(block_end));
249 <<
"Block trailer mismatch: "
250 <<
"expected block " <<
b
251 <<
", but trailer is for block " << t.
getBlock();
261 unsigned int maxblocks = 0;
272 unsigned int words = 0;
274 unsigned int maxblocks = 0;
278 blocks +=
amc.blocks();
284 return words + blocks + maxblocks * 2;
290 if (size < this->
size() * 8)
298 for (
unsigned int b = 0;
b <
blocks(); ++
b) {
301 std::vector<uint64_t> block_headers;
302 std::vector<uint64_t> block_load;
305 <<
"Considering block " <<
b
306 <<
" for payload " <<
amc.header().getBoardID()
307 <<
" with size " <<
amc.size()
308 <<
" and " <<
amc.blocks() <<
" blocks";
309 if (
amc.blocks() <
b + 1)
312 block_headers.push_back(
amc.header(
b));
313 auto words =
amc.block(
b);
314 block_load.insert(block_load.end(), words.begin(), words.end());
320 <<
"Writing header for AMC13 packet: "
321 <<
"format version " <<
h.getFormatVersion()
322 <<
", " <<
h.getNumberOfAMCs()
323 <<
" AMC packets, orbit " <<
h.getOrbitNumber();
328 block_headers.insert(block_headers.end(), block_load.begin(), block_load.end());
329 for (
const auto& word: block_headers)
332 std::string dstring(reinterpret_cast<char*>(block_start), reinterpret_cast<char*>(data));
EventNumber_t event() const
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)
void add(unsigned int amc_no, unsigned int board, const std::vector< uint64_t > &load)
tuple size
Write out results.
std::vector< uint64_t > payload_