Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:10:41

0001 #include "DQM/L1TMonitor/interface/L1TMP7ZeroSupp.h"
0002 
0003 const unsigned int L1TMP7ZeroSupp::maxMasks_ = 16;
0004 
0005 L1TMP7ZeroSupp::L1TMP7ZeroSupp(const edm::ParameterSet& ps)
0006     : fedDataToken_(consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawData"))),
0007       zsEnabled_(ps.getUntrackedParameter<bool>("zsEnabled")),
0008       fedIds_(ps.getParameter<std::vector<int>>("fedIds")),
0009       slinkHeaderSize_(ps.getUntrackedParameter<int>("lenSlinkHeader")),
0010       slinkTrailerSize_(ps.getUntrackedParameter<int>("lenSlinkTrailer")),
0011       amc13HeaderSize_(ps.getUntrackedParameter<int>("lenAMC13Header")),
0012       amc13TrailerSize_(ps.getUntrackedParameter<int>("lenAMC13Trailer")),
0013       amcHeaderSize_(ps.getUntrackedParameter<int>("lenAMCHeader")),
0014       amcTrailerSize_(ps.getUntrackedParameter<int>("lenAMCTrailer")),
0015       newZsFlagMask_(ps.getUntrackedParameter<int>("newZsFlagMask")),
0016       zsFlagMask_(ps.getUntrackedParameter<int>("zsFlagMask")),
0017       dataInvFlagMask_(ps.getUntrackedParameter<int>("dataInvFlagMask")),
0018       maxFedReadoutSize_(ps.getUntrackedParameter<int>("maxFEDReadoutSize")),
0019       checkOnlyCapIdsWithMasks_(ps.getUntrackedParameter<bool>("checkOnlyCapIdsWithMasks")),
0020       monitorDir_(ps.getUntrackedParameter<std::string>("monitorDir")),
0021       verbose_(ps.getUntrackedParameter<bool>("verbose")) {
0022   std::vector<int> onesMask(6, 0xffffffff);
0023   masks_.reserve(maxMasks_);
0024   for (unsigned int i = 0; i < maxMasks_; ++i) {
0025     std::string maskCapIdStr{"maskCapId" + std::to_string(i)};
0026     masks_.push_back(ps.getUntrackedParameter<std::vector<int>>(maskCapIdStr, onesMask));
0027     // which masks are defined?
0028     if (ps.exists(maskCapIdStr)) {
0029       definedMaskCapIds_.push_back(i);
0030     }
0031   }
0032   if (verbose_) {
0033     // check masks
0034     std::cout << "masks" << std::endl;
0035     for (unsigned int i = 0; i < maxMasks_; ++i) {
0036       std::cout << "caption ID" << i << ":" << std::endl;
0037       for (const auto& maskIt : masks_.at(i)) {
0038         std::cout << std::hex << std::setw(8) << std::setfill('0') << maskIt << std::dec << std::endl;
0039       }
0040     }
0041     std::cout << "----------" << std::endl;
0042   }
0043 }
0044 
0045 L1TMP7ZeroSupp::~L1TMP7ZeroSupp() = default;
0046 
0047 void L1TMP7ZeroSupp::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0048   edm::ParameterSetDescription desc;
0049   desc.add<edm::InputTag>("rawData");
0050   desc.add<std::vector<int>>("fedIds")->setComment("FED ids to analyze.");
0051   desc.addUntracked<bool>("zsEnabled", true)->setComment("MP7 zero suppression is enabled.");
0052   desc.addUntracked<int>("lenSlinkHeader", 8)->setComment("Number of Slink header bytes.");
0053   desc.addUntracked<int>("lenSlinkTrailer", 8)->setComment("Number of Slink trailer bytes.");
0054   desc.addUntracked<int>("lenAMC13Header", 8)->setComment("Number of AMC13 header bytes.");
0055   desc.addUntracked<int>("lenAMC13Trailer", 8)->setComment("Number of AMC13 trailer bytes.");
0056   desc.addUntracked<int>("lenAMCHeader", 8)->setComment("Number of AMC header bytes.");
0057   desc.addUntracked<int>("lenAMCTrailer", 0)->setComment("Number of AMC trailer bytes.");
0058   desc.addUntracked<int>("zsFlagMask", 0x1)->setComment("Zero suppression flag mask.");
0059   desc.addUntracked<int>("newZsFlagMask", 0x2)->setComment("Per-BX zero suppression flag mask.");
0060   desc.addUntracked<int>("dataInvFlagMask", 0x1)->setComment("Data inversion flag mask.");
0061   desc.addUntracked<int>("maxFEDReadoutSize", 10000)->setComment("Maximal FED readout size histogram x-axis value.");
0062   for (unsigned int i = 0; i < maxMasks_; ++i) {
0063     desc.addOptionalUntracked<std::vector<int>>("maskCapId" + std::to_string(i))
0064         ->setComment("ZS mask for caption id " + std::to_string(i) + ".");
0065   }
0066   desc.addUntracked<bool>("checkOnlyCapIdsWithMasks", true)
0067       ->setComment("Check only blocks that have a CapId for which a mask is defined.");
0068   desc.addUntracked<std::string>("monitorDir", "")
0069       ->setComment("Target directory in the DQM file. Will be created if not existing.");
0070   desc.addUntracked<bool>("verbose", false);
0071   descriptions.add("l1tMP7ZeroSupp", desc);
0072 }
0073 
0074 void L1TMP7ZeroSupp::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run&, const edm::EventSetup&) {
0075   // overall summary
0076   ibooker.setCurrentFolder(monitorDir_);
0077   bookCapIdHistograms(ibooker, maxMasks_);
0078   capIds_ = ibooker.book1D("capIds", "Caption ids found in data", maxMasks_, 0, maxMasks_);
0079   capIds_->setAxisTitle("caption id", 1);
0080 
0081   // per caption id subdirectories
0082   for (const auto& id : definedMaskCapIds_) {
0083     ibooker.setCurrentFolder(monitorDir_ + "/CapId" + std::to_string(id));
0084     bookCapIdHistograms(ibooker, id);
0085   }
0086 }
0087 
0088 void L1TMP7ZeroSupp::bookCapIdHistograms(DQMStore::IBooker& ibooker, const unsigned int& id) {
0089   std::string summaryTitleText = "Zero suppression validation summary";
0090   std::string sizeTitleText;
0091   if (id == maxMasks_) {
0092     sizeTitleText = "FED readout ";
0093   } else {
0094     summaryTitleText = summaryTitleText + ", caption id " + std::to_string(id);
0095     sizeTitleText = "cumulated caption id " + std::to_string(id) + " block ";
0096   }
0097 
0098   zeroSuppValMap_[id] = ibooker.book1D("zeroSuppVal", summaryTitleText, (int)NBINLABELS, 0, (int)NBINLABELS);
0099   zeroSuppValMap_[id]->setAxisTitle("ZS status", 1);
0100   zeroSuppValMap_[id]->setBinLabel(EVTS + 1, "events", 1);
0101   zeroSuppValMap_[id]->setBinLabel(EVTSGOOD + 1, "good events", 1);
0102   zeroSuppValMap_[id]->setBinLabel(EVTSBAD + 1, "bad events", 1);
0103   zeroSuppValMap_[id]->setBinLabel(BLOCKS + 1, "blocks", 1);
0104   zeroSuppValMap_[id]->setBinLabel(ZSBLKSGOOD + 1, "good blocks", 1);
0105   zeroSuppValMap_[id]->setBinLabel(ZSBLKSBAD + 1, "bad blocks", 1);
0106   zeroSuppValMap_[id]->setBinLabel(ZSBLKSBADFALSEPOS + 1, "false pos.", 1);
0107   zeroSuppValMap_[id]->setBinLabel(ZSBLKSBADFALSENEG + 1, "false neg.", 1);
0108   zeroSuppValMap_[id]->setBinLabel(BXBLOCKS + 1, "BX blocks", 1);
0109   zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSGOOD + 1, "good BX blocks", 1);
0110   zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBAD + 1, "bad BX blocks", 1);
0111   zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBADFALSEPOS + 1, "BX false pos.", 1);
0112   zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBADFALSENEG + 1, "BX false neg.", 1);
0113 
0114   errorSummaryNumMap_[id] = ibooker.book1D("errorSummaryNum", summaryTitleText, (int)RNBINLABELS, 0, (int)RNBINLABELS);
0115   errorSummaryNumMap_[id]->setBinLabel(REVTS + 1, "bad events", 1);
0116   errorSummaryNumMap_[id]->setBinLabel(RBLKS + 1, "bad blocks", 1);
0117   errorSummaryNumMap_[id]->setBinLabel(RBLKSFALSEPOS + 1, "false pos.", 1);
0118   errorSummaryNumMap_[id]->setBinLabel(RBLKSFALSENEG + 1, "false neg.", 1);
0119   errorSummaryNumMap_[id]->setBinLabel(RBXBLKS + 1, "bad BX blocks", 1);
0120   errorSummaryNumMap_[id]->setBinLabel(RBXBLKSFALSEPOS + 1, "BX false pos.", 1);
0121   errorSummaryNumMap_[id]->setBinLabel(RBXBLKSFALSENEG + 1, "BX false neg.", 1);
0122 
0123   errorSummaryDenMap_[id] = ibooker.book1D("errorSummaryDen", "denominators", (int)RNBINLABELS, 0, (int)RNBINLABELS);
0124   errorSummaryDenMap_[id]->setBinLabel(REVTS + 1, "# events", 1);
0125   errorSummaryDenMap_[id]->setBinLabel(RBLKS + 1, "# blocks", 1);
0126   errorSummaryDenMap_[id]->setBinLabel(RBLKSFALSEPOS + 1, "# blocks", 1);
0127   errorSummaryDenMap_[id]->setBinLabel(RBLKSFALSENEG + 1, "# blocks", 1);
0128   errorSummaryDenMap_[id]->setBinLabel(RBXBLKS + 1, "# BX blocks", 1);
0129   errorSummaryDenMap_[id]->setBinLabel(RBXBLKSFALSEPOS + 1, "# BX blocks", 1);
0130   errorSummaryDenMap_[id]->setBinLabel(RBXBLKSFALSENEG + 1, "# BX blocks", 1);
0131   // Setting canExtend to false is needed to get the correct behaviour when running multithreaded.
0132   // Otherwise, when merging the histgrams of the threads, TH1::Merge sums bins that have the same label in one bin.
0133   // This needs to come after the calls to setBinLabel.
0134   errorSummaryDenMap_[id]->getTH1F()->GetXaxis()->SetCanExtend(false);
0135 
0136   readoutSizeNoZSMap_[id] = ibooker.book1D("readoutSize", sizeTitleText + "size", 100, 0, maxFedReadoutSize_);
0137   readoutSizeNoZSMap_[id]->setAxisTitle("size (byte)", 1);
0138   readoutSizeZSMap_[id] =
0139       ibooker.book1D("readoutSizeZS", sizeTitleText + "size with zero suppression", 100, 0, maxFedReadoutSize_);
0140   readoutSizeZSMap_[id]->setAxisTitle("size (byte)", 1);
0141   readoutSizeZSExpectedMap_[id] = ibooker.book1D(
0142       "readoutSizeZSExpected", "Expected " + sizeTitleText + "size with zero suppression", 100, 0, maxFedReadoutSize_);
0143   readoutSizeZSExpectedMap_[id]->setAxisTitle("size (byte)", 1);
0144 }
0145 
0146 void L1TMP7ZeroSupp::analyze(const edm::Event& e, const edm::EventSetup& c) {
0147   if (verbose_)
0148     edm::LogInfo("L1TDQM") << "L1TMP7ZeroSupp: analyze..." << std::endl;
0149 
0150   edm::Handle<FEDRawDataCollection> feds;
0151   e.getByToken(fedDataToken_, feds);
0152 
0153   if (!feds.isValid()) {
0154     edm::LogError("L1TDQM") << "Cannot analyse: no FEDRawDataCollection found";
0155     return;
0156   }
0157 
0158   zeroSuppValMap_[maxMasks_]->Fill(EVTS);
0159   errorSummaryDenMap_[maxMasks_]->Fill(REVTS);
0160   for (const auto& id : definedMaskCapIds_) {
0161     zeroSuppValMap_[id]->Fill(EVTS);
0162     errorSummaryDenMap_[id]->Fill(REVTS);
0163   }
0164 
0165   std::map<unsigned int, bool> evtGood;
0166   evtGood[maxMasks_] = true;
0167   for (const auto& id : definedMaskCapIds_) {
0168     evtGood[id] = true;
0169   }
0170   unsigned valid_count = 0;
0171   for (const auto& fedId : fedIds_) {
0172     const FEDRawData& l1tRcd = feds->FEDData(fedId);
0173 
0174     unsigned int fedDataSize = l1tRcd.size();
0175     std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
0176     std::map<unsigned int, unsigned int> readoutSizeZSMap;
0177     std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
0178     readoutSizeNoZSMap[maxMasks_] = 0;
0179     readoutSizeZSMap[maxMasks_] = 0;
0180     readoutSizeZSExpectedMap[maxMasks_] = 0;
0181     for (const auto& id : definedMaskCapIds_) {
0182       readoutSizeNoZSMap[id] = 0;
0183       readoutSizeZSMap[id] = 0;
0184       readoutSizeZSExpectedMap[id] = 0;
0185     }
0186 
0187     edm::LogInfo("L1TDQM") << "Found FEDRawDataCollection with ID " << fedId << " and size " << l1tRcd.size();
0188 
0189     if ((int)l1tRcd.size() < slinkHeaderSize_ + slinkTrailerSize_ + amc13HeaderSize_ + amc13TrailerSize_ +
0190                                  amcHeaderSize_ + amcTrailerSize_) {
0191       if (l1tRcd.size() > 0) {
0192         edm::LogError("L1TDQM") << "Cannot analyse: invalid L1T raw data (size = " << l1tRcd.size() << ") for ID "
0193                                 << fedId << ".";
0194       }
0195       continue;
0196     } else {
0197       valid_count++;
0198     }
0199 
0200     const unsigned char* data = l1tRcd.data();
0201     FEDHeader header(data);
0202 
0203     if (header.check()) {
0204       edm::LogInfo("L1TDQM") << "Found SLink header:"
0205                              << " Trigger type " << header.triggerType() << " L1 event ID " << header.lvl1ID()
0206                              << " BX Number " << header.bxID() << " FED source " << header.sourceID() << " FED version "
0207                              << header.version();
0208     } else {
0209       edm::LogWarning("L1TDQM") << "Did not find a SLink header!";
0210     }
0211 
0212     FEDTrailer trailer(data + (l1tRcd.size() - slinkTrailerSize_));
0213 
0214     if (trailer.check()) {
0215       edm::LogInfo("L1TDQM") << "Found SLink trailer:"
0216                              << " Length " << trailer.fragmentLength() << " CRC " << trailer.crc() << " Status "
0217                              << trailer.evtStatus() << " Throttling bits " << trailer.ttsBits();
0218     } else {
0219       edm::LogWarning("L1TDQM") << "Did not find a SLink trailer!";
0220     }
0221 
0222     amc13::Packet packet;
0223     if (!packet.parse((const uint64_t*)data,
0224                       (const uint64_t*)(data + slinkHeaderSize_),
0225                       (l1tRcd.size() - slinkHeaderSize_ - slinkTrailerSize_) / 8,
0226                       header.lvl1ID(),
0227                       header.bxID())) {
0228       edm::LogError("L1TDQM") << "Could not extract AMC13 Packet.";
0229       return;
0230     }
0231 
0232     for (auto& amc : packet.payload()) {
0233       if (amc.size() == 0)
0234         continue;
0235 
0236       auto payload64 = amc.data();
0237       auto start = (const uint32_t*)payload64.get();
0238       // Want to have payload size in 32 bit words, but AMC measures
0239       // it in 64 bit words -> factor 2.
0240       const uint32_t* end = start + (amc.size() * 2);
0241 
0242       auto payload = std::make_unique<l1t::MP7Payload>(start, end, false);
0243 
0244       // getBlock() returns a non-null unique_ptr on success
0245       std::unique_ptr<l1t::Block> block;
0246       while ((block = payload->getBlock()) != nullptr) {
0247         if (verbose_) {
0248           std::cout << ">>> check zero suppression for block <<<" << std::endl
0249                     << "hdr:  " << std::hex << std::setw(8) << std::setfill('0') << block->header().raw() << std::dec
0250                     << " (ID " << block->header().getID() << ", size " << block->header().getSize() << ", CapID 0x"
0251                     << std::hex << std::setw(2) << std::setfill('0') << block->header().getCapID() << ", flags 0x"
0252                     << std::hex << std::setw(2) << std::setfill('0') << block->header().getFlags() << ")" << std::dec
0253                     << std::endl;
0254           for (const auto& word : block->payload()) {
0255             std::cout << "data: " << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << std::endl;
0256           }
0257         }
0258 
0259         unsigned int blockCapId = block->header().getCapID();
0260         unsigned int blockSize = block->header().getSize() * 4;  // times 4 to get the size in byte
0261         unsigned int blockHeaderSize = sizeof(block->header().raw());
0262         unsigned int blockHeaderFlags = block->header().getFlags();
0263         bool newZsFlagSet = ((blockHeaderFlags & newZsFlagMask_) != 0);  // use the per-BX ZS
0264         bool blockZsFlagSet =
0265             newZsFlagSet ? true : ((blockHeaderFlags & zsFlagMask_) != 0);  // ZS validation flag for whole block
0266         bool dataInvertFlagSet =
0267             newZsFlagSet && ((blockHeaderFlags & dataInvFlagMask_) != 0);  // invert the data before applying the mask
0268 
0269         capIds_->Fill(blockCapId);
0270 
0271         bool capIdDefined = false;
0272         if (zeroSuppValMap_.find(blockCapId) != zeroSuppValMap_.end()) {
0273           capIdDefined = true;
0274         }
0275 
0276         // Only check blocks with a CapId that has a defined ZS mask.
0277         if (checkOnlyCapIdsWithMasks_ and not capIdDefined) {
0278           continue;
0279         }
0280 
0281         // fill the denominator histograms
0282         zeroSuppValMap_[maxMasks_]->Fill(BLOCKS);
0283         errorSummaryDenMap_[maxMasks_]->Fill(RBLKS);
0284         errorSummaryDenMap_[maxMasks_]->Fill(RBLKSFALSEPOS);
0285         errorSummaryDenMap_[maxMasks_]->Fill(RBLKSFALSENEG);
0286         if (capIdDefined) {
0287           zeroSuppValMap_[blockCapId]->Fill(BLOCKS);
0288           errorSummaryDenMap_[blockCapId]->Fill(RBLKS);
0289           errorSummaryDenMap_[blockCapId]->Fill(RBLKSFALSEPOS);
0290           errorSummaryDenMap_[blockCapId]->Fill(RBLKSFALSENEG);
0291         }
0292 
0293         auto totalBlockSize = blockHeaderSize;
0294         if (!newZsFlagSet) {
0295           totalBlockSize += blockSize;
0296         }
0297         auto totalBlockSizeExpected = totalBlockSize;
0298         auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
0299 
0300         auto bxBlocks = block->getBxBlocks(6, newZsFlagSet);  // 6 32 bit MP7 payload words per BX
0301 
0302         // check all BX blocks
0303         bool allToSuppress = true;
0304         for (const auto& bxBlock : bxBlocks) {
0305           bool toSuppress = false;
0306           bool bxZsFlagSet = ((bxBlock.header().getFlags() & zsFlagMask_) != 0);  // ZS validation flag
0307 
0308           // check if this bxblock should be suppressed
0309           unsigned int wordcounter = 0;
0310           unsigned int wordsum = 0;
0311           for (const auto& word : bxBlock.payload()) {
0312             if (dataInvertFlagSet) {
0313               wordsum += masks_[blockCapId].at(wordcounter % 6) & (~word);
0314             } else {
0315               wordsum += masks_[blockCapId].at(wordcounter % 6) & word;
0316             }
0317             if (verbose_) {
0318               std::cout << "word: " << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << ", maskword"
0319                         << wordcounter % 6 << ": " << std::hex << std::setw(8) << std::setfill('0')
0320                         << masks_[blockCapId].at(wordcounter % 6) << std::dec << ", wordsum: " << wordsum << std::endl;
0321             }
0322             if (wordsum > 0) {
0323               if (verbose_) {
0324                 std::cout << "wordsum not 0: this BX block should be kept" << std::endl;
0325               }
0326               break;
0327             }
0328             ++wordcounter;
0329           }
0330           // the sum of payload words must be 0 for correct ZS
0331           if (wordsum == 0 && zsEnabled_) {
0332             toSuppress = true;
0333             if (verbose_) {
0334               std::cout << "wordsum == 0: this BX block should be zero suppressed" << std::endl;
0335             }
0336           }
0337           // update the overall block status
0338           allToSuppress = allToSuppress && toSuppress;
0339 
0340           // only fill the BX related things for the per-BX ZS
0341           if (newZsFlagSet) {
0342             // the ZS flag of the block is the AND of all BX block ZS flags
0343             blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
0344 
0345             // fill the BX related bins of the denominator histogram
0346             zeroSuppValMap_[maxMasks_]->Fill(BXBLOCKS);
0347             errorSummaryDenMap_[maxMasks_]->Fill(RBXBLKS);
0348             errorSummaryDenMap_[maxMasks_]->Fill(RBXBLKSFALSEPOS);
0349             errorSummaryDenMap_[maxMasks_]->Fill(RBXBLKSFALSENEG);
0350             if (capIdDefined) {
0351               zeroSuppValMap_[blockCapId]->Fill(BXBLOCKS);
0352               errorSummaryDenMap_[blockCapId]->Fill(RBXBLKS);
0353               errorSummaryDenMap_[blockCapId]->Fill(RBXBLKSFALSEPOS);
0354               errorSummaryDenMap_[blockCapId]->Fill(RBXBLKSFALSENEG);
0355             }
0356 
0357             unsigned int totalBxBlockSize =
0358                 bxBlock.getSize() * 4 + sizeof(bxBlock.header().raw());  // times 4 to get the size in byte
0359             // check if zero suppression flag agrees for the BX block
0360             if (toSuppress && bxZsFlagSet) {
0361               if (verbose_)
0362                 std::cout << "GOOD BX block with ZS flag true" << std::endl;
0363               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSGOOD);
0364               if (capIdDefined) {
0365                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSGOOD);
0366               }
0367             } else if (!toSuppress && !bxZsFlagSet) {
0368               if (verbose_)
0369                 std::cout << "GOOD BX block with ZS flag false" << std::endl;
0370               totalBlockSize += totalBxBlockSize;
0371               totalBlockSizeExpected += totalBxBlockSize;
0372               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSGOOD);
0373               if (capIdDefined) {
0374                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSGOOD);
0375               }
0376             } else if (!toSuppress && bxZsFlagSet) {
0377               if (verbose_)
0378                 std::cout << "BAD BX block with ZS flag true" << std::endl;
0379               totalBlockSizeExpected += totalBxBlockSize;
0380               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSBAD);
0381               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSBADFALSEPOS);
0382               errorSummaryNumMap_[maxMasks_]->Fill(RBXBLKS);
0383               errorSummaryNumMap_[maxMasks_]->Fill(RBXBLKSFALSEPOS);
0384               evtGood[maxMasks_] = false;
0385               if (capIdDefined) {
0386                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBAD);
0387                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBADFALSEPOS);
0388                 errorSummaryNumMap_[blockCapId]->Fill(RBXBLKS);
0389                 errorSummaryNumMap_[blockCapId]->Fill(RBXBLKSFALSEPOS);
0390                 evtGood[blockCapId] = false;
0391               }
0392             } else {
0393               if (verbose_)
0394                 std::cout << "BAD BX block with ZS flag false" << std::endl;
0395               totalBlockSize += totalBxBlockSize;
0396               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSBAD);
0397               zeroSuppValMap_[maxMasks_]->Fill(ZSBXBLKSBADFALSENEG);
0398               errorSummaryNumMap_[maxMasks_]->Fill(RBXBLKS);
0399               errorSummaryNumMap_[maxMasks_]->Fill(RBXBLKSFALSENEG);
0400               evtGood[maxMasks_] = false;
0401               if (capIdDefined) {
0402                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBAD);
0403                 zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBADFALSENEG);
0404                 errorSummaryNumMap_[blockCapId]->Fill(RBXBLKS);
0405                 errorSummaryNumMap_[blockCapId]->Fill(RBXBLKSFALSENEG);
0406                 evtGood[blockCapId] = false;
0407               }
0408             }
0409           }
0410         }
0411 
0412         readoutSizeNoZSMap[maxMasks_] += totalBlockSizeNoZS;
0413         if (capIdDefined) {
0414           readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
0415         }
0416 
0417         // check if zero suppression flag agrees for the whole block
0418         if (allToSuppress && blockZsFlagSet) {
0419           if (verbose_)
0420             std::cout << "GOOD block with ZS flag true" << std::endl;
0421           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSGOOD);
0422           if (capIdDefined) {
0423             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSGOOD);
0424           }
0425         } else if (!allToSuppress && !blockZsFlagSet) {
0426           if (verbose_)
0427             std::cout << "GOOD block with ZS flag false" << std::endl;
0428           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSGOOD);
0429           readoutSizeZSMap[maxMasks_] += totalBlockSize;
0430           readoutSizeZSExpectedMap[maxMasks_] += totalBlockSizeExpected;
0431           if (capIdDefined) {
0432             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSGOOD);
0433             readoutSizeZSMap[blockCapId] += totalBlockSize;
0434             readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
0435           }
0436         } else if (!allToSuppress && blockZsFlagSet) {
0437           if (verbose_)
0438             std::cout << "BAD block with ZS flag true" << std::endl;
0439           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSBAD);
0440           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSBADFALSEPOS);
0441           errorSummaryNumMap_[maxMasks_]->Fill(RBLKS);
0442           errorSummaryNumMap_[maxMasks_]->Fill(RBLKSFALSEPOS);
0443           readoutSizeZSExpectedMap[maxMasks_] += totalBlockSizeExpected;
0444           evtGood[maxMasks_] = false;
0445           if (capIdDefined) {
0446             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBAD);
0447             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBADFALSEPOS);
0448             errorSummaryNumMap_[blockCapId]->Fill(RBLKS);
0449             errorSummaryNumMap_[blockCapId]->Fill(RBLKSFALSEPOS);
0450             readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
0451             evtGood[blockCapId] = false;
0452           }
0453         } else {
0454           if (verbose_)
0455             std::cout << "BAD block with ZS flag false" << std::endl;
0456           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSBAD);
0457           zeroSuppValMap_[maxMasks_]->Fill(ZSBLKSBADFALSENEG);
0458           errorSummaryNumMap_[maxMasks_]->Fill(RBLKS);
0459           errorSummaryNumMap_[maxMasks_]->Fill(RBLKSFALSENEG);
0460           readoutSizeZSMap[maxMasks_] += totalBlockSize;
0461           evtGood[maxMasks_] = false;
0462           if (capIdDefined) {
0463             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBAD);
0464             zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBADFALSENEG);
0465             errorSummaryNumMap_[blockCapId]->Fill(RBLKS);
0466             errorSummaryNumMap_[blockCapId]->Fill(RBLKSFALSENEG);
0467             readoutSizeZSMap[blockCapId] += totalBlockSize;
0468             evtGood[blockCapId] = false;
0469           }
0470         }
0471       }
0472     }
0473     if (verbose_) {
0474       std::cout << "FED data size: " << fedDataSize << " bytes" << std::endl;
0475       std::cout << "Payload size no ZS: " << readoutSizeNoZSMap[maxMasks_] << " bytes" << std::endl;
0476       std::cout << "Payload size ZS: " << readoutSizeZSMap[maxMasks_] << " bytes" << std::endl;
0477       std::cout << "Payload size expected ZS: " << readoutSizeZSExpectedMap[maxMasks_] << " bytes" << std::endl;
0478       std::cout << "Filled readout size ZS with headers: "
0479                 << readoutSizeZSMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_] << " bytes" << std::endl;
0480       std::cout << "Filled expected readout size ZS with headers: "
0481                 << readoutSizeZSExpectedMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_] << " bytes"
0482                 << std::endl;
0483     }
0484     readoutSizeNoZSMap_[maxMasks_]->Fill(fedDataSize);
0485     readoutSizeZSMap_[maxMasks_]->Fill(readoutSizeZSMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_]);
0486     readoutSizeZSExpectedMap_[maxMasks_]->Fill(readoutSizeZSExpectedMap[maxMasks_] + fedDataSize -
0487                                                readoutSizeNoZSMap[maxMasks_]);
0488     for (const auto& id : definedMaskCapIds_) {
0489       readoutSizeNoZSMap_[id]->Fill(readoutSizeNoZSMap[id]);
0490       readoutSizeZSMap_[id]->Fill(readoutSizeZSMap[id]);
0491       readoutSizeZSExpectedMap_[id]->Fill(readoutSizeZSExpectedMap[id]);
0492     }
0493   }
0494 
0495   if (evtGood[maxMasks_]) {
0496     zeroSuppValMap_[maxMasks_]->Fill(EVTSGOOD);
0497   } else {
0498     zeroSuppValMap_[maxMasks_]->Fill(EVTSBAD);
0499     errorSummaryNumMap_[maxMasks_]->Fill(REVTS);
0500   }
0501   for (const auto& id : definedMaskCapIds_) {
0502     if (evtGood[id]) {
0503       zeroSuppValMap_[id]->Fill(EVTSGOOD);
0504     } else {
0505       zeroSuppValMap_[id]->Fill(EVTSBAD);
0506       errorSummaryNumMap_[id]->Fill(REVTS);
0507     }
0508   }
0509 }