DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fddetdataformats
include
fddetdataformats
CRTBernFrame.hpp
Go to the documentation of this file.
1
15
#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
16
#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
17
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 <stdexcept>
// For std::out_of_range
28
29
namespace
dunedaq::fddetdataformats
{
30
31
// NOLINTBEGIN(build/unsigned)
32
37
struct
CRTBernFrame
38
{
39
// The definition of the format is in terms of 64-bit words
40
using
word_t
= uint64_t;
// NOLINT
41
42
static
constexpr
int
s_num_channels
= 32;
43
static
constexpr
uint64_t
s_DTS_ticks_per_second
= 62'500'000;
44
static
constexpr
uint64_t
s_ns_per_DTS_tick
= 16;
45
46
struct
CRTBernData
47
{
48
static
constexpr
std::size_t
s_expected_bytes
{ 2 + 2 + 2 + 4 + 4 + 2 *
s_num_channels
+ 4 };
49
50
uint16_t
flags
= 0;
51
uint16_t
lostcpu
= 0;
52
uint16_t
lostfpga
= 0;
53
uint32_t
ts0
= 0;
54
uint32_t
ts1
= 0;
55
uint16_t
adc
[
s_num_channels
] = { 0 };
// NOLINT
56
uint32_t
coinc
= 0;
57
};
58
#warning "CRTBernData has padding inserted"
59
//static_assert(sizeof(CRTBernData) == CRTBernData::s_expected_bytes);
60
61
static
constexpr
std::size_t
s_expected_bytes
{
sizeof
(
detdataformats::DAQEthHeader
) +
sizeof
(uint16_t) +
62
CRTBernData::s_expected_bytes
};
63
65
uint16_t
get_adc
(
int
i_ch)
const
66
{
67
if
(i_ch < 0 || i_ch >=
s_num_channels
)
68
throw
std::out_of_range(
"ADC channel index out of range"
);
69
70
return
data
.adc[i_ch];
71
}
72
74
void
set_adc
(
int
i_ch, uint16_t val)
75
{
76
if
(i_ch < 0 || i_ch >=
s_num_channels
)
77
throw
std::out_of_range(
"ADC channel index out of range"
);
78
79
data
.adc[i_ch] = val;
// NOLINT(cppcoreguidelines-pro-bounds-constant-array-index)
80
}
81
83
uint64_t
get_timestamp
()
const
{
return
daq_header
.get_timestamp(); }
84
88
void
set_timestamp
(
const
uint64_t new_timestamp)
89
{
90
daq_header
.timestamp = new_timestamp;
91
data
.ts0 = (new_timestamp %
s_DTS_ticks_per_second
) *
s_ns_per_DTS_tick
;
92
}
93
94
uint16_t
get_mac5
()
const
{
return
mac5
; }
95
96
void
set_mac5
(
const
uint16_t new_mac5) {
mac5
= new_mac5; }
97
98
uint16_t
get_flags
()
const
{
return
data
.flags; }
99
100
void
set_flags
(
const
uint16_t new_flags) {
data
.flags = new_flags; }
101
103
uint16_t
get_lostcpu
()
const
{
return
data
.lostcpu; }
104
106
void
set_lostcpu
(
const
uint16_t new_lostcpu) {
data
.lostcpu = new_lostcpu; }
107
109
uint16_t
get_lostfpga
()
const
{
return
data
.lostfpga; }
110
112
void
set_lostfpga
(
const
uint16_t new_lostfpga) {
data
.lostfpga = new_lostfpga; }
113
114
uint32_t
get_ts0
()
const
{
return
data
.ts0; }
115
116
void
set_ts0
(
const
uint32_t new_ts0) {
data
.ts0 = new_ts0; }
117
118
uint32_t
get_ts1
()
const
{
return
data
.ts1; }
119
120
void
set_ts1
(
const
uint32_t new_ts1) {
data
.ts1 = new_ts1; }
121
122
uint32_t
get_coinc
()
const
{
return
data
.coinc; }
123
124
void
set_coinc
(
const
uint32_t new_coinc) {
data
.coinc = new_coinc; }
125
126
detdataformats::DAQEthHeader
daq_header
;
// Note this is de-facto public thanks to non-const get_daqheader
127
uint16_t
mac5
;
128
CRTBernData
data
;
129
130
};
// CRTBernFrame
131
#warning "CRTBernFrame has padding inserted"
132
// static_assert(sizeof(CRTBernFrame) == CRTBernFrame::s_expected_bytes)
133
134
static_assert
(std::endian::native == std::endian::little,
135
"The CRTBernFrame bitfield layout assumes little-endian architecture"
);
136
static_assert
(std::is_trivially_copyable_v<CRTBernFrame>,
137
"CRTBernFrame isn't trivially copyable and can't be safely std::memcpy'd"
);
138
static_assert
(std::is_standard_layout_v<CRTBernFrame>,
139
"CRTBernFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it"
);
140
141
}
// namespace dunedaq::fddetdataformats
142
143
// NOLINTEND(build/unsigned)
144
145
#endif
// FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
DAQEthHeader.hpp
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::CRTBernFrame::CRTBernData
Definition
CRTBernFrame.hpp:47
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::lostcpu
uint16_t lostcpu
Definition
CRTBernFrame.hpp:51
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::lostfpga
uint16_t lostfpga
Definition
CRTBernFrame.hpp:52
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::s_expected_bytes
static constexpr std::size_t s_expected_bytes
Definition
CRTBernFrame.hpp:48
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::ts0
uint32_t ts0
Definition
CRTBernFrame.hpp:53
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::adc
uint16_t adc[s_num_channels]
Definition
CRTBernFrame.hpp:55
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::coinc
uint32_t coinc
Definition
CRTBernFrame.hpp:56
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::ts1
uint32_t ts1
Definition
CRTBernFrame.hpp:54
dunedaq::fddetdataformats::CRTBernFrame::CRTBernData::flags
uint16_t flags
Definition
CRTBernFrame.hpp:50
dunedaq::fddetdataformats::CRTBernFrame
Struct for accessing/holding raw CRT data from the 'Bern' panels ProtoDUNE-II VD.
Definition
CRTBernFrame.hpp:38
dunedaq::fddetdataformats::CRTBernFrame::set_mac5
void set_mac5(const uint16_t new_mac5)
Definition
CRTBernFrame.hpp:96
dunedaq::fddetdataformats::CRTBernFrame::get_lostcpu
uint16_t get_lostcpu() const
Get the lostcpu counter of the CRTBernData.
Definition
CRTBernFrame.hpp:103
dunedaq::fddetdataformats::CRTBernFrame::set_adc
void set_adc(int i_ch, uint16_t val)
Set the adc value for channel i_ch to val.
Definition
CRTBernFrame.hpp:74
dunedaq::fddetdataformats::CRTBernFrame::get_mac5
uint16_t get_mac5() const
Definition
CRTBernFrame.hpp:94
dunedaq::fddetdataformats::CRTBernFrame::get_ts1
uint32_t get_ts1() const
Definition
CRTBernFrame.hpp:118
dunedaq::fddetdataformats::CRTBernFrame::get_adc
uint16_t get_adc(int i_ch) const
Get the adc value for channel i_ch.
Definition
CRTBernFrame.hpp:65
dunedaq::fddetdataformats::CRTBernFrame::data
CRTBernData data
Definition
CRTBernFrame.hpp:128
dunedaq::fddetdataformats::CRTBernFrame::s_ns_per_DTS_tick
static constexpr uint64_t s_ns_per_DTS_tick
Definition
CRTBernFrame.hpp:44
dunedaq::fddetdataformats::CRTBernFrame::set_lostcpu
void set_lostcpu(const uint16_t new_lostcpu)
Set the lostcpu counter of the CRTBernData.
Definition
CRTBernFrame.hpp:106
dunedaq::fddetdataformats::CRTBernFrame::set_coinc
void set_coinc(const uint32_t new_coinc)
Definition
CRTBernFrame.hpp:124
dunedaq::fddetdataformats::CRTBernFrame::get_ts0
uint32_t get_ts0() const
Definition
CRTBernFrame.hpp:114
dunedaq::fddetdataformats::CRTBernFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
CRTBernFrame.hpp:83
dunedaq::fddetdataformats::CRTBernFrame::get_coinc
uint32_t get_coinc() const
Definition
CRTBernFrame.hpp:122
dunedaq::fddetdataformats::CRTBernFrame::s_DTS_ticks_per_second
static constexpr uint64_t s_DTS_ticks_per_second
Definition
CRTBernFrame.hpp:43
dunedaq::fddetdataformats::CRTBernFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
CRTBernFrame.hpp:126
dunedaq::fddetdataformats::CRTBernFrame::word_t
uint64_t word_t
Definition
CRTBernFrame.hpp:40
dunedaq::fddetdataformats::CRTBernFrame::mac5
uint16_t mac5
Definition
CRTBernFrame.hpp:127
dunedaq::fddetdataformats::CRTBernFrame::get_lostfpga
uint16_t get_lostfpga() const
Get the lostfpga counter of the CRTBernData.
Definition
CRTBernFrame.hpp:109
dunedaq::fddetdataformats::CRTBernFrame::set_ts1
void set_ts1(const uint32_t new_ts1)
Definition
CRTBernFrame.hpp:120
dunedaq::fddetdataformats::CRTBernFrame::s_expected_bytes
static constexpr std::size_t s_expected_bytes
Definition
CRTBernFrame.hpp:61
dunedaq::fddetdataformats::CRTBernFrame::set_lostfpga
void set_lostfpga(const uint16_t new_lostfpga)
Set the lostfpga counter of the CRTBernData.
Definition
CRTBernFrame.hpp:112
dunedaq::fddetdataformats::CRTBernFrame::get_flags
uint16_t get_flags() const
Definition
CRTBernFrame.hpp:98
dunedaq::fddetdataformats::CRTBernFrame::set_flags
void set_flags(const uint16_t new_flags)
Definition
CRTBernFrame.hpp:100
dunedaq::fddetdataformats::CRTBernFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame also set the underlying ts0 to be consistent.
Definition
CRTBernFrame.hpp:88
dunedaq::fddetdataformats::CRTBernFrame::s_num_channels
static constexpr int s_num_channels
Definition
CRTBernFrame.hpp:42
dunedaq::fddetdataformats::CRTBernFrame::set_ts0
void set_ts0(const uint32_t new_ts0)
Definition
CRTBernFrame.hpp:116
Generated on
for DUNE-DAQ by
1.17.0