DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
fddetdataformats
include
fddetdataformats
CRTGrenobleFrame.hpp
Go to the documentation of this file.
1
15
#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_HPP_
16
#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_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
34
struct
CRTGrenobleFrame
35
{
36
// The definition of the format is in terms of 64-bit words
37
using
word_t
= uint64_t;
38
39
static
constexpr
int
s_num_channels
= 32;
40
static
constexpr
uint64_t
s_DTS_ticks_per_second
= 62'500'000;
41
static
constexpr
uint64_t
s_ns_per_DTS_tick
= 16;
42
43
struct
TGpsDateStruct
44
{
45
// "/ 8" below -> 8 bits to a byte
46
static
constexpr
int
s_expected_size
{ (8 + 8 + 8 + 8 + 16 + 12 + 3 + 1) / 8 };
47
48
uint32_t
seconds
: 8;
49
uint32_t
minutes
: 8;
50
uint32_t
hours
: 8;
51
uint32_t
year
: 8;
52
53
uint32_t
day
: 16;
54
uint32_t
new_date_cnt
: 12;
55
uint32_t
irigb_dec_ver
: 3;
56
uint32_t
irigb_valid
: 1;
57
};
58
static_assert
(
sizeof
(
TGpsDateStruct
) ==
TGpsDateStruct::s_expected_size
);
59
60
struct
STChannel
61
{
62
static
constexpr
int
s_expected_size
{
sizeof
(int) +
sizeof
(uint16_t) +
sizeof
(float) +
sizeof
(uint16_t) };
// NOLINT(runtime/int,google-runtime-int)
63
64
int
qTot
= 0;
65
uint16_t
n_zc
= 0;
66
float
cfd
= 0.;
67
uint16_t
flag
= 0;
68
};
69
70
#warning "CRTGrenobleFrame::STChannel has padding inserted"
71
// static_assert(sizeof(STChannel) == STChannel::s_expected_size);
72
73
struct
STEvent
74
{
75
static
constexpr
int
s_expected_size
{ 3 *
sizeof
(uint32_t) +
TGpsDateStruct::s_expected_size
+ 2 *
sizeof
(uint32_t) +
STChannel::s_expected_size
*
s_num_channels
};
76
77
uint32_t
eventID
= 0;
78
uint32_t
dateInSec
= 0;
79
uint32_t
timestamp
= 0;
80
TGpsDateStruct
gpsDate
;
81
uint32_t
pps_interval
= 0;
82
uint32_t
FIFO_AF_duration
=
83
0;
84
85
struct
STChannel
channels
[
s_num_channels
];
86
};
87
#warning "CRTGrenobleFrame::STEvent has padding inserted"
88
// static_assert(sizeof(STEvent) == STEvent::s_expected_size);
89
90
static
constexpr
std::size_t
s_expected_bytes
{
sizeof
(
detdataformats::DAQEthHeader
) +
CRTGrenobleFrame::STEvent::s_expected_size
};
91
93
int
get_adc
(
const
int
i_ch)
const
94
{
95
if
(i_ch < 0 || i_ch >=
s_num_channels
)
96
throw
std::out_of_range(
"ADC channel index out of range"
);
97
98
return
event
.channels[i_ch].qTot;
99
}
100
102
void
set_adc
(
const
int
i_ch,
const
int
val)
103
{
104
if
(i_ch < 0 || i_ch >=
s_num_channels
)
105
throw
std::out_of_range(
"ADC channel index out of range"
);
106
107
event
.channels[i_ch].qTot = val;
// NOLINT(cppcoreguidelines-pro-bounds-constant-array-index)
108
}
109
111
uint64_t
get_timestamp
()
const
{
return
daq_header
.get_timestamp(); }
112
114
void
set_timestamp
(
const
uint64_t new_timestamp) {
daq_header
.timestamp = new_timestamp; }
115
116
detdataformats::DAQEthHeader
daq_header
;
// Formally private, but has a non-const accessor
117
STEvent
event
;
118
119
};
// CRTGrenobleFrame
120
#warning "CRTGrenobleFrame has padding inserted"
121
// static_assert(sizeof(CRTGrenobleFrame) == CRTGrenobleFrame::s_expected_size);
122
123
static_assert
(std::endian::native == std::endian::little,
124
"The CRTGrenobleFrame bitfield layout assumes little-endian architecture"
);
125
static_assert
(std::is_trivially_copyable_v<CRTGrenobleFrame>,
126
"CRTGrenobleFrame isn't trivially copyable and can't be safely std::memcpy'd"
);
127
static_assert
(std::is_standard_layout_v<CRTGrenobleFrame>,
128
"CRTGrenobleFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it"
);
129
130
// NOLINTEND(build/unsigned)
131
132
}
// namespace dunedaq::fddetdataformats
133
134
#endif
// FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_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::CRTGrenobleFrame::STChannel
Definition
CRTGrenobleFrame.hpp:61
dunedaq::fddetdataformats::CRTGrenobleFrame::STChannel::n_zc
uint16_t n_zc
CFD time.
Definition
CRTGrenobleFrame.hpp:65
dunedaq::fddetdataformats::CRTGrenobleFrame::STChannel::flag
uint16_t flag
Flag containing trigger, trigger sum and overflow information.
Definition
CRTGrenobleFrame.hpp:67
dunedaq::fddetdataformats::CRTGrenobleFrame::STChannel::s_expected_size
static constexpr int s_expected_size
Definition
CRTGrenobleFrame.hpp:62
dunedaq::fddetdataformats::CRTGrenobleFrame::STChannel::qTot
int qTot
Total charge.
Definition
CRTGrenobleFrame.hpp:64
dunedaq::fddetdataformats::CRTGrenobleFrame::STChannel::cfd
float cfd
CFD value.
Definition
CRTGrenobleFrame.hpp:66
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent
Definition
CRTGrenobleFrame.hpp:74
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::FIFO_AF_duration
uint32_t FIFO_AF_duration
FIFO AF duration (4 ns) -> integration of Almost full fifo since last accepted trigger.
Definition
CRTGrenobleFrame.hpp:82
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::channels
struct STChannel channels[s_num_channels]
Definition
CRTGrenobleFrame.hpp:85
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::s_expected_size
static constexpr int s_expected_size
Definition
CRTGrenobleFrame.hpp:75
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::gpsDate
TGpsDateStruct gpsDate
TGPS date.
Definition
CRTGrenobleFrame.hpp:80
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::timestamp
uint32_t timestamp
Timestamp (4 ns) -> used to compute dt between events.
Definition
CRTGrenobleFrame.hpp:79
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::dateInSec
uint32_t dateInSec
Event date in seconds.
Definition
CRTGrenobleFrame.hpp:78
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::eventID
uint32_t eventID
Event ID.
Definition
CRTGrenobleFrame.hpp:77
dunedaq::fddetdataformats::CRTGrenobleFrame::STEvent::pps_interval
uint32_t pps_interval
IRIG-B subdivision in a second, expressed in 100 ns clock ticks.
Definition
CRTGrenobleFrame.hpp:81
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct
Definition
CRTGrenobleFrame.hpp:44
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::irigb_dec_ver
uint32_t irigb_dec_ver
Definition
CRTGrenobleFrame.hpp:55
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::year
uint32_t year
Definition
CRTGrenobleFrame.hpp:51
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::new_date_cnt
uint32_t new_date_cnt
Definition
CRTGrenobleFrame.hpp:54
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::irigb_valid
uint32_t irigb_valid
Definition
CRTGrenobleFrame.hpp:56
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::day
uint32_t day
Definition
CRTGrenobleFrame.hpp:53
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::hours
uint32_t hours
Definition
CRTGrenobleFrame.hpp:50
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::s_expected_size
static constexpr int s_expected_size
Definition
CRTGrenobleFrame.hpp:46
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::minutes
uint32_t minutes
Definition
CRTGrenobleFrame.hpp:49
dunedaq::fddetdataformats::CRTGrenobleFrame::TGpsDateStruct::seconds
uint32_t seconds
Definition
CRTGrenobleFrame.hpp:48
dunedaq::fddetdataformats::CRTGrenobleFrame
Struct for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
Definition
CRTGrenobleFrame.hpp:35
dunedaq::fddetdataformats::CRTGrenobleFrame::s_ns_per_DTS_tick
static constexpr uint64_t s_ns_per_DTS_tick
Definition
CRTGrenobleFrame.hpp:41
dunedaq::fddetdataformats::CRTGrenobleFrame::event
STEvent event
Definition
CRTGrenobleFrame.hpp:117
dunedaq::fddetdataformats::CRTGrenobleFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
CRTGrenobleFrame.hpp:111
dunedaq::fddetdataformats::CRTGrenobleFrame::s_DTS_ticks_per_second
static constexpr uint64_t s_DTS_ticks_per_second
Definition
CRTGrenobleFrame.hpp:40
dunedaq::fddetdataformats::CRTGrenobleFrame::word_t
uint64_t word_t
Definition
CRTGrenobleFrame.hpp:37
dunedaq::fddetdataformats::CRTGrenobleFrame::s_num_channels
static constexpr int s_num_channels
Definition
CRTGrenobleFrame.hpp:39
dunedaq::fddetdataformats::CRTGrenobleFrame::s_expected_bytes
static constexpr std::size_t s_expected_bytes
Definition
CRTGrenobleFrame.hpp:90
dunedaq::fddetdataformats::CRTGrenobleFrame::set_adc
void set_adc(const int i_ch, const int val)
Set the adc value for channel i_ch to val.
Definition
CRTGrenobleFrame.hpp:102
dunedaq::fddetdataformats::CRTGrenobleFrame::daq_header
detdataformats::DAQEthHeader daq_header
Definition
CRTGrenobleFrame.hpp:116
dunedaq::fddetdataformats::CRTGrenobleFrame::get_adc
int get_adc(const int i_ch) const
Get the adc value for channel i_ch.
Definition
CRTGrenobleFrame.hpp:93
dunedaq::fddetdataformats::CRTGrenobleFrame::set_timestamp
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
Definition
CRTGrenobleFrame.hpp:114
Generated on
for DUNE-DAQ by
1.17.0