7 zsEnabled_(ps.getUntrackedParameter<
bool>(
"zsEnabled")),
8 fedIds_(ps.getParameter<
std::vector<
int>>(
"fedIds")),
9 slinkHeaderSize_(ps.getUntrackedParameter<
int>(
"lenSlinkHeader")),
10 slinkTrailerSize_(ps.getUntrackedParameter<
int>(
"lenSlinkTrailer")),
11 amc13HeaderSize_(ps.getUntrackedParameter<
int>(
"lenAMC13Header")),
12 amc13TrailerSize_(ps.getUntrackedParameter<
int>(
"lenAMC13Trailer")),
13 amcHeaderSize_(ps.getUntrackedParameter<
int>(
"lenAMCHeader")),
14 amcTrailerSize_(ps.getUntrackedParameter<
int>(
"lenAMCTrailer")),
15 newZsFlagMask_(ps.getUntrackedParameter<
int>(
"newZsFlagMask")),
16 zsFlagMask_(ps.getUntrackedParameter<
int>(
"zsFlagMask")),
17 dataInvFlagMask_(ps.getUntrackedParameter<
int>(
"dataInvFlagMask")),
18 maxFedReadoutSize_(ps.getUntrackedParameter<
int>(
"maxFEDReadoutSize")),
19 checkOnlyCapIdsWithMasks_(ps.getUntrackedParameter<
bool>(
"checkOnlyCapIdsWithMasks")),
20 monitorDir_(ps.getUntrackedParameter<
std::
string>(
"monitorDir")),
21 verbose_(ps.getUntrackedParameter<
bool>(
"verbose")) {
22 std::vector<int> onesMask(6, 0xffffffff);
25 std::string maskCapIdStr{
"maskCapId" + std::to_string(
i)};
28 if (ps.
exists(maskCapIdStr)) {
36 std::cout <<
"caption ID" <<
i <<
":" << std::endl;
37 for (
const auto& maskIt :
masks_.at(
i)) {
38 std::cout << std::hex << std::setw(8) << std::setfill(
'0') << maskIt <<
std::dec << std::endl;
50 desc.
add<std::vector<int>>(
"fedIds")->setComment(
"FED ids to analyze.");
51 desc.
addUntracked<
bool>(
"zsEnabled",
true)->setComment(
"MP7 zero suppression is enabled.");
52 desc.
addUntracked<
int>(
"lenSlinkHeader", 8)->setComment(
"Number of Slink header bytes.");
53 desc.
addUntracked<
int>(
"lenSlinkTrailer", 8)->setComment(
"Number of Slink trailer bytes.");
54 desc.
addUntracked<
int>(
"lenAMC13Header", 8)->setComment(
"Number of AMC13 header bytes.");
55 desc.
addUntracked<
int>(
"lenAMC13Trailer", 8)->setComment(
"Number of AMC13 trailer bytes.");
56 desc.
addUntracked<
int>(
"lenAMCHeader", 8)->setComment(
"Number of AMC header bytes.");
57 desc.
addUntracked<
int>(
"lenAMCTrailer", 0)->setComment(
"Number of AMC trailer bytes.");
58 desc.
addUntracked<
int>(
"zsFlagMask", 0x1)->setComment(
"Zero suppression flag mask.");
59 desc.
addUntracked<
int>(
"newZsFlagMask", 0x2)->setComment(
"Per-BX zero suppression flag mask.");
60 desc.
addUntracked<
int>(
"dataInvFlagMask", 0x1)->setComment(
"Data inversion flag mask.");
61 desc.
addUntracked<
int>(
"maxFEDReadoutSize", 10000)->setComment(
"Maximal FED readout size histogram x-axis value.");
64 ->setComment(
"ZS mask for caption id " + std::to_string(
i) +
".");
66 desc.
addUntracked<
bool>(
"checkOnlyCapIdsWithMasks",
true)
67 ->setComment(
"Check only blocks that have a CapId for which a mask is defined.");
69 ->setComment(
"Target directory in the DQM file. Will be created if not existing.");
71 descriptions.
add(
"l1tMP7ZeroSupp", desc);
89 std::string summaryTitleText =
"Zero suppression validation summary";
92 sizeTitleText =
"FED readout ";
94 summaryTitleText = summaryTitleText +
", caption id " + std::to_string(
id);
95 sizeTitleText =
"cumulated caption id " + std::to_string(
id) +
" block ";
142 "readoutSizeZSExpected",
"Expected " + sizeTitleText +
"size with zero suppression", 100, 0,
maxFedReadoutSize_);
148 edm::LogInfo(
"L1TDQM") <<
"L1TMP7ZeroSupp: analyze..." << std::endl;
153 if (!
feds.isValid()) {
154 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
165 std::map<unsigned int, bool> evtGood;
170 unsigned valid_count = 0;
174 unsigned int fedDataSize = l1tRcd.
size();
175 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
176 std::map<unsigned int, unsigned int> readoutSizeZSMap;
177 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
182 readoutSizeNoZSMap[
id] = 0;
183 readoutSizeZSMap[
id] = 0;
184 readoutSizeZSExpectedMap[
id] = 0;
187 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
191 if (l1tRcd.
size() > 0) {
192 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID "
200 const unsigned char*
data = l1tRcd.
data();
205 <<
" Trigger type " <<
header.triggerType() <<
" L1 event ID " <<
header.lvl1ID()
206 <<
" BX Number " <<
header.bxID() <<
" FED source " <<
header.sourceID() <<
" FED version "
214 if (trailer.
check()) {
216 <<
" Length " << trailer.
fragmentLength() <<
" CRC " << trailer.
crc() <<
" Status "
228 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
236 auto payload64 =
amc.data();
237 auto start = (
const uint32_t*)payload64.get();
245 std::unique_ptr<l1t::Block>
block;
248 std::cout <<
">>> check zero suppression for block <<<" << std::endl
249 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') <<
block->header().raw() <<
std::dec
250 <<
" (ID " <<
block->header().getID() <<
", size " <<
block->header().getSize() <<
", CapID 0x"
251 << std::hex << std::setw(2) << std::setfill(
'0') <<
block->header().getCapID() <<
", flags 0x"
252 << std::hex << std::setw(2) << std::setfill(
'0') <<
block->header().getFlags() <<
")" <<
std::dec
254 for (
const auto&
word :
block->payload()) {
255 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec << std::endl;
259 unsigned int blockCapId =
block->header().getCapID();
260 unsigned int blockSize =
block->header().getSize() * 4;
261 unsigned int blockHeaderSize =
sizeof(
block->header().raw());
262 unsigned int blockHeaderFlags =
block->header().getFlags();
264 bool blockZsFlagSet =
266 bool dataInvertFlagSet =
271 bool capIdDefined =
false;
293 auto totalBlockSize = blockHeaderSize;
295 totalBlockSize += blockSize;
297 auto totalBlockSizeExpected = totalBlockSize;
298 auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
300 auto bxBlocks =
block->getBxBlocks(6, newZsFlagSet);
303 bool allToSuppress =
true;
304 for (
const auto& bxBlock : bxBlocks) {
305 bool toSuppress =
false;
306 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
309 unsigned int wordcounter = 0;
310 unsigned int wordsum = 0;
311 for (
const auto&
word : bxBlock.payload()) {
312 if (dataInvertFlagSet) {
313 wordsum +=
masks_[blockCapId].at(wordcounter % 6) & (~
word);
315 wordsum +=
masks_[blockCapId].at(wordcounter % 6) &
word;
318 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec <<
", maskword"
319 << wordcounter % 6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
320 <<
masks_[blockCapId].at(wordcounter % 6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
324 std::cout <<
"wordsum not 0: this BX block should be kept" << std::endl;
334 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
338 allToSuppress = allToSuppress && toSuppress;
343 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
357 unsigned int totalBxBlockSize =
358 bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
360 if (toSuppress && bxZsFlagSet) {
362 std::cout <<
"GOOD BX block with ZS flag true" << std::endl;
367 }
else if (!toSuppress && !bxZsFlagSet) {
369 std::cout <<
"GOOD BX block with ZS flag false" << std::endl;
370 totalBlockSize += totalBxBlockSize;
371 totalBlockSizeExpected += totalBxBlockSize;
376 }
else if (!toSuppress && bxZsFlagSet) {
378 std::cout <<
"BAD BX block with ZS flag true" << std::endl;
379 totalBlockSizeExpected += totalBxBlockSize;
390 evtGood[blockCapId] =
false;
394 std::cout <<
"BAD BX block with ZS flag false" << std::endl;
395 totalBlockSize += totalBxBlockSize;
406 evtGood[blockCapId] =
false;
412 readoutSizeNoZSMap[
maxMasks_] += totalBlockSizeNoZS;
414 readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
418 if (allToSuppress && blockZsFlagSet) {
420 std::cout <<
"GOOD block with ZS flag true" << std::endl;
425 }
else if (!allToSuppress && !blockZsFlagSet) {
427 std::cout <<
"GOOD block with ZS flag false" << std::endl;
429 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
430 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
433 readoutSizeZSMap[blockCapId] += totalBlockSize;
434 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
436 }
else if (!allToSuppress && blockZsFlagSet) {
438 std::cout <<
"BAD block with ZS flag true" << std::endl;
443 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
450 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
451 evtGood[blockCapId] =
false;
455 std::cout <<
"BAD block with ZS flag false" << std::endl;
460 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
467 readoutSizeZSMap[blockCapId] += totalBlockSize;
468 evtGood[blockCapId] =
false;
474 std::cout <<
"FED data size: " << fedDataSize <<
" bytes" << std::endl;
475 std::cout <<
"Payload size no ZS: " << readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
476 std::cout <<
"Payload size ZS: " << readoutSizeZSMap[
maxMasks_] <<
" bytes" << std::endl;
477 std::cout <<
"Payload size expected ZS: " << readoutSizeZSExpectedMap[
maxMasks_] <<
" bytes" << std::endl;
478 std::cout <<
"Filled readout size ZS with headers: "
479 << readoutSizeZSMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
480 std::cout <<
"Filled expected readout size ZS with headers: "
481 << readoutSizeZSExpectedMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes"