7 zsEnabled_(ps.getUntrackedParameter<
bool>(
"zsEnabled")),
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);
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.");
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.");
70 desc.addUntracked<
bool>(
"verbose",
false);
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;
173 unsigned int fedDataSize = l1tRcd.
size();
174 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
175 std::map<unsigned int, unsigned int> readoutSizeZSMap;
176 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
181 readoutSizeNoZSMap[
id] = 0;
182 readoutSizeZSMap[
id] = 0;
183 readoutSizeZSExpectedMap[
id] = 0;
186 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
190 if (l1tRcd.
size() > 0) {
191 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " 197 const unsigned char*
data = l1tRcd.
data();
202 <<
" Trigger type " <<
header.triggerType() <<
" L1 event ID " <<
header.lvl1ID()
203 <<
" BX Number " <<
header.bxID() <<
" FED source " <<
header.sourceID() <<
" FED version " 211 if (trailer.
check()) {
213 <<
" Length " << trailer.
fragmentLength() <<
" CRC " << trailer.
crc() <<
" Status " 225 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
233 auto payload64 =
amc.data();
234 auto start = (
const uint32_t*)payload64.get();
242 std::unique_ptr<l1t::Block>
block;
245 std::cout <<
">>> check zero suppression for block <<<" << std::endl
246 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') <<
block->header().raw() <<
std::dec 247 <<
" (ID " <<
block->header().getID() <<
", size " <<
block->header().getSize() <<
", CapID 0x" 248 << std::hex << std::setw(2) << std::setfill(
'0') <<
block->header().getCapID() <<
", flags 0x" 249 << std::hex << std::setw(2) << std::setfill(
'0') <<
block->header().getFlags() <<
")" <<
std::dec 251 for (
const auto&
word :
block->payload()) {
252 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec << std::endl;
256 unsigned int blockCapId =
block->header().getCapID();
257 unsigned int blockSize =
block->header().getSize() * 4;
258 unsigned int blockHeaderSize =
sizeof(
block->header().raw());
259 unsigned int blockHeaderFlags =
block->header().getFlags();
261 bool blockZsFlagSet =
263 bool dataInvertFlagSet =
268 bool capIdDefined =
false;
290 auto totalBlockSize = blockHeaderSize;
292 totalBlockSize += blockSize;
294 auto totalBlockSizeExpected = totalBlockSize;
295 auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
297 auto bxBlocks =
block->getBxBlocks(6, newZsFlagSet);
300 bool allToSuppress =
true;
301 for (
const auto& bxBlock : bxBlocks) {
302 bool toSuppress =
false;
303 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
306 unsigned int wordcounter = 0;
307 unsigned int wordsum = 0;
308 for (
const auto&
word : bxBlock.payload()) {
309 if (dataInvertFlagSet) {
310 wordsum +=
masks_[blockCapId].at(wordcounter % 6) & (~
word);
312 wordsum +=
masks_[blockCapId].at(wordcounter % 6) &
word;
315 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec <<
", maskword" 316 << wordcounter % 6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
317 <<
masks_[blockCapId].at(wordcounter % 6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
321 std::cout <<
"wordsum not 0: this BX block should be kept" << std::endl;
331 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
335 allToSuppress = allToSuppress && toSuppress;
340 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
354 unsigned int totalBxBlockSize =
355 bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
357 if (toSuppress && bxZsFlagSet) {
359 std::cout <<
"GOOD BX block with ZS flag true" << std::endl;
364 }
else if (!toSuppress && !bxZsFlagSet) {
366 std::cout <<
"GOOD BX block with ZS flag false" << std::endl;
367 totalBlockSize += totalBxBlockSize;
368 totalBlockSizeExpected += totalBxBlockSize;
373 }
else if (!toSuppress && bxZsFlagSet) {
375 std::cout <<
"BAD BX block with ZS flag true" << std::endl;
376 totalBlockSizeExpected += totalBxBlockSize;
387 evtGood[blockCapId] =
false;
391 std::cout <<
"BAD BX block with ZS flag false" << std::endl;
392 totalBlockSize += totalBxBlockSize;
403 evtGood[blockCapId] =
false;
409 readoutSizeNoZSMap[
maxMasks_] += totalBlockSizeNoZS;
411 readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
415 if (allToSuppress && blockZsFlagSet) {
417 std::cout <<
"GOOD block with ZS flag true" << std::endl;
422 }
else if (!allToSuppress && !blockZsFlagSet) {
424 std::cout <<
"GOOD block with ZS flag false" << std::endl;
426 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
427 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
430 readoutSizeZSMap[blockCapId] += totalBlockSize;
431 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
433 }
else if (!allToSuppress && blockZsFlagSet) {
435 std::cout <<
"BAD block with ZS flag true" << std::endl;
440 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
447 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
448 evtGood[blockCapId] =
false;
452 std::cout <<
"BAD block with ZS flag false" << std::endl;
457 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
464 readoutSizeZSMap[blockCapId] += totalBlockSize;
465 evtGood[blockCapId] =
false;
471 std::cout <<
"FED data size: " << fedDataSize <<
" bytes" << std::endl;
472 std::cout <<
"Payload size no ZS: " << readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
473 std::cout <<
"Payload size ZS: " << readoutSizeZSMap[
maxMasks_] <<
" bytes" << std::endl;
474 std::cout <<
"Payload size expected ZS: " << readoutSizeZSExpectedMap[
maxMasks_] <<
" bytes" << std::endl;
475 std::cout <<
"Filled readout size ZS with headers: " 476 << readoutSizeZSMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
477 std::cout <<
"Filled expected readout size ZS with headers: " 478 << readoutSizeZSExpectedMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes"
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
virtual void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken_
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
L1TMP7ZeroSupp(const edm::ParameterSet &ps)
size_t size() const
Lenght of the data buffer in bytes.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
T getUntrackedParameter(std::string const &, T const &) const
void bookCapIdHistograms(DQMStore::IBooker &ibooker, const unsigned int &id)
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
std::vector< unsigned int > definedMaskCapIds_
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
uint8_t evtStatus() const
Event fragment status information.
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)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~L1TMP7ZeroSupp() override
char data[epos_bytes_allocation]
std::vector< amc::Packet > payload() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::vector< int > fedIds_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_
bool check() const
Check that the trailer is OK.
bool checkOnlyCapIdsWithMasks_
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)