1 #ifndef artdaq_ots_Overlays_UDPFragment_hh
2 #define artdaq_ots_Overlays_UDPFragment_hh
4 #include "artdaq-core/Data/Fragment.hh"
5 #include "cetlib_except/exception.h"
17 std::ostream& operator<<(std::ostream&, UDPFragment
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),
"UDPFragment::Metadata size changed");
61 typedef uint32_t data_t;
63 typedef uint32_t event_size_t;
64 typedef uint32_t data_type_t;
66 event_size_t event_size : 28;
67 event_size_t type : 4;
69 static size_t const size_words = 1ul;
72 static_assert(
sizeof(
Header) == Header::size_words *
sizeof(Header::data_t),
"UDPFragment::Header size changed");
77 UDPFragment(artdaq::Fragment
const& f) : artdaq_Fragment_(f) {}
81 Header::event_size_t hdr_event_size()
const {
return header_()->event_size; }
82 Header::data_type_t hdr_data_type()
const {
return header_()->type; }
83 static constexpr
size_t hdr_size_words() {
return Header::size_words; }
86 size_t udp_data_words()
const {
return (hdr_event_size() - hdr_size_words()) * bytes_per_word_(); }
89 uint8_t
const* dataBegin()
const {
return reinterpret_cast<uint8_t const*
>(header_() + 1); }
92 uint8_t
const* dataEnd()
const {
return dataBegin() + udp_data_words(); }
99 static constexpr
size_t bytes_per_word_() {
return sizeof(Header::data_t) /
sizeof(uint8_t); }
105 Header
const* header_()
const {
return reinterpret_cast<UDPFragment::Header const*
>(artdaq_Fragment_.dataBeginBytes()); }
108 artdaq::Fragment
const& artdaq_Fragment_;