LDMX Software
packing::DAQSampleHeader Struct Reference

The capture header that the DAQ firmware inserts before each ECON-D event packet (one per sample) and the trailer word that it appends after the last sample of an event. More...

#include <DAQSampleHeader.h>

Public Member Functions

void from (uint32_t word)
 decode a DAQSampleHeader from the input word
 
uint32_t to () const
 construct a header word from our data
 
bool isEndingTrailer () const
 A special form of this DAQ header is used to signal the end of a multi-sample sequence.
 

Static Public Member Functions

static bool isValid (uint32_t word)
 check if the decoded word looks like a capture header
 
static uint32_t trailerNumSamples (uint32_t word)
 number of samples written in the ending trailer
 
static uint32_t endingTrailer (uint32_t n_samples=0)
 construct the special trailer form of this header
 

Public Attributes

uint32_t version_ {0}
 format version
 
uint32_t econd_id_ {0}
 configured ID of the ECON
 
uint32_t i_l1a_ {0}
 index of this sample within the event
 
bool is_soi_ {false}
 is this the sample of interest?
 
uint32_t econd_len_ {0}
 length of the ECON-D packet following this header in 32b words
 

Static Public Attributes

static const uint32_t VERSION {1}
 expected format version
 

Friends

std::ostream & operator<< (std::ostream &o, const DAQSampleHeader &h)
 output stream operator to make logging easier
 

Detailed Description

The capture header that the DAQ firmware inserts before each ECON-D event packet (one per sample) and the trailer word that it appends after the last sample of an event.

Header:

4b vers | 10b ECON ID | 5b i_l1a | S | 12b length
  • vers is the format version (1)
  • ECON ID is what it was configured in the software to be
  • i_l1a is the index of the sample relative to this event
  • S signals if this is the sample of interest (1) or not (0)
  • length is the length of the ECON-D event packet in 32b words NOT including this header (= ECON-D payload length + 2)

Trailer:

4b vers | 10b 0x3ff | 5b 0x1f | 0 | last | 6b 0 | 5b n_samples
Note
Ported from pflib::packing::DAQSampleHeader.

Definition at line 31 of file DAQSampleHeader.h.

Member Function Documentation

◆ endingTrailer()

uint32_t packing::DAQSampleHeader::endingTrailer ( uint32_t n_samples = 0)
static

construct the special trailer form of this header

Definition at line 38 of file DAQSampleHeader.cxx.

38 {
39 DAQSampleHeader h{.version_ = VERSION,
40 .econd_id_ = 0x3ff,
41 .i_l1a_ = 0x1f,
42 .is_soi_ = false,
43 .econd_len_ = 0};
44 return h.to() | (1u << 11) | (n_samples & MASK<5>);
45}
static const uint32_t VERSION
expected format version

References to(), and VERSION.

◆ from()

void packing::DAQSampleHeader::from ( uint32_t word)

decode a DAQSampleHeader from the input word

Definition at line 9 of file DAQSampleHeader.cxx.

9 {
10 version_ = ((word >> 28) & MASK<4>);
11 econd_id_ = ((word >> 18) & MASK<10>);
12 i_l1a_ = ((word >> 13) & MASK<5>);
13 is_soi_ = (((word >> 12) & MASK<1>) == 1);
14 econd_len_ = (word & MASK<12>);
15}
uint32_t version_
format version
bool is_soi_
is this the sample of interest?
uint32_t i_l1a_
index of this sample within the event
uint32_t econd_id_
configured ID of the ECON
uint32_t econd_len_
length of the ECON-D packet following this header in 32b words

References econd_id_, econd_len_, i_l1a_, is_soi_, and version_.

Referenced by packing::MultiSampleECONDEventPacket::from(), isValid(), and packing::MultiSampleECONDEventPacket::resync().

◆ isEndingTrailer()

bool packing::DAQSampleHeader::isEndingTrailer ( ) const

A special form of this DAQ header is used to signal the end of a multi-sample sequence.

Both i_l1a and econd_id are set to their maximum values.

Definition at line 30 of file DAQSampleHeader.cxx.

30 {
31 return ((i_l1a_ == 0x1f) and (econd_id_ == 0x3ff));
32}

References econd_id_, and i_l1a_.

Referenced by packing::MultiSampleECONDEventPacket::from(), isValid(), and packing::MultiSampleECONDEventPacket::resync().

◆ isValid()

bool packing::DAQSampleHeader::isValid ( uint32_t word)
static

check if the decoded word looks like a capture header

The version must be the expected one and the three bits between the S flag and the 9-bit length must be zero. The trailer does not pass this check.

Definition at line 23 of file DAQSampleHeader.cxx.

23 {
24 DAQSampleHeader h;
25 h.from(word);
26 return h.version_ == VERSION and not h.isEndingTrailer() and
27 ((word >> 9) & MASK<3>) == 0;
28}

References from(), isEndingTrailer(), VERSION, and version_.

Referenced by packing::MultiSampleECONDEventPacket::from(), and packing::MultiSampleECONDEventPacket::resync().

◆ to()

uint32_t packing::DAQSampleHeader::to ( ) const

construct a header word from our data

Definition at line 17 of file DAQSampleHeader.cxx.

17 {
18 return (((version_ & MASK<4>) << 28) | ((econd_id_ & MASK<10>) << 18) |
19 ((i_l1a_ & MASK<5>) << 13) | ((is_soi_ ? 1 : 0) << 12) |
20 (econd_len_ & MASK<12>));
21}

References econd_id_, econd_len_, i_l1a_, is_soi_, and version_.

Referenced by endingTrailer().

◆ trailerNumSamples()

uint32_t packing::DAQSampleHeader::trailerNumSamples ( uint32_t word)
static

number of samples written in the ending trailer

Definition at line 34 of file DAQSampleHeader.cxx.

34 {
35 return (word & MASK<5>);
36}

Referenced by packing::MultiSampleECONDEventPacket::from().

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & o,
const DAQSampleHeader & h )
friend

output stream operator to make logging easier

Definition at line 47 of file DAQSampleHeader.cxx.

47 {
48 return (o << "DAQSampleHeader { " << "version: " << h.version_ << ", "
49 << "econd_id: " << h.econd_id_ << ", " << "i_l1a: " << h.i_l1a_
50 << ", " << "is_soi: " << h.is_soi_ << ", "
51 << "econd_len: " << h.econd_len_ << " }");
52}

Member Data Documentation

◆ econd_id_

uint32_t packing::DAQSampleHeader::econd_id_ {0}

configured ID of the ECON

Definition at line 35 of file DAQSampleHeader.h.

35{0};

Referenced by from(), packing::MultiSampleECONDEventPacket::from(), isEndingTrailer(), packing::MultiSampleECONDEventPacket::resync(), and to().

◆ econd_len_

uint32_t packing::DAQSampleHeader::econd_len_ {0}

length of the ECON-D packet following this header in 32b words

Definition at line 41 of file DAQSampleHeader.h.

41{0};

Referenced by from(), packing::MultiSampleECONDEventPacket::from(), and to().

◆ i_l1a_

uint32_t packing::DAQSampleHeader::i_l1a_ {0}

index of this sample within the event

Definition at line 37 of file DAQSampleHeader.h.

37{0};

Referenced by from(), packing::MultiSampleECONDEventPacket::from(), isEndingTrailer(), packing::MultiSampleECONDEventPacket::resync(), and to().

◆ is_soi_

bool packing::DAQSampleHeader::is_soi_ {false}

is this the sample of interest?

Definition at line 39 of file DAQSampleHeader.h.

39{false};

Referenced by from(), packing::MultiSampleECONDEventPacket::from(), and to().

◆ VERSION

const uint32_t packing::DAQSampleHeader::VERSION {1}
static

◆ version_

uint32_t packing::DAQSampleHeader::version_ {0}

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