CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
RPCTwinMuxRawToDigi Class Reference

#include <RPCTwinMuxRawToDigi.h>

Inheritance diagram for RPCTwinMuxRawToDigi:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &setup) override
 
void produce (edm::Event &event, edm::EventSetup const &setup) override
 
 RPCTwinMuxRawToDigi (edm::ParameterSet const &config)
 
 ~RPCTwinMuxRawToDigi () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void compute_crc_64bit (std::uint16_t &crc, std::uint64_t const &word)
 
static void fillDescriptions (edm::ConfigurationDescriptions &descs)
 

Protected Member Functions

bool processBlock (int fed, std::uint64_t const *&word, std::uint64_t const *word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis) const
 
bool processCDFHeaders (int fed, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
 
bool processCDFTrailers (int fed, unsigned int nwords, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
 
void processRPCRecord (int fed, unsigned int amc_number, unsigned int bx_counter, rpctwinmux::RPCRecord const &record, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis, int bx_min, int bx_max, unsigned int link, unsigned int link_max) const
 
bool processTwinMux (int fed, unsigned int amc_number, unsigned int size, std::uint64_t const *&word, std::uint64_t const *word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis) const
 
void putCounters (edm::Event &event, std::unique_ptr< RPCAMCLinkCounters > counters)
 
void putRPCDigis (edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis)
 

Protected Attributes

int bx_max_
 
int bx_min_
 
bool calculate_crc_
 
edm::ESHandle< RPCLBLinkMapes_lb_link_map_
 
edm::ESHandle< RPCAMCLinkMapes_tm_link_map_
 
edm::ESWatcher< RPCTwinMuxLinkMapRcdes_tm_link_map_watcher_
 
std::vector< int > feds_
 
bool fill_counters_
 
edm::EDGetTokenT< FEDRawDataCollectionraw_token_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 30 of file RPCTwinMuxRawToDigi.h.

Constructor & Destructor Documentation

◆ RPCTwinMuxRawToDigi()

RPCTwinMuxRawToDigi::RPCTwinMuxRawToDigi ( edm::ParameterSet const &  config)

Definition at line 24 of file RPCTwinMuxRawToDigi.cc.

25  : calculate_crc_(config.getParameter<bool>("calculateCRC")),
26  fill_counters_(config.getParameter<bool>("fillCounters")),
27  bx_min_(config.getParameter<int>("bxMin")),
28  bx_max_(config.getParameter<int>("bxMax")) {
29  produces<RPCDigiCollection>();
30  if (fill_counters_) {
31  produces<RPCAMCLinkCounters>();
32  }
33  raw_token_ = consumes<FEDRawDataCollection>(config.getParameter<edm::InputTag>("inputTag"));
34 }

References fill_counters_, and raw_token_.

◆ ~RPCTwinMuxRawToDigi()

RPCTwinMuxRawToDigi::~RPCTwinMuxRawToDigi ( )
override

Definition at line 36 of file RPCTwinMuxRawToDigi.cc.

36 {}

Member Function Documentation

◆ beginRun()

void RPCTwinMuxRawToDigi::beginRun ( edm::Run const &  run,
edm::EventSetup const &  setup 
)
override

Definition at line 56 of file RPCTwinMuxRawToDigi.cc.

56  {
59  std::set<int> feds;
60  for (auto const &tm_link : es_tm_link_map_->getMap()) {
61  feds.insert(tm_link.first.getFED());
62  }
63  feds_.assign(feds.begin(), feds.end());
64  }
65 }

References edm::ESWatcher< T >::check(), es_tm_link_map_, es_tm_link_map_watcher_, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, feds_, get, RPCAMCLinkMap::getMap(), and singleTopDQM_cfi::setup.

◆ compute_crc_64bit()

void RPCTwinMuxRawToDigi::compute_crc_64bit ( std::uint16_t &  crc,
std::uint64_t const &  word 
)
static

Definition at line 38 of file RPCTwinMuxRawToDigi.cc.

39  { // overcome constness problem evf::compute_crc_64bit
40  unsigned char const *uchars(reinterpret_cast<unsigned char const *>(&word));
41  for (unsigned char const *uchar = uchars + 7; uchar >= uchars; --uchar) {
42  crc = evf::compute_crc_8bit(crc, *uchar);
43  }
44 }

References evf::compute_crc_8bit().

Referenced by processBlock(), processCDFHeaders(), processTwinMux(), and produce().

◆ fillDescriptions()

void RPCTwinMuxRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descs)
static

Definition at line 46 of file RPCTwinMuxRawToDigi.cc.

46  {
48  desc.add<edm::InputTag>("inputTag", edm::InputTag("rawDataCollector", ""));
49  desc.add<bool>("calculateCRC", true);
50  desc.add<bool>("fillCounters", true);
51  desc.add<int>("bxMin", -2);
52  desc.add<int>("bxMax", 2);
53  descs.add("rpcTwinMuxRawToDigi", desc);
54 }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and HLT_2018_cff::InputTag.

◆ processBlock()

bool RPCTwinMuxRawToDigi::processBlock ( int  fed,
std::uint64_t const *&  word,
std::uint64_t const *  word_end,
std::uint16_t &  crc,
RPCAMCLinkCounters counters,
std::set< std::pair< RPCDetId, RPCDigi > > &  digis 
) const
protected

Definition at line 214 of file RPCTwinMuxRawToDigi.cc.

219  {
220  // Block Header and Content
221  rpctwinmux::BlockHeader block_header(*word);
222  if (calculate_crc_) {
223  compute_crc_64bit(crc, *word);
224  }
225  ++word;
226 
227  unsigned int n_amc(block_header.getNAMC());
228  if (word + n_amc + 1 >= word_end) {
229  if (fill_counters_) {
231  }
232  edm::LogWarning("RPCTwinMuxRawToDigi") << "Block can not be complete for FED " << fed;
233  word = word_end;
234  return false;
235  }
236 
237  std::vector<std::pair<unsigned int, unsigned int> > amc_size_map;
238  for (unsigned int amc = 0; amc < n_amc; ++amc) {
239  LogDebug("RPCTwinMuxRawToDigi") << "Block AMC " << amc;
240  rpctwinmux::BlockAMCContent amc_content(*word);
241  if (calculate_crc_) {
242  compute_crc_64bit(crc, *word);
243  }
244  ++word;
245 
246  amc_size_map.push_back(std::make_pair(amc_content.getAMCNumber(), amc_content.getSize()));
247  if (!amc_content.isValid()) {
248  if (fill_counters_) {
249  counters.add(RPCAMCLinkEvents::amc_amc13_evc_bc_invalid_, RPCAMCLink(fed, amc_content.getAMCNumber()));
250  }
251  edm::LogWarning("RPCTwinMuxRawToDigi")
252  << "BlockAMCContent is reporting an invalid "
253  << "Event Counter or Bunch Counter for FED " << fed << ", AMC " << amc_content.getAMCNumber();
254  }
255  }
256 
257  for (std::pair<unsigned int, unsigned int> const &amc_size : amc_size_map) {
258  processTwinMux(fed, amc_size.first, amc_size.second, word, word_end, crc, counters, digis);
259  }
260 
261  if (word < word_end) {
262  rpctwinmux::BlockTrailer block_trailer(*word);
263  if (calculate_crc_) {
264  compute_crc_64bit(crc, *word);
265  }
266  ++word;
267  return true;
268  } else {
269  return false;
270  }
271 }

References RPCAMCLinkCounters::add(), amc, RPCAMCLinkEvents::amc_amc13_evc_bc_invalid_, calculate_crc_, compute_crc_64bit(), RPCAMCLinkEvents::fed_amc13_block_incomplete_, fill_counters_, rpctwinmux::BlockAMCContent::getAMCNumber(), rpctwinmux::BlockHeader::getNAMC(), rpctwinmux::BlockAMCContent::getSize(), rpctwinmux::BlockAMCContent::isValid(), LogDebug, processTwinMux(), and RPCAMCLink::wildcard_.

Referenced by produce().

◆ processCDFHeaders()

bool RPCTwinMuxRawToDigi::processCDFHeaders ( int  fed,
std::uint64_t const *&  word,
std::uint64_t const *&  word_end,
std::uint16_t &  crc,
RPCAMCLinkCounters counters 
) const
protected

Definition at line 137 of file RPCTwinMuxRawToDigi.cc.

141  {
142  bool more_headers(true);
143  for (; word < word_end && more_headers; ++word) {
144  if (calculate_crc_) {
145  compute_crc_64bit(crc, *word);
146  }
147 
148  LogDebug("RPCTwinMuxRawToDigi") << "CDF Header " << std::hex << *word << std::dec;
149  FEDHeader header(reinterpret_cast<unsigned char const *>(word));
150  if (!header.check()) {
151  if (fill_counters_) {
153  }
154  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Header check failed for FED id " << fed;
155  ++word;
156  break;
157  }
158  if (header.sourceID() != fed) {
159  if (fill_counters_) {
161  }
162  edm::LogWarning("RPCTwinMuxRawToDigi")
163  << "FED Header Source ID " << header.sourceID() << " does not match requested FED id " << fed;
164  break;
165  }
166 
167  // moreHeaders() not used
168  // more_headers = header.moreHeaders();
169  more_headers = false;
170  }
171 
172  return !more_headers;
173 }

References RPCAMCLinkCounters::add(), calculate_crc_, compute_crc_64bit(), TauDecayModes::dec, RPCAMCLinkEvents::fed_header_check_fail_, RPCAMCLinkEvents::fed_header_id_mismatch_, fill_counters_, RecoTauValidation_cfi::header, LogDebug, and RPCAMCLink::wildcard_.

Referenced by produce().

◆ processCDFTrailers()

bool RPCTwinMuxRawToDigi::processCDFTrailers ( int  fed,
unsigned int  nwords,
std::uint64_t const *&  word,
std::uint64_t const *&  word_end,
std::uint16_t &  crc,
RPCAMCLinkCounters counters 
) const
protected

Definition at line 175 of file RPCTwinMuxRawToDigi.cc.

180  {
181  bool more_trailers(true);
182  for (--word_end; word_end > word && more_trailers; --word_end) {
183  FEDTrailer trailer(reinterpret_cast<unsigned char const *>(word_end));
184  LogDebug("RPCTwinMuxRawToDigi") << "CDF Trailer " << std::hex << *word_end << std::dec << ", length "
185  << trailer.fragmentLength();
186  if (!trailer.check()) {
187  if (fill_counters_) {
189  }
190  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer check failed for FED id " << fed;
191  --word_end;
192  break;
193  }
194  if (trailer.fragmentLength() != nwords) {
195  if (fill_counters_) {
197  }
198  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer length " << trailer.fragmentLength()
199  << " does not match actual data size " << nwords << " for FED id " << fed;
200  --word_end;
201  break;
202  }
203 
204  // moreTrailers() not used
205  // more_trailers = trailer.moreTrailers();
206  more_trailers = false;
207  }
208 
209  ++word_end;
210 
211  return !more_trailers;
212 }

References RPCAMCLinkCounters::add(), FEDTrailer::check(), TauDecayModes::dec, RPCAMCLinkEvents::fed_trailer_check_fail_, RPCAMCLinkEvents::fed_trailer_length_mismatch_, fill_counters_, FEDTrailer::fragmentLength(), LogDebug, and RPCAMCLink::wildcard_.

Referenced by produce().

◆ processRPCRecord()

void RPCTwinMuxRawToDigi::processRPCRecord ( int  fed,
unsigned int  amc_number,
unsigned int  bx_counter,
rpctwinmux::RPCRecord const &  record,
RPCAMCLinkCounters counters,
std::set< std::pair< RPCDetId, RPCDigi > > &  digis,
int  bx_min,
int  bx_max,
unsigned int  link,
unsigned int  link_max 
) const
protected

Definition at line 389 of file RPCTwinMuxRawToDigi.cc.

398  {
399  LogDebug("RPCTwinMuxRawToDigi") << "RPCRecord " << std::hex << record.getRecord()[0] << ", " << record.getRecord()[1]
400  << std::dec << std::endl;
401  int bx_offset(record.getBXOffset());
402  RPCAMCLink tm_link(fed, amc_number);
403  for (; link <= link_max; ++link) {
404  tm_link.setAMCInput(link);
405  rpctwinmux::RPCLinkRecord link_record(record.getRPCLinkRecord(link));
406 
407  if (link_record.isError()) {
408  if (fill_counters_ && bx_offset == 0) {
409  counters.add(RPCAMCLinkEvents::input_link_error_, tm_link);
410  }
411  LogDebug("RPCTwinMuxRawToDigi") << "Link in error for " << tm_link;
412  continue;
413  } else if (!link_record.isAcknowledge()) {
414  if (fill_counters_ && bx_offset == 0) {
415  counters.add(RPCAMCLinkEvents::input_link_ack_fail_, tm_link);
416  }
417  LogDebug("RPCTwinMuxRawToDigi") << "Link without acknowledge for " << tm_link;
418  continue;
419  }
420 
421  if (!link_record.getPartitionData()) {
422  continue;
423  }
424 
425  int bx(bx_offset - (int)(link_record.getDelay()));
426  LogDebug("RPCTwinMuxRawToDigi") << "RPC BX " << bx << " for offset " << bx_offset;
427 
428  if (fill_counters_ && bx == 0 && link_record.isEOD()) { // EOD comes at the last delay
429  counters.add(RPCAMCLinkEvents::input_eod_, tm_link);
430  }
431 
432  RPCAMCLinkMap::map_type::const_iterator tm_link_it = es_tm_link_map_->getMap().find(tm_link);
433  if (tm_link_it == es_tm_link_map_->getMap().end()) {
434  if (fill_counters_ && bx_offset == 0) {
435  counters.add(RPCAMCLinkEvents::amc_link_invalid_, RPCAMCLink(fed, amc_number));
436  }
437  LogDebug("RPCTwinMuxRawToDigi") << "Skipping unknown TwinMuxLink " << tm_link;
438  continue;
439  }
440 
441  RPCLBLink lb_link = tm_link_it->second;
442 
443  if (link_record.getLinkBoard() > (unsigned int)RPCLBLink::max_linkboard_) {
444  if (fill_counters_ && bx_offset == 0) {
445  counters.add(RPCAMCLinkEvents::input_lb_invalid_, tm_link);
446  }
447  LogDebug("RPCTwinMuxRawToDigi") << "Skipping invalid LinkBoard " << link_record.getLinkBoard() << " for record "
448  << link << " (" << std::hex << link_record.getRecord() << " in "
449  << record.getRecord()[0] << ':' << record.getRecord()[1] << std::dec << " from "
450  << tm_link;
451  continue;
452  }
453 
454  if (link_record.getConnector() > (unsigned int)RPCLBLink::max_connector_) {
455  if (fill_counters_ && bx_offset == 0) {
457  }
458  LogDebug("RPCTwinMuxRawToDigi") << "Skipping invalid Connector " << link_record.getConnector() << " for record "
459  << link << " (" << std::hex << link_record.getRecord() << " in "
460  << record.getRecord()[0] << ':' << record.getRecord()[1] << std::dec << ") from "
461  << tm_link;
462  continue;
463  }
464 
465  lb_link.setLinkBoard(link_record.getLinkBoard());
466  lb_link.setConnector(link_record.getConnector());
467 
468  RPCLBLinkMap::map_type::const_iterator lb_link_it = es_lb_link_map_->getMap().find(lb_link);
469  if (lb_link_it == es_lb_link_map_->getMap().end()) {
470  if (fill_counters_ && bx_offset == 0) {
472  }
473  LogDebug("RPCTwinMuxRawToDigi") << "Could not find " << lb_link << " for record " << link << " (" << std::hex
474  << link_record.getRecord() << " in " << record.getRecord()[0] << ':'
475  << record.getRecord()[1] << std::dec << ") from " << tm_link;
476  continue;
477  }
478 
479  if (bx < bx_min || bx > bx_max) {
480  continue;
481  }
482 
483  if (fill_counters_ && bx == 0) {
484  counters.add(RPCAMCLinkEvents::amc_event_, RPCAMCLink(fed, amc_number));
485  counters.add(RPCAMCLinkEvents::input_event_, tm_link);
486  }
487 
488  RPCFebConnector const &feb_connector(lb_link_it->second);
489  RPCDetId det_id(feb_connector.getRPCDetId());
490  unsigned int channel_offset(link_record.getPartition() ? 9 : 1); // 1-16
491  std::uint8_t data(link_record.getPartitionData());
492 
493  for (unsigned int channel = 0; channel < 8; ++channel) {
494  if (data & (0x1 << channel)) {
495  unsigned int strip(feb_connector.getStrip(channel + channel_offset));
496  if (strip) {
497  digis.insert(std::pair<RPCDetId, RPCDigi>(det_id, RPCDigi(strip, bx)));
498  LogDebug("RPCTwinMuxRawToDigi") << "RPCDigi " << det_id.rawId() << ", " << strip << ", " << bx;
499  }
500  }
501  }
502 
503  // rpctwinmux::RPCBXRecord checks postponed: not implemented in firmware as planned and tbd if design or firmware should change
504  }
505 }

References RPCAMCLinkCounters::add(), RPCAMCLinkEvents::amc_event_, RPCAMCLinkEvents::amc_link_invalid_, simKBmtfDigis_cfi::bx, data, TauDecayModes::dec, es_lb_link_map_, es_tm_link_map_, fill_counters_, RPCLBLinkMap::getMap(), RPCAMCLinkMap::getMap(), RPCFebConnector::getRPCDetId(), RPCFebConnector::getStrip(), RPCAMCLinkEvents::input_connector_invalid_, RPCAMCLinkEvents::input_connector_not_used_, RPCAMCLinkEvents::input_eod_, RPCAMCLinkEvents::input_event_, RPCAMCLinkEvents::input_lb_invalid_, RPCAMCLinkEvents::input_link_ack_fail_, RPCAMCLinkEvents::input_link_error_, createfilelist::int, MainPageGenerator::link, LogDebug, RPCLBLink::max_connector_, RPCLBLink::max_linkboard_, GlobalPosition_Frontier_DevDB_cff::record, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), digitizers_cfi::strip, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by processTwinMux().

◆ processTwinMux()

bool RPCTwinMuxRawToDigi::processTwinMux ( int  fed,
unsigned int  amc_number,
unsigned int  size,
std::uint64_t const *&  word,
std::uint64_t const *  word_end,
std::uint16_t &  crc,
RPCAMCLinkCounters counters,
std::set< std::pair< RPCDetId, RPCDigi > > &  digis 
) const
protected

Definition at line 273 of file RPCTwinMuxRawToDigi.cc.

280  {
281  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux AMC#" << amc_number << ", size " << size;
282  if (!size) {
283  return true;
284  }
285  if (amc_number > (unsigned int)RPCAMCLink::max_amcnumber_) {
286  if (fill_counters_) {
288  }
289  edm::LogWarning("RPCTwinMuxRawToDigi") << "Invalid AMC Number " << amc_number << " for FED " << fed;
290  if (calculate_crc_) {
291  for (; size > 0; --size, ++word) {
292  compute_crc_64bit(crc, *word);
293  }
294  } else {
295  word += size;
296  }
297  return false;
298  }
299  if (word + size >= word_end || size < 3) {
300  if (fill_counters_) {
301  counters.add(RPCAMCLinkEvents::amc_payload_incomplete_, RPCAMCLink(fed, amc_number));
302  }
303  edm::LogWarning("RPCTwinMuxRawToDigi")
304  << "TwinMux Data can not be complete for FED " << fed << " AMC #" << amc_number;
305  if (calculate_crc_) {
306  for (; size > 0; --size, ++word) {
307  compute_crc_64bit(crc, *word);
308  }
309  } else {
310  word += size;
311  }
312  return false;
313  }
314 
316  unsigned int bx_counter(header.getBXCounter());
317  if (calculate_crc_) {
318  compute_crc_64bit(crc, *word);
319  ++word;
320  compute_crc_64bit(crc, *word);
321  ++word;
322  } else {
323  word += 2;
324  }
325  size -= 2;
326 
327  if (amc_number != header.getAMCNumber()) {
328  if (fill_counters_) {
329  counters.add(RPCAMCLinkEvents::amc_number_mismatch_, RPCAMCLink(fed, amc_number));
330  }
331  edm::LogWarning("RPCTwinMuxRawToDigi")
332  << "AMC Number inconsistent in TwinMuxHeader vs BlockAMCContent: " << header.getAMCNumber() << " vs "
333  << amc_number;
334  if (calculate_crc_) {
335  for (; size > 0; --size, ++word) {
336  compute_crc_64bit(crc, *word);
337  }
338  } else {
339  word += size;
340  }
341  return false;
342  }
343 
344  int bx_min(bx_min_), bx_max(bx_max_);
345  if (header.hasRPCBXWindow()) {
346  bx_min = std::max(bx_min, header.getRPCBXMin());
347  bx_max = std::min(bx_max, header.getRPCBXMax());
348  LogDebug("RPCTwinMuxRawToDigi") << "BX range set to " << bx_min << ", " << bx_max;
349  }
350 
351  bool has_first_rpc_word(false);
352  rpctwinmux::RPCRecord rpc_record;
353  for (; size > 1; --size, ++word) {
354  if (calculate_crc_) {
355  compute_crc_64bit(crc, *word);
356  }
358  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux data type " << std::hex << type << std::dec;
360  if (has_first_rpc_word) {
361  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 1);
362  }
363  rpc_record.reset();
364  rpc_record.set(0, *word);
365  has_first_rpc_word = true;
367  if (!has_first_rpc_word) {
368  edm::LogWarning("RPCTwinMuxRawToDigi") << "Received second RPC word without first";
369  } else {
370  rpc_record.set(1, *word);
371  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 4);
372  has_first_rpc_word = false;
373  }
374  }
375  }
376  if (has_first_rpc_word) {
377  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 1);
378  }
379 
381  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux Trailer " << std::hex << *word << std::dec;
382  if (calculate_crc_) {
383  compute_crc_64bit(crc, *word);
384  }
385  ++word;
386  return true;
387 }

References RPCAMCLinkCounters::add(), RPCAMCLinkEvents::amc_number_mismatch_, RPCAMCLinkEvents::amc_payload_incomplete_, bx_max_, bx_min_, calculate_crc_, compute_crc_64bit(), TauDecayModes::dec, RPCAMCLinkEvents::fed_amc13_amc_number_invalid_, fill_counters_, rpctwinmux::TwinMuxRecord::getType(), RecoTauValidation_cfi::header, LogDebug, SiStripPI::max, RPCAMCLink::max_amcnumber_, min(), processRPCRecord(), rpctwinmux::RPCRecord::reset(), rpctwinmux::TwinMuxRecord::rpc_first_type_, rpctwinmux::TwinMuxRecord::rpc_second_type_, rpctwinmux::RPCRecord::set(), findQualityFiles::size, and RPCAMCLink::wildcard_.

Referenced by processBlock().

◆ produce()

void RPCTwinMuxRawToDigi::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 67 of file RPCTwinMuxRawToDigi.cc.

67  {
68  // Get EventSetup Electronics Maps
71 
72  // Get RAW Data
73  edm::Handle<FEDRawDataCollection> raw_data_collection;
74  event.getByToken(raw_token_, raw_data_collection);
75 
76  std::set<std::pair<RPCDetId, RPCDigi> > rpc_digis;
77  std::unique_ptr<RPCAMCLinkCounters> counters(new RPCAMCLinkCounters());
78 
79  // Loop over the FEDs
80  for (int fed : feds_) {
81  if (fill_counters_) {
83  }
84 
85  std::uint16_t crc(0xffff);
86 
87  FEDRawData const &raw_data = raw_data_collection->FEDData(fed);
88  unsigned int nwords(raw_data.size() / sizeof(std::uint64_t));
89  if (!nwords) {
90  continue;
91  }
92 
93  std::uint64_t const *word(reinterpret_cast<std::uint64_t const *>(raw_data.data()));
94  std::uint64_t const *word_end = word + nwords;
95 
96  LogDebug("RPCTwinMuxRawToDigi") << "Handling FED " << fed << " with length " << nwords;
97 
98  // Handle the CDF Headers
99  if (!processCDFHeaders(fed, word, word_end, crc, *counters)) {
100  continue;
101  }
102 
103  // Handle the CDF Trailers
104  if (!processCDFTrailers(fed, nwords, word, word_end, crc, *counters)) {
105  continue;
106  }
107 
108  // Loop over the Blocks
109  while (word < word_end) {
110  processBlock(fed, word, word_end, crc, *counters, rpc_digis);
111  }
112 
113  // Complete CRC check with trailer
114  if (calculate_crc_) {
115  word = word_end;
116  word_end = reinterpret_cast<std::uint64_t const *>(raw_data.data()) + nwords - 1;
117  for (; word < word_end; ++word) {
118  compute_crc_64bit(crc, *word);
119  }
120  compute_crc_64bit(crc, (*word & 0xffffffff0000ffff)); // trailer excluding crc
121  FEDTrailer trailer(reinterpret_cast<unsigned char const *>(word_end));
122  if ((unsigned int)(trailer.crc()) != crc) {
123  if (fill_counters_) {
125  }
126  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer CRC doesn't match for FED id " << fed;
127  }
128  }
129  }
130 
131  putRPCDigis(event, rpc_digis);
132  if (fill_counters_) {
133  putCounters(event, std::move(counters));
134  }
135 }

References calculate_crc_, compute_crc_64bit(), FEDTrailer::crc(), FEDRawData::data(), es_lb_link_map_, es_tm_link_map_, RPCAMCLinkEvents::fed_event_, RPCAMCLinkEvents::fed_trailer_crc_mismatch_, FEDRawDataCollection::FEDData(), feds_, fill_counters_, get, LogDebug, eostools::move(), processBlock(), processCDFHeaders(), processCDFTrailers(), putCounters(), putRPCDigis(), raw_token_, singleTopDQM_cfi::setup, FEDRawData::size(), and RPCAMCLink::wildcard_.

◆ putCounters()

void RPCTwinMuxRawToDigi::putCounters ( edm::Event event,
std::unique_ptr< RPCAMCLinkCounters counters 
)
protected

Definition at line 530 of file RPCTwinMuxRawToDigi.cc.

530  {
531  event.put(std::move(counters));
532 }

References eostools::move().

Referenced by produce().

◆ putRPCDigis()

void RPCTwinMuxRawToDigi::putRPCDigis ( edm::Event event,
std::set< std::pair< RPCDetId, RPCDigi > > const &  digis 
)
protected

Definition at line 507 of file RPCTwinMuxRawToDigi.cc.

507  {
508  std::unique_ptr<RPCDigiCollection> rpc_digi_collection(new RPCDigiCollection());
509  RPCDetId rpc_det_id;
510  std::vector<RPCDigi> local_digis;
511  for (std::pair<RPCDetId, RPCDigi> const &rpc_digi : digis) {
512  LogDebug("RPCTwinMuxRawToDigi") << "RPCDigi " << rpc_digi.first.rawId() << ", " << rpc_digi.second.strip() << ", "
513  << rpc_digi.second.bx();
514  if (rpc_digi.first != rpc_det_id) {
515  if (!local_digis.empty()) {
516  rpc_digi_collection->put(RPCDigiCollection::Range(local_digis.begin(), local_digis.end()), rpc_det_id);
517  local_digis.clear();
518  }
519  rpc_det_id = rpc_digi.first;
520  }
521  local_digis.push_back(rpc_digi.second);
522  }
523  if (!local_digis.empty()) {
524  rpc_digi_collection->put(RPCDigiCollection::Range(local_digis.begin(), local_digis.end()), rpc_det_id);
525  }
526 
527  event.put(std::move(rpc_digi_collection));
528 }

References LogDebug, and eostools::move().

Referenced by produce().

Member Data Documentation

◆ bx_max_

int RPCTwinMuxRawToDigi::bx_max_
protected

Definition at line 85 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

◆ bx_min_

int RPCTwinMuxRawToDigi::bx_min_
protected

Definition at line 85 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

◆ calculate_crc_

bool RPCTwinMuxRawToDigi::calculate_crc_
protected

Definition at line 84 of file RPCTwinMuxRawToDigi.h.

Referenced by processBlock(), processCDFHeaders(), processTwinMux(), and produce().

◆ es_lb_link_map_

edm::ESHandle<RPCLBLinkMap> RPCTwinMuxRawToDigi::es_lb_link_map_
protected

Definition at line 90 of file RPCTwinMuxRawToDigi.h.

Referenced by processRPCRecord(), and produce().

◆ es_tm_link_map_

edm::ESHandle<RPCAMCLinkMap> RPCTwinMuxRawToDigi::es_tm_link_map_
protected

Definition at line 89 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun(), processRPCRecord(), and produce().

◆ es_tm_link_map_watcher_

edm::ESWatcher<RPCTwinMuxLinkMapRcd> RPCTwinMuxRawToDigi::es_tm_link_map_watcher_
protected

Definition at line 87 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun().

◆ feds_

std::vector<int> RPCTwinMuxRawToDigi::feds_
protected

Definition at line 88 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun(), and produce().

◆ fill_counters_

bool RPCTwinMuxRawToDigi::fill_counters_
protected

◆ raw_token_

edm::EDGetTokenT<FEDRawDataCollection> RPCTwinMuxRawToDigi::raw_token_
protected

Definition at line 82 of file RPCTwinMuxRawToDigi.h.

Referenced by produce(), and RPCTwinMuxRawToDigi().

edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:153
RPCAMCLinkEvents::fed_amc13_amc_number_invalid_
static unsigned const int fed_amc13_amc_number_invalid_
Definition: RPCAMCLinkEvents.h:20
RPCTwinMuxRawToDigi::processBlock
bool processBlock(int fed, std::uint64_t const *&word, std::uint64_t const *word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis) const
Definition: RPCTwinMuxRawToDigi.cc:214
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
RPCTwinMuxRawToDigi::processTwinMux
bool processTwinMux(int fed, unsigned int amc_number, unsigned int size, std::uint64_t const *&word, std::uint64_t const *word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis) const
Definition: RPCTwinMuxRawToDigi.cc:273
rpctwinmux::TwinMuxRecord::rpc_first_type_
static unsigned const int rpc_first_type_
Definition: RPCTwinMuxRecord.h:11
rpctwinmux::TwinMuxTrailer
Definition: RPCTwinMuxRecord.h:250
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
rpctwinmux::TwinMuxRecord::rpc_second_type_
static unsigned const int rpc_second_type_
Definition: RPCTwinMuxRecord.h:12
rpctwinmux::TwinMuxHeader
Definition: RPCTwinMuxRecord.h:170
RPCAMCLinkEvents::input_event_
static unsigned const int input_event_
Definition: RPCAMCLinkEvents.h:36
min
T min(T a, T b)
Definition: MathUtil.h:58
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
RPCAMCLinkEvents::input_connector_invalid_
static unsigned const int input_connector_invalid_
Definition: RPCAMCLinkEvents.h:41
RPCDetId
Definition: RPCDetId.h:16
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
RPCFebConnector
Definition: RPCFebConnector.h:12
RPCTwinMuxRawToDigi::bx_max_
int bx_max_
Definition: RPCTwinMuxRawToDigi.h:85
edm::Handle
Definition: AssociativeIterator.h:50
RPCLBLinkMap::getMap
map_type & getMap()
Definition: RPCLBLinkMap.h:27
RPCAMCLinkEvents::fed_trailer_length_mismatch_
static unsigned const int fed_trailer_length_mismatch_
Definition: RPCAMCLinkEvents.h:15
RPCAMCLinkEvents::amc_number_mismatch_
static unsigned const int amc_number_mismatch_
Definition: RPCAMCLinkEvents.h:30
RPCTwinMuxRawToDigi::processRPCRecord
void processRPCRecord(int fed, unsigned int amc_number, unsigned int bx_counter, rpctwinmux::RPCRecord const &record, RPCAMCLinkCounters &counters, std::set< std::pair< RPCDetId, RPCDigi > > &digis, int bx_min, int bx_max, unsigned int link, unsigned int link_max) const
Definition: RPCTwinMuxRawToDigi.cc:389
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
RPCTwinMuxRawToDigi::putRPCDigis
void putRPCDigis(edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis)
Definition: RPCTwinMuxRawToDigi.cc:507
RPCAMCLinkEvents::input_lb_invalid_
static unsigned const int input_lb_invalid_
Definition: RPCAMCLinkEvents.h:40
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
simKBmtfDigis_cfi.bx
bx
Definition: simKBmtfDigis_cfi.py:55
RPCTwinMuxRawToDigi::processCDFTrailers
bool processCDFTrailers(int fed, unsigned int nwords, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
Definition: RPCTwinMuxRawToDigi.cc:175
config
Definition: config.py:1
RPCTwinMuxRawToDigi::putCounters
void putCounters(edm::Event &event, std::unique_ptr< RPCAMCLinkCounters > counters)
Definition: RPCTwinMuxRawToDigi.cc:530
rpctwinmux::RPCRecord::set
void set(unsigned int word, std::uint64_t const record)
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
RPCAMCLinkEvents::amc_event_
static unsigned const int amc_event_
Definition: RPCAMCLinkEvents.h:23
RPCAMCLinkEvents::fed_event_
static unsigned const int fed_event_
Definition: RPCAMCLinkEvents.h:11
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
RPCTwinMuxRawToDigi::feds_
std::vector< int > feds_
Definition: RPCTwinMuxRawToDigi.h:88
RPCAMCLinkEvents::amc_payload_incomplete_
static unsigned const int amc_payload_incomplete_
Definition: RPCAMCLinkEvents.h:28
RPCAMCLinkEvents::fed_header_check_fail_
static unsigned const int fed_header_check_fail_
Definition: RPCAMCLinkEvents.h:12
RPCAMCLinkEvents::fed_trailer_crc_mismatch_
static unsigned const int fed_trailer_crc_mismatch_
Definition: RPCAMCLinkEvents.h:16
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
RPCAMCLinkEvents::fed_trailer_check_fail_
static unsigned const int fed_trailer_check_fail_
Definition: RPCAMCLinkEvents.h:14
edm::LogWarning
Definition: MessageLogger.h:141
RPCAMCLinkEvents::input_link_ack_fail_
static unsigned const int input_link_ack_fail_
Definition: RPCAMCLinkEvents.h:38
rpctwinmux::RPCLinkRecord
Definition: RPCTwinMuxRecord.h:281
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
FEDTrailer
Definition: FEDTrailer.h:14
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
RPCTwinMuxRawToDigi::processCDFHeaders
bool processCDFHeaders(int fed, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
Definition: RPCTwinMuxRawToDigi.cc:137
RPCDigiCollection
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
Definition: RPCDigiCollection.h:13
RPCTwinMuxRawToDigi::es_tm_link_map_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
Definition: RPCTwinMuxRawToDigi.h:89
createfilelist.int
int
Definition: createfilelist.py:10
rpctwinmux::BlockTrailer
Definition: RPCTwinMuxRecord.h:69
RPCLBLinkMapRcd
Definition: RPCLBLinkMapRcd.h:6
rpctwinmux::RPCRecord
Definition: RPCTwinMuxRecord.h:352
RPCAMCLinkEvents::fed_amc13_block_incomplete_
static unsigned const int fed_amc13_block_incomplete_
Definition: RPCAMCLinkEvents.h:18
get
#define get
RPCAMCLinkCounters::add
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
RPCTwinMuxRawToDigi::fill_counters_
bool fill_counters_
Definition: RPCTwinMuxRawToDigi.h:84
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
RPCAMCLinkEvents::amc_link_invalid_
static unsigned const int amc_link_invalid_
Definition: RPCAMCLinkEvents.h:34
RPCTwinMuxRawToDigi::es_tm_link_map_watcher_
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
Definition: RPCTwinMuxRawToDigi.h:87
RPCAMCLinkEvents::amc_amc13_evc_bc_invalid_
static unsigned const int amc_amc13_evc_bc_invalid_
Definition: RPCAMCLinkEvents.h:24
type
type
Definition: HCALResponse.h:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
RPCDigi
Definition: RPCDigi.h:19
RPCTwinMuxRawToDigi::bx_min_
int bx_min_
Definition: RPCTwinMuxRawToDigi.h:85
RPCTwinMuxRawToDigi::raw_token_
edm::EDGetTokenT< FEDRawDataCollection > raw_token_
Definition: RPCTwinMuxRawToDigi.h:82
rpctwinmux::TwinMuxRecord::getType
unsigned int getType() const
RPCTwinMuxRawToDigi::compute_crc_64bit
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
Definition: RPCTwinMuxRawToDigi.cc:38
RPCAMCLinkEvents::fed_header_id_mismatch_
static unsigned const int fed_header_id_mismatch_
Definition: RPCAMCLinkEvents.h:13
RPCTwinMuxRawToDigi::es_lb_link_map_
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
Definition: RPCTwinMuxRawToDigi.h:90
MuonDigiCollection< RPCDetId, RPCDigi >::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
rpctwinmux::RPCRecord::reset
void reset()
amc
Definition: AMCSpec.h:8
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
rpctwinmux::BlockAMCContent
Definition: RPCTwinMuxRecord.h:104
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
RPCAMCLinkEvents::input_connector_not_used_
static unsigned const int input_connector_not_used_
Definition: RPCAMCLinkEvents.h:42
RPCAMCLinkMap::getMap
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
amc
double amc
Definition: hdecay.h:20
RPCAMCLinkEvents::input_link_error_
static unsigned const int input_link_error_
Definition: RPCAMCLinkEvents.h:37
event
Definition: event.py:1
FEDHeader
Definition: FEDHeader.h:14
RPCTwinMuxLinkMapRcd
Definition: RPCTwinMuxLinkMapRcd.h:6
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
evf::compute_crc_8bit
unsigned short compute_crc_8bit(unsigned short crc, unsigned char data)
Definition: CRC16.h:56
edm::InputTag
Definition: InputTag.h:15
RPCTwinMuxRawToDigi::calculate_crc_
bool calculate_crc_
Definition: RPCTwinMuxRawToDigi.h:84
rpctwinmux::BlockHeader
Definition: RPCTwinMuxRecord.h:38
RPCAMCLinkEvents::input_eod_
static unsigned const int input_eod_
Definition: RPCAMCLinkEvents.h:39
RPCAMCLinkCounters
Definition: RPCAMCLinkCounters.h:9
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443