Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:15

0001 #ifndef EventFilter_RPCRawToDigi_RPCTwinMuxRawToDigi_h
0002 #define EventFilter_RPCRawToDigi_RPCTwinMuxRawToDigi_h
0003 
0004 #include <cstdint>
0005 #include <vector>
0006 #include <utility>
0007 #include <set>
0008 
0009 #include "FWCore/Framework/interface/ESHandle.h"
0010 #include "FWCore/Framework/interface/ESWatcher.h"
0011 #include "FWCore/Framework/interface/stream/EDProducer.h"
0012 #include "FWCore/Utilities/interface/ESGetToken.h"
0013 
0014 #include "CondFormats/DataRecord/interface/RPCTwinMuxLinkMapRcd.h"
0015 #include "CondFormats/RPCObjects/interface/RPCLBLinkMap.h"
0016 #include "CondFormats/RPCObjects/interface/RPCAMCLinkMap.h"
0017 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0018 #include "DataFormats/RPCDigi/interface/RPCAMCLinkCounters.h"
0019 #include "DataFormats/RPCDigi/interface/RPCDigi.h"
0020 #include "CondFormats/DataRecord/interface/RPCLBLinkMapRcd.h"
0021 
0022 #include "EventFilter/RPCRawToDigi/interface/RPCTwinMuxRecord.h"
0023 
0024 namespace edm {
0025   class ConfigurationDescriptions;
0026   class Event;
0027   class EventSetup;
0028   class ParameterSet;
0029   class Run;
0030 }  // namespace edm
0031 
0032 class RPCTwinMuxRawToDigi : public edm::stream::EDProducer<> {
0033 public:
0034   RPCTwinMuxRawToDigi(edm::ParameterSet const& config);
0035   ~RPCTwinMuxRawToDigi() override;
0036 
0037   static void compute_crc_64bit(std::uint16_t& crc, std::uint64_t const& word);
0038 
0039   static void fillDescriptions(edm::ConfigurationDescriptions& descs);
0040 
0041   void beginRun(edm::Run const& run, edm::EventSetup const& setup) override;
0042   void produce(edm::Event& event, edm::EventSetup const& setup) override;
0043 
0044 protected:
0045   bool processCDFHeaders(int fed,
0046                          std::uint64_t const*& word,
0047                          std::uint64_t const*& word_end,
0048                          std::uint16_t& crc,
0049                          RPCAMCLinkCounters& counters) const;
0050   bool processCDFTrailers(int fed,
0051                           unsigned int nwords,
0052                           std::uint64_t const*& word,
0053                           std::uint64_t const*& word_end,
0054                           std::uint16_t& crc,
0055                           RPCAMCLinkCounters& counters) const;
0056   bool processBlock(int fed,
0057                     std::uint64_t const*& word,
0058                     std::uint64_t const* word_end,
0059                     std::uint16_t& crc,
0060                     RPCAMCLinkCounters& counters,
0061                     std::set<std::pair<RPCDetId, RPCDigi> >& digis) const;
0062   bool processTwinMux(int fed,
0063                       unsigned int amc_number,
0064                       unsigned int size,
0065                       std::uint64_t const*& word,
0066                       std::uint64_t const* word_end,
0067                       std::uint16_t& crc,
0068                       RPCAMCLinkCounters& counters,
0069                       std::set<std::pair<RPCDetId, RPCDigi> >& digis) const;
0070   void processRPCRecord(int fed,
0071                         unsigned int amc_number,
0072                         unsigned int bx_counter,
0073                         rpctwinmux::RPCRecord const& record,
0074                         RPCAMCLinkCounters& counters,
0075                         std::set<std::pair<RPCDetId, RPCDigi> >& digis,
0076                         int bx_min,
0077                         int bx_max,
0078                         unsigned int link,
0079                         unsigned int link_max) const;
0080   void putRPCDigis(edm::Event& event, std::set<std::pair<RPCDetId, RPCDigi> > const& digis);
0081   void putCounters(edm::Event& event, std::unique_ptr<RPCAMCLinkCounters> counters);
0082 
0083 protected:
0084   edm::EDGetTokenT<FEDRawDataCollection> raw_token_;
0085 
0086   bool calculate_crc_, fill_counters_;
0087   int bx_min_, bx_max_;
0088 
0089   edm::ESWatcher<RPCTwinMuxLinkMapRcd> es_tm_link_map_watcher_;
0090   std::vector<int> feds_;
0091   edm::ESHandle<RPCAMCLinkMap> es_tm_link_map_;
0092   edm::ESHandle<RPCLBLinkMap> es_lb_link_map_;
0093   edm::ESGetToken<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd> es_tm_link_map_br_token_;
0094   edm::ESGetToken<RPCAMCLinkMap, RPCTwinMuxLinkMapRcd> es_tm_link_map_token_;
0095   edm::ESGetToken<RPCLBLinkMap, RPCLBLinkMapRcd> es_lb_link_map_token_;
0096 };
0097 
0098 #endif  // EventFilter_RPCRawToDigi_RPCTwinMuxRawToDigi_h