10 #define EDM_ML_DEBUG 1
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);
52 const std::vector<uint64_t>&
load,
54 edm::LogInfo(
"AMC") <<
"Adding board " << board <<
" with payload size " << load.size() <<
" as payload #"
74 std::map<int, int> amc_index;
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;
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;
187 unsigned int words = 0;
189 unsigned int maxblocks = 0;
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;
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
static const unsigned int LV1_mask
static void writeCRC(const uint64_t *start, uint64_t *end)
unsigned int size() const
unsigned int getCRC() const
unsigned int blocks() const
bool check(unsigned int crc, unsigned int block, unsigned int lv1_id, unsigned int bx) const
static const unsigned int CRC_mask
static const unsigned int BlkNo_mask
int bunchCrossing() const
static const unsigned int BX_mask
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
Log< level::Error, false > LogError
Trailer(const uint64_t *data)
std::vector< amc::Packet > payload_
unsigned int getBX() const
unsigned int getBlock() const
static const unsigned int BX_shift
unsigned int getLV1ID() const
Log< level::Info, false > LogInfo
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)
static const unsigned int LV1_shift
static const unsigned int BlkNo_shift
char data[epos_bytes_allocation]
static const unsigned int CRC_shift
Log< level::Warning, false > LogWarning
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
tuple size
Write out results.