1 #ifndef EventFilter_GEMRawToDigi_VFATdata_h 2 #define EventFilter_GEMRawToDigi_VFATdata_h 18 const uint16_t ChipID_,
22 const uint16_t crc_calc_,
23 const int SlotNumber_,
24 const bool isBlockGood_) :
46 m_BC = 0x0fff & (word >> 48);
49 m_Flag = 0x0f & (word >> 32);
52 m_msData = 0xffff000000000000 & (word << 48);
57 (static_cast<uint64_t>(
m_b1010 & 0x0f) << 60) |
71 m_lsData = 0xffff000000000000 & (word << 48);
76 (static_cast<uint64_t>(
m_msData & 0x0000ffffffffffff) << 16) |
90 (static_cast<uint64_t>(
m_lsData & 0x0000ffffffffffff) << 16) |
95 uint16_t
bc ()
const {
return m_BC; }
108 uint16_t
crc_cal(uint16_t crc_in, uint16_t dato)
111 uint16_t
mask = 0x0001;
113 uint16_t crc_temp = crc_in;
114 unsigned char datalen = 16;
115 for (
int i=0;
i<datalen;
i++){
116 if (dato & v) d = 0x0001;
118 if ((crc_temp & mask)^d) crc_temp = crc_temp>>1 ^ 0x8408;
119 else crc_temp = crc_temp>>1;
127 uint16_t vfatBlockWords[12];
128 vfatBlockWords[11] = ((0x000f &
m_b1010)<<12) |
m_BC;
129 vfatBlockWords[10] = ((0x000f &
m_b1100)<<12) | ((0x00ff &
m_EC) <<4) | (0x000f &
m_Flag);
131 vfatBlockWords[8] = (0xffff000000000000 &
m_msData) >> 48;
132 vfatBlockWords[7] = (0x0000ffff00000000 &
m_msData) >> 32;
133 vfatBlockWords[6] = (0x00000000ffff0000 &
m_msData) >> 16;
134 vfatBlockWords[5] = (0x000000000000ffff &
m_msData);
135 vfatBlockWords[4] = (0xffff000000000000 &
m_lsData) >> 48;
136 vfatBlockWords[3] = (0x0000ffff00000000 &
m_lsData) >> 32;
137 vfatBlockWords[2] = (0x00000000ffff0000 &
m_lsData) >> 16;
138 vfatBlockWords[1] = (0x000000000000ffff &
m_lsData);
140 uint16_t crc_fin = 0xffff;
141 for (
int i = 11;
i >= 1;
i--){
142 crc_fin = this->
crc_cal(crc_fin, vfatBlockWords[
i]);
151 uint16_t vfatBlockWords[12];
152 vfatBlockWords[11] = ((0x000f &
b1010)<<12) | BC;
153 vfatBlockWords[10] = ((0x000f &
b1100)<<12) | ((0x00ff & EC) <<4) | (0x000f &
Flag);
154 vfatBlockWords[9] = ((0x000f &
b1110)<<12) | ChipID;
155 vfatBlockWords[8] = (0xffff000000000000 &
msData) >> 48;
156 vfatBlockWords[7] = (0x0000ffff00000000 &
msData) >> 32;
157 vfatBlockWords[6] = (0x00000000ffff0000 &
msData) >> 16;
158 vfatBlockWords[5] = (0x000000000000ffff &
msData);
159 vfatBlockWords[4] = (0xffff000000000000 &
lsData) >> 48;
160 vfatBlockWords[3] = (0x0000ffff00000000 &
lsData) >> 32;
161 vfatBlockWords[2] = (0x00000000ffff0000 &
lsData) >> 16;
162 vfatBlockWords[1] = (0x000000000000ffff &
lsData);
164 uint16_t crc_fin = 0xffff;
165 for (
int i = 11;
i >= 1;
i--){
166 crc_fin = this->
crc_cal(crc_fin, vfatBlockWords[
i]);
173 uint16_t vfatBlockWords[12];
174 vfatBlockWords[11] = ((0x000f & vfatData->
b1010())<<12) | vfatData->
bc();
175 vfatBlockWords[10] = ((0x000f & vfatData->
b1100())<<12) | ((0x00ff & vfatData->
ec()) <<4) | (0x000f & vfatData->
flag());
176 vfatBlockWords[9] = ((0x000f & vfatData->
b1110())<<12) | vfatData->
chipID();
177 vfatBlockWords[8] = (0xffff000000000000 & vfatData->
msData()) >> 48;
178 vfatBlockWords[7] = (0x0000ffff00000000 & vfatData->
msData()) >> 32;
179 vfatBlockWords[6] = (0x00000000ffff0000 & vfatData->
msData()) >> 16;
180 vfatBlockWords[5] = (0x000000000000ffff & vfatData->
msData());
181 vfatBlockWords[4] = (0xffff000000000000 & vfatData->
lsData()) >> 48;
182 vfatBlockWords[3] = (0x0000ffff00000000 & vfatData->
lsData()) >> 32;
183 vfatBlockWords[2] = (0x00000000ffff0000 & vfatData->
lsData()) >> 16;
184 vfatBlockWords[1] = (0x000000000000ffff & vfatData->
lsData());
186 uint16_t crc_fin = 0xffff;
187 for (
int i = 11;
i >= 1;
i--){
188 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.