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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void 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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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.

References fill_counters_, and raw_token_.

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 }
Definition: config.py:1
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_br_token_
edm::EDGetTokenT< FEDRawDataCollection > raw_token_
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_token_
edm::ESGetToken< RPCLBLinkMap, RPCLBLinkMapRcd > es_lb_link_map_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.

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.

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 }
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_br_token_
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::vector< int > feds_

◆ 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.

References evf::compute_crc_8bit().

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

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 }
uint64_t word
unsigned short compute_crc_8bit(unsigned short crc, unsigned char data)
Definition: CRC16.h:56

◆ fillDescriptions()

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

Definition at line 48 of file RPCTwinMuxRawToDigi.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

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 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ 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.

References amc, RPCAMCLinkEvents::amc_amc13_evc_bc_invalid_, calculate_crc_, compute_crc_64bit(), caHitNtupletGeneratorKernels::counters, 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().

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 }
static unsigned int const amc_amc13_evc_bc_invalid_
uint64_t word
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
double amc
Definition: hdecay.h:20
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
static unsigned int const fed_amc13_block_incomplete_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
Log< level::Warning, false > LogWarning
Definition: AMCSpec.h:8
#define LogDebug(id)

◆ 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.

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

Referenced by produce().

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 }
static unsigned int const fed_header_check_fail_
uint64_t word
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
static unsigned int const fed_header_id_mismatch_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ 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.

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

Referenced by produce().

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 }
static unsigned int const fed_trailer_length_mismatch_
uint64_t word
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
Log< level::Warning, false > LogWarning
static unsigned int const fed_trailer_check_fail_
#define LogDebug(id)

◆ 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.

References RPCAMCLinkEvents::amc_event_, RPCAMCLinkEvents::amc_link_invalid_, nano_mu_digi_cff::bx, caHitNtupletGeneratorKernels::counters, 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, LogDebug, RPCLBLink::max_connector_, RPCLBLink::max_linkboard_, AlCaHarvesting_cff::record, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), nano_mu_digi_cff::strip, and testProducerWithPsetDescEmpty_cfi::x1.

Referenced by processTwinMux().

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) {
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) {
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
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) {
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) {
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));
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 }
static unsigned int const input_connector_not_used_
static unsigned int const amc_event_
static unsigned int const input_link_error_
static unsigned int const input_lb_invalid_
static unsigned int const amc_link_invalid_
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
map_type & getMap()
Definition: RPCAMCLinkMap.h:27
map_type & getMap()
Definition: RPCLBLinkMap.h:27
static unsigned int const input_event_
static unsigned int const input_link_ack_fail_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
edm::ESHandle< RPCLBLinkMap > es_lb_link_map_
edm::ESHandle< RPCAMCLinkMap > es_tm_link_map_
static unsigned int const input_eod_
#define LogDebug(id)
static unsigned int const input_connector_invalid_

◆ 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.

References RPCAMCLinkEvents::amc_number_mismatch_, RPCAMCLinkEvents::amc_payload_incomplete_, bx_max_, bx_min_, calculate_crc_, compute_crc_64bit(), caHitNtupletGeneratorKernels::counters, TauDecayModes::dec, RPCAMCLinkEvents::fed_amc13_amc_number_invalid_, fill_counters_, rpctwinmux::TwinMuxRecord::getType(), RecoTauValidation_cfi::header, LogDebug, SiStripPI::max, RPCAMCLink::max_amcnumber_, SiStripPI::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().

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_) {
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_) {
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 }
size
Write out results.
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
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
void set(unsigned int word, std::uint64_t const record)
static unsigned int const rpc_first_type_
static unsigned int const amc_number_mismatch_
static unsigned int const rpc_second_type_
unsigned int getType() const
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ produce()

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

Definition at line 69 of file RPCTwinMuxRawToDigi.cc.

References calculate_crc_, compute_crc_64bit(), caHitNtupletGeneratorKernels::counters, 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_.

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_) {
136  }
137 }
static unsigned int const fed_trailer_crc_mismatch_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
uint64_t word
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
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
edm::ESGetToken< RPCAMCLinkMap, RPCTwinMuxLinkMapRcd > es_tm_link_map_token_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
static unsigned int const fed_event_
edm::ESGetToken< RPCLBLinkMap, RPCLBLinkMapRcd > es_lb_link_map_token_
unsigned long long uint64_t
Definition: Time.h:13
std::vector< int > feds_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
bool processCDFHeaders(int fed, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
void putCounters(edm::Event &event, std::unique_ptr< RPCAMCLinkCounters > counters)
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
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
Log< level::Warning, false > LogWarning
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)
Definition: event.py:1
#define LogDebug(id)

◆ putCounters()

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

Definition at line 532 of file RPCTwinMuxRawToDigi.cc.

References caHitNtupletGeneratorKernels::counters, and eostools::move().

Referenced by produce().

532  {
533  event.put(std::move(counters));
534 }
TupleMultiplicity< TrackerTraits > const HitToTuple< TrackerTraits > const cms::cuda::AtomicPairCounter GPUCACellT< TrackerTraits > const *__restrict__ uint32_t const *__restrict__ CellNeighborsVector< TrackerTraits > const CellTracksVector< TrackerTraits > const OuterHitOfCell< TrackerTraits > const int32_t uint32_t Counters * counters
def move(src, dest)
Definition: eostools.py:511

◆ putRPCDigis()

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

Definition at line 509 of file RPCTwinMuxRawToDigi.cc.

References LogDebug, and eostools::move().

Referenced by produce().

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

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