1 #ifndef EventFilter_GEMRawToDigi_VFATdata_h 2 #define EventFilter_GEMRawToDigi_VFATdata_h 16 const uint16_t ChipID_,
20 const uint16_t crc_calc_,
21 const int SlotNumber_,
22 const bool isBlockGood_) :
44 m_BC = 0x0fff & (word >> 48);
47 m_Flag = 0x0f & (word >> 32);
50 m_msData = 0xffff000000000000 & (word << 48);
55 (static_cast<uint64_t>(
m_b1010 & 0x0f) << 60) |
69 m_lsData = 0xffff000000000000 & (word << 48);
74 (static_cast<uint64_t>(
m_msData & 0x0000ffffffffffff) << 16) |
88 (static_cast<uint64_t>(
m_lsData & 0x0000ffffffffffff) << 16) |
93 uint16_t
bc ()
const {
return m_BC; }
106 uint16_t
crc_cal(uint16_t crc_in, uint16_t dato)
109 uint16_t
mask = 0x0001;
111 uint16_t crc_temp = crc_in;
112 unsigned char datalen = 16;
113 for (
int i=0;
i<datalen;
i++){
114 if (dato & v) d = 0x0001;
116 if ((crc_temp & mask)^d) crc_temp = crc_temp>>1 ^ 0x8408;
117 else crc_temp = crc_temp>>1;
125 uint16_t vfatBlockWords[12];
126 vfatBlockWords[11] = ((0x000f &
m_b1010)<<12) |
m_BC;
127 vfatBlockWords[10] = ((0x000f &
m_b1100)<<12) | ((0x00ff &
m_EC) <<4) | (0x000f &
m_Flag);
129 vfatBlockWords[8] = (0xffff000000000000 &
m_msData) >> 48;
130 vfatBlockWords[7] = (0x0000ffff00000000 &
m_msData) >> 32;
131 vfatBlockWords[6] = (0x00000000ffff0000 &
m_msData) >> 16;
132 vfatBlockWords[5] = (0x000000000000ffff &
m_msData);
133 vfatBlockWords[4] = (0xffff000000000000 &
m_lsData) >> 48;
134 vfatBlockWords[3] = (0x0000ffff00000000 &
m_lsData) >> 32;
135 vfatBlockWords[2] = (0x00000000ffff0000 &
m_lsData) >> 16;
136 vfatBlockWords[1] = (0x000000000000ffff &
m_lsData);
138 uint16_t crc_fin = 0xffff;
139 for (
int i = 11;
i >= 1;
i--){
140 crc_fin = this->
crc_cal(crc_fin, vfatBlockWords[
i]);
149 uint16_t vfatBlockWords[12];
150 vfatBlockWords[11] = ((0x000f &
b1010)<<12) | BC;
151 vfatBlockWords[10] = ((0x000f &
b1100)<<12) | ((0x00ff & EC) <<4) | (0x000f &
Flag);
152 vfatBlockWords[9] = ((0x000f &
b1110)<<12) | ChipID;
153 vfatBlockWords[8] = (0xffff000000000000 &
msData) >> 48;
154 vfatBlockWords[7] = (0x0000ffff00000000 &
msData) >> 32;
155 vfatBlockWords[6] = (0x00000000ffff0000 &
msData) >> 16;
156 vfatBlockWords[5] = (0x000000000000ffff &
msData);
157 vfatBlockWords[4] = (0xffff000000000000 &
lsData) >> 48;
158 vfatBlockWords[3] = (0x0000ffff00000000 &
lsData) >> 32;
159 vfatBlockWords[2] = (0x00000000ffff0000 &
lsData) >> 16;
160 vfatBlockWords[1] = (0x000000000000ffff &
lsData);
162 uint16_t crc_fin = 0xffff;
163 for (
int i = 11;
i >= 1;
i--){
164 crc_fin = this->
crc_cal(crc_fin, vfatBlockWords[
i]);
171 uint16_t vfatBlockWords[12];
172 vfatBlockWords[11] = ((0x000f & vfatData->
b1010())<<12) | vfatData->
bc();
173 vfatBlockWords[10] = ((0x000f & vfatData->
b1100())<<12) | ((0x00ff & vfatData->
ec()) <<4) | (0x000f & vfatData->
flag());
174 vfatBlockWords[9] = ((0x000f & vfatData->
b1110())<<12) | vfatData->
chipID();
175 vfatBlockWords[8] = (0xffff000000000000 & vfatData->
msData()) >> 48;
176 vfatBlockWords[7] = (0x0000ffff00000000 & vfatData->
msData()) >> 32;
177 vfatBlockWords[6] = (0x00000000ffff0000 & vfatData->
msData()) >> 16;
178 vfatBlockWords[5] = (0x000000000000ffff & vfatData->
msData());
179 vfatBlockWords[4] = (0xffff000000000000 & vfatData->
lsData()) >> 48;
180 vfatBlockWords[3] = (0x0000ffff00000000 & vfatData->
lsData()) >> 32;
181 vfatBlockWords[2] = (0x00000000ffff0000 & vfatData->
lsData()) >> 16;
182 vfatBlockWords[1] = (0x000000000000ffff & vfatData->
lsData());
184 uint16_t crc_fin = 0xffff;
185 for (
int i = 11;
i >= 1;
i--){
186 crc_fin = this->
crc_cal(crc_fin, vfatBlockWords[
i]);
uint16_t checkCRC(const VFATdata *vfatData)
uint16_t m_crc_calc
Check Sum value recalculated, 16 bits.
VFATdata(const uint8_t b1010_, const uint16_t BC_, const uint8_t b1100_, const uint8_t EC_, const uint8_t Flag_, const uint8_t b1110_, const uint16_t ChipID_, const uint64_t lsData_, const uint64_t msData_, const uint16_t crc_, const uint16_t crc_calc_, const int SlotNumber_, const bool isBlockGood_)
uint8_t m_b1100
1100:4, Control bits, shoud be 1100
bool m_isBlockGood
Shows if block is good (control bits, chip ID and CRC checks)
void read_sw(uint64_t word)
Read second word from the block.
uint16_t m_crc
Check Sum value, 16 bits.
uint8_t m_Flag
Control Flags: 4 bits, Hamming Error/AFULL/SEUlogic/SUEI2C.
static const int nChannels
uint8_t m_b1010
1010:4 Control bits, shoud be 1010
uint64_t m_lsData
channels from 1to64
uint64_t m_msData
channels from 65to128
uint16_t crc_cal(uint16_t crc_in, uint16_t dato)
uint16_t crc_calc() const
void read_fw(uint64_t word)
Read first word from the block.
uint16_t m_BC
Bunch Crossing number, 12 bits.
unsigned long long uint64_t
uint16_t m_ChipID
Chip ID, 12 bits.
uint8_t m_EC
Event Counter, 8 bits.
uint8_t m_b1110
1110:4 Control bits, shoud be 1110
uint16_t checkCRC(uint8_t b1010, uint16_t BC, uint8_t b1100, uint8_t EC, uint8_t Flag, uint8_t b1110, uint16_t ChipID, uint64_t msData, uint64_t lsData)
static const int sizeChipID
int m_SlotNumber
Calculated chip position.
void read_tw(uint64_t word)
Read third word from the block.