111 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
120 std::map<unsigned int, bool> evtGood;
122 for (
const auto &
id: definedMaskCapIds_) {
125 unsigned valid_count = 0;
126 for (
const auto& fedId:
fedIds_) {
129 unsigned int fedDataSize = l1tRcd.
size();
130 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
131 std::map<unsigned int, unsigned int> readoutSizeZSMap;
132 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
136 for (
const auto &
id: definedMaskCapIds_) {
137 readoutSizeNoZSMap[
id] = 0;
138 readoutSizeZSMap[
id] = 0;
139 readoutSizeZSExpectedMap[
id] = 0;
142 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " << fedId <<
" and size " << l1tRcd.
size();
145 if (l1tRcd.
size() > 0) {
146 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " << fedId <<
".";
153 const unsigned char *
data = l1tRcd.
data();
157 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();
164 if (trailer.check()) {
165 edm::LogInfo(
"L1TDQM") <<
"Found SLink trailer:" <<
" Length " << trailer.lenght() <<
" CRC " << trailer.crc() <<
" Status " << trailer.evtStatus() <<
" Throttling bits " << trailer.ttsBits();
177 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
185 auto payload64 =
amc.data();
186 const uint32_t *
start = (
const uint32_t*) payload64.get();
189 const uint32_t *
end = start + (
amc.size() * 2);
191 std::unique_ptr<l1t::Payload>
payload;
195 std::unique_ptr<l1t::Block>
block;
196 while ((block = payload->getBlock()).
get()) {
198 std::cout <<
">>> check zero suppression for block <<<" << std::endl
199 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 200 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
201 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
202 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
204 for (
const auto& word: block->payload()) {
205 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
209 unsigned int blockCapId = block->header().getCapID();
210 unsigned int blockSize = block->header().getSize() * 4;
211 unsigned int blockHeaderSize =
sizeof(block->header().raw());
212 bool zsFlagSet = ((block->header().getFlags() &
zsFlagMask_) != 0);
213 bool toSuppress =
false;
217 bool capIdDefined =
false;
224 auto totalBlockSize = blockSize + blockHeaderSize;
225 readoutSizeNoZSMap[
maxMasks_] += totalBlockSize;
227 readoutSizeNoZSMap[blockCapId] += totalBlockSize;
231 unsigned int wordcounter = 0;
232 unsigned int wordsum = 0;
233 for (
const auto& word: block->payload()) {
234 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
236 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 237 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
238 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
248 std::cout <<
"wordsum == 0: this block should be zero suppressed" << std::endl;
253 if (toSuppress && zsFlagSet) {
259 }
else if (!toSuppress && !zsFlagSet) {
262 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
263 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
266 readoutSizeZSMap[blockCapId] += totalBlockSize;
267 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
269 }
else if (!toSuppress && zsFlagSet) {
273 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
278 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
279 evtGood[blockCapId] =
false;
285 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
290 readoutSizeZSMap[blockCapId] += totalBlockSize;
291 evtGood[blockCapId] =
false;
299 for (
const auto &
id: definedMaskCapIds_) {
306 if (evtGood[maxMasks_]) {
311 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_
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_