CMS 3D CMS Logo

GEMAMC13.h
Go to the documentation of this file.
1 #ifndef DataFormats_GEMDigi_GEMAMC13_h
2 #define DataFormats_GEMDigi_GEMAMC13_h
3 #include <vector>
4 #include "GEMAMC.h"
5 
6 class GEMAMC13 {
7 public:
8  union CDFHeader {
10  struct {
11  uint64_t fov : 8; // not used
12  uint64_t sourceId : 12; // FED number assigned by CDAQ
13  uint64_t bxId : 12; // BX number, Reset by BC0
14  uint64_t lv1Id : 24; // L1A / event number, Reset by EC0
15  uint64_t eventType : 4; // Event Type (1 for normal, 2 for calibration)
16  uint64_t cb5 : 4; // 0x5
17  };
18  };
19  union AMC13Header {
21  struct {
22  uint64_t cb0 : 4; // 0x0
23  uint64_t orbitN : 32; // Orbit Number
24  uint64_t reserved0 : 16; // reserved
25  uint64_t nAMC : 4; // Number of AMCs following (0 to 12)
26  uint64_t calType : 4; // Calibration event type
27  uint64_t uFov : 4; // Format version: 0x1
28  };
29  };
30  union AMC13Trailer {
32  struct {
33  uint64_t bxIdT : 12; // bx id
34  uint64_t lv1IdT : 8; // level 1 id
35  uint64_t blkN : 8; // block number
36  uint64_t : 4;
37  uint64_t crc32 : 32; // Overall CRC
38  };
39  };
40  union CDFTrailer {
42  struct {
46  uint64_t tts : 4; // tts
47  uint64_t evtStat : 4; // event status
51  uint64_t crcCDF : 16; // CDF crc
52  uint64_t evtLength : 24; // event length
53  uint64_t eventType : 4; // Event Type
54  uint64_t cbA : 4; // 0xA
55  };
56  };
57  union AMCHeader {
59  struct {
60  uint64_t boardId : 16; // board id
61  uint64_t amcNo : 4; // amc number
62  uint64_t blkNo : 8; // block number
63  uint64_t unused : 4; // unused
64  uint64_t amcSize : 24; // amc size
65  uint64_t errStrip : 8; // errStrip
66  };
67  };
68 
69  GEMAMC13() : cdfh_(0), amc13h_(0), amc13t_(0), cdft_(0) {}
71  amcHeaders_.clear();
72  amcs_.clear();
73  }
74 
76  void setCDFHeader(uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id);
77  uint64_t getCDFHeader() const { return cdfh_; }
78 
80  void setAMC13Header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN);
81  uint64_t getAMC13Header() const { return amc13h_; }
82 
84  void setAMC13Trailer(uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT);
85  uint64_t getAMC13Trailer() const { return amc13t_; }
86 
88  void setCDFTrailer(uint32_t EvtLength);
89  uint64_t getCDFTrailer() const { return cdft_; }
90  uint32_t fragmentLength() const { return CDFTrailer{cdft_}.evtLength; }
91  uint8_t evtStatus() const { return CDFTrailer{cdft_}.evtStat; }
92  uint8_t ttsBits() const { return CDFTrailer{cdft_}.tts; }
93 
94  uint16_t bunchCrossing() const { return CDFHeader{cdfh_}.bxId; }
95  uint32_t lv1Id() const { return CDFHeader{cdfh_}.lv1Id; }
96  uint16_t sourceId() const { return CDFHeader{cdfh_}.sourceId; }
97 
98  uint32_t orbitNumber() const { return AMC13Header{amc13h_}.orbitN; }
99  uint8_t nAMC() const { return AMC13Header{amc13h_}.nAMC; }
100 
101  const std::vector<uint64_t>* getAMCheaders() const { return &amcHeaders_; }
102  uint32_t getAMCsize(int i) const { return AMCHeader{amcHeaders_.at(i)}.amcSize; }
103  void addAMCheader(uint64_t word);
104  void addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID);
105 
106  uint32_t crc() const { return AMC13Trailer{amc13t_}.crc32; }
107 
108  const std::vector<GEMAMC>* getAMCpayloads() const { return &amcs_; }
109  void addAMCpayload(const GEMAMC& a) { amcs_.push_back(a); }
110  void clearAMCpayloads() { amcs_.clear(); }
111 
112  static const int lastBC = 3564;
113 
114 private:
115  uint64_t cdfh_; // CDFHeader
116  uint64_t amc13h_; // AMC13Header
117  uint64_t amc13t_; // AMC13Trailer
118  uint64_t cdft_; // CDFTrailer
119 
120  // AMC headers
121  std::vector<uint64_t> amcHeaders_;
122  // AMCs payload
123  std::vector<GEMAMC> amcs_;
124 };
125 
126 #endif
void addAMCpayload(const GEMAMC &a)
Definition: GEMAMC13.h:109
uint64_t blkNo
Definition: GEMAMC13.h:62
uint64_t sourceId
Definition: GEMAMC13.h:12
void setAMC13Trailer(uint64_t word)
Definition: GEMAMC13.h:83
uint32_t fragmentLength() const
Definition: GEMAMC13.h:90
uint64_t evtLength
Definition: GEMAMC13.h:52
const std::vector< uint64_t > * getAMCheaders() const
Definition: GEMAMC13.h:101
GEMAMC13()
Definition: GEMAMC13.h:69
uint64_t cdft_
Definition: GEMAMC13.h:118
std::vector< GEMAMC > amcs_
Definition: GEMAMC13.h:123
uint64_t word
Definition: GEMAMC13.h:9
void setAMC13Header(uint64_t word)
Definition: GEMAMC13.h:79
uint64_t eventType
Definition: GEMAMC13.h:53
uint32_t crc() const
Definition: GEMAMC13.h:106
uint64_t word
uint64_t wrongFedId
Definition: GEMAMC13.h:50
uint64_t eventType
Definition: GEMAMC13.h:15
uint64_t errStrip
Definition: GEMAMC13.h:65
void setCDFHeader(uint64_t word)
Definition: GEMAMC13.h:75
void clearAMCpayloads()
Definition: GEMAMC13.h:110
static const int lastBC
Definition: GEMAMC13.h:112
uint32_t getAMCsize(int i) const
Definition: GEMAMC13.h:102
uint64_t amc13t_
Definition: GEMAMC13.h:117
uint64_t getCDFTrailer() const
Definition: GEMAMC13.h:89
const std::vector< GEMAMC > * getAMCpayloads() const
Definition: GEMAMC13.h:108
uint64_t getAMC13Header() const
Definition: GEMAMC13.h:81
uint64_t moreTrailers
Definition: GEMAMC13.h:45
uint32_t orbitNumber() const
Definition: GEMAMC13.h:98
uint64_t cdfh_
Definition: GEMAMC13.h:115
uint8_t nAMC() const
Definition: GEMAMC13.h:99
uint64_t reserved0
Definition: GEMAMC13.h:24
uint64_t crcModified
Definition: GEMAMC13.h:44
uint32_t lv1Id() const
Definition: GEMAMC13.h:95
uint16_t sourceId() const
Definition: GEMAMC13.h:96
uint16_t bunchCrossing() const
Definition: GEMAMC13.h:94
void addAMCheader(uint64_t word)
Definition: GEMAMC13.cc:39
uint64_t amcSize
Definition: GEMAMC13.h:64
uint64_t evtStat
Definition: GEMAMC13.h:47
uint64_t amc13h_
Definition: GEMAMC13.h:116
uint64_t slinkError
Definition: GEMAMC13.h:49
unsigned long long uint64_t
Definition: Time.h:13
uint64_t lv1Id
Definition: GEMAMC13.h:14
std::vector< uint64_t > amcHeaders_
Definition: GEMAMC13.h:121
uint8_t ttsBits() const
Definition: GEMAMC13.h:92
uint64_t getCDFHeader() const
Definition: GEMAMC13.h:77
Definition: GEMAMC.h:6
uint64_t amcNo
Definition: GEMAMC13.h:61
uint64_t unused
Definition: GEMAMC13.h:63
double a
Definition: hdecay.h:119
uint64_t boardId
Definition: GEMAMC13.h:60
~GEMAMC13()
Definition: GEMAMC13.h:70
uint64_t getAMC13Trailer() const
Definition: GEMAMC13.h:85
uint8_t evtStatus() const
Definition: GEMAMC13.h:91
void setCDFTrailer(uint64_t word)
Definition: GEMAMC13.h:87