DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fddetdataformats
include
fddetdataformats
DAPHNEEthFrame.hpp
Go to the documentation of this file.
1
13
14
#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
15
#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
16
17
#include "
fddetdataformats/FrameConcepts.hpp
"
18
#include "
fddetdataformats/Utils.hpp
"
19
20
#include "
detdataformats/DAQEthHeader.hpp
"
21
22
#include <algorithm>
// For std::min
23
#include <cassert>
// For assert()
24
#include <cstdint>
// For uint32_t etc
25
#include <cstdio>
26
#include <cstdlib>
27
#include <limits>
28
#include <tuple>
29
#include <stdexcept>
// For std::out_of_range
30
31
namespace
dunedaq::fddetdataformats
{
32
33
// NOLINTBEGIN(build/unsigned)
34
41
struct
DAPHNEEthFrame
42
{
43
// The definition of the format is in terms of 64-bit words
44
using
word_t
= uint64_t;
45
46
// Dataframe format version
47
static
constexpr
uint8_t
version
= 1;
48
49
static
constexpr
int
s_bits_per_adc
= 14;
50
static
constexpr
int
s_bits_per_word
= 8 *
sizeof
(
word_t
);
51
static
constexpr
int
s_num_adcs
= 1024;
52
static
constexpr
int
s_num_adc_words
=
s_num_adcs
*
s_bits_per_adc
/
s_bits_per_word
;
53
54
struct
Header
55
{
56
static
constexpr
size_t
s_expected_bytes
{ 7 *
sizeof
(
word_t
) };
57
58
// The following bitfields constitute what could be considered "word_t w0;"
59
word_t
trigger_sample_value
: 14;
60
word_t
rsv_0
: 2;
61
word_t
threshold
: 14;
62
word_t
rsv_1
: 2;
63
word_t
baseline
: 14;
64
word_t
rsv_2
: 6;
65
word_t
version
: 4;
66
word_t
channel
: 8;
67
68
word_t
w1
;
69
word_t
w2
;
70
word_t
w3
;
71
word_t
w4
;
72
word_t
w5
;
73
word_t
w6
;
74
};
75
static_assert
(
sizeof
(
Header
) ==
Header::s_expected_bytes
);
76
77
static
constexpr
size_t
s_expected_bytes
=
sizeof
(
detdataformats::DAQEthHeader
) +
Header::s_expected_bytes
+
s_num_adc_words
*
sizeof
(
word_t
);
78
86
uint16_t
get_adc
(
int
i)
const
;
// NOLINT
87
89
void
set_adc
(
int
i, uint16_t val);
// NOLINT
90
92
uint64_t
get_timestamp
()
const
{
return
daq_header
.get_timestamp(); }
93
95
void
set_timestamp
(
const
uint64_t new_timestamp) {
daq_header
.timestamp = new_timestamp; }
96
98
uint8_t
get_channel
()
const
{
return
header
.channel; }
99
101
void
set_channel
(
const
uint8_t new_channel) {
header
.channel = new_channel; }
102
103
bool
operator<
(
const
DAPHNEEthFrame
& other)
const
{
104
return
std::tuple(this->
get_timestamp
(), this->
get_channel
()) < std::tuple(other.
get_timestamp
(), other.
get_channel
());
105
}
106
107
detdataformats::DAQEthHeader
daq_header
;
108
Header
header
;
109
word_t
adc_words
[
s_num_adc_words
];
// NOLINT
110
};
111
112
static_assert
(std::endian::native == std::endian::little,
113
"The DAPHNEEthFrame bitfield layout assumes little-endian architecture"
);
114
115
static_assert
(
AdaptableFrameConcept<DAPHNEEthFrame>
,
"DAPHNEEthFrame does not satisfy the AdaptableFrameConcept"
);
116
117
}
// namespace dunedaq::fddetdataformats
118
119
#include "
detail/DAPHNEEthFrame.hxx
"
120
121
// NOLINTEND(build/unsigned)
122
123
#endif
// FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_DAPHNEETHFRAME_HPP_
DAPHNEEthFrame.hxx
DAQEthHeader.hpp
FrameConcepts.hpp
dunedaq::fddetdataformats::AdaptableFrameConcept
Definition
FrameConcepts.hpp:96
Utils.hpp
dunedaq::fddetdataformats
Definition
CRTBernFrame.hpp:29
dunedaq::detdataformats::DAQEthHeader
DAQEthHeader is a versioned and unified structure for every FE electronics.
Definition
DAQEthHeader.hpp:23
dunedaq::fddetdataformats::DAPHNEEthFrame::Header
Definition
DAPHNEEthFrame.hpp:55
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::s_expected_bytes
static constexpr size_t s_expected_bytes
Definition
DAPHNEEthFrame.hpp:56
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::rsv_0
word_t rsv_0
Definition
DAPHNEEthFrame.hpp:60
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::version
word_t version
Definition
DAPHNEEthFrame.hpp:65
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w3
word_t w3
Definition
DAPHNEEthFrame.hpp:70
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::rsv_2
word_t rsv_2
Definition
DAPHNEEthFrame.hpp:64
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::trigger_sample_value
word_t trigger_sample_value
Definition
DAPHNEEthFrame.hpp:59
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w6
word_t w6
Definition
DAPHNEEthFrame.hpp:73
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::baseline
word_t baseline
Definition
DAPHNEEthFrame.hpp:63
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::threshold
word_t threshold
Definition
DAPHNEEthFrame.hpp:61
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w1
word_t w1
Definition
DAPHNEEthFrame.hpp:68
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w5
word_t w5
Definition
DAPHNEEthFrame.hpp:72
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::rsv_1
word_t rsv_1
Definition
DAPHNEEthFrame.hpp:62
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::channel
word_t channel
Definition
DAPHNEEthFrame.hpp:66
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w2
word_t w2
Definition
DAPHNEEthFrame.hpp:69
dunedaq::fddetdataformats::DAPHNEEthFrame::Header::w4
word_t w4
Definition
DAPHNEEthFrame.hpp:71
dunedaq::fddetdataformats::DAPHNEEthFrame
Struct for accessing raw DAPHNE eth frames.
Definition
DAPHNEEthFrame.hpp:42
dunedaq::fddetdataformats::DAPHNEEthFrame::s_expected_bytes
static constexpr size_t s_expected_bytes
Definition
DAPHNEEthFrame.hpp:77
dunedaq::fddetdataformats::DAPHNEEthFrame::set_adc
void set_adc(int i, uint16_t val)
Set the ith ADC value in the frame to val.
Definition
DAPHNEEthFrame.hxx:17
dunedaq::fddetdataformats::DAPHNEEthFrame::s_num_adcs
static constexpr int s_num_adcs
Definition
DAPHNEEthFrame.hpp:51
dunedaq::fddetdataformats::DAPHNEEthFrame::s_bits_per_word
static constexpr int s_bits_per_word
Definition
DAPHNEEthFrame.hpp:50
dunedaq::fddetdataformats::DAPHNEEthFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
DAPHNEEthFrame.hpp:95
dunedaq::fddetdataformats::DAPHNEEthFrame::adc_words
word_t adc_words[s_num_adc_words]
Definition
DAPHNEEthFrame.hpp:109
dunedaq::fddetdataformats::DAPHNEEthFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
DAPHNEEthFrame.hpp:92
dunedaq::fddetdataformats::DAPHNEEthFrame::operator<
bool operator<(const DAPHNEEthFrame &other) const
Definition
DAPHNEEthFrame.hpp:103
dunedaq::fddetdataformats::DAPHNEEthFrame::set_channel
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
Definition
DAPHNEEthFrame.hpp:101
dunedaq::fddetdataformats::DAPHNEEthFrame::header
Header header
Definition
DAPHNEEthFrame.hpp:108
dunedaq::fddetdataformats::DAPHNEEthFrame::s_num_adc_words
static constexpr int s_num_adc_words
Definition
DAPHNEEthFrame.hpp:52
dunedaq::fddetdataformats::DAPHNEEthFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
DAPHNEEthFrame.hpp:107
dunedaq::fddetdataformats::DAPHNEEthFrame::s_bits_per_adc
static constexpr int s_bits_per_adc
Definition
DAPHNEEthFrame.hpp:49
dunedaq::fddetdataformats::DAPHNEEthFrame::get_channel
uint8_t get_channel() const
Get the channel identifier of the frame.
Definition
DAPHNEEthFrame.hpp:98
dunedaq::fddetdataformats::DAPHNEEthFrame::version
static constexpr uint8_t version
Definition
DAPHNEEthFrame.hpp:47
dunedaq::fddetdataformats::DAPHNEEthFrame::word_t
uint64_t word_t
Definition
DAPHNEEthFrame.hpp:44
dunedaq::fddetdataformats::DAPHNEEthFrame::get_adc
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.
Definition
DAPHNEEthFrame.hxx:5
Generated on
for DUNE-DAQ by
1.17.0