CMS 3D CMS Logo

AMC13Event.cc
Go to the documentation of this file.
1 #include <cstdint>
3 
4 using namespace gem;
5 
7 {
8  // CDF Header word
9  // 63 - 60 | 59 - 56 | 55 - 32 | 31 - 20 | 19 - 8 |
10  // cb5 | Evt_ty | LV1_id | BX_id | Source_id |
11  return (static_cast<uint64_t>(m_cb5 & 0x0f) << 60) |
12  (static_cast<uint64_t>(m_Evt_ty & 0x0f) << 56) |
13  (static_cast<uint64_t>(m_LV1_id & 0x00ffffff) << 32) |
14  (static_cast<uint64_t>(m_BX_id & 0x0fff) << 20) |
15  (static_cast<uint64_t>(m_Source_id & 0x0fff) << 8);
16 }
17 
19 {
20  m_cb5 = 0x0f & (word >> 60);
21  m_Evt_ty = 0x0f & (word >> 56);
22  m_LV1_id = 0x00ffffff & (word >> 32);
23  m_BX_id = 0x0fff & (word >> 20);
24  m_Source_id = 0x0fff & (word >> 8);
25 }
26 
27 void AMC13Event::setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id)
28 {
29  m_cb5 = cb5;
30  m_Evt_ty = Evt_ty;
31  m_LV1_id = LV1_id;
32  m_BX_id = BX_id;
33  m_Source_id = Source_id;
34 }
35 
37 {
38  // AMC13 Header word
39  // 63 - 60 | 59 - 56 | 55 - 52 | 51 - 36 | 35 - 4 | 4 - 0 |
40  // uFOV | CalTyp | nAMC | Reserved| OrN | cb0 |
41  return (static_cast<uint64_t>(m_CalTyp & 0x0f) << 56) |
42  (static_cast<uint64_t>(m_nAMC & 0x0f) << 52) |
43  (static_cast<uint64_t>(m_OrN) << 4) |
44  (static_cast<uint64_t>(m_cb0 & 0x0f));
45 }
46 
48 {
49  m_CalTyp = 0x0f & (word >> 56);
50  m_nAMC = 0x0f & (word >> 52);
51  m_OrN = word >> 4;
52  m_cb0 = 0x0f & word;
53 }
54 
55 void AMC13Event::setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0)
56 {
57  m_CalTyp = CalTyp;
58  m_nAMC = nAMC;
59  m_OrN = OrN;
60  m_cb0 = cb0;
61 }
62 
64 {
65  // m_AMC_size.push_back(0x00ffffff&(word>>32));
66  // m_Blk_No.push_back(0xff&(word>>20));
67  // m_AMC_No.push_back(0x0f&(word>>16));
68  // m_BoardID.push_back(0xffff&word);
69  m_amcHeaders.push_back(word);
70 }
71 
72 void AMC13Event::addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID)
73 {
74  // AMC Header word
75  // 55 - 32 | 27 - 20 | 19 - 16 | 15 - 0 |
76  // AMC_size | Blk_No | AMC_No | BoardID |
77  uint64_t word =
78  (static_cast<uint64_t>(AMC_size & 0x00ffffff) << 32) |
79  (static_cast<uint64_t>(Blk_No & 0xff) << 20) |
80  (static_cast<uint64_t>(AMC_No & 0x0f) << 16) |
81  (static_cast<uint64_t>(BoardID & 0xffff));
82  m_amcHeaders.push_back(word);
83 }
84 
86 {
87  // AMC13 trailer word
88  // 63 - 32 | 27 - 20 | 19 - 12 | 11 - 0 |
89  // CRC_amc13 | Blk_No | LV1_idT | BX_idT |
90  return (static_cast<uint64_t>(m_CRC_amc13) << 32) |
91  (static_cast<uint64_t>(m_Blk_NoT & 0xff) << 20) |
92  (static_cast<uint64_t>(m_LV1_idT & 0xff) << 12) |
93  (static_cast<uint64_t>(m_BX_idT & 0x0fff));
94 }
95 
97 {
98  m_CRC_amc13 = word >> 32;
99  m_Blk_NoT = 0xff & (word >> 20);
100  m_LV1_idT = 0xff & (word >> 12);
101  m_BX_idT = 0x0fff & word;
102 }
103 
104 void AMC13Event::setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT)
105 {
106  m_CRC_amc13 = CRC_amc13;
107  m_Blk_NoT = Blk_NoT;
108  m_LV1_idT = LV1_idT;
109  m_BX_idT = BX_idT;
110 }
111 
113 {
114  // CDF trailer word
115  // 63 - 60 | 55 - 32 | 31 - 16 |
116  // cbA | EvtLength | CRC_cdf |
117  return (static_cast<uint64_t>(m_cbA & 0x0f) << 60) |
118  (static_cast<uint64_t>(m_EvtLength & 0x00ffffff) << 32) |
119  (static_cast<uint64_t>(m_CRC_cdf & 0xffff) << 16);
120 }
121 
123 {
124  m_cbA = 0x0f & (word >> 60);
125  m_EvtLength = 0x00ffffff & (word >> 32);
126  m_CRC_cdf = 0xffff & (word >> 16);
127 }
128 
129 void AMC13Event::setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf)
130 {
131  m_cbA = cbA;
132  m_EvtLength = EvtLength;
133  m_CRC_cdf = CRC_cdf;
134 }
void addAMCheader(uint64_t word)
Definition: AMC13Event.cc:63
void setCDFHeader(uint8_t cb5, uint8_t Evt_ty, uint32_t LV1_id, uint16_t BX_id, uint16_t Source_id)
Definition: AMC13Event.cc:27
uint16_t m_CRC_cdf
Definition: AMC13Event.h:70
uint8_t m_Evt_ty
Definition: AMC13Event.h:45
uint8_t m_cb0
Definition: AMC13Event.h:53
uint8_t m_CalTyp
Definition: AMC13Event.h:50
A class for AMC data.
Definition: AMC13Event.h:6
uint16_t m_Source_id
Definition: AMC13Event.h:48
uint8_t m_cbA
Definition: AMC13Event.h:68
uint32_t m_EvtLength
Definition: AMC13Event.h:69
void setAMC13header(uint8_t CalTyp, uint8_t nAMC, uint32_t OrN, uint8_t cb0)
Definition: AMC13Event.cc:55
uint64_t getCDFTrailer() const
Definition: AMC13Event.cc:112
uint8_t m_nAMC
Definition: AMC13Event.h:51
uint64_t getCDFHeader() const
Definition: AMC13Event.cc:6
uint32_t m_OrN
Definition: AMC13Event.h:52
int nAMC() const
Definition: AMC13Event.h:13
uint32_t m_LV1_id
Definition: AMC13Event.h:46
uint8_t m_LV1_idT
Definition: AMC13Event.h:65
unsigned long long uint64_t
Definition: Time.h:15
std::vector< uint64_t > m_amcHeaders
Definition: AMC13Event.h:55
void setCDFTrailer(uint8_t cbA, uint32_t EvtLength, uint16_t CRC_cdf)
Definition: AMC13Event.cc:129
uint16_t m_BX_id
Definition: AMC13Event.h:47
uint64_t getAMC13trailer() const
Definition: AMC13Event.cc:85
uint16_t m_BX_idT
Definition: AMC13Event.h:66
uint8_t m_cb5
Definition: AMC13Event.h:44
uint64_t getAMC13header() const
Definition: AMC13Event.cc:36
uint8_t m_Blk_NoT
Definition: AMC13Event.h:64
uint32_t m_CRC_amc13
Definition: AMC13Event.h:63
void setAMC13trailer(uint32_t CRC_amc13, uint8_t Blk_NoT, uint8_t LV1_idT, uint16_t BX_idT)
Definition: AMC13Event.cc:104