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"))
23 std::vector<int> onesMask(6, 0xffffffff);
29 if (ps.
exists(maskCapIdStr)) {
37 std::cout <<
"caption ID" <<
i <<
":" << std::endl;
38 for (
const auto& maskIt:
masks_.at(
i)) {
39 std::cout << std::hex << std::setw(8) << std::setfill(
'0') << maskIt <<
std::dec << std::endl;
51 desc.
add<std::vector<int>>(
"fedIds")->setComment(
"FED ids to analyze.");
52 desc.
addUntracked<
bool>(
"zsEnabled",
true)->setComment(
"MP7 zero suppression is enabled.");
53 desc.
addUntracked<
int>(
"lenSlinkHeader", 8)->setComment(
"Number of Slink header bytes.");
54 desc.
addUntracked<
int>(
"lenSlinkTrailer", 8)->setComment(
"Number of Slink trailer bytes.");
55 desc.
addUntracked<
int>(
"lenAMC13Header", 8)->setComment(
"Number of AMC13 header bytes.");
56 desc.
addUntracked<
int>(
"lenAMC13Trailer", 8)->setComment(
"Number of AMC13 trailer bytes.");
57 desc.
addUntracked<
int>(
"lenAMCHeader", 8)->setComment(
"Number of AMC header bytes.");
58 desc.
addUntracked<
int>(
"lenAMCTrailer", 0)->setComment(
"Number of AMC trailer bytes.");
59 desc.
addUntracked<
int>(
"zsFlagMask", 0x1)->setComment(
"Zero suppression flag mask.");
60 desc.
addUntracked<
int>(
"newZsFlagMask", 0x2)->setComment(
"Per-BX zero suppression flag mask.");
61 desc.
addUntracked<
int>(
"dataInvFlagMask", 0x1)->setComment(
"Data inversion flag mask.");
62 desc.
addUntracked<
int>(
"maxFEDReadoutSize", 10000)->setComment(
"Maximal FED readout size histogram x-axis value.");
64 desc.
addOptionalUntracked<std::vector<int>>(
"maskCapId"+std::to_string(
i))->setComment(
"ZS mask for caption id "+std::to_string(
i)+
".");
66 desc.
addUntracked<
bool>(
"checkOnlyCapIdsWithMasks",
true)->setComment(
"Check only blocks that have a CapId for which a mask is defined.");
67 desc.
addUntracked<
std::string>(
"monitorDir",
"")->setComment(
"Target directory in the DQM file. Will be created if not existing.");
69 descriptions.
add(
"l1tMP7ZeroSupp", desc);
91 std::string summaryTitleText =
"Zero suppression validation summary";
94 sizeTitleText =
"FED readout ";
96 summaryTitleText = summaryTitleText+
", caption id "+std::to_string(
id);
97 sizeTitleText =
"cumulated caption id "+std::to_string(
id)+
" block ";
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();
190 if (l1tRcd.
size() > 0) {
191 edm::LogError(
"L1TDQM") <<
"Cannot analyse: invalid L1T raw data (size = " << l1tRcd.
size() <<
") for ID " <<
fedId <<
".";
198 const unsigned char *
data = l1tRcd.
data();
201 if (header.
check()) {
202 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();
209 if (trailer.
check()) {
222 edm::LogError(
"L1TDQM") <<
"Could not extract AMC13 Packet.";
230 auto payload64 =
amc.data();
231 auto start = (
const uint32_t*) payload64.get();
239 std::unique_ptr<l1t::Block>
block;
240 while ((block = payload->getBlock()) !=
nullptr) {
242 std::cout <<
">>> check zero suppression for block <<<" << std::endl
243 <<
"hdr: " << std::hex << std::setw(8) << std::setfill(
'0') << block->header().raw() <<
std::dec 244 <<
" (ID " << block->header().getID() <<
", size " << block->header().getSize()
245 <<
", CapID 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getCapID()
246 <<
", flags 0x" << std::hex << std::setw(2) << std::setfill(
'0') << block->header().getFlags()
248 for (
const auto& word: block->payload()) {
249 std::cout <<
"data: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec << std::endl;
253 unsigned int blockCapId = block->header().getCapID();
254 unsigned int blockSize = block->header().getSize() * 4;
255 unsigned int blockHeaderSize =
sizeof(block->header().raw());
256 unsigned int blockHeaderFlags = block->header().getFlags();
258 bool blockZsFlagSet = newZsFlagSet ?
true : ((blockHeaderFlags &
zsFlagMask_) != 0);
259 bool dataInvertFlagSet = newZsFlagSet && ((blockHeaderFlags &
dataInvFlagMask_) != 0);
263 bool capIdDefined =
false;
285 auto totalBlockSize = blockHeaderSize;
287 totalBlockSize += blockSize;
289 auto totalBlockSizeExpected = totalBlockSize;
290 auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
292 auto bxBlocks = block->getBxBlocks(6, newZsFlagSet);
295 bool allToSuppress =
true;
296 for (
const auto& bxBlock: bxBlocks) {
297 bool toSuppress =
false;
298 bool bxZsFlagSet = ((bxBlock.header().getFlags() &
zsFlagMask_) != 0);
301 unsigned int wordcounter = 0;
302 unsigned int wordsum = 0;
303 for (
const auto& word: bxBlock.payload()) {
304 if (dataInvertFlagSet) {
305 wordsum +=
masks_[blockCapId].at(wordcounter%6) & (~word);
307 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
310 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec 311 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
312 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
316 std::cout <<
"wordsum not 0: this BX block should be kept" << std::endl;
326 std::cout <<
"wordsum == 0: this BX block should be zero suppressed" << std::endl;
330 allToSuppress = allToSuppress && toSuppress;
335 blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
349 unsigned int totalBxBlockSize = bxBlock.getSize() * 4 +
sizeof(bxBlock.header().raw());
351 if (toSuppress && bxZsFlagSet) {
357 }
else if (!toSuppress && !bxZsFlagSet) {
359 totalBlockSize += totalBxBlockSize;
360 totalBlockSizeExpected += totalBxBlockSize;
365 }
else if (!toSuppress && bxZsFlagSet) {
367 totalBlockSizeExpected += totalBxBlockSize;
378 evtGood[blockCapId] =
false;
382 totalBlockSize += totalBxBlockSize;
393 evtGood[blockCapId] =
false;
399 readoutSizeNoZSMap[
maxMasks_] += totalBlockSizeNoZS;
401 readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
405 if (allToSuppress && blockZsFlagSet) {
411 }
else if (!allToSuppress && !blockZsFlagSet) {
414 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
415 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
418 readoutSizeZSMap[blockCapId] += totalBlockSize;
419 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
421 }
else if (!allToSuppress && blockZsFlagSet) {
427 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSizeExpected;
434 readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
435 evtGood[blockCapId] =
false;
443 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
450 readoutSizeZSMap[blockCapId] += totalBlockSize;
451 evtGood[blockCapId] =
false;
457 std::cout <<
"FED data size: " << fedDataSize <<
" bytes" << std::endl;
458 std::cout <<
"Payload size no ZS: " << readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
459 std::cout <<
"Payload size ZS: " << readoutSizeZSMap[
maxMasks_] <<
" bytes" << std::endl;
460 std::cout <<
"Payload size expected ZS: " << readoutSizeZSExpectedMap[
maxMasks_] <<
" bytes" << std::endl;
461 std::cout <<
"Filled readout size ZS with headers: " << readoutSizeZSMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
462 std::cout <<
"Filled expected readout size ZS with headers: " << readoutSizeZSExpectedMap[
maxMasks_] + fedDataSize - readoutSizeNoZSMap[
maxMasks_] <<
" bytes" << std::endl;
467 for (
const auto &
id: definedMaskCapIds_) {
480 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
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
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.
bool check() const
Check that the trailer is OK.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
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_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
MonitorElement * book1D(Args &&...args)
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setCurrentFolder(const std::string &fullpath)
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
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) 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
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &c) override
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
bool checkOnlyCapIdsWithMasks_