7 zsEnabled_(ps.getUntrackedParameter<bool>(
"zsEnabled")),
8 fedIds_(ps.getParameter<std::
vector<int>>(
"fedIds")),
9 slinkHeaderSize_(ps.getUntrackedParameter<int>(
"lenSlinkHeader")),
10 slinkTrailerSize_(ps.getUntrackedParameter<int>(
"lenSlinkTrailer")),
11 amc13HeaderSize_(ps.getUntrackedParameter<int>(
"lenAMC13Header")),
12 amc13TrailerSize_(ps.getUntrackedParameter<int>(
"lenAMC13Trailer")),
13 amcHeaderSize_(ps.getUntrackedParameter<int>(
"lenAMCHeader")),
14 amcTrailerSize_(ps.getUntrackedParameter<int>(
"lenAMCTrailer")),
15 newZsFlagMask_(ps.getUntrackedParameter<int>(
"newZsFlagMask")),
16 zsFlagMask_(ps.getUntrackedParameter<int>(
"zsFlagMask")),
17 dataInvFlagMask_(ps.getUntrackedParameter<int>(
"dataInvFlagMask")),
18 maxFedReadoutSize_(ps.getUntrackedParameter<int>(
"maxFEDReadoutSize")),
19 checkOnlyCapIdsWithMasks_(ps.getUntrackedParameter<bool>(
"checkOnlyCapIdsWithMasks")),
20 monitorDir_(ps.getUntrackedParameter<std::
string>(
"monitorDir")),
21 verbose_(ps.getUntrackedParameter<bool>(
"verbose")) {
22 std::vector<int> onesMask(6, 0xffffffff);
28 if (ps.
exists(maskCapIdStr)) {
36 std::cout <<
"caption ID" <<
i <<
":" << std::endl;
37 for (
const auto& maskIt :
masks_.at(
i)) {
38 std::cout << std::hex << std::setw(8) << std::setfill(
'0') << maskIt <<
std::dec << std::endl;
50 desc.
add<std::vector<int>>(
"fedIds")->setComment(
"FED ids to analyze.");
51 desc.
addUntracked<
bool>(
"zsEnabled",
true)->setComment(
"MP7 zero suppression is enabled.");
52 desc.
addUntracked<
int>(
"lenSlinkHeader", 8)->setComment(
"Number of Slink header bytes.");
53 desc.
addUntracked<
int>(
"lenSlinkTrailer", 8)->setComment(
"Number of Slink trailer bytes.");
54 desc.
addUntracked<
int>(
"lenAMC13Header", 8)->setComment(
"Number of AMC13 header bytes.");
55 desc.
addUntracked<
int>(
"lenAMC13Trailer", 8)->setComment(
"Number of AMC13 trailer bytes.");
56 desc.
addUntracked<
int>(
"lenAMCHeader", 8)->setComment(
"Number of AMC header bytes.");
57 desc.
addUntracked<
int>(
"lenAMCTrailer", 0)->setComment(
"Number of AMC trailer bytes.");
58 desc.
addUntracked<
int>(
"zsFlagMask", 0x1)->setComment(
"Zero suppression flag mask.");
59 desc.
addUntracked<
int>(
"newZsFlagMask", 0x2)->setComment(
"Per-BX zero suppression flag mask.");
60 desc.
addUntracked<
int>(
"dataInvFlagMask", 0x1)->setComment(
"Data inversion flag mask.");
61 desc.
addUntracked<
int>(
"maxFEDReadoutSize", 10000)->setComment(
"Maximal FED readout size histogram x-axis value.");
66 desc.
addUntracked<
bool>(
"checkOnlyCapIdsWithMasks",
true)
67 ->setComment(
"Check only blocks that have a CapId for which a mask is defined.");
69 ->setComment(
"Target directory in the DQM file. Will be created if not existing.");
71 descriptions.
add(
"l1tMP7ZeroSupp", desc);
89 std::string summaryTitleText =
"Zero suppression validation summary";
92 sizeTitleText =
"FED readout ";
94 summaryTitleText = summaryTitleText +
", caption id " +
std::to_string(
id);
95 sizeTitleText =
"cumulated caption id " +
std::to_string(
id) +
" block ";
142 "readoutSizeZSExpected",
"Expected " + sizeTitleText +
"size with zero suppression", 100, 0,
maxFedReadoutSize_);
148 edm::LogInfo(
"L1TDQM") <<
"L1TMP7ZeroSupp: analyze..." << std::endl;
154 edm::LogError(
"L1TDQM") <<
"Cannot analyse: no FEDRawDataCollection found";
165 std::map<unsigned int, bool> evtGood;
167 for (
const auto&
id : definedMaskCapIds_) {
170 unsigned valid_count = 0;
174 unsigned int fedDataSize = l1tRcd.
size();
175 std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
176 std::map<unsigned int, unsigned int> readoutSizeZSMap;
177 std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
181 for (
const auto&
id : definedMaskCapIds_) {
182 readoutSizeNoZSMap[
id] = 0;
183 readoutSizeZSMap[
id] = 0;
184 readoutSizeZSExpectedMap[
id] = 0;
187 edm::LogInfo(
"L1TDQM") <<
"Found FEDRawDataCollection with ID " <<
fedId <<
" and size " << l1tRcd.
size();
191 if (l1tRcd.
size() > 0) {
192 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID "
200 const unsigned char*
data = l1tRcd.
data();
203 if (header.
check()) {
205 <<
" Trigger type " << header.
triggerType() <<
" L1 event ID " << header.
lvl1ID()
206 <<
" BX Number " << header.
bxID() <<
" FED source " << header.
sourceID() <<
" FED version "
214 if (trailer.
check()) {
216 <<
" Length " << trailer.
fragmentLength() <<
" CRC " << trailer.
crc() <<
" Status "
228 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
236 auto payload64 =
amc.data();
237 auto start = (
const uint32_t*)payload64.get();
245 std::unique_ptr<l1t::Block>
block;
246 while ((block = payload->getBlock()) !=
nullptr) {
248 std::cout <<
">>> check zero suppression for block <<<" << std::endl
249 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec
250 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize() <<
", CapID 0x"
251 << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID() <<
", flags 0x"
252 << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags() <<
")" <<
std::dec
254 for (
const auto&
word : block->payload()) {
255 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec << std::endl;
259 unsigned int blockCapId = block->header().getCapID();
260 unsigned int blockSize = block->header().getSize() * 4;
261 unsigned int blockHeaderSize =
sizeof(block->header().raw());
262 unsigned int blockHeaderFlags = block->header().getFlags();
264 bool blockZsFlagSet =
265 newZsFlagSet ?
true : ((blockHeaderFlags &
zsFlagMask_) != 0);
266 bool dataInvertFlagSet =
271 bool capIdDefined =
false;
293 auto totalBlockSize = blockHeaderSize;
295 totalBlockSize += blockSize;
297 auto totalBlockSizeExpected = totalBlockSize;
298 auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
300 auto bxBlocks = block->getBxBlocks(6, newZsFlagSet);
303 bool allToSuppress =
true;
304 for (
const auto& bxBlock : bxBlocks) {
305 bool toSuppress =
false;
306 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
309 unsigned int wordcounter = 0;
310 unsigned int wordsum = 0;
311 for (
const auto&
word : bxBlock.payload()) {
312 if (dataInvertFlagSet) {
313 wordsum +=
masks_[blockCapId].at(wordcounter % 6) & (~
word);
315 wordsum +=
masks_[blockCapId].at(wordcounter % 6) &
word;
318 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') <<
word <<
std::dec <<
", maskword"
319 << wordcounter % 6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
320 <<
masks_[blockCapId].at(wordcounter % 6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
324 std::cout <<
"wordsum not 0: this BX block should be kept" << std::endl;
334 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
338 allToSuppress = allToSuppress && toSuppress;
343 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
357 unsigned int totalBxBlockSize =
358 bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
360 if (toSuppress && bxZsFlagSet) {
362 std::cout <<
"GOOD BX block with ZS flag true" << std::endl;
367 }
else if (!toSuppress && !bxZsFlagSet) {
369 std::cout <<
"GOOD BX block with ZS flag false" << std::endl;
370 totalBlockSize += totalBxBlockSize;
371 totalBlockSizeExpected += totalBxBlockSize;
376 }
else if (!toSuppress && bxZsFlagSet) {
378 std::cout <<
"BAD BX block with ZS flag true" << std::endl;
379 totalBlockSizeExpected += totalBxBlockSize;
390 evtGood[blockCapId] =
false;
394 std::cout <<
"BAD BX block with ZS flag false" << std::endl;
395 totalBlockSize += totalBxBlockSize;
406 evtGood[blockCapId] =
false;
412 readoutSizeNoZSMap[
maxMasks_] += totalBlockSizeNoZS;
414 readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
418 if (allToSuppress && blockZsFlagSet) {
420 std::cout <<
"GOOD block with ZS flag true" << std::endl;
425 }
else if (!allToSuppress && !blockZsFlagSet) {
427 std::cout <<
"GOOD block with ZS flag false" << std::endl;
429 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
430 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
433 readoutSizeZSMap[blockCapId] += totalBlockSize;
434 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
436 }
else if (!allToSuppress && blockZsFlagSet) {
438 std::cout <<
"BAD block with ZS flag true" << std::endl;
443 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
450 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
451 evtGood[blockCapId] =
false;
455 std::cout <<
"BAD block with ZS flag false" << std::endl;
460 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
467 readoutSizeZSMap[blockCapId] += totalBlockSize;
468 evtGood[blockCapId] =
false;
474 std::cout <<
"FED data size: " << fedDataSize <<
" bytes" << std::endl;
475 std::cout <<
"Payload size no ZS: " << readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
476 std::cout <<
"Payload size ZS: " << readoutSizeZSMap[
maxMasks_] <<
" bytes" << std::endl;
477 std::cout <<
"Payload size expected ZS: " << readoutSizeZSExpectedMap[
maxMasks_] <<
" bytes" << std::endl;
478 std::cout <<
"Filled readout size ZS with headers: "
479 << readoutSizeZSMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
480 std::cout <<
"Filled expected readout size ZS with headers: "
481 << readoutSizeZSExpectedMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes"
487 readoutSizeNoZSMap[maxMasks_]);
488 for (
const auto&
id : definedMaskCapIds_) {
501 for (
const auto&
id : definedMaskCapIds_) {
std::vector< amc::Packet > payload() const
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
T getUntrackedParameter(std::string const &, T const &) const
const edm::EventSetup & c
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint16_t *__restrict__ id
virtual void setCurrentFolder(std::string const &fullpath)
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
L1TMP7ZeroSupp(const edm::ParameterSet &ps)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
uint16_t crc() const
Cyclic Redundancy Code of the event fragment including header and trailer.
std::string to_string(const V &value)
bool check() const
Check that the trailer is OK.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Log< level::Error, false > LogError
size_t size() const
Lenght of the data buffer in bytes.
uint32_t fragmentLength() const
The length of the event fragment counted in 64-bit words including header and trailer.
void bookCapIdHistograms(DQMStore::IBooker &ibooker, const unsigned int &id)
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
std::vector< unsigned int > definedMaskCapIds_
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Info, false > LogInfo
uint8_t ttsBits() const
Current value of the Trigger Throttling System bits.
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)
uint8_t evtStatus() const
Event fragment status information.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~L1TMP7ZeroSupp() override
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_
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_
bool checkOnlyCapIdsWithMasks_
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)