2#include "Packing/RawDataFile/EventPacket.h"
4#include "Packing/Utility/Mask.h"
11 const std::map<uint16_t, std::vector<uint32_t>>& unwrapped_subsys_data)
12 : id_{id}, event_length_in_words_{0} {
17 for (
auto const& [subsys_id, subsys_data] : unwrapped_subsys_data) {
18 subsys_data_.emplace_back(id_, subsys_id, subsys_data);
19 auto& subsys = subsys_data_.back();
21 event_length_in_words_ +=
22 subsys.header().size() + subsys.data().size() + subsys.tail().size();
29 uint32_t word = ((subsys_data_.size() & utility::mask<16>) << 16) +
30 ((event_length_in_words_ & utility::mask<15>) << 1) + crc_ok_;
42 uint16_t num_subsys = (word >> 16) & utility::mask<16>;
43 event_length_in_words_ = (word >> 1) & utility::mask<15>;
44 crc_ok_ = word & utility::mask<1>;
46 r.
read(subsys_data_, num_subsys);
55 w << h << subsys_data_ << t;
61 c << h << subsys_data_ << t;
EventPacket()=default
default constructor for reading
std::vector< uint32_t > header() const
Get the header words.
utility::CRC & add(utility::CRC &c) const
add the event packet to the input crc
std::vector< uint32_t > tail() const
Get the tail words.
utility::Reader & read(utility::Reader &r)
read the event packet from the input reader
utility::Writer & write(utility::Writer &w) const
write the event packet to the input writer
The HGC ROC and FPGA use a CRC checksum to double check that the data transfer has been done correctl...
uint32_t get()
Get the calculate checksum from the calculator.
Reader & read(WordType *w, std::size_t count)
Read the next 'count' words into the input handle.