File indexing completed on 2024-09-07 04:36:13
0001 #ifndef EventFilter_L1TRawToDigi_AMC13_SPEC__h
0002 #define EventFilter_L1TRawToDigi_AMC13_SPEC__h
0003
0004 #include <memory>
0005 #include <vector>
0006 #include <cstdint>
0007
0008 #include "AMCSpec.h"
0009
0010 namespace edm {
0011 class Event;
0012 }
0013
0014 namespace amc13 {
0015 class Header {
0016 public:
0017 Header() : data_(0) {}
0018 Header(const uint64_t *data) : data_(data[0]) {}
0019 Header(unsigned int namc, unsigned int orbit);
0020
0021 inline uint64_t raw() const { return data_; };
0022 bool check() const;
0023
0024 inline unsigned int getFormatVersion() const { return (data_ >> uFOV_shift) & uFOV_mask; };
0025 inline unsigned int getNumberOfAMCs() const { return (data_ >> nAMC_shift) & nAMC_mask; };
0026 inline unsigned int getOrbitNumber() const { return (data_ >> OrN_shift) & OrN_mask; };
0027
0028 private:
0029 static const unsigned int uFOV_shift = 60;
0030 static const unsigned int uFOV_mask = 0xf;
0031 static const unsigned int nAMC_shift = 52;
0032 static const unsigned int nAMC_mask = 0xf;
0033 static const unsigned int OrN_shift = 4;
0034 static const unsigned int OrN_mask = 0xffffffff;
0035
0036 static const unsigned int fov = 1;
0037 static const unsigned int max_amc = 12;
0038
0039 uint64_t data_;
0040 };
0041
0042 class Trailer {
0043 public:
0044 Trailer(const uint64_t *data) : data_(data[0]) {}
0045 Trailer(unsigned int blk, unsigned int lv1, unsigned int bx);
0046
0047 inline unsigned int getCRC() const { return (data_ >> CRC_shift) & CRC_mask; };
0048 inline unsigned int getBlock() const { return (data_ >> BlkNo_shift) & BlkNo_mask; };
0049 inline unsigned int getLV1ID() const { return (data_ >> LV1_shift) & LV1_mask; };
0050 inline unsigned int getBX() const { return (data_ >> BX_shift) & BX_mask; };
0051
0052 uint64_t raw() const { return data_; };
0053 bool check(unsigned int crc, unsigned int block, unsigned int lv1_id, unsigned int bx) const;
0054 static void writeCRC(const uint64_t *start, uint64_t *end);
0055
0056 private:
0057 static const unsigned int CRC_shift = 32;
0058 static const unsigned int CRC_mask = 0xffffffff;
0059 static const unsigned int BlkNo_shift = 20;
0060 static const unsigned int BlkNo_mask = 0xff;
0061 static const unsigned int LV1_shift = 12;
0062 static const unsigned int LV1_mask = 0xff;
0063 static const unsigned int BX_shift = 0;
0064 static const unsigned int BX_mask = 0xfff;
0065
0066 uint64_t data_;
0067 };
0068
0069 class Packet {
0070 public:
0071 Packet() {}
0072
0073 unsigned int blocks() const;
0074 unsigned int size() const;
0075
0076 void add(unsigned int amc_no,
0077 unsigned int board,
0078 unsigned int lv1id,
0079 unsigned int orbit,
0080 unsigned int bx,
0081 const std::vector<uint64_t> &load,
0082 unsigned int user = 0);
0083 bool parse(const uint64_t *start,
0084 const uint64_t *data,
0085 unsigned int size,
0086 unsigned int lv1,
0087 unsigned int bx,
0088 bool legacy_mc = false,
0089 bool mtf7_mode = false);
0090 bool write(const edm::Event &ev, unsigned char *ptr, unsigned int skip, unsigned int size) const;
0091
0092 inline std::vector<amc::Packet> payload() const { return payload_; };
0093
0094 private:
0095 Header header_;
0096 std::vector<amc::Packet> payload_;
0097 };
0098 }
0099
0100 #endif