152 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
163 std::map<unsigned int, bool> evtGood;
165 for (
const auto &
id: definedMaskCapIds_) {
168 unsigned valid_count = 0;
172 unsigned int fedDataSize = l1tRcd.
size();
173 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
174 std::map<unsigned int, unsigned int> readoutSizeZSMap;
175 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
179 for (
const auto &
id: definedMaskCapIds_) {
180 readoutSizeNoZSMap[
id] = 0;
181 readoutSizeZSMap[
id] = 0;
182 readoutSizeZSExpectedMap[
id] = 0;
185 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
188 if (l1tRcd.
size() > 0) {
189 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " <<
fedId <<
".";
196 const unsigned char *
data = l1tRcd.
data();
200 edm::LogInfo(
"L1TDQM") <<
"Found SLink header:" <<
" Trigger type " <<
header.triggerType() <<
" L1 event ID " <<
header.lvl1ID() <<
" BX Number " <<
header.bxID() <<
" FED source " <<
header.sourceID() <<
" FED version " <<
header.version();
207 if (trailer.check()) {
208 edm::LogInfo(
"L1TDQM") <<
"Found SLink trailer:" <<
" Length " << trailer.fragmentLength() <<
" CRC " << trailer.crc() <<
" Status " << trailer.evtStatus() <<
" Throttling bits " << trailer.ttsBits();
220 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
228 auto payload64 =
amc.data();
229 auto start = (
const uint32_t*) payload64.get();
237 std::unique_ptr<l1t::Block>
block;
238 while ((block = payload->getBlock()) !=
nullptr) {
240 std::cout <<
">>> check zero suppression for block <<<" << std::endl
241 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 242 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
243 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
244 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
246 for (
const auto& word: block->payload()) {
247 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
251 unsigned int blockCapId = block->header().getCapID();
252 unsigned int blockSize = block->header().getSize() * 4;
253 unsigned int blockHeaderSize =
sizeof(block->header().raw());
254 unsigned int blockHeaderFlags = block->header().getFlags();
256 bool blockZsFlagSet = newZsFlagSet ?
true : ((blockHeaderFlags &
zsFlagMask_) != 0);
257 bool dataInvertFlagSet = newZsFlagSet && ((blockHeaderFlags &
dataInvFlagMask_) != 0);
262 bool capIdDefined =
false;
275 auto totalBlockSize = blockHeaderSize;
277 totalBlockSize += blockSize;
279 auto totalBlockSizeExpected = totalBlockSize;
280 auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
282 auto bxBlocks = block->getBxBlocks(6, newZsFlagSet);
285 bool allToSuppress =
true;
286 for (
const auto& bxBlock: bxBlocks) {
287 bool toSuppress =
false;
288 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
291 unsigned int wordcounter = 0;
292 unsigned int wordsum = 0;
293 for (
const auto& word: bxBlock.payload()) {
294 if (dataInvertFlagSet) {
295 wordsum +=
masks_[blockCapId].at(wordcounter%6) & (~word);
297 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
300 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 301 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
302 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
306 std::cout <<
"wordsum not 0: this BX block should be kept" << std::endl;
316 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
320 allToSuppress = allToSuppress && toSuppress;
325 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
339 unsigned int totalBxBlockSize = bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
341 if (toSuppress && bxZsFlagSet) {
347 }
else if (!toSuppress && !bxZsFlagSet) {
349 totalBlockSize += totalBxBlockSize;
350 totalBlockSizeExpected += totalBxBlockSize;
355 }
else if (!toSuppress && bxZsFlagSet) {
357 totalBlockSizeExpected += totalBxBlockSize;
368 evtGood[blockCapId] =
false;
372 totalBlockSize += totalBxBlockSize;
383 evtGood[blockCapId] =
false;
389 readoutSizeNoZSMap[
maxMasks_] += totalBlockSizeNoZS;
391 readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
395 if (allToSuppress && blockZsFlagSet) {
401 }
else if (!allToSuppress && !blockZsFlagSet) {
404 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
405 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
408 readoutSizeZSMap[blockCapId] += totalBlockSize;
409 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
411 }
else if (!allToSuppress && blockZsFlagSet) {
417 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
424 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
425 evtGood[blockCapId] =
false;
433 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
440 readoutSizeZSMap[blockCapId] += totalBlockSize;
441 evtGood[blockCapId] =
false;
447 std::cout <<
"FED data size: " << fedDataSize <<
" bytes" << std::endl;
448 std::cout <<
"Payload size no ZS: " << readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
449 std::cout <<
"Payload size ZS: " << readoutSizeZSMap[
maxMasks_] <<
" bytes" << std::endl;
450 std::cout <<
"Payload size expected ZS: " << readoutSizeZSExpectedMap[
maxMasks_] <<
" bytes" << std::endl;
451 std::cout <<
"Filled readout size ZS with headers: " << readoutSizeZSMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
452 std::cout <<
"Filled expected readout size ZS with headers: " << readoutSizeZSExpectedMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
457 for (
const auto &
id: definedMaskCapIds_) {
464 if (evtGood[maxMasks_]) {
470 for (
const auto &
id: definedMaskCapIds_) {
std::vector< amc::Packet > payload() const
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
size_t size() const
Lenght of the data buffer in bytes.
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
std::vector< unsigned int > definedMaskCapIds_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
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]
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::vector< int > fedIds_
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_