CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
L1TMP7ZeroSupp Class Reference

#include <L1TMP7ZeroSupp.h>

Inheritance diagram for L1TMP7ZeroSupp:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

 L1TMP7ZeroSupp (const edm::ParameterSet &ps)
 
 ~L1TMP7ZeroSupp () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void bookHistograms (DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Private Types

enum  binlabels {
  EVTS = 0, EVTSGOOD, EVTSBAD, BLOCKS,
  ZSBLKSGOOD, ZSBLKSBAD, ZSBLKSBADFALSEPOS, ZSBLKSBADFALSENEG,
  BXBLOCKS, ZSBXBLKSGOOD, ZSBXBLKSBAD, ZSBXBLKSBADFALSEPOS,
  ZSBXBLKSBADFALSENEG, NBINLABELS
}
 
enum  ratioBinlabels {
  REVTS = 0, RBLKS, RBLKSFALSEPOS, RBLKSFALSENEG,
  RBXBLKS, RBXBLKSFALSEPOS, RBXBLKSFALSENEG, RNBINLABELS
}
 

Private Member Functions

void bookCapIdHistograms (DQMStore::IBooker &ibooker, const unsigned int &id)
 

Private Attributes

int amc13HeaderSize_
 
int amc13TrailerSize_
 
int amcHeaderSize_
 
int amcTrailerSize_
 
MonitorElementcapIds_
 
bool checkOnlyCapIdsWithMasks_
 
int dataInvFlagMask_
 
std::vector< unsigned int > definedMaskCapIds_
 
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
 
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
 
edm::EDGetTokenT< FEDRawDataCollectionfedDataToken_
 
std::vector< int > fedIds_
 
std::vector< std::vector< int > > masks_
 
int maxFedReadoutSize_
 
std::string monitorDir_
 
int newZsFlagMask_
 
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
 
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
 
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_
 
int slinkHeaderSize_
 
int slinkTrailerSize_
 
bool verbose_
 
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
 
bool zsEnabled_
 
int zsFlagMask_
 

Static Private Attributes

static const unsigned int maxMasks_ = 16
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 21 of file L1TMP7ZeroSupp.h.

Member Enumeration Documentation

◆ binlabels

◆ ratioBinlabels

Enumerator
REVTS 
RBLKS 
RBLKSFALSEPOS 
RBLKSFALSENEG 
RBXBLKS 
RBXBLKSFALSEPOS 
RBXBLKSFALSENEG 
RNBINLABELS 

Definition at line 51 of file L1TMP7ZeroSupp.h.

Constructor & Destructor Documentation

◆ L1TMP7ZeroSupp()

L1TMP7ZeroSupp::L1TMP7ZeroSupp ( const edm::ParameterSet ps)

Definition at line 5 of file L1TMP7ZeroSupp.cc.

References gather_cfg::cout, TauDecayModes::dec, definedMaskCapIds_, edm::ParameterSet::exists(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, masks_, maxMasks_, AlCaHLTBitMon_QueryRunRegistry::string, to_string(), and verbose_.

6  : fedDataToken_(consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawData"))),
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")),
21  verbose_(ps.getUntrackedParameter<bool>("verbose")) {
22  std::vector<int> onesMask(6, 0xffffffff);
23  masks_.reserve(maxMasks_);
24  for (unsigned int i = 0; i < maxMasks_; ++i) {
25  std::string maskCapIdStr{"maskCapId" + std::to_string(i)};
26  masks_.push_back(ps.getUntrackedParameter<std::vector<int>>(maskCapIdStr, onesMask));
27  // which masks are defined?
28  if (ps.exists(maskCapIdStr)) {
29  definedMaskCapIds_.push_back(i);
30  }
31  }
32  if (verbose_) {
33  // check masks
34  std::cout << "masks" << std::endl;
35  for (unsigned int i = 0; i < maxMasks_; ++i) {
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;
39  }
40  }
41  std::cout << "----------" << std::endl;
42  }
43 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string monitorDir_
static std::string to_string(const XMLCh *ch)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< unsigned int > definedMaskCapIds_
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
std::vector< int > fedIds_
bool checkOnlyCapIdsWithMasks_

◆ ~L1TMP7ZeroSupp()

L1TMP7ZeroSupp::~L1TMP7ZeroSupp ( )
overridedefault

Member Function Documentation

◆ analyze()

void L1TMP7ZeroSupp::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 146 of file L1TMP7ZeroSupp.cc.

References amc13HeaderSize_, amc13TrailerSize_, amcHeaderSize_, amcTrailerSize_, groupFilesInBlocks::block, BLOCKS, BXBLOCKS, capIds_, FEDTrailer::check(), checkOnlyCapIdsWithMasks_, gather_cfg::cout, FEDTrailer::crc(), FEDRawData::data(), data, dataInvFlagMask_, TauDecayModes::dec, definedMaskCapIds_, MillePedeFileConverter_cfg::e, mps_fire::end, errorSummaryDenMap_, errorSummaryNumMap_, EVTS, EVTSBAD, EVTSGOOD, FEDTrailer::evtStatus(), fedDataToken_, l1tstage2_dqm_sourceclient-live_cfg::fedId, fedIds_, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, dqm::impl::MonitorElement::Fill(), FEDTrailer::fragmentLength(), RecoTauValidation_cfi::header, l1ctLayer2EG_cff::id, masks_, maxMasks_, newZsFlagMask_, amc13::Packet::parse(), jetsAK4_Puppi_cff::payload, amc13::Packet::payload(), RBLKS, RBLKSFALSENEG, RBLKSFALSEPOS, RBXBLKS, RBXBLKSFALSENEG, RBXBLKSFALSEPOS, readoutSizeNoZSMap_, readoutSizeZSExpectedMap_, readoutSizeZSMap_, REVTS, FEDRawData::size(), slinkHeaderSize_, slinkTrailerSize_, command_line::start, funct::true, FEDTrailer::ttsBits(), verbose_, zeroSuppValMap_, ZSBLKSBAD, ZSBLKSBADFALSENEG, ZSBLKSBADFALSEPOS, ZSBLKSGOOD, ZSBXBLKSBAD, ZSBXBLKSBADFALSENEG, ZSBXBLKSBADFALSEPOS, ZSBXBLKSGOOD, zsEnabled_, and zsFlagMask_.

146  {
147  if (verbose_)
148  edm::LogInfo("L1TDQM") << "L1TMP7ZeroSupp: analyze..." << std::endl;
149 
151  e.getByToken(fedDataToken_, feds);
152 
153  if (!feds.isValid()) {
154  edm::LogError("L1TDQM") << "Cannot analyse: no FEDRawDataCollection found";
155  return;
156  }
157 
160  for (const auto& id : definedMaskCapIds_) {
161  zeroSuppValMap_[id]->Fill(EVTS);
162  errorSummaryDenMap_[id]->Fill(REVTS);
163  }
164 
165  std::map<unsigned int, bool> evtGood;
166  evtGood[maxMasks_] = true;
167  for (const auto& id : definedMaskCapIds_) {
168  evtGood[id] = true;
169  }
170  for (const auto& fedId : fedIds_) {
171  const FEDRawData& l1tRcd = feds->FEDData(fedId);
172 
173  unsigned int fedDataSize = l1tRcd.size();
174  std::map<unsigned int, unsigned int> readoutSizeNoZSMap;
175  std::map<unsigned int, unsigned int> readoutSizeZSMap;
176  std::map<unsigned int, unsigned int> readoutSizeZSExpectedMap;
177  readoutSizeNoZSMap[maxMasks_] = 0;
178  readoutSizeZSMap[maxMasks_] = 0;
179  readoutSizeZSExpectedMap[maxMasks_] = 0;
180  for (const auto& id : definedMaskCapIds_) {
181  readoutSizeNoZSMap[id] = 0;
182  readoutSizeZSMap[id] = 0;
183  readoutSizeZSExpectedMap[id] = 0;
184  }
185 
186  edm::LogInfo("L1TDQM") << "Found FEDRawDataCollection with ID " << fedId << " and size " << l1tRcd.size();
187 
190  if (l1tRcd.size() > 0) {
191  edm::LogError("L1TDQM") << "Cannot analyse: invalid L1T raw data (size = " << l1tRcd.size() << ") for ID "
192  << fedId << ".";
193  }
194  continue;
195  }
196 
197  const unsigned char* data = l1tRcd.data();
199 
200  if (header.check()) {
201  edm::LogInfo("L1TDQM") << "Found SLink header:"
202  << " Trigger type " << header.triggerType() << " L1 event ID " << header.lvl1ID()
203  << " BX Number " << header.bxID() << " FED source " << header.sourceID() << " FED version "
204  << header.version();
205  } else {
206  edm::LogWarning("L1TDQM") << "Did not find a SLink header!";
207  }
208 
209  FEDTrailer trailer(data + (l1tRcd.size() - slinkTrailerSize_));
210 
211  if (trailer.check()) {
212  edm::LogInfo("L1TDQM") << "Found SLink trailer:"
213  << " Length " << trailer.fragmentLength() << " CRC " << trailer.crc() << " Status "
214  << trailer.evtStatus() << " Throttling bits " << trailer.ttsBits();
215  } else {
216  edm::LogWarning("L1TDQM") << "Did not find a SLink trailer!";
217  }
218 
219  amc13::Packet packet;
220  if (!packet.parse((const uint64_t*)data,
221  (const uint64_t*)(data + slinkHeaderSize_),
222  (l1tRcd.size() - slinkHeaderSize_ - slinkTrailerSize_) / 8,
223  header.lvl1ID(),
224  header.bxID())) {
225  edm::LogError("L1TDQM") << "Could not extract AMC13 Packet.";
226  return;
227  }
228 
229  for (auto& amc : packet.payload()) {
230  if (amc.size() == 0)
231  continue;
232 
233  auto payload64 = amc.data();
234  auto start = (const uint32_t*)payload64.get();
235  // Want to have payload size in 32 bit words, but AMC measures
236  // it in 64 bit words -> factor 2.
237  const uint32_t* end = start + (amc.size() * 2);
238 
239  auto payload = std::make_unique<l1t::MP7Payload>(start, end, false);
240 
241  // getBlock() returns a non-null unique_ptr on success
242  std::unique_ptr<l1t::Block> block;
243  while ((block = payload->getBlock()) != nullptr) {
244  if (verbose_) {
245  std::cout << ">>> check zero suppression for block <<<" << std::endl
246  << "hdr: " << std::hex << std::setw(8) << std::setfill('0') << block->header().raw() << std::dec
247  << " (ID " << block->header().getID() << ", size " << block->header().getSize() << ", CapID 0x"
248  << std::hex << std::setw(2) << std::setfill('0') << block->header().getCapID() << ", flags 0x"
249  << std::hex << std::setw(2) << std::setfill('0') << block->header().getFlags() << ")" << std::dec
250  << std::endl;
251  for (const auto& word : block->payload()) {
252  std::cout << "data: " << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << std::endl;
253  }
254  }
255 
256  unsigned int blockCapId = block->header().getCapID();
257  unsigned int blockSize = block->header().getSize() * 4; // times 4 to get the size in byte
258  unsigned int blockHeaderSize = sizeof(block->header().raw());
259  unsigned int blockHeaderFlags = block->header().getFlags();
260  bool newZsFlagSet = ((blockHeaderFlags & newZsFlagMask_) != 0); // use the per-BX ZS
261  bool blockZsFlagSet =
262  newZsFlagSet ? true : ((blockHeaderFlags & zsFlagMask_) != 0); // ZS validation flag for whole block
263  bool dataInvertFlagSet =
264  newZsFlagSet && ((blockHeaderFlags & dataInvFlagMask_) != 0); // invert the data before applying the mask
265 
266  capIds_->Fill(blockCapId);
267 
268  bool capIdDefined = false;
269  if (zeroSuppValMap_.find(blockCapId) != zeroSuppValMap_.end()) {
270  capIdDefined = true;
271  }
272 
273  // Only check blocks with a CapId that has a defined ZS mask.
274  if (checkOnlyCapIdsWithMasks_ and not capIdDefined) {
275  continue;
276  }
277 
278  // fill the denominator histograms
283  if (capIdDefined) {
284  zeroSuppValMap_[blockCapId]->Fill(BLOCKS);
285  errorSummaryDenMap_[blockCapId]->Fill(RBLKS);
286  errorSummaryDenMap_[blockCapId]->Fill(RBLKSFALSEPOS);
287  errorSummaryDenMap_[blockCapId]->Fill(RBLKSFALSENEG);
288  }
289 
290  auto totalBlockSize = blockHeaderSize;
291  if (!newZsFlagSet) {
292  totalBlockSize += blockSize;
293  }
294  auto totalBlockSizeExpected = totalBlockSize;
295  auto totalBlockSizeNoZS = blockHeaderSize + blockSize;
296 
297  auto bxBlocks = block->getBxBlocks(6, newZsFlagSet); // 6 32 bit MP7 payload words per BX
298 
299  // check all BX blocks
300  bool allToSuppress = true;
301  for (const auto& bxBlock : bxBlocks) {
302  bool toSuppress = false;
303  bool bxZsFlagSet = ((bxBlock.header().getFlags() & zsFlagMask_) != 0); // ZS validation flag
304 
305  // check if this bxblock should be suppressed
306  unsigned int wordcounter = 0;
307  unsigned int wordsum = 0;
308  for (const auto& word : bxBlock.payload()) {
309  if (dataInvertFlagSet) {
310  wordsum += masks_[blockCapId].at(wordcounter % 6) & (~word);
311  } else {
312  wordsum += masks_[blockCapId].at(wordcounter % 6) & word;
313  }
314  if (verbose_) {
315  std::cout << "word: " << std::hex << std::setw(8) << std::setfill('0') << word << std::dec << ", maskword"
316  << wordcounter % 6 << ": " << std::hex << std::setw(8) << std::setfill('0')
317  << masks_[blockCapId].at(wordcounter % 6) << std::dec << ", wordsum: " << wordsum << std::endl;
318  }
319  if (wordsum > 0) {
320  if (verbose_) {
321  std::cout << "wordsum not 0: this BX block should be kept" << std::endl;
322  }
323  break;
324  }
325  ++wordcounter;
326  }
327  // the sum of payload words must be 0 for correct ZS
328  if (wordsum == 0 && zsEnabled_) {
329  toSuppress = true;
330  if (verbose_) {
331  std::cout << "wordsum == 0: this BX block should be zero suppressed" << std::endl;
332  }
333  }
334  // update the overall block status
335  allToSuppress = allToSuppress && toSuppress;
336 
337  // only fill the BX related things for the per-BX ZS
338  if (newZsFlagSet) {
339  // the ZS flag of the block is the AND of all BX block ZS flags
340  blockZsFlagSet = blockZsFlagSet && bxZsFlagSet;
341 
342  // fill the BX related bins of the denominator histogram
347  if (capIdDefined) {
348  zeroSuppValMap_[blockCapId]->Fill(BXBLOCKS);
349  errorSummaryDenMap_[blockCapId]->Fill(RBXBLKS);
350  errorSummaryDenMap_[blockCapId]->Fill(RBXBLKSFALSEPOS);
351  errorSummaryDenMap_[blockCapId]->Fill(RBXBLKSFALSENEG);
352  }
353 
354  unsigned int totalBxBlockSize =
355  bxBlock.getSize() * 4 + sizeof(bxBlock.header().raw()); // times 4 to get the size in byte
356  // check if zero suppression flag agrees for the BX block
357  if (toSuppress && bxZsFlagSet) {
358  if (verbose_)
359  std::cout << "GOOD BX block with ZS flag true" << std::endl;
361  if (capIdDefined) {
362  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSGOOD);
363  }
364  } else if (!toSuppress && !bxZsFlagSet) {
365  if (verbose_)
366  std::cout << "GOOD BX block with ZS flag false" << std::endl;
367  totalBlockSize += totalBxBlockSize;
368  totalBlockSizeExpected += totalBxBlockSize;
370  if (capIdDefined) {
371  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSGOOD);
372  }
373  } else if (!toSuppress && bxZsFlagSet) {
374  if (verbose_)
375  std::cout << "BAD BX block with ZS flag true" << std::endl;
376  totalBlockSizeExpected += totalBxBlockSize;
381  evtGood[maxMasks_] = false;
382  if (capIdDefined) {
383  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBAD);
384  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBADFALSEPOS);
385  errorSummaryNumMap_[blockCapId]->Fill(RBXBLKS);
386  errorSummaryNumMap_[blockCapId]->Fill(RBXBLKSFALSEPOS);
387  evtGood[blockCapId] = false;
388  }
389  } else {
390  if (verbose_)
391  std::cout << "BAD BX block with ZS flag false" << std::endl;
392  totalBlockSize += totalBxBlockSize;
397  evtGood[maxMasks_] = false;
398  if (capIdDefined) {
399  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBAD);
400  zeroSuppValMap_[blockCapId]->Fill(ZSBXBLKSBADFALSENEG);
401  errorSummaryNumMap_[blockCapId]->Fill(RBXBLKS);
402  errorSummaryNumMap_[blockCapId]->Fill(RBXBLKSFALSENEG);
403  evtGood[blockCapId] = false;
404  }
405  }
406  }
407  }
408 
409  readoutSizeNoZSMap[maxMasks_] += totalBlockSizeNoZS;
410  if (capIdDefined) {
411  readoutSizeNoZSMap[blockCapId] += totalBlockSizeNoZS;
412  }
413 
414  // check if zero suppression flag agrees for the whole block
415  if (allToSuppress && blockZsFlagSet) {
416  if (verbose_)
417  std::cout << "GOOD block with ZS flag true" << std::endl;
419  if (capIdDefined) {
420  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSGOOD);
421  }
422  } else if (!allToSuppress && !blockZsFlagSet) {
423  if (verbose_)
424  std::cout << "GOOD block with ZS flag false" << std::endl;
426  readoutSizeZSMap[maxMasks_] += totalBlockSize;
427  readoutSizeZSExpectedMap[maxMasks_] += totalBlockSizeExpected;
428  if (capIdDefined) {
429  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSGOOD);
430  readoutSizeZSMap[blockCapId] += totalBlockSize;
431  readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
432  }
433  } else if (!allToSuppress && blockZsFlagSet) {
434  if (verbose_)
435  std::cout << "BAD block with ZS flag true" << std::endl;
440  readoutSizeZSExpectedMap[maxMasks_] += totalBlockSizeExpected;
441  evtGood[maxMasks_] = false;
442  if (capIdDefined) {
443  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBAD);
444  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBADFALSEPOS);
445  errorSummaryNumMap_[blockCapId]->Fill(RBLKS);
446  errorSummaryNumMap_[blockCapId]->Fill(RBLKSFALSEPOS);
447  readoutSizeZSExpectedMap[blockCapId] += totalBlockSizeExpected;
448  evtGood[blockCapId] = false;
449  }
450  } else {
451  if (verbose_)
452  std::cout << "BAD block with ZS flag false" << std::endl;
457  readoutSizeZSMap[maxMasks_] += totalBlockSize;
458  evtGood[maxMasks_] = false;
459  if (capIdDefined) {
460  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBAD);
461  zeroSuppValMap_[blockCapId]->Fill(ZSBLKSBADFALSENEG);
462  errorSummaryNumMap_[blockCapId]->Fill(RBLKS);
463  errorSummaryNumMap_[blockCapId]->Fill(RBLKSFALSENEG);
464  readoutSizeZSMap[blockCapId] += totalBlockSize;
465  evtGood[blockCapId] = false;
466  }
467  }
468  }
469  }
470  if (verbose_) {
471  std::cout << "FED data size: " << fedDataSize << " bytes" << std::endl;
472  std::cout << "Payload size no ZS: " << readoutSizeNoZSMap[maxMasks_] << " bytes" << std::endl;
473  std::cout << "Payload size ZS: " << readoutSizeZSMap[maxMasks_] << " bytes" << std::endl;
474  std::cout << "Payload size expected ZS: " << readoutSizeZSExpectedMap[maxMasks_] << " bytes" << std::endl;
475  std::cout << "Filled readout size ZS with headers: "
476  << readoutSizeZSMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_] << " bytes" << std::endl;
477  std::cout << "Filled expected readout size ZS with headers: "
478  << readoutSizeZSExpectedMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_] << " bytes"
479  << std::endl;
480  }
481  readoutSizeNoZSMap_[maxMasks_]->Fill(fedDataSize);
482  readoutSizeZSMap_[maxMasks_]->Fill(readoutSizeZSMap[maxMasks_] + fedDataSize - readoutSizeNoZSMap[maxMasks_]);
483  readoutSizeZSExpectedMap_[maxMasks_]->Fill(readoutSizeZSExpectedMap[maxMasks_] + fedDataSize -
484  readoutSizeNoZSMap[maxMasks_]);
485  for (const auto& id : definedMaskCapIds_) {
486  readoutSizeNoZSMap_[id]->Fill(readoutSizeNoZSMap[id]);
487  readoutSizeZSMap_[id]->Fill(readoutSizeZSMap[id]);
488  readoutSizeZSExpectedMap_[id]->Fill(readoutSizeZSExpectedMap[id]);
489  }
490  }
491 
492  if (evtGood[maxMasks_]) {
494  } else {
497  }
498  for (const auto& id : definedMaskCapIds_) {
499  if (evtGood[id]) {
500  zeroSuppValMap_[id]->Fill(EVTSGOOD);
501  } else {
502  zeroSuppValMap_[id]->Fill(EVTSBAD);
503  errorSummaryNumMap_[id]->Fill(REVTS);
504  }
505  }
506 }
Definition: start.py:1
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken_
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
Log< level::Error, false > LogError
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
void Fill(long long x)
std::vector< unsigned int > definedMaskCapIds_
uint64_t word
MonitorElement * capIds_
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
std::vector< std::vector< int > > masks_
static const unsigned int maxMasks_
Log< level::Info, false > LogInfo
unsigned long long uint64_t
Definition: Time.h:13
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)
Definition: AMC13Spec.cc:60
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
std::vector< amc::Packet > payload() const
Definition: AMC13Spec.h:92
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
std::vector< int > fedIds_
Log< level::Warning, false > LogWarning
Definition: AMCSpec.h:8
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_
bool checkOnlyCapIdsWithMasks_

◆ bookCapIdHistograms()

void L1TMP7ZeroSupp::bookCapIdHistograms ( DQMStore::IBooker ibooker,
const unsigned int &  id 
)
private

Definition at line 88 of file L1TMP7ZeroSupp.cc.

References BLOCKS, dqm::implementation::IBooker::book1D(), BXBLOCKS, errorSummaryDenMap_, errorSummaryNumMap_, EVTS, EVTSBAD, EVTSGOOD, l1ctLayer2EG_cff::id, maxFedReadoutSize_, maxMasks_, NBINLABELS, RBLKS, RBLKSFALSENEG, RBLKSFALSEPOS, RBXBLKS, RBXBLKSFALSENEG, RBXBLKSFALSEPOS, readoutSizeNoZSMap_, readoutSizeZSExpectedMap_, readoutSizeZSMap_, REVTS, RNBINLABELS, AlCaHLTBitMon_QueryRunRegistry::string, to_string(), zeroSuppValMap_, ZSBLKSBAD, ZSBLKSBADFALSENEG, ZSBLKSBADFALSEPOS, ZSBLKSGOOD, ZSBXBLKSBAD, ZSBXBLKSBADFALSENEG, ZSBXBLKSBADFALSEPOS, and ZSBXBLKSGOOD.

Referenced by bookHistograms().

88  {
89  std::string summaryTitleText = "Zero suppression validation summary";
90  std::string sizeTitleText;
91  if (id == maxMasks_) {
92  sizeTitleText = "FED readout ";
93  } else {
94  summaryTitleText = summaryTitleText + ", caption id " + std::to_string(id);
95  sizeTitleText = "cumulated caption id " + std::to_string(id) + " block ";
96  }
97 
98  zeroSuppValMap_[id] = ibooker.book1D("zeroSuppVal", summaryTitleText, (int)NBINLABELS, 0, (int)NBINLABELS);
99  zeroSuppValMap_[id]->setAxisTitle("ZS status", 1);
100  zeroSuppValMap_[id]->setBinLabel(EVTS + 1, "events", 1);
101  zeroSuppValMap_[id]->setBinLabel(EVTSGOOD + 1, "good events", 1);
102  zeroSuppValMap_[id]->setBinLabel(EVTSBAD + 1, "bad events", 1);
103  zeroSuppValMap_[id]->setBinLabel(BLOCKS + 1, "blocks", 1);
104  zeroSuppValMap_[id]->setBinLabel(ZSBLKSGOOD + 1, "good blocks", 1);
105  zeroSuppValMap_[id]->setBinLabel(ZSBLKSBAD + 1, "bad blocks", 1);
106  zeroSuppValMap_[id]->setBinLabel(ZSBLKSBADFALSEPOS + 1, "false pos.", 1);
107  zeroSuppValMap_[id]->setBinLabel(ZSBLKSBADFALSENEG + 1, "false neg.", 1);
108  zeroSuppValMap_[id]->setBinLabel(BXBLOCKS + 1, "BX blocks", 1);
109  zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSGOOD + 1, "good BX blocks", 1);
110  zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBAD + 1, "bad BX blocks", 1);
111  zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBADFALSEPOS + 1, "BX false pos.", 1);
112  zeroSuppValMap_[id]->setBinLabel(ZSBXBLKSBADFALSENEG + 1, "BX false neg.", 1);
113 
114  errorSummaryNumMap_[id] = ibooker.book1D("errorSummaryNum", summaryTitleText, (int)RNBINLABELS, 0, (int)RNBINLABELS);
115  errorSummaryNumMap_[id]->setBinLabel(REVTS + 1, "bad events", 1);
116  errorSummaryNumMap_[id]->setBinLabel(RBLKS + 1, "bad blocks", 1);
117  errorSummaryNumMap_[id]->setBinLabel(RBLKSFALSEPOS + 1, "false pos.", 1);
118  errorSummaryNumMap_[id]->setBinLabel(RBLKSFALSENEG + 1, "false neg.", 1);
119  errorSummaryNumMap_[id]->setBinLabel(RBXBLKS + 1, "bad BX blocks", 1);
120  errorSummaryNumMap_[id]->setBinLabel(RBXBLKSFALSEPOS + 1, "BX false pos.", 1);
121  errorSummaryNumMap_[id]->setBinLabel(RBXBLKSFALSENEG + 1, "BX false neg.", 1);
122 
123  errorSummaryDenMap_[id] = ibooker.book1D("errorSummaryDen", "denominators", (int)RNBINLABELS, 0, (int)RNBINLABELS);
124  errorSummaryDenMap_[id]->setBinLabel(REVTS + 1, "# events", 1);
125  errorSummaryDenMap_[id]->setBinLabel(RBLKS + 1, "# blocks", 1);
126  errorSummaryDenMap_[id]->setBinLabel(RBLKSFALSEPOS + 1, "# blocks", 1);
127  errorSummaryDenMap_[id]->setBinLabel(RBLKSFALSENEG + 1, "# blocks", 1);
128  errorSummaryDenMap_[id]->setBinLabel(RBXBLKS + 1, "# BX blocks", 1);
129  errorSummaryDenMap_[id]->setBinLabel(RBXBLKSFALSEPOS + 1, "# BX blocks", 1);
130  errorSummaryDenMap_[id]->setBinLabel(RBXBLKSFALSENEG + 1, "# BX blocks", 1);
131  // Setting canExtend to false is needed to get the correct behaviour when running multithreaded.
132  // Otherwise, when merging the histgrams of the threads, TH1::Merge sums bins that have the same label in one bin.
133  // This needs to come after the calls to setBinLabel.
134  errorSummaryDenMap_[id]->getTH1F()->GetXaxis()->SetCanExtend(false);
135 
136  readoutSizeNoZSMap_[id] = ibooker.book1D("readoutSize", sizeTitleText + "size", 100, 0, maxFedReadoutSize_);
137  readoutSizeNoZSMap_[id]->setAxisTitle("size (byte)", 1);
139  ibooker.book1D("readoutSizeZS", sizeTitleText + "size with zero suppression", 100, 0, maxFedReadoutSize_);
140  readoutSizeZSMap_[id]->setAxisTitle("size (byte)", 1);
142  "readoutSizeZSExpected", "Expected " + sizeTitleText + "size with zero suppression", 100, 0, maxFedReadoutSize_);
143  readoutSizeZSExpectedMap_[id]->setAxisTitle("size (byte)", 1);
144 }
std::map< unsigned int, MonitorElement * > readoutSizeZSExpectedMap_
std::map< unsigned int, MonitorElement * > zeroSuppValMap_
std::map< unsigned int, MonitorElement * > readoutSizeNoZSMap_
static std::string to_string(const XMLCh *ch)
std::map< unsigned int, MonitorElement * > errorSummaryNumMap_
std::map< unsigned int, MonitorElement * > errorSummaryDenMap_
static const unsigned int maxMasks_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::map< unsigned int, MonitorElement * > readoutSizeZSMap_

◆ bookHistograms()

void L1TMP7ZeroSupp::bookHistograms ( DQMStore::IBooker ibooker,
const edm::Run ,
const edm::EventSetup  
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 74 of file L1TMP7ZeroSupp.cc.

References dqm::implementation::IBooker::book1D(), bookCapIdHistograms(), capIds_, definedMaskCapIds_, maxMasks_, monitorDir_, dqm::impl::MonitorElement::setAxisTitle(), dqm::implementation::NavigatorBase::setCurrentFolder(), and to_string().

74  {
75  // overall summary
78  capIds_ = ibooker.book1D("capIds", "Caption ids found in data", maxMasks_, 0, maxMasks_);
79  capIds_->setAxisTitle("caption id", 1);
80 
81  // per caption id subdirectories
82  for (const auto& id : definedMaskCapIds_) {
83  ibooker.setCurrentFolder(monitorDir_ + "/CapId" + std::to_string(id));
84  bookCapIdHistograms(ibooker, id);
85  }
86 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::string monitorDir_
static std::string to_string(const XMLCh *ch)
void bookCapIdHistograms(DQMStore::IBooker &ibooker, const unsigned int &id)
std::vector< unsigned int > definedMaskCapIds_
MonitorElement * capIds_
static const unsigned int maxMasks_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)

◆ fillDescriptions()

void L1TMP7ZeroSupp::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 47 of file L1TMP7ZeroSupp.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, mps_fire::i, maxMasks_, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

47  {
49  desc.add<edm::InputTag>("rawData");
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.");
62  for (unsigned int i = 0; i < maxMasks_; ++i) {
63  desc.addOptionalUntracked<std::vector<int>>("maskCapId" + std::to_string(i))
64  ->setComment("ZS mask for caption id " + std::to_string(i) + ".");
65  }
66  desc.addUntracked<bool>("checkOnlyCapIdsWithMasks", true)
67  ->setComment("Check only blocks that have a CapId for which a mask is defined.");
68  desc.addUntracked<std::string>("monitorDir", "")
69  ->setComment("Target directory in the DQM file. Will be created if not existing.");
70  desc.addUntracked<bool>("verbose", false);
71  descriptions.add("l1tMP7ZeroSupp", desc);
72 }
static std::string to_string(const XMLCh *ch)
static const unsigned int maxMasks_
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ amc13HeaderSize_

int L1TMP7ZeroSupp::amc13HeaderSize_
private

Definition at line 70 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ amc13TrailerSize_

int L1TMP7ZeroSupp::amc13TrailerSize_
private

Definition at line 71 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ amcHeaderSize_

int L1TMP7ZeroSupp::amcHeaderSize_
private

Definition at line 72 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ amcTrailerSize_

int L1TMP7ZeroSupp::amcTrailerSize_
private

Definition at line 73 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ capIds_

MonitorElement* L1TMP7ZeroSupp::capIds_
private

Definition at line 95 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookHistograms().

◆ checkOnlyCapIdsWithMasks_

bool L1TMP7ZeroSupp::checkOnlyCapIdsWithMasks_
private

Definition at line 80 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ dataInvFlagMask_

int L1TMP7ZeroSupp::dataInvFlagMask_
private

Definition at line 76 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ definedMaskCapIds_

std::vector<unsigned int> L1TMP7ZeroSupp::definedMaskCapIds_
private

Definition at line 87 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), bookHistograms(), and L1TMP7ZeroSupp().

◆ errorSummaryDenMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::errorSummaryDenMap_
private

Definition at line 91 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ errorSummaryNumMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::errorSummaryNumMap_
private

Definition at line 90 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ fedDataToken_

edm::EDGetTokenT<FEDRawDataCollection> L1TMP7ZeroSupp::fedDataToken_
private

Definition at line 62 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ fedIds_

std::vector<int> L1TMP7ZeroSupp::fedIds_
private

Definition at line 64 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ masks_

std::vector<std::vector<int> > L1TMP7ZeroSupp::masks_
private

Definition at line 65 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and L1TMP7ZeroSupp().

◆ maxFedReadoutSize_

int L1TMP7ZeroSupp::maxFedReadoutSize_
private

Definition at line 78 of file L1TMP7ZeroSupp.h.

Referenced by bookCapIdHistograms().

◆ maxMasks_

const unsigned int L1TMP7ZeroSupp::maxMasks_ = 16
staticprivate

◆ monitorDir_

std::string L1TMP7ZeroSupp::monitorDir_
private

Definition at line 82 of file L1TMP7ZeroSupp.h.

Referenced by bookHistograms().

◆ newZsFlagMask_

int L1TMP7ZeroSupp::newZsFlagMask_
private

Definition at line 74 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ readoutSizeNoZSMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::readoutSizeNoZSMap_
private

Definition at line 92 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ readoutSizeZSExpectedMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::readoutSizeZSExpectedMap_
private

Definition at line 94 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ readoutSizeZSMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::readoutSizeZSMap_
private

Definition at line 93 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ slinkHeaderSize_

int L1TMP7ZeroSupp::slinkHeaderSize_
private

Definition at line 68 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ slinkTrailerSize_

int L1TMP7ZeroSupp::slinkTrailerSize_
private

Definition at line 69 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ verbose_

bool L1TMP7ZeroSupp::verbose_
private

Definition at line 83 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and L1TMP7ZeroSupp().

◆ zeroSuppValMap_

std::map<unsigned int, MonitorElement*> L1TMP7ZeroSupp::zeroSuppValMap_
private

Definition at line 89 of file L1TMP7ZeroSupp.h.

Referenced by analyze(), and bookCapIdHistograms().

◆ zsEnabled_

bool L1TMP7ZeroSupp::zsEnabled_
private

Definition at line 63 of file L1TMP7ZeroSupp.h.

Referenced by analyze().

◆ zsFlagMask_

int L1TMP7ZeroSupp::zsFlagMask_
private

Definition at line 75 of file L1TMP7ZeroSupp.h.

Referenced by analyze().