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 hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () 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::ESGetToken< RPCLBLinkMap, RPCLBLinkMapRcdes_lb_link_map_token_
 
edm::ESHandle< RPCAMCLinkMapes_tm_link_map_
 
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcdes_tm_link_map_br_token_
 
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcdes_tm_link_map_token_
 
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 32 of file RPCTwinMuxRawToDigi.h.

Constructor & Destructor Documentation

◆ RPCTwinMuxRawToDigi()

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

Definition at line 23 of file RPCTwinMuxRawToDigi.cc.

24  : calculate_crc_(config.getParameter<bool>("calculateCRC")),
25  fill_counters_(config.getParameter<bool>("fillCounters")),
26  bx_min_(config.getParameter<int>("bxMin")),
27  bx_max_(config.getParameter<int>("bxMax")),
28  es_tm_link_map_br_token_(esConsumes<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd, edm::Transition::BeginRun>()),
29  es_tm_link_map_token_(esConsumes<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd>()),
30  es_lb_link_map_token_(esConsumes<RPCLBLinkMap, RPCLBLinkMapRcd>()) {
31  produces<RPCDigiCollection>();
32  if (fill_counters_) {
33  produces<RPCAMCLinkCounters>();
34  }
35  raw_token_ = consumes<FEDRawDataCollection>(config.getParameter<edm::InputTag>("inputTag"));
36 }

References fill_counters_, and raw_token_.

◆ ~RPCTwinMuxRawToDigi()

RPCTwinMuxRawToDigi::~RPCTwinMuxRawToDigi ( )
override

Definition at line 38 of file RPCTwinMuxRawToDigi.cc.

38 {}

Member Function Documentation

◆ beginRun()

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

Definition at line 58 of file RPCTwinMuxRawToDigi.cc.

58  {
60  auto link_map = setup.getHandle(es_tm_link_map_br_token_);
61  std::set<int> feds;
62  for (auto const &tm_link : link_map->getMap()) {
63  feds.insert(tm_link.first.getFED());
64  }
65  feds_.assign(feds.begin(), feds.end());
66  }
67 }

References edm::ESWatcher< T >::check(), es_tm_link_map_br_token_, es_tm_link_map_watcher_, l1tstage2emulator_dqm_sourceclient-live_cfg::feds, feds_, 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 40 of file RPCTwinMuxRawToDigi.cc.

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

References evf::compute_crc_8bit().

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

◆ fillDescriptions()

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

Definition at line 48 of file RPCTwinMuxRawToDigi.cc.

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

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_FULL_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 216 of file RPCTwinMuxRawToDigi.cc.

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

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 139 of file RPCTwinMuxRawToDigi.cc.

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

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 177 of file RPCTwinMuxRawToDigi.cc.

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

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 391 of file RPCTwinMuxRawToDigi.cc.

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

References RPCAMCLinkCounters::add(), RPCAMCLinkEvents::amc_event_, RPCAMCLinkEvents::amc_link_invalid_, l1GtPatternGenerator_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 275 of file RPCTwinMuxRawToDigi.cc.

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

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 69 of file RPCTwinMuxRawToDigi.cc.

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

References calculate_crc_, compute_crc_64bit(), FEDTrailer::crc(), FEDRawData::data(), es_lb_link_map_, es_lb_link_map_token_, es_tm_link_map_, es_tm_link_map_token_, RPCAMCLinkEvents::fed_event_, RPCAMCLinkEvents::fed_trailer_crc_mismatch_, FEDRawDataCollection::FEDData(), feds_, fill_counters_, 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 532 of file RPCTwinMuxRawToDigi.cc.

532  {
533  event.put(std::move(counters));
534 }

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 509 of file RPCTwinMuxRawToDigi.cc.

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

References LogDebug, and eostools::move().

Referenced by produce().

Member Data Documentation

◆ bx_max_

int RPCTwinMuxRawToDigi::bx_max_
protected

Definition at line 87 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

◆ bx_min_

int RPCTwinMuxRawToDigi::bx_min_
protected

Definition at line 87 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

◆ calculate_crc_

bool RPCTwinMuxRawToDigi::calculate_crc_
protected

Definition at line 86 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 92 of file RPCTwinMuxRawToDigi.h.

Referenced by processRPCRecord(), and produce().

◆ es_lb_link_map_token_

edm::ESGetToken<RPCLBLinkMap, RPCLBLinkMapRcd> RPCTwinMuxRawToDigi::es_lb_link_map_token_
protected

Definition at line 95 of file RPCTwinMuxRawToDigi.h.

Referenced by produce().

◆ es_tm_link_map_

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

Definition at line 91 of file RPCTwinMuxRawToDigi.h.

Referenced by processRPCRecord(), and produce().

◆ es_tm_link_map_br_token_

edm::ESGetToken<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd> RPCTwinMuxRawToDigi::es_tm_link_map_br_token_
protected

Definition at line 93 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun().

◆ es_tm_link_map_token_

edm::ESGetToken<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd> RPCTwinMuxRawToDigi::es_tm_link_map_token_
protected

Definition at line 94 of file RPCTwinMuxRawToDigi.h.

Referenced by produce().

◆ es_tm_link_map_watcher_

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

Definition at line 89 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun().

◆ feds_

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

Definition at line 90 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 84 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:216
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:275
RPCTwinMuxRawToDigi::es_tm_link_map_br_token_
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_br_token_
Definition: RPCTwinMuxRawToDigi.h:93
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
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
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:87
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
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
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:391
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:509
RPCAMCLinkEvents::input_lb_invalid_
static unsigned const int input_lb_invalid_
Definition: RPCAMCLinkEvents.h:40
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
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:177
config
Definition: config.py:1
RPCTwinMuxRawToDigi::putCounters
void putCounters(edm::Event &event, std::unique_ptr< RPCAMCLinkCounters > counters)
Definition: RPCTwinMuxRawToDigi.cc:532
RPCTwinMuxRawToDigi::es_lb_link_map_token_
edm::ESGetToken< RPCLBLinkMap, RPCLBLinkMapRcd > es_lb_link_map_token_
Definition: RPCTwinMuxRawToDigi.h:95
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:90
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
RPCAMCLinkEvents::input_link_ack_fail_
static unsigned const int input_link_ack_fail_
Definition: RPCAMCLinkEvents.h:38
rpctwinmux::RPCLinkRecord
Definition: RPCTwinMuxRecord.h:281
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
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:139
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
RPCDigiCollection
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
Definition: RPCDigiCollection.h:13
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
RPCTwinMuxRawToDigi::es_tm_link_map_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
Definition: RPCTwinMuxRawToDigi.h:91
createfilelist.int
int
Definition: createfilelist.py:10
rpctwinmux::BlockTrailer
Definition: RPCTwinMuxRecord.h:69
rpctwinmux::RPCRecord
Definition: RPCTwinMuxRecord.h:352
RPCAMCLinkEvents::fed_amc13_block_incomplete_
static unsigned const int fed_amc13_block_incomplete_
Definition: RPCAMCLinkEvents.h:18
RPCAMCLinkCounters::add
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
RPCTwinMuxRawToDigi::fill_counters_
bool fill_counters_
Definition: RPCTwinMuxRawToDigi.h:86
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:89
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
RPCAMCLinkEvents::amc_amc13_evc_bc_invalid_
static unsigned const int amc_amc13_evc_bc_invalid_
Definition: RPCAMCLinkEvents.h:24
eostools.move
def move(src, dest)
Definition: eostools.py:511
RPCDigi
Definition: RPCDigi.h:19
RPCTwinMuxRawToDigi::bx_min_
int bx_min_
Definition: RPCTwinMuxRawToDigi.h:87
RPCTwinMuxRawToDigi::raw_token_
edm::EDGetTokenT< FEDRawDataCollection > raw_token_
Definition: RPCTwinMuxRawToDigi.h:84
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:40
RPCAMCLinkEvents::fed_header_id_mismatch_
static unsigned const int fed_header_id_mismatch_
Definition: RPCAMCLinkEvents.h:13
RPCTwinMuxRawToDigi::es_tm_link_map_token_
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_token_
Definition: RPCTwinMuxRawToDigi.h:94
RPCTwinMuxRawToDigi::es_lb_link_map_
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
Definition: RPCTwinMuxRawToDigi.h:92
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
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:86
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