148 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
159 std::map<unsigned int, bool> evtGood;
161 for (
const auto &
id: definedMaskCapIds_) {
164 unsigned valid_count = 0;
168 unsigned int fedDataSize = l1tRcd.
size();
169 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
170 std::map<unsigned int, unsigned int> readoutSizeZSMap;
171 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
175 for (
const auto &
id: definedMaskCapIds_) {
176 readoutSizeNoZSMap[
id] = 0;
177 readoutSizeZSMap[
id] = 0;
178 readoutSizeZSExpectedMap[
id] = 0;
181 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
184 if (l1tRcd.
size() > 0) {
185 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " <<
fedId <<
".";
192 const unsigned char *
data = l1tRcd.
data();
196 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();
203 if (trailer.check()) {
204 edm::LogInfo(
"L1TDQM") <<
"Found SLink trailer:" <<
" Length " << trailer.lenght() <<
" CRC " << trailer.crc() <<
" Status " << trailer.evtStatus() <<
" Throttling bits " << trailer.ttsBits();
216 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
224 auto payload64 =
amc.data();
225 auto start = (
const uint32_t*) payload64.get();
233 std::unique_ptr<l1t::Block>
block;
234 while ((block = payload->getBlock()) !=
nullptr) {
236 std::cout <<
">>> check zero suppression for block <<<" << std::endl
237 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 238 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
239 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
240 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
242 for (
const auto& word: block->payload()) {
243 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
247 unsigned int blockCapId = block->header().getCapID();
248 unsigned int blockSize = block->header().getSize() * 4;
249 unsigned int blockHeaderSize =
sizeof(block->header().raw());
250 unsigned int blockHeaderFlags = block->header().getFlags();
252 bool blockZsFlagSet = newZsFlagSet ?
true : ((blockHeaderFlags &
zsFlagMask_) != 0);
253 bool dataInvertFlagSet = newZsFlagSet && ((blockHeaderFlags &
dataInvFlagMask_) != 0);
258 bool capIdDefined =
false;
271 auto totalBlockSize = blockHeaderSize;
273 totalBlockSize += blockSize;
276 auto bxBlocks = block->getBxBlocks(6, newZsFlagSet);
279 bool allToSuppress =
true;
280 for (
const auto& bxBlock: bxBlocks) {
281 bool toSuppress =
false;
282 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
285 unsigned int wordcounter = 0;
286 unsigned int wordsum = 0;
287 for (
const auto& word: bxBlock.payload()) {
288 if (dataInvertFlagSet) {
289 wordsum +=
masks_[blockCapId].at(wordcounter%6) & (~word);
291 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
294 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 295 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
296 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
307 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
311 allToSuppress = allToSuppress && toSuppress;
316 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
330 unsigned int totalBxBlockSize = bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
332 if (toSuppress && bxZsFlagSet) {
338 }
else if (!toSuppress && !bxZsFlagSet) {
344 }
else if (!toSuppress && bxZsFlagSet) {
346 totalBlockSize += totalBxBlockSize;
357 evtGood[blockCapId] =
false;
361 totalBlockSize += totalBxBlockSize;
372 evtGood[blockCapId] =
false;
378 readoutSizeNoZSMap[
maxMasks_] += totalBlockSize;
380 readoutSizeNoZSMap[blockCapId] += totalBlockSize;
384 if (allToSuppress && blockZsFlagSet) {
390 }
else if (!allToSuppress && !blockZsFlagSet) {
393 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
394 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
397 readoutSizeZSMap[blockCapId] += totalBlockSize;
398 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
400 }
else if (!allToSuppress && blockZsFlagSet) {
406 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
413 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
414 evtGood[blockCapId] =
false;
422 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
429 readoutSizeZSMap[blockCapId] += totalBlockSize;
430 evtGood[blockCapId] =
false;
438 for (
const auto &
id: definedMaskCapIds_) {
445 if (evtGood[maxMasks_]) {
451 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_
payload
payload postfix for testing
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_