DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
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
19
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
30
31// NOLINTBEGIN(build/unsigned)
32
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
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;
81 uint32_t pps_interval = 0;
83 0;
84
86 };
87#warning "CRTGrenobleFrame::STEvent has padding inserted"
88 // static_assert(sizeof(STEvent) == STEvent::s_expected_size);
89
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
118
119}; // CRTGrenobleFrame
120#warning "CRTGrenobleFrame has padding inserted"
121// static_assert(sizeof(CRTGrenobleFrame) == CRTGrenobleFrame::s_expected_size);
122
123static_assert(std::endian::native == std::endian::little,
124 "The CRTGrenobleFrame bitfield layout assumes little-endian architecture");
125static_assert(std::is_trivially_copyable_v<CRTGrenobleFrame>,
126 "CRTGrenobleFrame isn't trivially copyable and can't be safely std::memcpy'd");
127static_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 is a versioned and unified structure for every FE electronics.
uint16_t flag
Flag containing trigger, trigger sum and overflow information.
uint32_t FIFO_AF_duration
FIFO AF duration (4 ns) -> integration of Almost full fifo since last accepted trigger.
uint32_t timestamp
Timestamp (4 ns) -> used to compute dt between events.
uint32_t pps_interval
IRIG-B subdivision in a second, expressed in 100 ns clock ticks.
Struct for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
static constexpr std::size_t s_expected_bytes
void set_adc(const int i_ch, const int val)
Set the adc value for channel i_ch to val.
int get_adc(const int i_ch) const
Get the adc value for channel i_ch.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.