130 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
139 std::map<unsigned int, bool> evtGood;
141 for (
const auto &
id: definedMaskCapIds_) {
144 unsigned valid_count = 0;
145 for (
const auto& fedId:
fedIds_) {
148 unsigned int fedDataSize = l1tRcd.
size();
149 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
150 std::map<unsigned int, unsigned int> readoutSizeZSMap;
151 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
155 for (
const auto &
id: definedMaskCapIds_) {
156 readoutSizeNoZSMap[
id] = 0;
157 readoutSizeZSMap[
id] = 0;
158 readoutSizeZSExpectedMap[
id] = 0;
161 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " << fedId <<
" and size " << l1tRcd.
size();
164 if (l1tRcd.
size() > 0) {
165 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " << fedId <<
".";
172 const unsigned char *
data = l1tRcd.
data();
176 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();
183 if (trailer.check()) {
184 edm::LogInfo(
"L1TDQM") <<
"Found SLink trailer:" <<
" Length " << trailer.lenght() <<
" CRC " << trailer.crc() <<
" Status " << trailer.evtStatus() <<
" Throttling bits " << trailer.ttsBits();
196 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
204 auto payload64 =
amc.data();
205 const uint32_t *
start = (
const uint32_t*) payload64.get();
208 const uint32_t *
end = start + (
amc.size() * 2);
210 std::unique_ptr<l1t::Payload>
payload;
214 std::unique_ptr<l1t::Block>
block;
215 while ((block = payload->getBlock()).
get()) {
217 std::cout <<
">>> check zero suppression for block <<<" << std::endl
218 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 219 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
220 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
221 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
223 for (
const auto& word: block->payload()) {
224 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
228 unsigned int blockCapId = block->header().getCapID();
229 unsigned int blockSize = block->header().getSize() * 4;
230 unsigned int blockHeaderSize =
sizeof(block->header().raw());
231 bool zsFlagSet = ((block->header().getFlags() &
zsFlagMask_) != 0);
232 bool toSuppress =
false;
236 bool capIdDefined =
false;
243 auto totalBlockSize = blockSize + blockHeaderSize;
244 readoutSizeNoZSMap[
maxMasks_] += totalBlockSize;
246 readoutSizeNoZSMap[blockCapId] += totalBlockSize;
250 unsigned int wordcounter = 0;
251 unsigned int wordsum = 0;
252 for (
const auto& word: block->payload()) {
253 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
255 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 256 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
257 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
267 std::cout <<
"wordsum == 0: this block should be zero suppressed" << std::endl;
272 if (toSuppress && zsFlagSet) {
278 }
else if (!toSuppress && !zsFlagSet) {
281 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
282 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
285 readoutSizeZSMap[blockCapId] += totalBlockSize;
286 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
288 }
else if (!toSuppress && zsFlagSet) {
292 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
297 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
298 evtGood[blockCapId] =
false;
304 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
309 readoutSizeZSMap[blockCapId] += totalBlockSize;
310 evtGood[blockCapId] =
false;
318 for (
const auto &
id: definedMaskCapIds_) {
325 if (evtGood[maxMasks_]) {
330 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::vector< unsigned int > definedMaskCapIds_
payload
payload postfix for testing
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
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_