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 ( edm::ParameterSet const &  config)

Definition at line 24 of file RPCTwinMuxRawToDigi.cc.

References fill_counters_, edm::ParameterSet::getParameter(), and raw_token_.

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 }
Definition: config.py:1
edm::EDGetTokenT< FEDRawDataCollection > raw_token_
RPCTwinMuxRawToDigi::~RPCTwinMuxRawToDigi ( )
override

Definition at line 36 of file RPCTwinMuxRawToDigi.cc.

36 {}

Member Function Documentation

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

Definition at line 56 of file RPCTwinMuxRawToDigi.cc.

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

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 }
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
std::vector< int > feds_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
void RPCTwinMuxRawToDigi::compute_crc_64bit ( std::uint16_t &  crc,
std::uint64_t const &  word 
)
static

Definition at line 38 of file RPCTwinMuxRawToDigi.cc.

References evf::compute_crc_8bit().

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

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 }
uint64_t word
unsigned short compute_crc_8bit(unsigned short crc, unsigned char data)
Definition: CRC16.h:56
void RPCTwinMuxRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descs)
static

Definition at line 46 of file RPCTwinMuxRawToDigi.cc.

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

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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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.

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().

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 }
#define LogDebug(id)
static unsigned int const amc_amc13_evc_bc_invalid_
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
uint64_t word
double amc
Definition: hdecay.h:20
static unsigned int const fed_amc13_block_incomplete_
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
Definition: AMCSpec.h:8
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.

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

Referenced by produce().

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 }
#define LogDebug(id)
static unsigned int const fed_header_check_fail_
uint64_t word
static unsigned int const fed_header_id_mismatch_
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
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.

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().

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 }
#define LogDebug(id)
static unsigned int const fed_trailer_length_mismatch_
uint64_t word
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static unsigned int const fed_trailer_check_fail_
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.

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_, rpctwinmux::RPCRecord::getBXOffset(), RPCLBLinkMap::getMap(), RPCAMCLinkMap::getMap(), rpctwinmux::RPCRecord::getRecord(), RPCFebConnector::getRPCDetId(), rpctwinmux::RPCRecord::getRPCLinkRecord(), 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_, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), digitizers_cfi::strip, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by processTwinMux().

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 }
#define LogDebug(id)
static unsigned int const input_connector_not_used_
static unsigned int const amc_event_
JetCorrectorParameters::Record record
Definition: classes.h:7
static unsigned int const input_link_error_
static unsigned int const input_lb_invalid_
static unsigned int const amc_link_invalid_
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
map_type & getMap()
Definition: RPCLBLinkMap.h:27
static unsigned int const input_event_
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static unsigned int const input_link_ack_fail_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
static unsigned int const input_eod_
static unsigned int const input_connector_invalid_
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.

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::TwinMuxHeader::getAMCNumber(), rpctwinmux::TwinMuxHeader::getBXCounter(), rpctwinmux::TwinMuxHeader::getRPCBXMax(), rpctwinmux::TwinMuxHeader::getRPCBXMin(), rpctwinmux::TwinMuxRecord::getType(), rpctwinmux::TwinMuxHeader::hasRPCBXWindow(), 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().

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 }
#define LogDebug(id)
size
Write out results.
type
Definition: HCALResponse.h:21
static unsigned int const fed_amc13_amc_number_invalid_
static unsigned int const amc_payload_incomplete_
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
uint64_t word
void set(unsigned int word, std::uint64_t const record)
unsigned int getType() const
T min(T a, T b)
Definition: MathUtil.h:58
static unsigned int const rpc_first_type_
static unsigned int const amc_number_mismatch_
void add(unsigned int event, RPCAMCLink const &link, unsigned int count=1)
static unsigned int const rpc_second_type_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
void RPCTwinMuxRawToDigi::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
override

Definition at line 67 of file RPCTwinMuxRawToDigi.cc.

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_, edm::EventSetup::get(), LogDebug, eostools::move(), processBlock(), processCDFHeaders(), processCDFTrailers(), putCounters(), putRPCDigis(), raw_token_, FEDRawData::size(), and RPCAMCLink::wildcard_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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 }
#define LogDebug(id)
static unsigned int const fed_trailer_crc_mismatch_
bool processCDFHeaders(int fed, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
uint64_t word
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
edm::EDGetTokenT< FEDRawDataCollection > raw_token_
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 processCDFTrailers(int fed, unsigned int nwords, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
static unsigned int const fed_event_
unsigned long long uint64_t
Definition: Time.h:13
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
std::vector< int > feds_
void putCounters(edm::Event &event, std::unique_ptr< RPCAMCLinkCounters > counters)
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
def move(src, dest)
Definition: eostools.py:511
void putRPCDigis(edm::Event &event, std::set< std::pair< RPCDetId, RPCDigi > > const &digis)
void RPCTwinMuxRawToDigi::putCounters ( edm::Event event,
std::unique_ptr< RPCAMCLinkCounters counters 
)
protected

Definition at line 530 of file RPCTwinMuxRawToDigi.cc.

References DEFINE_FWK_MODULE, and eostools::move().

Referenced by produce().

530  {
531  event.put(std::move(counters));
532 }
def move(src, dest)
Definition: eostools.py:511
void RPCTwinMuxRawToDigi::putRPCDigis ( edm::Event event,
std::set< std::pair< RPCDetId, RPCDigi > > const &  digis 
)
protected

Definition at line 507 of file RPCTwinMuxRawToDigi.cc.

References LogDebug, and eostools::move().

Referenced by produce().

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 }
#define LogDebug(id)
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

int RPCTwinMuxRawToDigi::bx_max_
protected

Definition at line 85 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

int RPCTwinMuxRawToDigi::bx_min_
protected

Definition at line 85 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

bool RPCTwinMuxRawToDigi::calculate_crc_
protected

Definition at line 84 of file RPCTwinMuxRawToDigi.h.

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

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

Definition at line 90 of file RPCTwinMuxRawToDigi.h.

Referenced by processRPCRecord(), and produce().

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

Definition at line 89 of file RPCTwinMuxRawToDigi.h.

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

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

Definition at line 87 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun().

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

Definition at line 88 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun(), and produce().

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

Definition at line 82 of file RPCTwinMuxRawToDigi.h.

Referenced by produce(), and RPCTwinMuxRawToDigi().