4 #ifndef artdaq_dune_Overlays_FelixFormat_hh 5 #define artdaq_dune_Overlays_FelixFormat_hh 19 typedef std::vector<uint16_t>
adc_v;
41 timestamp_1 = new_timestamp;
55 std::cout <<
"SOF:" << unsigned(
sof) <<
" version:" << unsigned(
version)
57 <<
" slot:" << unsigned(
slot_no)
58 <<
" crate:" << unsigned(
crate_no) <<
" mm:" << unsigned(
mm)
59 <<
" oos:" << unsigned(
oos)
72 std::cout <<
"SOF:" << std::bitset<8>(
sof)
73 <<
" version:" << std::bitset<5>(
version)
74 <<
" fiber:" << std::bitset<3>(
fiber_no)
75 <<
" slot:" << std::bitset<5>(
slot_no)
76 <<
" crate:" << std::bitset<3>(
crate_no) <<
" mm:" <<
bool(
mm)
78 <<
" wib_errors:" << std::bitset<16>(
wib_errors)
80 <<
" Z: " <<
z <<
'\n';
88 word_t s1_error : 4, s2_error : 4,
reserved_1 : 8, checksum_a_1 : 8,
90 word_t checksum_a_2 : 8, checksum_b_2 : 8, coldata_convert_count : 16;
92 word_t hdr_1 : 4, hdr_3 : 4, hdr_2 : 4, hdr_4 : 4, hdr_5 : 4, hdr_7 : 4,
96 return (uint16_t)checksum_a_1 | (checksum_a_2 << 8);
99 return (uint16_t)checksum_b_1 | (checksum_b_2 << 8);
101 uint8_t
hdr(
const uint8_t i)
const {
103 case 1:
return hdr_1;
104 case 2:
return hdr_2;
105 case 3:
return hdr_3;
106 case 4:
return hdr_4;
107 case 5:
return hdr_5;
108 case 6:
return hdr_6;
109 case 7:
return hdr_7;
110 case 8:
return hdr_8;
116 checksum_a_1 = new_checksum_a;
117 checksum_a_2 = new_checksum_a >> 8;
120 checksum_b_1 = new_checksum_b;
121 checksum_b_2 = new_checksum_b >> 8;
123 void set_hdr(
const uint8_t i,
const uint8_t new_hdr) {
125 case 1: hdr_1 = new_hdr;
break;
126 case 2: hdr_2 = new_hdr;
break;
127 case 3: hdr_3 = new_hdr;
break;
128 case 4: hdr_4 = new_hdr;
break;
129 case 5: hdr_5 = new_hdr;
break;
130 case 6: hdr_6 = new_hdr;
break;
131 case 7: hdr_7 = new_hdr;
break;
132 case 8: hdr_8 = new_hdr;
break;
138 std::cout <<
"s1_error:" << unsigned(s1_error)
139 <<
" s2_error:" << unsigned(s2_error)
140 <<
" checksum_a1:" << unsigned(checksum_a_1)
141 <<
" checksum_b1:" << unsigned(checksum_b_1)
142 <<
" checksum_a2:" << unsigned(checksum_a_2)
143 <<
" checksum_b1:" << unsigned(checksum_b_2)
144 <<
" coldata_convert_count:" << unsigned(coldata_convert_count)
145 <<
" error_register:" << unsigned(error_register)
146 <<
" hdr_1:" << unsigned(hdr_1) <<
" hdr_2:" << unsigned(hdr_2)
147 <<
" hdr_3:" << unsigned(hdr_3) <<
" hdr_4:" << unsigned(hdr_4)
148 <<
" hdr_5:" << unsigned(hdr_5) <<
" hdr_6:" << unsigned(hdr_6)
149 <<
" hdr_7:" << unsigned(hdr_7) <<
" hdr_8:" << unsigned(hdr_8);
153 std::cout <<
std::hex <<
"s1_error:" << s1_error <<
" s2_error:" << s2_error
154 <<
" checksum_a1:" << checksum_a_1
155 <<
" checksum_b1:" << checksum_b_1
156 <<
" checksum_a2:" << checksum_a_2
157 <<
" checksum_b1:" << checksum_b_2
158 <<
" coldata_convert_count:" << coldata_convert_count
159 <<
" error_register:" << error_register <<
" hdr_1:" << hdr_1
160 <<
" hdr_2:" << hdr_2 <<
" hdr_3:" << hdr_3 <<
" hdr_4:" << hdr_4
161 <<
" hdr_5:" << hdr_5 <<
" hdr_6:" << hdr_6 <<
" hdr_7:" << hdr_7
162 <<
" hdr_8:" << hdr_8;
166 std::cout <<
"s1_error:" << std::bitset<4>(s1_error)
167 <<
" s2_error:" << std::bitset<4>(s2_error)
168 <<
" checksum_a1:" << std::bitset<8>(checksum_a_1)
169 <<
" checksum_b1:" << std::bitset<8>(checksum_b_1)
170 <<
" checksum_a2:" << std::bitset<8>(checksum_a_2)
171 <<
" checksum_b2:" << std::bitset<8>(checksum_b_2)
172 <<
" coldata_convert_count:" 173 << std::bitset<16>(coldata_convert_count)
174 <<
" error_register:" << std::bitset<16>(error_register)
175 <<
" hdr_1:" << std::bitset<8>(hdr_1)
176 <<
" hdr_2:" << std::bitset<8>(hdr_2)
177 <<
" hdr_3:" << std::bitset<8>(hdr_3)
178 <<
" hdr_4:" << std::bitset<8>(hdr_4)
179 <<
" hdr_5:" << std::bitset<8>(hdr_5)
180 <<
" hdr_6:" << std::bitset<8>(hdr_6)
181 <<
" hdr_7:" << std::bitset<8>(hdr_7)
182 <<
" hdr_8:" << std::bitset<8>(hdr_8);
193 word_t adc0ch0_1 : 8, adc1ch0_1 : 8, adc0ch0_2 : 4, adc0ch1_1 : 4,
194 adc1ch0_2 : 4, adc1ch1_1 : 4;
195 word_t adc0ch1_2 : 8, adc1ch1_2 : 8, adc0ch2_1 : 8, adc1ch2_1 : 8;
196 word_t adc0ch2_2 : 4, adc0ch3_1 : 4, adc1ch2_2 : 4, adc1ch3_1 : 4,
197 adc0ch3_2 : 8, adc1ch3_2 : 8;
199 uint16_t
channel(
const uint8_t
adc,
const uint8_t ch)
const {
202 case 0:
return adc0ch0_1 | adc0ch0_2 << 8;
203 case 1:
return adc0ch1_1 | adc0ch1_2 << 4;
204 case 2:
return adc0ch2_1 | adc0ch2_2 << 8;
205 case 3:
return adc0ch3_1 | adc0ch3_2 << 4;
207 }
else if (adc % 2 == 1) {
209 case 0:
return adc1ch0_1 | adc1ch0_2 << 8;
210 case 1:
return adc1ch1_1 | adc1ch1_2 << 4;
211 case 2:
return adc1ch2_1 | adc1ch2_2 << 8;
212 case 3:
return adc1ch3_1 | adc1ch3_2 << 4;
219 const uint16_t new_val) {
222 case 0: adc0ch0_1 = new_val; adc0ch0_2 = new_val >> 8;
break;
223 case 1: adc0ch1_1 = new_val; adc0ch1_2 = new_val >> 4;
break;
224 case 2: adc0ch2_1 = new_val; adc0ch2_2 = new_val >> 8;
break;
225 case 3: adc0ch3_1 = new_val; adc0ch3_2 = new_val >> 4;
break;
227 }
else if (adc % 2 == 1) {
229 case 0: adc1ch0_1 = new_val; adc1ch0_2 = new_val >> 8;
break;
230 case 1: adc1ch1_1 = new_val; adc1ch1_2 = new_val >> 4;
break;
231 case 2: adc1ch2_1 = new_val; adc1ch2_2 = new_val >> 8;
break;
232 case 3: adc1ch3_1 = new_val; adc1ch3_2 = new_val >> 4;
break;
246 uint16_t
channel(
const uint8_t
adc,
const uint8_t ch)
const {
248 return segments[(adc / 2) * 2 + ch / 4].
channel(adc, ch);
252 segments[(adc / 2) * 2 + ch / 4].set_channel(adc, ch, new_val);
256 std::cout <<
"\t\t0\t1\t2\t3\t4\t5\t6\t7\n";
257 for (
int i = 0; i < 8; i++) {
258 std::cout <<
"Stream " << i <<
":\t";
259 for (
int j = 0; j < 8; j++) {
274 word_t sof_1 : 8, : 24;
279 word_t : 8, : 20, : 4;
285 static constexpr
size_t num_frame_hdr_words = 4;
286 static constexpr
size_t num_COLDATA_hdr_words = 4;
287 #if defined FELIXHEAD && defined FELIXTRAIL 288 static constexpr
size_t num_frame_words = 120;
289 #elif defined FELIXHEAD || defined FELIXTRAIL 290 static constexpr
size_t num_frame_words = 118;
292 static constexpr
size_t num_frame_words = 116;
294 static constexpr
size_t num_frame_bytes = num_frame_words *
sizeof(
word_t);
295 static constexpr
size_t num_COLDATA_words = 28;
297 static constexpr
size_t num_block_per_frame = 4;
298 static constexpr
size_t num_ch_per_frame = 256;
299 static constexpr
size_t num_ch_per_block = 64;
300 static constexpr
size_t num_seg_per_block = 8;
301 static constexpr
size_t num_ch_per_seg = 8;
305 uint8_t
sof()
const {
return sof_1; }
306 word_t FelixHead()
const {
return FelixHead_; }
314 uint8_t
mm()
const {
return head.
mm; }
319 uint8_t
z()
const {
return head.
z; }
322 void set_FelixHead(
const word_t new_flxhead) { FelixHead_ = new_flxhead; }
323 void set_sof(
const uint8_t new_sof) { sof_1 = new_sof; }
331 void set_mm(
const uint8_t new_mm) { head.
mm = new_mm; }
340 void set_z(uint8_t new_z) { head.
z = new_z; }
361 uint8_t
hdr(
const uint8_t block_num,
const uint8_t i)
const {
return blocks[block_num].
head.
hdr(i); }
363 void set_s1_error(
const uint8_t block_num,
const uint8_t new_s1_error) {
366 void set_s2_error(
const uint8_t block_num,
const uint8_t new_s2_error) {
376 const uint16_t new_coldata_convert_count) {
382 void set_hdr(
const uint8_t block_num,
const uint8_t i,
const uint8_t new_hdr) {
387 uint16_t
channel(
const uint8_t block_num,
const uint8_t
adc,
const uint8_t ch)
const {
388 return blocks[block_num].
channel(adc, ch);
390 uint16_t
channel(
const uint8_t block_num,
const uint8_t ch)
const {
391 return channel(block_num, ch / 8, ch % 8);
396 const uint16_t new_val) {
399 void set_channel(
const uint8_t block_num,
const uint8_t ch,
const uint16_t new_val) {
400 set_channel(block_num, ch / 8, ch % 8, new_val);
403 set_channel(ch / 64, ch % 64, new_val);
409 return &blocks[block%4].
head;
414 std::cout <<
"Printing frame:\n";
416 for(
auto b: blocks) {
void set_mm(const uint8_t new_mm)
uint8_t hdr(const uint8_t block_num, const uint8_t i) const
void set_checksum_a(const uint8_t block_num, const uint16_t new_checksum_a)
void set_oos(const uint8_t new_oos)
void set_channel(const uint8_t ch, const uint16_t new_val)
void set_fiber_no(const uint8_t new_fiber_no)
uint16_t channel(const uint8_t adc, const uint8_t ch) const
void set_hdr(const uint8_t block_num, const uint8_t i, const uint8_t new_hdr)
void set_wib_errors(const uint16_t new_wib_errors)
void set_wib_counter(uint16_t new_wib_counter)
QTextStream & hex(QTextStream &s)
const ColdataHeader * coldata_header(const unsigned &block=0) const
const WIBHeader * wib_header() const
std::vector< uint16_t > adc_v
uint16_t checksum_b(const uint8_t block_num) const
void set_coldata_convert_count(const uint8_t block_num, const uint16_t new_coldata_convert_count)
uint16_t channel(const uint8_t block_num, const uint8_t ch) const
void set_z(uint8_t new_z)
void set_timestamp(uint64_t new_timestamp)
void set_channel(const uint8_t adc, const uint8_t ch, uint16_t new_val)
uint16_t channel(const uint8_t adc, const uint8_t ch) const
void set_channel(const uint8_t adc, const uint8_t ch, const uint16_t new_val)
uint16_t wib_errors() const
uint16_t error_register(const uint8_t block_num) const
uint8_t s2_error(const uint8_t block_num) const
void set_version(const uint8_t new_version)
void set_sof(const uint8_t new_sof)
uint16_t channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
QTextStream & dec(QTextStream &s)
void set_error_register(const uint8_t block_num, const uint16_t new_error_register)
void set_crate_no(const uint8_t new_crate_no)
void set_s1_error(const uint8_t block_num, const uint8_t new_s1_error)
void set_checksum_b(const uint8_t block_num, const uint16_t new_checksum_b)
uint16_t coldata_convert_count(const uint8_t block_num) const
uint16_t checksum_a(const uint8_t block_num) const
void set_slot_no(const uint8_t new_slot_no)
void set_channel(const uint8_t block_num, const uint8_t ch, const uint16_t new_val)
uint16_t wib_counter() const
uint16_t channel(const uint8_t ch) const
uint8_t s1_error(const uint8_t block_num) const
void set_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch, const uint16_t new_val)
uint64_t timestamp() const
void set_s2_error(const uint8_t block_num, const uint8_t new_s2_error)