LDMX Software
Public Member Functions | Private Attributes | List of all members
packing::rawdatafile::EventPacket Class Reference

Event Packet structure. More...

#include <EventPacket.h>

Public Member Functions

 EventPacket ()=default
 default constructor for reading
 
 EventPacket (uint32_t id, const std::map< uint16_t, std::vector< uint32_t > > &unwrapped_subsys_data)
 define event id for reading
 
std::vector< uint32_t > header () const
 Get the header words.
 
std::vector< uint32_t > tail () const
 Get the tail words.
 
const uint32_t & id () const
 
std::vector< SubsystemPacket > & data ()
 
utility::Readerread (utility::Reader &r)
 read the event packet from the input reader
 
utility::Writerwrite (utility::Writer &w) const
 write the event packet to the input writer
 
utility::CRCadd (utility::CRC &c) const
 add the event packet to the input crc
 

Private Attributes

uint32_t id_
 
uint16_t event_length_in_words_
 
std::vector< SubsystemPacketsubsys_data_
 
bool crc_ok_
 
uint32_t crc_
 

Detailed Description

Event Packet structure.

Definition at line 17 of file EventPacket.h.

Constructor & Destructor Documentation

◆ EventPacket()

packing::rawdatafile::EventPacket::EventPacket ( uint32_t  id,
const std::map< uint16_t, std::vector< uint32_t > > &  unwrapped_subsys_data 
)

define event id for reading

Definition at line 9 of file EventPacket.cxx.

12 : id_{id}, event_length_in_words_{0} {
13 crc_ok_ = true;
14
15 utility::CRC crc;
16
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();
20 crc << subsys;
21 event_length_in_words_ +=
22 subsys.header().size() + subsys.data().size() + subsys.tail().size();
23 }
24
25 crc_ = crc.get();
26}

References packing::utility::CRC::get().

Member Function Documentation

◆ add()

utility::CRC & packing::rawdatafile::EventPacket::add ( utility::CRC c) const

add the event packet to the input crc

Definition at line 59 of file EventPacket.cxx.

59 {
60 std::vector<uint32_t> h{header()}, t{tail()};
61 c << h << subsys_data_ << t;
62 return c;
63}
std::vector< uint32_t > header() const
Get the header words.
std::vector< uint32_t > tail() const
Get the tail words.

References header(), and tail().

◆ data()

std::vector< SubsystemPacket > & packing::rawdatafile::EventPacket::data ( )
inline

Definition at line 34 of file EventPacket.h.

34{ return subsys_data_; }

◆ header()

std::vector< uint32_t > packing::rawdatafile::EventPacket::header ( ) const

Get the header words.

Definition at line 28 of file EventPacket.cxx.

28 {
29 uint32_t word = ((subsys_data_.size() & utility::mask<16>) << 16) +
30 ((event_length_in_words_ & utility::mask<15>) << 1) + crc_ok_;
31 return {id_, word};
32}

Referenced by add(), and write().

◆ id()

const uint32_t & packing::rawdatafile::EventPacket::id ( ) const
inline

Definition at line 33 of file EventPacket.h.

33{ return id_; }

◆ read()

utility::Reader & packing::rawdatafile::EventPacket::read ( utility::Reader r)

read the event packet from the input reader

Definition at line 36 of file EventPacket.cxx.

36 {
37 r >> id_;
38
39 uint32_t word;
40 r >> word;
41
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>;
45
46 r.read(subsys_data_, num_subsys);
47
48 r >> crc_;
49
50 return r;
51}

References packing::utility::Reader::read().

◆ tail()

std::vector< uint32_t > packing::rawdatafile::EventPacket::tail ( ) const

Get the tail words.

Definition at line 34 of file EventPacket.cxx.

34{ return {crc_}; }

Referenced by add(), and write().

◆ write()

utility::Writer & packing::rawdatafile::EventPacket::write ( utility::Writer w) const

write the event packet to the input writer

Definition at line 53 of file EventPacket.cxx.

53 {
54 std::vector<uint32_t> h{header()}, t{tail()};
55 w << h << subsys_data_ << t;
56 return w;
57}

References header(), and tail().

Member Data Documentation

◆ crc_

uint32_t packing::rawdatafile::EventPacket::crc_
private

Definition at line 55 of file EventPacket.h.

◆ crc_ok_

bool packing::rawdatafile::EventPacket::crc_ok_
private

Definition at line 54 of file EventPacket.h.

◆ event_length_in_words_

uint16_t packing::rawdatafile::EventPacket::event_length_in_words_
private

Definition at line 52 of file EventPacket.h.

◆ id_

uint32_t packing::rawdatafile::EventPacket::id_
private

Definition at line 51 of file EventPacket.h.

◆ subsys_data_

std::vector<SubsystemPacket> packing::rawdatafile::EventPacket::subsys_data_
private

Definition at line 53 of file EventPacket.h.


The documentation for this class was generated from the following files: