8 zsEnabled_(ps.getUntrackedParameter<bool>(
"zsEnabled",
true)),
9 fedIds_(ps.getParameter<std::vector<int>>(
"fedIds")),
10 slinkHeaderSize_(ps.getUntrackedParameter<int>(
"lenSlinkHeader", 8)),
11 slinkTrailerSize_(ps.getUntrackedParameter<int>(
"lenSlinkTrailer", 8)),
12 amc13HeaderSize_(ps.getUntrackedParameter<int>(
"lenAMC13Header", 8)),
13 amc13TrailerSize_(ps.getUntrackedParameter<int>(
"lenAMC13Trailer", 8)),
14 amcHeaderSize_(ps.getUntrackedParameter<int>(
"lenAMCHeader", 8)),
15 amcTrailerSize_(ps.getUntrackedParameter<int>(
"lenAMCTrailer", 0)),
16 zsFlagMask_(ps.getUntrackedParameter<int>(
"zsFlagMask", 0x1)),
17 maxFedReadoutSize_(ps.getUntrackedParameter<int>(
"maxFEDReadoutSize", 10000)),
18 monitorDir_(ps.getUntrackedParameter<std::
string>(
"monitorDir",
"")),
19 verbose_(ps.getUntrackedParameter<bool>(
"verbose",
false)),
22 std::vector<int> zeroMask(6, 0);
27 ss <<
"maskCapId" <<
i;
30 if (ps.
exists(ss.str().c_str())) {
38 std::cout <<
"caption ID" <<
i <<
":" << std::endl;
39 for (
const auto& maskIt:
masks_.at(
i)) {
40 std::cout << std::hex << std::setw(8) << std::setfill(
'0') << maskIt <<
std::dec << std::endl;
71 std::string summaryTitleText =
"Zero suppression validation summary";
74 sizeTitleText =
"FED readout ";
77 ss << summaryTitleText <<
", caption id " << id;
78 summaryTitleText = ss.str();
80 ss <<
"cumulated caption id " <<
id <<
" block ";
81 sizeTitleText = ss.str();
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;
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();
156 if (header.
check()) {
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()
203 for (
const auto& word: block->payload()) {
208 unsigned int blockCapId = block->header().getCapID();
209 unsigned int blockSize = block->header().getSize() * 4;
210 unsigned int blockHeaderSize =
sizeof(block->header().raw());
211 bool zsFlagSet = ((block->header().raw() &
zsFlagMask_) != 0);
212 bool toSuppress =
false;
216 bool capIdDefined =
false;
223 auto totalBlockSize = blockSize + blockHeaderSize;
224 readoutSizeNoZSMap[
maxMasks_] += totalBlockSize;
226 readoutSizeNoZSMap[blockCapId] += totalBlockSize;
230 unsigned int wordcounter = 0;
231 unsigned int wordsum = 0;
232 for (
const auto& word: block->payload()) {
233 wordsum +=
masks_[blockCapId].at(wordcounter%6) & word;
235 std::cout <<
"word: " << std::hex << std::setw(8) << std::setfill(
'0') << word <<
std::dec
236 <<
", maskword" << wordcounter%6 <<
": " << std::hex << std::setw(8) << std::setfill(
'0')
237 <<
masks_[blockCapId].at(wordcounter%6) <<
std::dec <<
", wordsum: " << wordsum << std::endl;
247 std::cout <<
"wordsum == 0: this block should be zero suppressed" << std::endl;
252 if (toSuppress && zsFlagSet) {
257 }
else if (!toSuppress && !zsFlagSet) {
259 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
260 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
263 readoutSizeZSMap[blockCapId] += totalBlockSize;
264 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
266 }
else if (!toSuppress && zsFlagSet) {
269 readoutSizeZSExpectedMap[
maxMasks_] += totalBlockSize;
274 readoutSizeZSExpectedMap[blockCapId] += totalBlockSize;
275 evtGood[blockCapId] =
false;
280 readoutSizeZSMap[
maxMasks_] += totalBlockSize;
285 readoutSizeZSMap[blockCapId] += totalBlockSize;
286 evtGood[blockCapId] =
false;
294 for (
const auto &
id: definedMaskCapIds_) {
306 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_
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.
void bookCapIdHistograms(DQMStore::IBooker &, const unsigned int &)
std::vector< unsigned int > definedMaskCapIds_
MonitorElement * book1D(Args &&...args)
std::vector< std::vector< int > > masks_
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)
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_
virtual void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
volatile std::atomic< bool > shutdown_flag false
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()