Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef EventFilter_RPCRawToDigi_RPCAMCRecord_h
0002 #define EventFilter_RPCRawToDigi_RPCAMCRecord_h
0003 
0004 #include <cstdint>
0005 
0006 namespace rpcamc {
0007 
0008   class Header {  // http://joule.bu.edu/~hazen/CMS/AMC13/UpdatedDAQPath.pdf
0009   protected:
0010     // First Word
0011     static std::uint64_t const amc_number_mask_ = 0x0f00000000000000;
0012     static std::uint64_t const event_counter_mask_ = 0x00ffffff00000000;
0013     static std::uint64_t const bx_counter_mask_ = 0x00000000fff00000;
0014     static std::uint64_t const data_length_mask_ = 0x00000000000fffff;
0015 
0016     static unsigned int const amc_number_offset_ = 56;
0017     static unsigned int const event_counter_offset_ = 32;
0018     static unsigned int const bx_counter_offset_ = 20;
0019     static unsigned int const data_length_offset_ = 0;
0020 
0021     // Second word
0022     static std::uint64_t const orbit_counter_mask_ = 0x00000000ffff0000;
0023     static std::uint64_t const board_id_mask_ = 0x000000000000ffff;
0024 
0025     static unsigned int const orbit_counter_offset_ = 16;
0026     static unsigned int const board_id_offset_ = 0;
0027 
0028   public:
0029     Header();
0030     Header(std::uint64_t const record[2]);
0031     Header(unsigned int amc_number,
0032            unsigned int event_counter,
0033            unsigned int bx_counter,
0034            unsigned int data_length,
0035            unsigned int orbit_counter,
0036            unsigned int board_id);
0037     virtual ~Header();
0038 
0039     void set(unsigned int nword, std::uint64_t const word);
0040     virtual void reset();
0041 
0042     std::uint64_t const* getRecord() const;
0043 
0044     unsigned int getAMCNumber() const;
0045     unsigned int getEventCounter() const;
0046     unsigned int getBXCounter() const;
0047     unsigned int getDataLength() const;
0048     bool hasDataLength() const;  // derived
0049 
0050     unsigned int getOrbitCounter() const;
0051     unsigned int getBoardId() const;
0052 
0053     void setAMCNumber(unsigned int amc_number);
0054     void setEventCounter(unsigned int event_counter);
0055     void setBXCounter(unsigned int bx_counter);
0056     void setDataLength(unsigned int data_length);
0057 
0058     void setOrbitCounter(unsigned int orbit_counter);
0059     void setBoardId(unsigned int board_id);
0060 
0061   protected:
0062     std::uint64_t record_[2];
0063   };
0064 
0065   class Trailer {  // http://joule.bu.edu/~hazen/CMS/AMC13/UpdatedDAQPath.pdf
0066   protected:
0067     static std::uint64_t const crc_mask_ = 0xffffffff00000000;
0068     static std::uint64_t const event_counter_mask_ = 0x00000000ff000000;
0069     static std::uint64_t const data_length_mask_ = 0x00000000000fffff;
0070 
0071     static unsigned int const crc_offset_ = 32;
0072     static unsigned int const event_counter_offset_ = 24;
0073     static unsigned int const data_length_offset_ = 0;
0074 
0075   public:
0076     Trailer(std::uint64_t const record = 0x0);
0077     Trailer(std::uint32_t crc, unsigned int event_counter, unsigned int data_length);
0078 
0079     void set(std::uint64_t const record);
0080     void reset();
0081 
0082     std::uint64_t const& getRecord() const;
0083 
0084     std::uint32_t getCRC() const;
0085     unsigned int getEventCounter() const;
0086     unsigned int getDataLength() const;
0087 
0088     void setCRC(std::uint32_t crc);
0089     void setEventCounter(unsigned int event_counter);
0090     void setDataLength(unsigned int data_length);
0091 
0092   protected:
0093     std::uint64_t record_;
0094   };
0095 
0096 }  // namespace rpcamc
0097 
0098 #include "EventFilter/RPCRawToDigi/interface/RPCAMCRecord.icc"
0099 
0100 #endif  // EventFilter_RPCRawToDigi_RPCAMCRecord_h