142 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
153 std::map<unsigned int, bool> evtGood;
155 for (
const auto &
id: definedMaskCapIds_) {
158 unsigned valid_count = 0;
162 unsigned int fedDataSize = l1tRcd.
size();
163 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
164 std::map<unsigned int, unsigned int> readoutSizeZSMap;
165 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
169 for (
const auto &
id: definedMaskCapIds_) {
170 readoutSizeNoZSMap[
id] = 0;
171 readoutSizeZSMap[
id] = 0;
172 readoutSizeZSExpectedMap[
id] = 0;
175 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
178 if (l1tRcd.
size() > 0) {
179 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " <<
fedId <<
".";
186 const unsigned char *
data = l1tRcd.
data();
190 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();
197 if (trailer.check()) {
198 edm::LogInfo(
"L1TDQM") <<
"Found SLink trailer:" <<
" Length " << trailer.lenght() <<
" CRC " << trailer.crc() <<
" Status " << trailer.evtStatus() <<
" Throttling bits " << trailer.ttsBits();
210 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
218 auto payload64 =
amc.data();
219 const uint32_t *
start = (
const uint32_t*) payload64.get();
222 const uint32_t *
end = start + (
amc.size() * 2);
224 std::unique_ptr<l1t::Payload>
payload;
228 std::unique_ptr<l1t::Block>
block;
229 while ((block = payload->getBlock()).
get()) {
231 std::cout <<
">>> check zero suppression for block <<<" << std::endl
232 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 233 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
234 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
235 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
237 for (
const auto& word: block->payload()) {
238 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
242 unsigned int blockCapId = block->header().getCapID();
243 unsigned int blockSize = block->header().getSize() * 4;
244 unsigned int blockHeaderSize =
sizeof(block->header().raw());
245 bool zsFlagSet = ((block->header().getFlags() &
zsFlagMask_) != 0);
246 bool toSuppress =
false;
250 bool capIdDefined =
false;
263 auto totalBlockSize = blockSize + blockHeaderSize;
264 readoutSizeNoZSMap[
maxMasks_] += totalBlockSize;
266 readoutSizeNoZSMap[blockCapId] += totalBlockSize;
270 unsigned int wordcounter = 0;
271 unsigned int wordsum = 0;
272 for (
const auto& word: block->payload()) {
273 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
275 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 276 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
277 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
287 std::cout <<
"wordsum == 0: this block should be zero suppressed" << std::endl;
292 if (toSuppress && zsFlagSet) {
298 }
else if (!toSuppress && !zsFlagSet) {
301 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
302 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
305 readoutSizeZSMap[blockCapId] += totalBlockSize;
306 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
308 }
else if (!toSuppress && zsFlagSet) {
314 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
321 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
322 evtGood[blockCapId] =
false;
330 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
337 readoutSizeZSMap[blockCapId] += totalBlockSize;
338 evtGood[blockCapId] =
false;
346 for (
const auto &
id: definedMaskCapIds_) {
353 if (evtGood[maxMasks_]) {
359 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_