Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:57

0001 #ifndef EventFilter_RPCRawToDigi_RPCMP7Record_h
0002 #define EventFilter_RPCRawToDigi_RPCMP7Record_h
0003 
0004 #include <cstdint>
0005 
0006 #include "EventFilter/RPCRawToDigi/interface/RPCAMCRecord.h"
0007 
0008 namespace rpcmp7 {
0009 
0010   class Header : public rpcamc::Header {
0011   public:
0012     static unsigned int const l1a_type_ = 0xd0;
0013 
0014   protected:
0015     // Second word
0016     static std::uint64_t const event_type_mask_ = 0x0000ffff00000000;
0017     static unsigned int const event_type_offset_ = 32;
0018 
0019   public:
0020     Header();
0021     Header(std::uint64_t const record[2]);
0022     Header(unsigned int amc_number,
0023            unsigned int event_counter,
0024            unsigned int bx_counter,
0025            unsigned int data_length,
0026            unsigned int orbit_counter,
0027            unsigned int board_id,
0028            unsigned int event_type = l1a_type_);
0029     ~Header() override;
0030 
0031     void reset() override;
0032 
0033     unsigned int getEventType() const;
0034 
0035     void setEventType(unsigned int event_type);
0036   };
0037 
0038   class SubHeader {
0039   protected:
0040     static std::uint64_t const algo_rev_mask_ = 0xffffffff00000000;
0041     static std::uint64_t const fw_rev_mask_ = 0x0000000000ffffff;
0042 
0043     static unsigned int const algo_rev_offset_ = 32;
0044     static unsigned int const fw_rev_offset_ = 0;
0045 
0046   public:
0047     SubHeader(std::uint64_t const record = 0x0);
0048 
0049     void set(std::uint64_t const word);
0050     void reset();
0051 
0052     std::uint64_t const& getRecord() const;
0053 
0054     unsigned int getAlgoVersion() const;
0055     unsigned int getFirmwareVersion() const;
0056 
0057     void setAlgoVersion(unsigned int algo_rev);
0058     void setFirmwareVersion(unsigned int fw_rev);
0059 
0060   protected:
0061     std::uint64_t record_;
0062   };
0063 
0064   class BlockHeader {
0065   protected:
0066     static std::uint32_t const id_mask_ = 0xff000000;
0067     static std::uint32_t const length_mask_ = 0x00ff0000;
0068     static std::uint32_t const caption_id_mask_ = 0x0000ff00;
0069     static std::uint32_t const zs_per_bx_mask_ = 0x00000002;
0070     static std::uint32_t const is_zs_mask_ = 0x00000001;
0071 
0072     static unsigned int const id_offset_ = 24;
0073     static unsigned int const length_offset_ = 16;
0074     static unsigned int const caption_id_offset_ = 8;
0075     static unsigned int const zs_per_bx_offset_ = 1;
0076     static unsigned int const is_zs_offset_ = 0;
0077 
0078   public:
0079     BlockHeader(std::uint32_t const record = 0x0);
0080 
0081     void set(std::uint32_t const record);
0082     void reset();
0083 
0084     std::uint32_t const& getRecord() const;
0085 
0086     unsigned int getId() const;
0087     unsigned int getLength() const;
0088     unsigned int getCaptionId() const;
0089     bool hasZeroSuppressionPerBX() const;
0090     bool isZeroSuppressed() const;
0091 
0092     bool isZeroSuppressionInverted() const;
0093 
0094     void setId(unsigned int id);
0095     void setLength(unsigned int length);
0096     void setCaptionId(unsigned int caption_id);
0097     void setZeroSuppressionPerBX(bool zs_per_bx);
0098     void setZeroSuppressed(bool is_zs);
0099 
0100     void setZeroSuppressionInverted(bool zs_inverted);
0101 
0102   protected:
0103     std::uint32_t record_;
0104   };
0105 
0106   class BXHeader {
0107   protected:
0108     static std::uint32_t const first_word_mask_ = 0xff000000;
0109     static std::uint32_t const total_length_mask_ = 0x00ff0000;
0110     static std::uint32_t const is_zs_mask_ = 0x00000001;
0111 
0112     static unsigned int const first_word_offset_ = 24;
0113     static unsigned int const total_length_offset_ = 16;
0114     static unsigned int const is_zs_offset_ = 0;
0115 
0116   public:
0117     BXHeader(std::uint32_t const record = 0x0);
0118 
0119     void set(std::uint32_t const record);
0120     void reset();
0121 
0122     std::uint32_t const& getRecord() const;
0123 
0124     unsigned int getFirstWord() const;
0125     unsigned int getTotalLength() const;
0126     bool isZeroSuppressed() const;
0127 
0128     // https://twiki.cern.ch/twiki/pub/CMS/MP7ZeroSuppression/mp7_zs_payload_formats.pdf
0129     unsigned int getBXId() const;
0130     unsigned int getTotalBX() const;
0131 
0132     void setFirstWord(unsigned int first_word);
0133     void setTotalLength(unsigned int length);
0134     void setZeroSuppressed(bool zs);
0135 
0136   protected:
0137     std::uint32_t record_;
0138   };
0139 
0140 }  // namespace rpcmp7
0141 
0142 #include "EventFilter/RPCRawToDigi/interface/RPCMP7Record.icc"
0143 
0144 #endif  // EventFilter_RPCRawToDigi_RPCMP7Record_h