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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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 ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void compute_crc_64bit (std::uint16_t &crc, std::uint64_t const &word)
 
static void fillDescriptions (edm::ConfigurationDescriptions &descs)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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 Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 30 of file RPCTwinMuxRawToDigi.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file RPCTwinMuxRawToDigi.cc.

References fill_counters_, edm::ParameterSet::getParameter(), 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 {
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 ( )

Definition at line 36 of file RPCTwinMuxRawToDigi.cc.

37 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 59 of file RPCTwinMuxRawToDigi.cc.

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

60 {
63  std::set<int> feds;
64  for (auto const & tm_link : es_tm_link_map_->getMap()) {
65  feds.insert(tm_link.first.getFED());
66  }
67  feds_.assign(feds.begin(), feds.end());
68  }
69 }
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
map_type & getMap()
Definition: RPCAMCLinkMap.h:28
edm::ESWatcher< RPCTwinMuxLinkMapRcd > es_tm_link_map_watcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
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 39 of file RPCTwinMuxRawToDigi.cc.

References evf::compute_crc_8bit().

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

40 { // overcome constness problem evf::compute_crc_64bit
41  unsigned char const * uchars(reinterpret_cast<unsigned char const *>(&word));
42  for (unsigned char const * uchar = uchars + 7
43  ; uchar >= uchars ; --uchar) {
44  crc = evf::compute_crc_8bit(crc, *uchar);
45  }
46 }
unsigned short compute_crc_8bit(unsigned short crc, unsigned char data)
Definition: CRC16.h:79
void RPCTwinMuxRawToDigi::fillDescriptions ( edm::ConfigurationDescriptions descs)
static

Definition at line 48 of file RPCTwinMuxRawToDigi.cc.

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

49 {
51  desc.add<edm::InputTag>("inputTag", edm::InputTag("rawDataCollector", ""));
52  desc.add<bool>("calculateCRC", true);
53  desc.add<bool>("fillCounters", true);
54  desc.add<int>("bxMin", -2);
55  desc.add<int>("bxMax", 2);
56  descs.add("RPCTwinMuxRawToDigi", desc);
57 }
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 226 of file RPCTwinMuxRawToDigi.cc.

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

Referenced by produce().

231 {
232  // Block Header and Content
233  rpctwinmux::BlockHeader block_header(*word);
234  if (calculate_crc_) {
235  compute_crc_64bit(crc, *word);
236  }
237  ++word;
238 
239  unsigned int n_amc(block_header.getNAMC());
240  if (word + n_amc + 1 >= word_end) {
241  if (fill_counters_) {
243  }
244  edm::LogWarning("RPCTwinMuxRawToDigi") << "Block can not be complete for FED " << fed;
245  word = word_end;
246  return false;
247  }
248 
249  std::vector<std::pair<unsigned int, unsigned int> > amc_size_map;
250  for (unsigned int amc = 0 ; amc < n_amc ; ++amc) {
251  LogDebug("RPCTwinMuxRawToDigi") << "Block AMC " << amc;
252  rpctwinmux::BlockAMCContent amc_content(*word);
253  if (calculate_crc_) {
254  compute_crc_64bit(crc, *word);
255  }
256  ++word;
257 
258  amc_size_map.push_back(std::make_pair(amc_content.getAMCNumber(), amc_content.getSize()));
259  if (!amc_content.isValid()) {
260  if (fill_counters_) {
261  counters.add(RPCAMCLinkCounters::amc_evc_bc_invalid_, RPCAMCLink(fed, amc_content.getAMCNumber()));
262  }
263  edm::LogWarning("RPCTwinMuxRawToDigi") << "BlockAMCContent is reporting an invalid "
264  << "Event Counter or Bunch Counter for FED " << fed
265  << ", AMC " << amc_content.getAMCNumber();
266  }
267  }
268 
269  for (std::pair<unsigned int, unsigned int> const & amc_size : amc_size_map) {
270  processTwinMux(fed, amc_size.first, amc_size.second
271  , word, word_end
272  , crc, counters
273  , digis);
274  }
275 
276  if (word < word_end) {
277  rpctwinmux::BlockTrailer block_trailer(*word);
278  if (calculate_crc_) {
279  compute_crc_64bit(crc, *word);
280  }
281  ++word;
282  return true;
283  } else {
284  return false;
285  }
286 }
#define LogDebug(id)
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 amc_evc_bc_invalid_
double amc
Definition: hdecay.h:20
static unsigned int const fed_block_length_invalid_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
void add(unsigned int type, RPCAMCLink const &link, unsigned int count=1)
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 149 of file RPCTwinMuxRawToDigi.cc.

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

Referenced by produce().

153 {
154  bool more_headers(true);
155  for ( ; word < word_end && more_headers ; ++word) {
156  if (calculate_crc_) {
157  compute_crc_64bit(crc, *word);
158  }
159 
160  LogDebug("RPCTwinMuxRawToDigi") << "CDF Header " << std::hex << *word << std::dec;
161  FEDHeader header(reinterpret_cast<unsigned char const *>(word));
162  if (!header.check()) {
163  if (fill_counters_) {
165  }
166  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Header check failed for FED id " << fed;
167  ++word;
168  break;
169  }
170  if (header.sourceID() != fed) {
171  if (fill_counters_) {
173  }
174  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Header Source ID " << header.sourceID()
175  << " does not match requested FED id " << fed;
176  break;
177  }
178 
179  // moreHeaders() not used
180  // more_headers = header.moreHeaders();
181  more_headers = false;
182  }
183 
184  return !more_headers;
185 }
#define LogDebug(id)
static unsigned int const fed_header_check_fail_
static unsigned int const fed_header_id_mismatch_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
void add(unsigned int type, RPCAMCLink const &link, unsigned int count=1)
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 187 of file RPCTwinMuxRawToDigi.cc.

References RPCAMCLinkCounters::add(), FEDTrailer::check(), TauDecayModes::dec, RPCAMCLinkCounters::fed_trailer_check_fail_, RPCAMCLinkCounters::fed_trailer_length_mismatch_, fill_counters_, createfilelist::int, FEDTrailer::lenght(), LogDebug, and RPCAMCLink::wildcard_.

Referenced by produce().

191 {
192  bool more_trailers(true);
193  for (--word_end ; word_end > word && more_trailers ; --word_end) {
194  FEDTrailer trailer(reinterpret_cast<unsigned char const *>(word_end));
195  LogDebug("RPCTwinMuxRawToDigi") << "CDF Trailer " << std::hex << *word_end << std::dec
196  << ", length " << trailer.lenght();
197  if (!trailer.check()) {
198  if (fill_counters_) {
200  }
201  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer check failed for FED id " << fed;
202  --word_end;
203  break;
204  }
205  if (trailer.lenght() != (int)nwords) {
206  if (fill_counters_) {
208  }
209  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer length " << trailer.lenght()
210  << " does not match actual data size " << nwords
211  << " for FED id " << fed;
212  --word_end;
213  break;
214  }
215 
216  // moreTrailers() not used
217  // more_trailers = trailer.moreTrailers();
218  more_trailers = false;
219  }
220 
221  ++word_end;
222 
223  return !more_trailers;
224 }
#define LogDebug(id)
static unsigned int const fed_trailer_length_mismatch_
static unsigned int const fed_trailer_check_fail_
void add(unsigned int type, RPCAMCLink const &link, unsigned int count=1)
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 399 of file RPCTwinMuxRawToDigi.cc.

References RPCAMCLinkCounters::add(), RPCAMCLinkCounters::amc_data_, RPCAMCLinkCounters::amc_link_invalid_, 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(), RPCAMCLinkCounters::input_connector_invalid_, RPCAMCLinkCounters::input_connector_not_used_, RPCAMCLinkCounters::input_data_, RPCAMCLinkCounters::input_eod_, RPCAMCLinkCounters::input_lb_invalid_, RPCAMCLinkCounters::input_link_ack_fail_, RPCAMCLinkCounters::input_link_error_, createfilelist::int, LogDebug, RPCLBLink::max_connector_, RPCLBLink::max_linkboard_, RPCLBLink::setConnector(), RPCLBLink::setLinkBoard(), and digi_MixPreMix_cfi::strip.

Referenced by processTwinMux().

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

References RPCAMCLinkCounters::add(), RPCAMCLinkCounters::amc_number_mismatch_, RPCAMCLinkCounters::amc_payload_length_invalid_, bx_max_, bx_min_, calculate_crc_, compute_crc_64bit(), TauDecayModes::dec, RPCAMCLinkCounters::fed_block_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, hpstanc_transforms::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().

293 {
294  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux AMC#" << amc_number << ", size " << size;
295  if (!size) {
296  return true;
297  }
298  if (amc_number > (unsigned int)RPCAMCLink::max_amcnumber_) {
299  if (fill_counters_) {
301  }
302  edm::LogWarning("RPCTwinMuxRawToDigi") << "Invalid AMC Number " << amc_number
303  << " for FED " << fed;
304  if (calculate_crc_) {
305  for ( ; size > 0 ; --size, ++word) {
306  compute_crc_64bit(crc, *word);
307  }
308  } else {
309  word += size;
310  }
311  return false;
312  }
313  if (word + size >= word_end || size < 3) {
314  if (fill_counters_) {
316  }
317  edm::LogWarning("RPCTwinMuxRawToDigi") << "TwinMux Data can not be complete for FED " << fed << " AMC #" << amc_number;
318  if (calculate_crc_) {
319  for ( ; size > 0 ; --size, ++word) {
320  compute_crc_64bit(crc, *word);
321  }
322  } else {
323  word += size;
324  }
325  return false;
326  }
327 
329  unsigned int bx_counter(header.getBXCounter());
330  if (calculate_crc_) {
331  compute_crc_64bit(crc, *word); ++word;
332  compute_crc_64bit(crc, *word); ++word;
333  } else {
334  word += 2;
335  }
336  size -= 2;
337 
338  if (amc_number != header.getAMCNumber()) {
339  if (fill_counters_) {
340  counters.add(RPCAMCLinkCounters::amc_number_mismatch_, RPCAMCLink(fed, amc_number));
341  }
342  edm::LogWarning("RPCTwinMuxRawToDigi") << "AMC Number inconsistent in TwinMuxHeader vs BlockAMCContent: " << header.getAMCNumber()
343  << " vs " << amc_number;
344  if (calculate_crc_) {
345  for ( ; size > 0 ; --size, ++word) {
346  compute_crc_64bit(crc, *word);
347  }
348  } else {
349  word += size;
350  }
351  return false;
352  }
353 
354  int bx_min(bx_min_), bx_max(bx_max_);
355  if (header.hasRPCBXWindow()) {
356  bx_min = std::max(bx_min, header.getRPCBXMin());
357  bx_max = std::min(bx_max, header.getRPCBXMax());
358  LogDebug("RPCTwinMuxRawToDigi") << "BX range set to " << bx_min << ", " << bx_max;
359  }
360 
361  bool has_first_rpc_word(false);
362  rpctwinmux::RPCRecord rpc_record;
363  for ( ; size > 1 ; --size, ++word) {
364  if (calculate_crc_) {
365  compute_crc_64bit(crc, *word);
366  }
367  unsigned int type(rpctwinmux::TwinMuxRecord::getType(*word));
368  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux data type " << std::hex << type << std::dec;
370  if (has_first_rpc_word) {
371  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 1);
372  }
373  rpc_record.reset();
374  rpc_record.set(0, *word);
375  has_first_rpc_word = true;
377  if (!has_first_rpc_word) {
378  edm::LogWarning("RPCTwinMuxRawToDigi") << "Received second RPC word without first";
379  } else {
380  rpc_record.set(1, *word);
381  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 4);
382  has_first_rpc_word = false;
383  }
384  }
385  }
386  if (has_first_rpc_word) {
387  processRPCRecord(fed, amc_number, bx_counter, rpc_record, counters, digis, bx_min, bx_max, 0, 1);
388  }
389 
390  rpctwinmux::TwinMuxTrailer trailer(*word);
391  LogDebug("RPCTwinMuxRawToDigi") << "TwinMux Trailer " << std::hex << *word << std::dec;
392  if (calculate_crc_) {
393  compute_crc_64bit(crc, *word);
394  }
395  ++word;
396  return true;
397 }
#define LogDebug(id)
size
Write out results.
type
Definition: HCALResponse.h:21
static unsigned int const fed_block_amc_number_invalid_
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
void set(unsigned int word, std::uint64_t const record)
unsigned int getType() const
static unsigned int const amc_payload_length_invalid_
T min(T a, T b)
Definition: MathUtil.h:58
static unsigned int const rpc_first_type_
static unsigned int const rpc_second_type_
static unsigned int const amc_number_mismatch_
static void compute_crc_64bit(std::uint16_t &crc, std::uint64_t const &word)
void add(unsigned int type, RPCAMCLink const &link, unsigned int count=1)
void RPCTwinMuxRawToDigi::produce ( edm::Event event,
edm::EventSetup const &  setup 
)
overridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 71 of file RPCTwinMuxRawToDigi.cc.

References calculate_crc_, compute_crc_64bit(), FEDTrailer::crc(), FEDRawData::data(), es_lb_link_map_, es_tm_link_map_, RPCAMCLinkCounters::fed_event_, RPCAMCLinkCounters::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().

72 {
73  // Get EventSetup Electronics Maps
76 
77  // Get RAW Data
78  edm::Handle<FEDRawDataCollection> raw_data_collection;
79  event.getByToken(raw_token_, raw_data_collection);
80 
81  std::set<std::pair<RPCDetId, RPCDigi> > rpc_digis;
82  std::unique_ptr<RPCAMCLinkCounters> counters(new RPCAMCLinkCounters());
83 
84  // Loop over the FEDs
85  for (int fed : feds_) {
86 
87  if (fill_counters_) {
89  }
90 
91  std::uint16_t crc(0xffff);
92 
93  FEDRawData const & raw_data = raw_data_collection->FEDData(fed);
94  unsigned int nwords(raw_data.size() / sizeof(std::uint64_t));
95  if (!nwords) {
96  continue;
97  }
98 
99  std::uint64_t const * word(reinterpret_cast<std::uint64_t const *>(raw_data.data()));
100  std::uint64_t const * word_end = word + nwords;
101 
102  LogDebug("RPCTwinMuxRawToDigi") << "Handling FED " << fed << " with length " << nwords;
103 
104  // Handle the CDF Headers
105  if (!processCDFHeaders(fed
106  , word, word_end
107  , crc, *counters)) {
108  continue;
109  }
110 
111  // Handle the CDF Trailers
112  if (!processCDFTrailers(fed, nwords
113  , word, word_end
114  , crc, *counters)) {
115  continue;
116  }
117 
118  // Loop over the Blocks
119  while (word < word_end) {
120  processBlock(fed
121  , word, word_end
122  , crc, *counters, rpc_digis);
123  }
124 
125  // Complete CRC check with trailer
126  if (calculate_crc_) {
127  word = word_end;
128  word_end = reinterpret_cast<std::uint64_t const *>(raw_data.data()) + nwords - 1;
129  for ( ; word < word_end ; ++word) {
130  compute_crc_64bit(crc, *word);
131  }
132  compute_crc_64bit(crc, (*word & 0xffffffff0000ffff)); // trailer excluding crc
133  FEDTrailer trailer(reinterpret_cast<unsigned char const *>(word_end));
134  if ((unsigned int)(trailer.crc()) != crc) {
135  if (fill_counters_) {
137  }
138  edm::LogWarning("RPCTwinMuxRawToDigi") << "FED Trailer CRC doesn't match for FED id " << fed;
139  }
140  }
141  }
142 
143  putRPCDigis(event, rpc_digis);
144  if (fill_counters_) {
145  putCounters(event, std::move(counters));
146  }
147 }
#define LogDebug(id)
static unsigned int const fed_event_
bool processCDFHeaders(int fed, std::uint64_t const *&word, std::uint64_t const *&word_end, std::uint16_t &crc, RPCAMCLinkCounters &counters) const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
static unsigned int const fed_trailer_crc_mismatch_
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
unsigned long long uint64_t
Definition: Time.h:15
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
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:510
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 543 of file RPCTwinMuxRawToDigi.cc.

References DEFINE_FWK_MODULE, and eostools::move().

Referenced by produce().

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

Definition at line 518 of file RPCTwinMuxRawToDigi.cc.

References LogDebug, and eostools::move().

Referenced by produce().

520 {
521  std::unique_ptr<RPCDigiCollection> rpc_digi_collection(new RPCDigiCollection());
522  RPCDetId rpc_det_id;
523  std::vector<RPCDigi> local_digis;
524  for (std::pair<RPCDetId, RPCDigi> const & rpc_digi : digis) {
525  LogDebug("RPCTwinMuxRawToDigi") << "RPCDigi " << rpc_digi.first.rawId()
526  << ", " << rpc_digi.second.strip() << ", " << rpc_digi.second.bx();
527  if (rpc_digi.first != rpc_det_id) {
528  if (!local_digis.empty()) {
529  rpc_digi_collection->put(RPCDigiCollection::Range(local_digis.begin(), local_digis.end()), rpc_det_id);
530  local_digis.clear();
531  }
532  rpc_det_id = rpc_digi.first;
533  }
534  local_digis.push_back(rpc_digi.second);
535  }
536  if (!local_digis.empty()) {
537  rpc_digi_collection->put(RPCDigiCollection::Range(local_digis.begin(), local_digis.end()), rpc_det_id);
538  }
539 
540  event.put(std::move(rpc_digi_collection));
541 }
#define LogDebug(id)
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

int RPCTwinMuxRawToDigi::bx_max_
protected

Definition at line 79 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

int RPCTwinMuxRawToDigi::bx_min_
protected

Definition at line 79 of file RPCTwinMuxRawToDigi.h.

Referenced by processTwinMux().

bool RPCTwinMuxRawToDigi::calculate_crc_
protected

Definition at line 78 of file RPCTwinMuxRawToDigi.h.

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

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

Definition at line 84 of file RPCTwinMuxRawToDigi.h.

Referenced by processRPCRecord(), and produce().

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

Definition at line 83 of file RPCTwinMuxRawToDigi.h.

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

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

Definition at line 81 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun().

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

Definition at line 82 of file RPCTwinMuxRawToDigi.h.

Referenced by beginRun(), and produce().

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

Definition at line 76 of file RPCTwinMuxRawToDigi.h.

Referenced by produce(), and RPCTwinMuxRawToDigi().