1 #ifndef artdaq_ots_Overlays_STIBFragment_hh
2 #define artdaq_ots_Overlays_STIBFragment_hh
4 #include "artdaq-core/Data/Fragment.hh"
5 #include "cetlib/exception.h"
17 std::ostream& operator<<(std::ostream&, STIBFragment
const&);
33 typedef uint64_t data_t;
39 static size_t const size_words = 1ull;
42 static_assert(
sizeof(
Metadata) == Metadata::size_words *
sizeof(Metadata::data_t),
43 "STIBFragment::Metadata size changed");
62 typedef uint32_t data_t;
64 typedef uint32_t event_size_t;
65 typedef uint64_t counter_t;
67 event_size_t event_size : 28;
68 event_size_t unused : 4;
70 counter_t bunch_counter : 48;
71 counter_t unused2 : 16;
73 counter_t trigger_counter : 40;
74 counter_t trigger_input0 : 4;
75 counter_t trigger_input1 : 4;
76 counter_t unused3 : 16;
78 static size_t const size_words = 6ul;
81 static_assert(
sizeof(
Header) == Header::size_words *
sizeof(Header::data_t),
82 "STIBFragment::Header size changed");
87 STIBFragment(artdaq::Fragment
const& f) : artdaq_Fragment_(f) {}
91 Header::event_size_t hdr_event_size()
const {
return header_()->event_size; }
92 static constexpr
size_t hdr_size_words() {
return Header::size_words; }
94 Header::counter_t hdr_bunch_counter()
const {
return header_()->bunch_counter; }
95 Header::counter_t hdr_trigger_counter()
const {
return header_()->trigger_counter; }
96 Header::counter_t hdr_trigger_input0()
const {
return header_()->trigger_input0; }
97 Header::counter_t hdr_trigger_input1()
const {
return header_()->trigger_input1; }
100 size_t stib_data_words()
const {
return hdr_event_size() - hdr_size_words(); }
103 uint32_t
const* dataBegin()
const
105 return reinterpret_cast<uint32_t const*
>(header_() + 1);
109 uint32_t
const* dataEnd()
const {
return dataBegin() + stib_data_words(); }
116 static constexpr
size_t bytes_per_word_()
118 return sizeof(Header::data_t) /
sizeof(uint8_t);
125 Header
const* header_()
const
127 return reinterpret_cast<STIBFragment::Header const*
>(
128 artdaq_Fragment_.dataBeginBytes());
132 artdaq::Fragment
const& artdaq_Fragment_;