LDMX Software
Packing
src
Packing
DAQSampleHeader.cxx
1
#include "Packing/DAQSampleHeader.h"
2
3
#include "Packing/Utility/Mask.h"
4
5
using
packing::utility::MASK;
6
7
namespace
packing {
8
9
void
DAQSampleHeader::from
(uint32_t word) {
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
}
16
17
uint32_t
DAQSampleHeader::to
()
const
{
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
}
22
23
bool
DAQSampleHeader::isValid
(uint32_t word) {
24
DAQSampleHeader
h;
25
h.
from
(word);
26
return
h.
version_
==
VERSION
and not h.
isEndingTrailer
() and
27
((word >> 9) & MASK<3>) == 0;
28
}
29
30
bool
DAQSampleHeader::isEndingTrailer
()
const
{
31
return
((
i_l1a_
== 0x1f) and (
econd_id_
== 0x3ff));
32
}
33
34
uint32_t
DAQSampleHeader::trailerNumSamples
(uint32_t word) {
35
return
(word & MASK<5>);
36
}
37
38
uint32_t
DAQSampleHeader::endingTrailer
(uint32_t n_samples) {
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
}
46
47
std::ostream& operator<<(std::ostream& o,
const
DAQSampleHeader
& h) {
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
}
53
54
}
// namespace packing
packing::DAQSampleHeader
The capture header that the DAQ firmware inserts before each ECON-D event packet (one per sample) and...
Definition
DAQSampleHeader.h:31
packing::DAQSampleHeader::version_
uint32_t version_
format version
Definition
DAQSampleHeader.h:33
packing::DAQSampleHeader::is_soi_
bool is_soi_
is this the sample of interest?
Definition
DAQSampleHeader.h:39
packing::DAQSampleHeader::isEndingTrailer
bool isEndingTrailer() const
A special form of this DAQ header is used to signal the end of a multi-sample sequence.
Definition
DAQSampleHeader.cxx:30
packing::DAQSampleHeader::i_l1a_
uint32_t i_l1a_
index of this sample within the event
Definition
DAQSampleHeader.h:37
packing::DAQSampleHeader::from
void from(uint32_t word)
decode a DAQSampleHeader from the input word
Definition
DAQSampleHeader.cxx:9
packing::DAQSampleHeader::endingTrailer
static uint32_t endingTrailer(uint32_t n_samples=0)
construct the special trailer form of this header
Definition
DAQSampleHeader.cxx:38
packing::DAQSampleHeader::econd_id_
uint32_t econd_id_
configured ID of the ECON
Definition
DAQSampleHeader.h:35
packing::DAQSampleHeader::VERSION
static const uint32_t VERSION
expected format version
Definition
DAQSampleHeader.h:44
packing::DAQSampleHeader::to
uint32_t to() const
construct a header word from our data
Definition
DAQSampleHeader.cxx:17
packing::DAQSampleHeader::econd_len_
uint32_t econd_len_
length of the ECON-D packet following this header in 32b words
Definition
DAQSampleHeader.h:41
packing::DAQSampleHeader::isValid
static bool isValid(uint32_t word)
check if the decoded word looks like a capture header
Definition
DAQSampleHeader.cxx:23
packing::DAQSampleHeader::trailerNumSamples
static uint32_t trailerNumSamples(uint32_t word)
number of samples written in the ending trailer
Definition
DAQSampleHeader.cxx:34
Generated by
1.12.0