9 zsEnabled_(ps.getUntrackedParameter<bool>(
"zsEnabled")),
10 fedIds_(ps.getParameter<
std::vector<
int>>(
"fedIds")),
11 slinkHeaderSize_(ps.getUntrackedParameter<
int>(
"lenSlinkHeader")),
12 slinkTrailerSize_(ps.getUntrackedParameter<
int>(
"lenSlinkTrailer")),
13 amc13HeaderSize_(ps.getUntrackedParameter<
int>(
"lenAMC13Header")),
14 amc13TrailerSize_(ps.getUntrackedParameter<
int>(
"lenAMC13Trailer")),
15 amcHeaderSize_(ps.getUntrackedParameter<
int>(
"lenAMCHeader")),
16 amcTrailerSize_(ps.getUntrackedParameter<
int>(
"lenAMCTrailer")),
17 zsFlagMask_(ps.getUntrackedParameter<
int>(
"zsFlagMask")),
18 maxFedReadoutSize_(ps.getUntrackedParameter<
int>(
"maxFEDReadoutSize")),
19 monitorDir_(ps.getUntrackedParameter<
std::
string>(
"monitorDir")),
20 verbose_(ps.getUntrackedParameter<bool>(
"verbose"))
22 std::vector<int> zeroMask(6, 0);
28 if (ps.
exists(maskCapIdStr.c_str())) {
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>(
"maxFEDReadoutSize", 10000)->setComment(
"Maximal FED readout size histogram x-axis value.");
61 desc.
addOptionalUntracked<std::vector<int>>((
"maskCapId"+std::to_string(
i)).c_str())->setComment((
"ZS mask for caption id "+std::to_string(
i)+
".").c_str());
63 desc.
addUntracked<
std::string>(
"monitorDir",
"")->setComment(
"Target directory in the DQM file. Will be created if not existing.");
65 descriptions.
add(
"l1tMP7ZeroSupp", desc);
90 std::string summaryTitleText =
"Zero suppression validation summary";
93 sizeTitleText =
"FED readout ";
96 ss << summaryTitleText <<
", caption id " <<
id;
97 summaryTitleText = ss.str();
99 ss <<
"cumulated caption id " <<
id <<
" block ";
100 sizeTitleText = ss.str();
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;
159 for (
const auto& fedId:
fedIds_) {
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();
189 if (header.
check()) {
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_) {
359 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
virtual void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
int evtStatus()
Event fragment status information.
L1TMP7ZeroSupp(const edm::ParameterSet &ps)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
size_t size() const
Lenght of the data buffer in bytes.
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
void bookCapIdHistograms(DQMStore::IBooker &, const unsigned int &)
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_
MonitorElement * book1D(Args &&...args)
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
int ttsBits()
Current value of the Trigger Throttling System bitsAQ).
void setCurrentFolder(const std::string &fullpath)
unsigned long long uint64_t
int lenght()
The length of the event fragment counted in 64-bit words including header and trailer.
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)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual 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.
int crc()
Cyclic Redundancy Code of the event fragment including header and trailer.
std::vector< int > fedIds_
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) 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)
virtual ~L1TMP7ZeroSupp()