FelixFormat.hh
Go to the documentation of this file.
1 // FelixFormat.hh
2 // Milo Vermeulen 2018
3 
4 #ifndef artdaq_dune_Overlays_FelixFormat_hh
5 #define artdaq_dune_Overlays_FelixFormat_hh
6 
7 // Set these if you have a header and/or a trailer in your frames.
8 // #define FELIXHEAD
9 // #define FELIXTRAIL
10 
11 #include <bitset>
12 #include <iostream>
13 #include <vector>
14 
15 namespace dune {
16 
17 typedef uint32_t word_t;
18 typedef uint16_t adc_t;
19 typedef std::vector<uint16_t> adc_v;
20 
21 //===================
22 // WIB header struct
23 //===================
24 struct WIBHeader {
25  word_t sof : 8, version : 5, fiber_no : 3, crate_no : 5, slot_no : 3,
26  reserved_1 : 8;
27  word_t mm : 1, oos : 1, reserved_2 : 14, wib_errors : 16;
28  word_t timestamp_1;
29  word_t timestamp_2 : 16, wib_counter_1 : 15, z : 1;
30 
31  uint64_t timestamp() const {
32  uint64_t timestamp = timestamp_1 | ((uint64_t)timestamp_2 << 32);
33  if (!z) {
34  timestamp |= (uint64_t)wib_counter_1 << 48;
35  }
36  return timestamp;
37  }
38  uint16_t wib_counter() const { return z ? wib_counter_1 : 0; }
39 
40  void set_timestamp(const uint64_t new_timestamp) {
41  timestamp_1 = new_timestamp;
42  timestamp_2 = new_timestamp >> 32;
43  if (!z) {
44  wib_counter_1 = new_timestamp >> 48;
45  }
46  }
47  void set_wib_counter(const uint16_t new_wib_counter) {
48  if(z) {
49  wib_counter_1 = new_wib_counter;
50  }
51  }
52 
53  // Print functions for debugging.
54  void print() const {
55  std::cout << "SOF:" << unsigned(sof) << " version:" << unsigned(version)
56  << " fiber:" << unsigned(fiber_no)
57  << " slot:" << unsigned(slot_no)
58  << " crate:" << unsigned(crate_no) << " mm:" << unsigned(mm)
59  << " oos:" << unsigned(oos)
60  << " wib_errors:" << unsigned(wib_errors)
61  << " timestamp: " << timestamp() << '\n';
62  }
63  void printHex() const {
64  std::cout << std::hex << "SOF:" << sof << " version:" << version
65  << " fiber:" << fiber_no << " slot:" << slot_no
66  << " crate:" << crate_no << " mm:" << mm << " oos:" << oos
67  << " wib_errors:" << wib_errors << " timestamp: " << timestamp()
68  << std::dec << '\n';
69  }
70 
71  void printBits() const {
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)
77  << " oos:" << bool(oos)
78  << " wib_errors:" << std::bitset<16>(wib_errors)
79  << " timestamp: " << timestamp() << '\n'
80  << " Z: " << z << '\n';
81  }
82 };
83 
84 //=======================
85 // COLDATA header struct
86 //=======================
87 struct ColdataHeader {
88  word_t s1_error : 4, s2_error : 4, reserved_1 : 8, checksum_a_1 : 8,
89  checksum_b_1 : 8;
90  word_t checksum_a_2 : 8, checksum_b_2 : 8, coldata_convert_count : 16;
91  word_t error_register : 16, reserved_2 : 16;
92  word_t hdr_1 : 4, hdr_3 : 4, hdr_2 : 4, hdr_4 : 4, hdr_5 : 4, hdr_7 : 4,
93  hdr_6 : 4, hdr_8 : 4;
94 
95  uint16_t checksum_a() const {
96  return (uint16_t)checksum_a_1 | (checksum_a_2 << 8);
97  }
98  uint16_t checksum_b() const {
99  return (uint16_t)checksum_b_1 | (checksum_b_2 << 8);
100  }
101  uint8_t hdr(const uint8_t i) const {
102  switch(i) {
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;
111  }
112  return 0;
113  }
114 
115  void set_checksum_a(const uint16_t new_checksum_a) {
116  checksum_a_1 = new_checksum_a;
117  checksum_a_2 = new_checksum_a >> 8;
118  }
119  void set_checksum_b(const uint16_t new_checksum_b) {
120  checksum_b_1 = new_checksum_b;
121  checksum_b_2 = new_checksum_b >> 8;
122  }
123  void set_hdr(const uint8_t i, const uint8_t new_hdr) {
124  switch(i) {
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;
133  }
134  }
135 
136  // Print functions for debugging.
137  void print() const {
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);
150  std::cout << '\n';
151  }
152  void printHex() const {
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;
163  std::cout << '\n';
164  }
165  void printBits() const {
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);
183  std::cout << '\n';
184  }
185 };
186 
187 //========================
188 // COLDATA segment struct
189 //========================
191  // This struct contains three words of ADC values that form the main repeating
192  // pattern in the COLDATA block.
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;
198 
199  uint16_t channel(const uint8_t adc, const uint8_t ch) const {
200  if (adc % 2 == 0) {
201  switch (ch % 4) {
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;
206  }
207  } else if (adc % 2 == 1) {
208  switch (ch % 4) {
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;
213  }
214  }
215  return 0;
216  }
217 
218  void set_channel(const uint8_t adc, const uint8_t ch,
219  const uint16_t new_val) {
220  if (adc % 2 == 0) {
221  switch (ch % 4) {
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;
226  }
227  } else if (adc % 2 == 1) {
228  switch (ch % 4) {
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;
233  }
234  }
235  }
236 };
237 
238 //======================
239 // COLDATA block struct
240 //======================
241 struct ColdataBlock {
243 
244  ColdataSegment segments[8];
245 
246  uint16_t channel(const uint8_t adc, const uint8_t ch) const {
247  // Each segment houses one half (four channels) of two subsequent ADCs.
248  return segments[(adc / 2) * 2 + ch / 4].channel(adc, ch);
249  }
250 
251  void set_channel(const uint8_t adc, const uint8_t ch, uint16_t new_val) {
252  segments[(adc / 2) * 2 + ch / 4].set_channel(adc, ch, new_val);
253  }
254 
255  void printADCs() const {
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++) {
260  std::cout << std::hex << channel(i, j) << '\t';
261  }
262  std::cout << std::dec << '\n';
263  }
264  }
265 };
266 
267 //=============
268 // FELIX frame
269 //=============
270 class FelixFrame {
271  private:
272 #ifdef FELIXHEAD
273  word_t FelixHead_;
274  word_t sof_1 : 8, : 24;
275 #endif
277  ColdataBlock blocks[4];
278 #ifdef FELIXTRAIL
279  word_t /*eof*/ : 8, /* CRC_1 */ : 20, : 4;
280  word_t : 32;
281 #endif
282 
283  public:
284  // Constant expressions
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;
291 #else
292  static constexpr size_t num_frame_words = 116;
293 #endif
294  static constexpr size_t num_frame_bytes = num_frame_words * sizeof(word_t);
295  static constexpr size_t num_COLDATA_words = 28;
296 
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;
302 
303  // WIB header accessors
304 #ifdef FELIXHEAD
305  uint8_t sof() const { return sof_1; }
306  word_t FelixHead() const { return FelixHead_; }
307 #else
308  uint8_t sof() const { return head.sof; }
309 #endif
310  uint8_t version() const { return head.version; }
311  uint8_t fiber_no() const { return head.fiber_no; }
312  uint8_t crate_no() const { return head.crate_no; }
313  uint8_t slot_no() const { return head.slot_no; }
314  uint8_t mm() const { return head.mm; }
315  uint8_t oos() const { return head.oos; }
316  uint16_t wib_errors() const { return head.wib_errors; }
317  uint64_t timestamp() const { return head.timestamp(); }
318  uint16_t wib_counter() const { return head.wib_counter(); }
319  uint8_t z() const { return head.z; }
320  // WIB header mutators
321 #ifdef FELIXHEAD
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; }
324 #else
325  void set_sof(const uint8_t new_sof) { head.sof = new_sof; }
326 #endif
327  void set_version(const uint8_t new_version) { head.version = new_version; }
328  void set_fiber_no(const uint8_t new_fiber_no) { head.fiber_no = new_fiber_no; }
329  void set_crate_no(const uint8_t new_crate_no) { head.crate_no = new_crate_no; }
330  void set_slot_no(const uint8_t new_slot_no) { head.slot_no = new_slot_no; }
331  void set_mm(const uint8_t new_mm) { head.mm = new_mm; }
332  void set_oos(const uint8_t new_oos) { head.oos = new_oos; }
333  void set_wib_errors(const uint16_t new_wib_errors) {
334  head.wib_errors = new_wib_errors;
335  }
336  void set_timestamp(uint64_t new_timestamp) { head.set_timestamp(new_timestamp); }
337  void set_wib_counter(uint16_t new_wib_counter) {
338  head.wib_counter_1 = new_wib_counter;
339  }
340  void set_z(uint8_t new_z) { head.z = new_z; }
341 
342  // COLDATA header accessors
343  uint8_t s1_error(const uint8_t block_num) const {
344  return blocks[block_num].head.s1_error;
345  }
346  uint8_t s2_error(const uint8_t block_num) const {
347  return blocks[block_num].head.s2_error;
348  }
349  uint16_t checksum_a(const uint8_t block_num) const {
350  return blocks[block_num].head.checksum_a();
351  }
352  uint16_t checksum_b(const uint8_t block_num) const {
353  return blocks[block_num].head.checksum_b();
354  }
355  uint16_t coldata_convert_count(const uint8_t block_num) const {
356  return blocks[block_num].head.coldata_convert_count;
357  }
358  uint16_t error_register(const uint8_t block_num) const {
359  return blocks[block_num].head.error_register;
360  }
361  uint8_t hdr(const uint8_t block_num, const uint8_t i) const { return blocks[block_num].head.hdr(i); }
362  // COLDATA header mutators
363  void set_s1_error(const uint8_t block_num, const uint8_t new_s1_error) {
364  blocks[block_num].head.s1_error = new_s1_error;
365  }
366  void set_s2_error(const uint8_t block_num, const uint8_t new_s2_error) {
367  blocks[block_num].head.s2_error = new_s2_error;
368  }
369  void set_checksum_a(const uint8_t block_num, const uint16_t new_checksum_a) {
370  blocks[block_num].head.set_checksum_a(new_checksum_a);
371  }
372  void set_checksum_b(const uint8_t block_num, const uint16_t new_checksum_b) {
373  blocks[block_num].head.set_checksum_b(new_checksum_b);
374  }
375  void set_coldata_convert_count(const uint8_t block_num,
376  const uint16_t new_coldata_convert_count) {
377  blocks[block_num].head.coldata_convert_count = new_coldata_convert_count;
378  }
379  void set_error_register(const uint8_t block_num, const uint16_t new_error_register) {
380  blocks[block_num].head.error_register = new_error_register;
381  }
382  void set_hdr(const uint8_t block_num, const uint8_t i, const uint8_t new_hdr) {
383  blocks[block_num].head.set_hdr(i, new_hdr);
384  }
385 
386  // Channel accessors
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);
389  }
390  uint16_t channel(const uint8_t block_num, const uint8_t ch) const {
391  return channel(block_num, ch / 8, ch % 8);
392  }
393  uint16_t channel(const uint8_t ch) const { return channel(ch / 64, ch % 64); }
394  // Channel mutators
395  void set_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch,
396  const uint16_t new_val) {
397  blocks[block_num].set_channel(adc, ch, new_val);
398  }
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);
401  }
402  void set_channel(const uint8_t ch, const uint16_t new_val) {
403  set_channel(ch / 64, ch % 64, new_val);
404  }
405 
406  // Const struct accessors.
407  const WIBHeader* wib_header() const { return &head; }
408  const ColdataHeader* coldata_header(const unsigned& block = 0) const {
409  return &blocks[block%4].head;
410  }
411 
412  // Utility functions
413  void print() const {
414  std::cout << "Printing frame:\n";
415  head.print();
416  for(auto b: blocks) {
417  b.head.print();
418  b.printADCs();
419  }
420  }
421 };
422 
423 // //========================
424 // // Reordered FELIX frames
425 // //========================
426 // static constexpr unsigned num_reord = 6000;
427 // class ReorderedFelixFrames {
428 // private:
429 // WIBHeader head[num_reord];
430 // ColdataHeader blockhead[num_reord*4];
431 // adc_t ADCs[num_reord*256];
432 
433 // public:
434 // static constexpr unsigned frame_size = sizeof(WIBHeader)+sizeof(word_t)+4*sizeof(ColdataHeader)+256*sizeof(adc_t);
435 
436 // // WIB header accessors
437 // uint8_t sof(const size_t frame_ID = 0) const { return head[frame_ID].sof; }
438 // uint8_t version(const size_t frame_ID = 0) const { return head[frame_ID].version; }
439 // uint8_t fiber_no(const size_t frame_ID = 0) const { return head[frame_ID].fiber_no; }
440 // uint8_t crate_no(const size_t frame_ID = 0) const { return head[frame_ID].crate_no; }
441 // uint8_t slot_no(const size_t frame_ID = 0) const { return head[frame_ID].slot_no; }
442 // uint8_t mm(const size_t frame_ID = 0) const { return head[frame_ID].mm; }
443 // uint8_t oos(const size_t frame_ID = 0) const { return head[frame_ID].oos; }
444 // uint16_t wib_errors(const size_t frame_ID = 0) const { return head[frame_ID].wib_errors; }
445 // uint64_t timestamp(const size_t frame_ID = 0) const { return head[frame_ID].timestamp(); }
446 // uint16_t wib_counter(const size_t frame_ID = 0) const { return head[frame_ID].wib_counter(); }
447 // uint8_t z(const size_t frame_ID = 0) const { return head[frame_ID].z; }
448 // // WIB header mutators
449 // void set_sof(const size_t frame_ID, const uint8_t new_sof) { head[frame_ID].sof = new_sof; }
450 // void set_version(const size_t frame_ID, const uint8_t new_version) { head[frame_ID].version = new_version; }
451 // void set_fiber_no(const size_t frame_ID, const uint8_t new_fiber_no) { head[frame_ID].fiber_no = new_fiber_no; }
452 // void set_crate_no(const size_t frame_ID, const uint8_t new_crate_no) { head[frame_ID].crate_no = new_crate_no; }
453 // void set_slot_no(const size_t frame_ID, const uint8_t new_slot_no) { head[frame_ID].slot_no = new_slot_no; }
454 // void set_mm(const size_t frame_ID, const uint8_t new_mm) { head[frame_ID].mm = new_mm; }
455 // void set_oos(const size_t frame_ID, const uint8_t new_oos) { head[frame_ID].oos = new_oos; }
456 // void set_wib_errors(const size_t frame_ID, const uint16_t new_wib_errors) {
457 // head[frame_ID].wib_errors = new_wib_errors;
458 // }
459 // void set_timestamp(const size_t frame_ID, uint64_t new_timestamp) { head[frame_ID].set_timestamp(new_timestamp); }
460 // void set_wib_counter(const size_t frame_ID, uint16_t new_wib_counter) {
461 // head[frame_ID].wib_counter_1 = new_wib_counter;
462 // }
463 // void set_z(const size_t frame_ID, uint8_t new_z) { head[frame_ID].z = new_z; }
464 
465 // // COLDATA header accessors
466 // uint8_t s1_error(const size_t frame_ID, const uint8_t block_num) const {
467 // return blockhead[frame_ID*4+block_num].s1_error;
468 // }
469 // uint8_t s2_error(const size_t frame_ID, const uint8_t block_num) const {
470 // return blockhead[frame_ID*4+block_num].s2_error;
471 // }
472 // uint16_t checksum_a(const size_t frame_ID, const uint8_t block_num) const {
473 // return blockhead[frame_ID*4+block_num].checksum_a();
474 // }
475 // uint16_t checksum_b(const size_t frame_ID, const uint8_t block_num) const {
476 // return blockhead[frame_ID*4+block_num].checksum_b();
477 // }
478 // uint16_t coldata_convert_count(const size_t frame_ID, const uint8_t block_num) const {
479 // return blockhead[frame_ID*4+block_num].coldata_convert_count;
480 // }
481 // uint16_t error_register(const size_t frame_ID, const uint8_t block_num) const {
482 // return blockhead[frame_ID*4+block_num].error_register;
483 // }
484 // uint8_t hdr(const size_t frame_ID, const uint8_t block_num, const uint8_t i) const { return blockhead[frame_ID*4+block_num].hdr(i); }
485 // // COLDATA header mutators
486 // void set_s1_error(const size_t frame_ID, const uint8_t block_num, const uint8_t new_s1_error) {
487 // blockhead[frame_ID*4+block_num].s1_error = new_s1_error;
488 // }
489 // void set_s2_error(const size_t frame_ID, const uint8_t block_num, const uint8_t new_s2_error) {
490 // blockhead[frame_ID*4+block_num].s2_error = new_s2_error;
491 // }
492 // void set_checksum_a(const size_t frame_ID, const uint8_t block_num, const uint16_t new_checksum_a) {
493 // blockhead[frame_ID*4+block_num].set_checksum_a(new_checksum_a);
494 // }
495 // void set_checksum_b(const size_t frame_ID, const uint8_t block_num, const uint16_t new_checksum_b) {
496 // blockhead[frame_ID*4+block_num].set_checksum_b(new_checksum_b);
497 // }
498 // void set_coldata_convert_count(const size_t frame_ID, const uint8_t block_num,
499 // const uint16_t new_coldata_convert_count) {
500 // blockhead[frame_ID*4+block_num].coldata_convert_count = new_coldata_convert_count;
501 // }
502 // void set_error_register(const size_t frame_ID, const uint8_t block_num, const uint16_t new_error_register) {
503 // blockhead[frame_ID*4+block_num].error_register = new_error_register;
504 // }
505 // void set_hdr(const size_t frame_ID, const uint8_t block_num, const uint8_t i, const uint8_t new_hdr) {
506 // blockhead[frame_ID*4+block_num].set_hdr(i, new_hdr);
507 // }
508 
509 // size_t total_frames() const { return num_reord/* ADCs.size()/256 */; }
510 
511 // // Channel accessors
512 // uint16_t channel(const size_t frame_ID, const uint8_t block_num, const uint8_t adc, const uint8_t ch) const {
513 // return ADCs[(block_num*64 + adc*8 + ch)*total_frames() + frame_ID];
514 // }
515 // uint16_t channel(const size_t frame_ID, const uint8_t block_num, const uint8_t ch) const {
516 // return channel(frame_ID, block_num, ch / 8, ch % 8);
517 // }
518 // uint16_t channel(const size_t frame_ID, const uint8_t ch) const { return channel(frame_ID, ch / 64, ch % 64); }
519 // // Channel mutators
520 // void set_channel(const size_t frame_ID, const uint8_t block_num, const uint8_t adc, const uint8_t ch,
521 // const uint16_t new_val) {
522 // ADCs[(block_num * 64 + adc * 8 + ch) * total_frames() + frame_ID] = new_val;
523 // }
524 // void set_channel(const size_t frame_ID, const uint8_t block_num, const uint8_t ch, const uint16_t new_val) {
525 // set_channel(frame_ID, block_num, ch / 8, ch % 8, new_val);
526 // }
527 // void set_channel(const size_t frame_ID, const uint8_t ch, const uint16_t new_val) {
528 // set_channel(frame_ID, ch / 64, ch % 64, new_val);
529 // }
530 
531 // // Waveform accessor
532 // // adc_v waveform(const uint8_t ch) {
533 // // return adc_v(ADCs.begin() + ch * total_frames(),
534 // // ADCs.begin() + (ch+1) * total_frames());
535 // // }
536 
537 // // Utility functions
538 // void print(const size_t frame_ID) const {
539 // std::cout << "Printing frame " << frame_ID << ":\n";
540 // head[frame_ID].print();
541 // for (unsigned i = 0; i < 4; ++i) {
542 // blockhead[frame_ID*4+i].print();
543 
544 // std::cout << "\t\t0\t1\t2\t3\t4\t5\t6\t7\n";
545 // for (int j = 0; j < 8; j++) {
546 // std::cout << "Stream " << j << ":\t";
547 // for (int k = 0; k < 8; k++) {
548 // std::cout << std::hex << channel(frame_ID, i*64+j*8+k) << '\t';
549 // }
550 // std::cout << std::dec << '\n';
551 // }
552 // }
553 // }
554 // };
555 
556 } // namespace dune
557 
558 #endif /* artdaq_dune_Overlays_FelixFormat_hh */
uint16_t adc_t
Definition: FelixFormat.hh:18
void set_mm(const uint8_t new_mm)
Definition: FelixFormat.hh:331
uint8_t hdr(const uint8_t block_num, const uint8_t i) const
Definition: FelixFormat.hh:361
uint8_t version() const
Definition: FelixFormat.hh:310
void set_hdr(const uint8_t i, const uint8_t new_hdr)
Definition: FelixFormat.hh:123
void printBits() const
Definition: FelixFormat.hh:71
void set_checksum_a(const uint8_t block_num, const uint16_t new_checksum_a)
Definition: FelixFormat.hh:369
uint16_t wib_counter() const
Definition: FelixFormat.hh:38
void set_oos(const uint8_t new_oos)
Definition: FelixFormat.hh:332
void print() const
Definition: FelixFormat.hh:413
uint32_t word_t
Definition: FelixFormat.hh:17
void set_channel(const uint8_t ch, const uint16_t new_val)
Definition: FelixFormat.hh:402
void set_fiber_no(const uint8_t new_fiber_no)
Definition: FelixFormat.hh:328
uint16_t channel(const uint8_t adc, const uint8_t ch) const
Definition: FelixFormat.hh:246
void set_hdr(const uint8_t block_num, const uint8_t i, const uint8_t new_hdr)
Definition: FelixFormat.hh:382
uint8_t slot_no() const
Definition: FelixFormat.hh:313
void set_wib_errors(const uint16_t new_wib_errors)
Definition: FelixFormat.hh:333
void set_wib_counter(uint16_t new_wib_counter)
Definition: FelixFormat.hh:337
int16_t adc
Definition: CRTFragment.hh:202
QTextStream & hex(QTextStream &s)
uint8_t channel
Definition: CRTFragment.hh:201
const ColdataHeader * coldata_header(const unsigned &block=0) const
Definition: FelixFormat.hh:408
const WIBHeader * wib_header() const
Definition: FelixFormat.hh:407
uint8_t mm() const
Definition: FelixFormat.hh:314
uint8_t sof() const
Definition: FelixFormat.hh:308
std::vector< uint16_t > adc_v
Definition: FelixFormat.hh:19
uint16_t checksum_b(const uint8_t block_num) const
Definition: FelixFormat.hh:352
word_t wib_counter_1
Definition: FelixFormat.hh:29
void set_wib_counter(const uint16_t new_wib_counter)
Definition: FelixFormat.hh:47
void set_coldata_convert_count(const uint8_t block_num, const uint16_t new_coldata_convert_count)
Definition: FelixFormat.hh:375
word_t coldata_convert_count
Definition: FelixFormat.hh:90
uint16_t channel(const uint8_t block_num, const uint8_t ch) const
Definition: FelixFormat.hh:390
uint8_t fiber_no() const
Definition: FelixFormat.hh:311
void set_z(uint8_t new_z)
Definition: FelixFormat.hh:340
uint8_t z() const
Definition: FelixFormat.hh:319
void set_timestamp(uint64_t new_timestamp)
Definition: FelixFormat.hh:336
void set_channel(const uint8_t adc, const uint8_t ch, uint16_t new_val)
Definition: FelixFormat.hh:251
uint16_t channel(const uint8_t adc, const uint8_t ch) const
Definition: FelixFormat.hh:199
void set_channel(const uint8_t adc, const uint8_t ch, const uint16_t new_val)
Definition: FelixFormat.hh:218
uint16_t wib_errors() const
Definition: FelixFormat.hh:316
uint64_t timestamp() const
Definition: FelixFormat.hh:31
word_t timestamp_1
Definition: FelixFormat.hh:28
uint16_t error_register(const uint8_t block_num) const
Definition: FelixFormat.hh:358
void printHex() const
Definition: FelixFormat.hh:63
uint8_t s2_error(const uint8_t block_num) const
Definition: FelixFormat.hh:346
void set_version(const uint8_t new_version)
Definition: FelixFormat.hh:327
void set_checksum_b(const uint16_t new_checksum_b)
Definition: FelixFormat.hh:119
void set_sof(const uint8_t new_sof)
Definition: FelixFormat.hh:325
void set_timestamp(const uint64_t new_timestamp)
Definition: FelixFormat.hh:40
uint16_t channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
Definition: FelixFormat.hh:387
QTextStream & dec(QTextStream &s)
void set_error_register(const uint8_t block_num, const uint16_t new_error_register)
Definition: FelixFormat.hh:379
uint8_t crate_no() const
Definition: FelixFormat.hh:312
uint8_t hdr(const uint8_t i) const
Definition: FelixFormat.hh:101
void set_crate_no(const uint8_t new_crate_no)
Definition: FelixFormat.hh:329
void set_s1_error(const uint8_t block_num, const uint8_t new_s1_error)
Definition: FelixFormat.hh:363
void print() const
Definition: FelixFormat.hh:54
void set_checksum_b(const uint8_t block_num, const uint16_t new_checksum_b)
Definition: FelixFormat.hh:372
uint8_t oos() const
Definition: FelixFormat.hh:315
void printBits() const
Definition: FelixFormat.hh:165
uint16_t coldata_convert_count(const uint8_t block_num) const
Definition: FelixFormat.hh:355
uint16_t checksum_a(const uint8_t block_num) const
Definition: FelixFormat.hh:349
void print() const
Definition: FelixFormat.hh:137
void set_slot_no(const uint8_t new_slot_no)
Definition: FelixFormat.hh:330
word_t timestamp_2
Definition: FelixFormat.hh:29
void set_channel(const uint8_t block_num, const uint8_t ch, const uint16_t new_val)
Definition: FelixFormat.hh:399
static bool * b
Definition: config.cpp:1043
void set_checksum_a(const uint16_t new_checksum_a)
Definition: FelixFormat.hh:115
uint16_t wib_counter() const
Definition: FelixFormat.hh:318
uint16_t channel(const uint8_t ch) const
Definition: FelixFormat.hh:393
uint8_t s1_error(const uint8_t block_num) const
Definition: FelixFormat.hh:343
void set_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch, const uint16_t new_val)
Definition: FelixFormat.hh:395
int bool
Definition: qglobal.h:345
uint64_t timestamp() const
Definition: FelixFormat.hh:317
uint16_t checksum_a() const
Definition: FelixFormat.hh:95
void printADCs() const
Definition: FelixFormat.hh:255
void printHex() const
Definition: FelixFormat.hh:152
ColdataHeader head
Definition: FelixFormat.hh:242
void set_s2_error(const uint8_t block_num, const uint8_t new_s2_error)
Definition: FelixFormat.hh:366
uint16_t checksum_b() const
Definition: FelixFormat.hh:98