1 #ifndef dune_artdaq_Overlays_PennMicroSlice_hh 2 #define dune_artdaq_Overlays_PennMicroSlice_hh 17 #ifdef PENN_OLD_STRUCTS 50 typedef uint8_t data_packet_type_t;
51 typedef uint32_t short_nova_timestamp_t;
61 short_nova_timestamp_t short_nova_timestamp : 27;
62 data_packet_type_t data_packet_type : 3;
67 struct Warning_Header {
71 typedef uint8_t warning_type_t;
72 typedef uint8_t data_packet_type_t;
73 typedef uint32_t short_nova_timestamp_t;
80 uint32_t padding : 24;
81 warning_type_t warning_type : 5;
82 data_packet_type_t data_packet_type : 3;
85 static data_size_t
const num_bits_padding = 24;
86 static data_size_t
const num_bits_warning = 5;
87 static data_size_t
const num_bits_packet_type = 3;
120 uint32_t padding : 24;
121 warning_type_t warning_type : 5;
122 data_packet_type_t data_packet_type : 3;
125 static data_size_t
const num_bits_padding = 24;
126 static data_size_t
const num_bits_warning = 5;
127 static data_size_t
const num_bits_packet_type = 3;
144 short_nova_timestamp_t short_nova_timestamp : 27;
145 data_packet_type_t data_packet_type : 3;
147 static size_t const size_bytes =
sizeof(
data_t);
148 static size_t const size_u32 =
sizeof(
data_t)/
sizeof(uint32_t);
150 static data_size_t
const num_bits_padding = 2;
151 static data_size_t
const num_bits_short_tstamp = 27;
152 static data_size_t
const num_bits_packet_type = 3;
160 if ((ts_ref & 0x7FFFFFF) == short_nova_timestamp) {
163 }
else if ((ts_ref & 0x7FFFFFF) > short_nova_timestamp) {
165 return ts_ref - ((ts_ref & 0x7FFFFFF) - short_nova_timestamp);
169 return ts_ref - ((ts_ref & 0x7FFFFFF) + (0x7FFFFFF - short_nova_timestamp));
175 if ((ts_ref & 0x7FFFFFF) == short_nova_timestamp) {
178 }
else if ((ts_ref & 0x7FFFFFF) > short_nova_timestamp) {
181 return ts_ref + (0x7FFFFFF - ((ts_ref & 0x7FFFFFF))) + short_nova_timestamp;
184 return ts_ref + (short_nova_timestamp - (ts_ref & 0x7FFFFFF));
198 counter_set_t tsu_wu : 10;
199 counter_set_t tsu_el : 10;
200 counter_set_t tsu_extra : 4;
201 counter_set_t tsu_nu : 6;
202 counter_set_t tsu_sl : 6;
203 counter_set_t tsu_nl : 6;
204 counter_set_t tsu_su : 6;
206 counter_set_t bsu_rm : 16;
207 counter_set_t bsu_cu : 10;
209 counter_set_t bsu_cl1 : 6;
210 counter_set_t bsu_extra : 1;
211 counter_set_t bsu_cl2 : 7;
212 counter_set_t bsu_rl : 10;
214 counter_set_t padding : 30;
216 static data_size_t
const num_bits_tsu_wu = 10;
217 static data_size_t
const num_bits_tsu_el = 10;
218 static data_size_t
const num_bits_tsu_extra = 4;
219 static data_size_t
const num_bits_tsu_nu = 6;
220 static data_size_t
const num_bits_tsu_sl = 6;
221 static data_size_t
const num_bits_tsu_nl = 6;
222 static data_size_t
const num_bits_tsu_su = 6;
223 static data_size_t
const num_bits_bsu_rm = 16;
224 static data_size_t
const num_bits_bsu_cu = 10;
225 static data_size_t
const num_bits_bsu_cl1 = 6;
226 static data_size_t
const num_bits_bsu_extra = 1;
227 static data_size_t
const num_bits_bsu_cl2 = 7;
228 static data_size_t
const num_bits_bsu_rl = 10;
229 static data_size_t
const num_bits_padding = 30;
230 static data_size_t
const num_bits_bsu_cl = 13;
236 static data_size_t
const counter_type_tsu_wu = 10;
237 static data_size_t
const counter_type_tsu_el = 20;
238 static data_size_t
const counter_type_tsu_extra = 24;
239 static data_size_t
const counter_type_tsu_nu = 30;
240 static data_size_t
const counter_type_tsu_sl = 36;
241 static data_size_t
const counter_type_tsu_nl = 42;
242 static data_size_t
const counter_type_tsu_su = 48;
243 static data_size_t
const counter_type_bsu_rm = 64;
244 static data_size_t
const counter_type_bsu_cu = 74;
245 static data_size_t
const counter_type_bsu_cl1 = 80;
246 static data_size_t
const counter_type_bsu_extra = 81;
247 static data_size_t
const counter_type_bsu_cl2 = 88;
248 static data_size_t
const counter_type_bsu_rl = 98;
249 static data_size_t
const counter_type_padding = 128;
251 static data_size_t
const counter_type_unknown = 129;
252 static data_size_t
const counter_type_bsu_cl = 130;
254 static size_t const size_bytes = 2*
sizeof(uint64_t);
255 static size_t const size_u32 = size_bytes/
sizeof(uint32_t);
258 static size_t const size_words_ptb_u32 = 3;
259 static size_t const size_words_ptb_bytes = size_words_ptb_u32*
sizeof(uint32_t);
261 static size_t const ptb_offset_u32 = 0;
262 static size_t const ptb_offset_bytes = ptb_offset_u32*
sizeof(uint32_t);
265 static size_t const payload_offset_u32 = 1+ptb_offset_u32;
266 static size_t const payload_offset_bytes = payload_offset_u32*
sizeof(uint32_t);
268 counter_set_t
get_bsu_cl() {
return ((bsu_cl2 << 10) | (bsu_cl1));};
271 return ((tsu_wu & (1 << idx)) != 0x0);
274 return ((tsu_el & (1 << idx)) != 0x0);
277 return ((tsu_extra & (1 << idx)) != 0x0);
280 return ((tsu_nu & (1 << idx)) != 0x0);
283 return ((tsu_sl & (1 << idx)) != 0x0);
286 return ((tsu_nl & (1 << idx)) != 0x0);
289 return ((tsu_su & (1 << idx)) != 0x0);
293 return ((bsu_rm & (1 << idx)) != 0x0);
296 return ((bsu_cu & (1 << idx)) != 0x0);
300 if (idx < num_bits_bsu_cl1) {
301 return ((bsu_cl1 & (1 << idx)) != 0x0);
303 return ((bsu_cl2 & (1 << (idx-num_bits_bsu_cl1))) != 0x0);
307 return ((bsu_rl & (1 << idx)) != 0x0);
313 return (((reinterpret_cast<const uint8_t*>(
this)[idx/8]) & (1 << (idx%8))) != 0x0);
319 if (bit_idx < counter_type_tsu_wu)
return counter_type_tsu_wu;
320 else if (bit_idx < counter_type_tsu_el)
return counter_type_tsu_el;
321 else if (bit_idx < counter_type_tsu_extra)
return counter_type_tsu_extra;
322 else if (bit_idx < counter_type_tsu_nu)
return counter_type_tsu_nu;
323 else if (bit_idx < counter_type_tsu_sl)
return counter_type_tsu_sl;
324 else if (bit_idx < counter_type_tsu_nl)
return counter_type_tsu_nl;
325 else if (bit_idx < counter_type_tsu_su)
return counter_type_tsu_su;
326 else if (bit_idx < counter_type_bsu_rm)
return counter_type_bsu_rm;
327 else if (bit_idx < counter_type_bsu_cu)
return counter_type_bsu_cu;
328 else if (bit_idx == (counter_type_bsu_extra-1))
return counter_type_bsu_extra;
329 else if (bit_idx < counter_type_bsu_cl2)
return counter_type_bsu_cl;
330 else if (bit_idx < counter_type_bsu_rl)
return counter_type_bsu_rl;
331 else if (bit_idx < counter_type_padding)
return counter_type_padding;
332 else return counter_type_unknown;
338 if (bit_idx < counter_type_tsu_wu)
return bit_idx;
339 else if (bit_idx < counter_type_tsu_el)
return (bit_idx - counter_type_tsu_wu);
340 else if (bit_idx < counter_type_tsu_extra)
return (bit_idx - counter_type_tsu_el);
341 else if (bit_idx < counter_type_tsu_nu)
return (bit_idx - counter_type_tsu_extra);
342 else if (bit_idx < counter_type_tsu_sl)
return (bit_idx - counter_type_tsu_nu);
343 else if (bit_idx < counter_type_tsu_nl)
return (bit_idx - counter_type_tsu_sl);
344 else if (bit_idx < counter_type_tsu_su)
return (bit_idx - counter_type_tsu_nl);
345 else if (bit_idx < counter_type_bsu_rm)
return (bit_idx - counter_type_tsu_su);
346 else if (bit_idx < counter_type_bsu_cu)
return (bit_idx - counter_type_bsu_rm);
347 else if (bit_idx == (counter_type_bsu_extra-1))
return 0;
348 else if (bit_idx < counter_type_bsu_cl1)
return (bit_idx - counter_type_bsu_cu);
350 else if (bit_idx < counter_type_bsu_cl2)
return (bit_idx - counter_type_bsu_cu -1);
351 else if (bit_idx < counter_type_bsu_rl)
return (bit_idx - counter_type_bsu_cl2);
352 else if (bit_idx < counter_type_padding)
return (bit_idx - counter_type_bsu_rl);
353 else return counter_type_unknown;
365 trigger_type_t padding_low : 8;
370 trigger_type_t trigger_id_ext : 4;
371 trigger_type_t trigger_id_calib: 4;
372 trigger_type_t trigger_id_muon : 8;
373 trigger_type_t trigger_type : 5;
374 trigger_type_t padding_high : 3;
376 static data_size_t
const num_bits_padding_low = 8;
377 static data_size_t
const num_bits_trigger_id_ext = 4;
378 static data_size_t
const num_bits_trigger_id_calib= 4;
379 static data_size_t
const num_bits_trigger_id_muon = 8;
380 static data_size_t
const num_bits_trigger_type = 5;
381 static data_size_t
const num_bits_padding_high = 3;
403 static trigger_type_t
const muon = 0x10;
404 static trigger_type_t
const external = 0x08;
405 static trigger_type_t
const calibration = 0x04;
409 static trigger_type_t
const I01_08 = 0x8;
410 static trigger_type_t
const ssp = 0x8;
411 static trigger_type_t
const I09 = 0x4;
412 static trigger_type_t
const I10 = 0x2;
413 static trigger_type_t
const I12 = 0x1;
420 static trigger_type_t
const C1 = 0x8;
421 static trigger_type_t
const C2 = 0x4;
422 static trigger_type_t
const C3 = 0x2;
423 static trigger_type_t
const C4 = 0x1;
433 static trigger_type_t
const TA = 0x80;
434 static trigger_type_t
const TB = 0x40;
435 static trigger_type_t
const TC = 0x20;
436 static trigger_type_t
const TD = 0x10;
437 static trigger_type_t
const TE = 0x08;
438 static trigger_type_t
const TF = 0x04;
439 static trigger_type_t
const TG = 0x02;
440 static trigger_type_t
const TH = 0x01;
442 static trigger_type_t
const bsu_rm_cl = 0x80;
443 static trigger_type_t
const tsu_sl_nu = 0x40;
444 static trigger_type_t
const tsu_su_nl = 0x20;
445 static trigger_type_t
const tsu_el_wu = 0x10;
447 static size_t const size_bytes =
sizeof(uint32_t);
448 static size_t const size_u32 = size_bytes/
sizeof(uint32_t);
452 static size_t const ptb_offset_u32 = 2;
453 static size_t const ptb_offset_bytes = ptb_offset_u32*
sizeof(uint32_t);
456 static size_t const payload_offset_u32 = 1+ptb_offset_u32;
457 static size_t const payload_offset_bytes = payload_offset_u32*
sizeof(uint32_t);
464 return ((trigger_type & muon) != 0x0);
467 return ((trigger_type & external) != 0x0);
470 return ((trigger_type & calibration) != 0x0);
476 return ((trigger_id_ext & t) != 0x0);
480 return ((trigger_id_ext & ssp) != 0x0);
483 return ((trigger_id_ext & I09) != 0x0);
486 return ((trigger_id_ext & I10) != 0x0);
489 return ((trigger_id_ext & I12) != 0x0);
497 return ((trigger_id_calib & t) != 0x0);
501 return ((trigger_id_calib & C1) != 0);
504 return ((trigger_id_calib & C2) != 0);
507 return ((trigger_id_calib & C3) != 0);
510 return ((trigger_id_calib & C4) != 0);
516 return ((trigger_id_muon & t) != 0x0);
520 return ((trigger_id_muon & TA) != 0);
523 return ((trigger_id_muon & TB) != 0);
526 return ((trigger_id_muon & TC) != 0);
529 return ((trigger_id_muon & TD) != 0);
532 return ((trigger_id_muon & TE) != 0);
535 return ((trigger_id_muon & TF) != 0);
538 return ((trigger_id_muon & TG) != 0);
541 return ((trigger_id_muon & TH) != 0);
547 return ((trigger_id_muon & bsu_rm_cl) != 0);
550 return ((trigger_id_muon & tsu_sl_nu) != 0);
553 return ((trigger_id_muon & tsu_su_nl) != 0);
556 return ((trigger_id_muon & tsu_el_wu) != 0);
565 switch (trigger_type) {
567 return "calibration";
586 timestamp_t nova_timestamp : 64;
588 static data_size_t
const num_bits_timestamp = 64;
589 static size_t const size_bytes =
sizeof(uint64_t);
590 static size_t const size_u32 = size_bytes/
sizeof(uint32_t);
592 static size_t const ptb_offset_u32 = 1;
593 static size_t const ptb_offset_bytes = ptb_offset_u32*
sizeof(uint32_t);
596 static size_t const payload_offset_u32 = 1+ptb_offset_u32;
597 static size_t const payload_offset_bytes = payload_offset_u32*
sizeof(uint32_t);
656 sample_count_t
sampleCount(sample_count_t &n_counter_words, sample_count_t &n_trigger_words,
657 sample_count_t &n_timestamp_words,
658 sample_count_t &n_selftest_words, sample_count_t &n_checksum_words,
659 bool swap_payload_header_bytes,
size_t override_uslice_size = 0)
const;
666 uint8_t*
sampleTimeSplit(uint64_t boundary_time,
size_t& remaining_size,
bool swap_payload_header_bytes,
667 size_t override_uslice_size = 0)
const;
678 sample_count_t &n_words_b, sample_count_t &n_counter_words_b,
679 sample_count_t &n_trigger_words_b,
680 sample_count_t &n_timestamp_words_b, sample_count_t &n_selftest_words_b,
681 sample_count_t &n_checksum_words_b,
682 sample_count_t &n_words_a, sample_count_t &n_counter_words_a,
683 sample_count_t &n_trigger_words_a,
684 sample_count_t &n_timestamp_words_a, sample_count_t &n_selftest_words_a,
685 sample_count_t &n_checksum_words_a,
686 bool swap_payload_header_bytes,
687 size_t override_uslice_size = 0)
const;
692 uint64_t overlap_time,
size_t& overlap_size, uint8_t*& overlap_data_ptr,
693 sample_count_t &n_words_b, sample_count_t &n_counter_words_b,
694 sample_count_t &n_trigger_words_b,
695 sample_count_t &n_timestamp_words_b, sample_count_t &n_selftest_words_b,
696 sample_count_t &n_checksum_words_b,
697 sample_count_t &n_words_a, sample_count_t &n_counter_words_a,
698 sample_count_t &n_trigger_words_a,
699 sample_count_t &n_timestamp_words_a, sample_count_t &n_selftest_words_a,
700 sample_count_t &n_checksum_words_a,
701 sample_count_t &n_words_o, sample_count_t &n_counter_words_o,
702 sample_count_t &n_trigger_words_o,
703 sample_count_t &n_timestamp_words_o, sample_count_t &n_selftest_words_o,
704 sample_count_t &n_checksum_words_o,
706 bool swap_payload_header_bytes,
size_t override_uslice_size = 0)
const;
721 mask = (1 << param) - 1;
725 uint32_t*
raw()
const;
733 uint32_t
const*
data_()
const;
static microslice_size_t const payload_size_trigger
static uint64_t getMask(int param)
bool has_external_trigger()
static microslice_size_t const payload_size_timestamp
static const Warning_Word::warning_type_t WarnFIFOHalfFull
bool get_tsu_nu(uint32_t idx)
bool get_bsu_cu(uint32_t idx)
bool has_muon_tsu_sl_nu()
static const Payload_Header::data_packet_type_t DataTypeWarning
bool has_calibration(trigger_type_t t)
bool has_muon_tsu_el_wu()
static microslice_size_t const payload_size_checksum
Counter payload description.
uint8_t * get_payload(uint32_t word_id, Payload_Header::data_packet_type_t &data_packet_type, Payload_Header::short_nova_timestamp_t &short_nova_timestamp, size_t &size, bool swap_payload_header_bytes, size_t override_uslice_size=0) const
static const uint64_t ROLLOVER_HIGH_VALUE
bool get_counter_status(uint32_t idx) const
bool get_tsu_el(uint32_t idx)
static const Payload_Header::data_packet_type_t DataTypeTimestamp
sample_count_t sampleCount(sample_count_t &n_counter_words, sample_count_t &n_trigger_words, sample_count_t &n_timestamp_words, sample_count_t &n_selftest_words, sample_count_t &n_checksum_words, bool swap_payload_header_bytes, size_t override_uslice_size=0) const
bool get_bsu_rl(uint32_t idx)
counter_set_t get_bsu_cl()
static microslice_size_t const payload_size_counter
bool has_muon_tsu_su_nl()
bool get_tsu_extra(uint32_t idx)
Header const * header_() const
bool has_external_trigger(trigger_type_t t)
bool has_muon_trigger(trigger_type_t t)
uint8_t * current_payload_
static const Warning_Word::warning_type_t WarnUnknownDataType
PennMicroSlice(uint8_t *address)
Header::block_size_t microslice_size_t
dune::PennMicroSlice::microslice_size_t size() const
static const Payload_Header::data_packet_type_t DataTypeChecksum
bool get_tsu_sl(uint32_t idx)
bool get_bsu_rm(uint32_t idx)
uint32_t current_word_id_
uint8_t * sampleTimeSplitAndCountTwice(uint64_t boundary_time, size_t &remaining_size, uint64_t overlap_time, size_t &overlap_size, uint8_t *&overlap_data_ptr, sample_count_t &n_words_b, sample_count_t &n_counter_words_b, sample_count_t &n_trigger_words_b, sample_count_t &n_timestamp_words_b, sample_count_t &n_selftest_words_b, sample_count_t &n_checksum_words_b, sample_count_t &n_words_a, sample_count_t &n_counter_words_a, sample_count_t &n_trigger_words_a, sample_count_t &n_timestamp_words_a, sample_count_t &n_selftest_words_a, sample_count_t &n_checksum_words_a, sample_count_t &n_words_o, sample_count_t &n_counter_words_o, sample_count_t &n_trigger_words_o, sample_count_t &n_timestamp_words_o, sample_count_t &n_selftest_words_o, sample_count_t &n_checksum_words_o, uint32_t &checksum, bool swap_payload_header_bytes, size_t override_uslice_size=0) const
static const Payload_Header::data_packet_type_t DataTypeTrigger
bool get_tsu_wu(uint32_t idx)
static data_size_t get_counter_type(uint32_t bit_idx)
bool get_bsu_cl(uint32_t idx)
static std::string getTriggerTypeName(trigger_type_t trigger_type)
bool get_tsu_su(uint32_t idx)
bool get_tsu_nl(uint32_t idx)
uint32_t const * data_() const
static const Warning_Word::warning_type_t WarnTimeout
bool has_muon_bsu_rm_cl()
static uint32_t get_counter_type_pos(uint32_t bit_idx)
static const Warning_Word::warning_type_t WarnFIFOFull
uint8_t * get_next_payload(uint32_t &word_id, Payload_Header::data_packet_type_t &data_packet_type, Payload_Header::short_nova_timestamp_t &short_nova_timestamp, size_t &size, bool swap_payload_header_bytes, size_t override_uslice_size=0)
static const uint32_t ROLLOVER_LOW_VALUE
static microslice_size_t const payload_size_warning
static const Payload_Header::data_packet_type_t DataTypeCounter
uint8_t data_packet_type_t
uint8_t * sampleTimeSplit(uint64_t boundary_time, size_t &remaining_size, bool swap_payload_header_bytes, size_t override_uslice_size=0) const
uint8_t * sampleTimeSplitAndCount(uint64_t boundary_time, size_t &remaining_size, sample_count_t &n_words_b, sample_count_t &n_counter_words_b, sample_count_t &n_trigger_words_b, sample_count_t &n_timestamp_words_b, sample_count_t &n_selftest_words_b, sample_count_t &n_checksum_words_b, sample_count_t &n_words_a, sample_count_t &n_counter_words_a, sample_count_t &n_trigger_words_a, sample_count_t &n_timestamp_words_a, sample_count_t &n_selftest_words_a, sample_count_t &n_checksum_words_a, bool swap_payload_header_bytes, size_t override_uslice_size=0) const