10 #define EDM_ML_DEBUG 1 22 data_ = (
static_cast<uint64_t>(blk & BlkNo_mask) << BlkNo_shift) |
23 (
static_cast<uint64_t>(lv1 & LV1_mask) << LV1_shift) | (
static_cast<uint64_t>(bx & BX_mask) << BX_shift);
27 if ((crc != 0 && crc != getCRC()) || block != getBlock() || (lv1_id & LV1_mask) != getLV1ID() ||
28 (bx & BX_mask) != getBX()) {
30 <<
"\n\tBX " << getBX() <<
", LV1 ID " << getLV1ID() <<
", block # " << getBlock()
31 <<
", CRC " << std::hex << std::setw(8) << std::setfill(
'0') << getCRC() <<
std::dec 33 <<
"\n\tBX " << (bx & BX_mask) <<
", LV1 ID " << (lv1_id & LV1_mask) <<
", block # " 34 << block <<
", CRC " << std::hex << std::setw(8) << std::setfill(
'0') << crc;
41 std::string dstring(reinterpret_cast<const char*>(start), reinterpret_cast<const char*>(end) + 4);
44 *end = ((*end) & ~(
uint64_t(CRC_mask) << CRC_shift)) | (
static_cast<uint64_t>(crc & CRC_mask) << CRC_shift);
52 const std::vector<uint64_t>&
load,
54 edm::LogInfo(
"AMC") <<
"Adding board " << board <<
" with payload size " << load.size() <<
" as payload #" 57 payload_.push_back(
amc::Packet(amc_no, board, lv1id, orbit, bx, load, user));
74 std::map<int, int> amc_index;
78 if (!header_.check()) {
80 <<
"format version " << header_.getFormatVersion() <<
", " << header_.getNumberOfAMCs()
85 if (size < 2 + header_.getNumberOfAMCs())
90 for (
unsigned int i = 0;
i < header_.getNumberOfAMCs(); ++
i) {
92 amc_index[payload_.back().blockHeader().getAMCNumber()] =
i;
95 unsigned int tot_size = 0;
96 unsigned int tot_nblocks = 0;
97 unsigned int maxblocks = 0;
99 bool check_crc =
false;
100 for (
const auto&
amc : payload_) {
101 tot_size +=
amc.blockHeader().getSize();
102 tot_nblocks +=
amc.blockHeader().getBlocks();
103 maxblocks =
std::max(maxblocks,
amc.blockHeader().getBlocks());
105 if (
amc.blockHeader().validCRC())
109 unsigned int words = tot_size +
114 edm::LogError(
"L1T") <<
"Encountered AMC 13 packet with " << size <<
" words, " 115 <<
"but expected " << words <<
" words: " << tot_size <<
" payload words, " << tot_nblocks
116 <<
" AMC header words, and 2 AMC 13 header words.";
122 for (
auto&
amc : payload_) {
123 amc.addPayload(data,
amc.blockHeader().getBlockSize());
124 data +=
amc.blockHeader().getBlockSize();
131 std::string check(reinterpret_cast<const char*>(start), reinterpret_cast<const char*>(data) - 4);
134 LogDebug(
"L1T") <<
"checking data checksum of " << std::hex << crc <<
std::dec;
137 t.
check(crc, 0, lv1, bx);
140 for (
unsigned int b = 1;
b < maxblocks; ++
b) {
142 std::vector<amc::BlockHeader>
headers;
148 for (
const auto&
amc : headers) {
149 payload_[amc_index[
amc.getAMCNumber()]].addPayload(data,
amc.getBlockSize());
150 data +=
amc.getBlockSize();
159 std::string check(reinterpret_cast<const char*>(start), reinterpret_cast<const char*>(data) - 4);
162 LogDebug(
"L1T") <<
"checking data checksum of " << std::hex << crc <<
std::dec;
170 for (
auto&
amc : payload_) {
171 amc.finalize(lv1, bx, legacy_mc, mtf7_mode);
178 unsigned int maxblocks = 0;
180 for (
const auto&
amc : payload_)
187 unsigned int words = 0;
189 unsigned int maxblocks = 0;
191 for (
const auto&
amc : payload_) {
192 words +=
amc.header().getSize();
193 blocks +=
amc.blocks();
199 return words + blocks + maxblocks * 2;
203 if (size < this->
size() * 8)
211 for (
unsigned int b = 0;
b <
blocks(); ++
b) {
214 std::vector<uint64_t> block_headers;
215 std::vector<uint64_t> block_load;
216 for (
const auto&
amc : payload_) {
217 edm::LogInfo(
"AMC") <<
"Considering block " <<
b <<
" for payload " <<
amc.blockHeader().getBoardID()
218 <<
" with size " <<
amc.size() <<
" and " <<
amc.blocks() <<
" blocks";
219 if (
amc.blocks() <
b + 1)
222 block_headers.push_back(
amc.blockHeader(
b));
223 auto words =
amc.block(
b);
224 block_load.insert(block_load.end(), words.begin(), words.end());
229 edm::LogInfo(
"AMC") <<
"Writing header for AMC13 packet: " 230 <<
"format version " <<
h.getFormatVersion() <<
", " <<
h.getNumberOfAMCs()
231 <<
" AMC packets, orbit " <<
h.getOrbitNumber();
236 block_headers.insert(block_headers.end(), block_load.begin(), block_load.end());
237 for (
const auto&
word : block_headers)
EventNumber_t event() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static void writeCRC(const uint64_t *start, uint64_t *end)
unsigned int size() const
unsigned int blocks() const
bool check(unsigned int crc, unsigned int block, unsigned int lv1_id, unsigned int bx) const
int bunchCrossing() const
void add(unsigned int amc_no, unsigned int board, unsigned int lv1id, unsigned int orbit, unsigned int bx, const std::vector< uint64_t > &load, unsigned int user=0)
bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const
Trailer(const uint64_t *data)
unsigned long long uint64_t
bool parse(const uint64_t *start, const uint64_t *data, unsigned int size, unsigned int lv1, unsigned int bx, bool legacy_mc=false, bool mtf7_mode=false)
char data[epos_bytes_allocation]