DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CRTBernFrame.hpp
Go to the documentation of this file.
1
11#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
12#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
13
15
16#include <algorithm> // For std::min
17#include <cassert> // For assert()
18#include <cstdint> // For uint32_t etc
19#include <cstdio>
20#include <cstdlib>
21#include <stdexcept> // For std::out_of_range
22
24
30{
31public:
32 // ===============================================================
33 // Preliminaries
34 // ===============================================================
35
36 // The definition of the format is in terms of 64-bit words
37 using word_t = uint64_t; // NOLINT
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 uint16_t flags = 0;
46 uint16_t lostcpu = 0;
47 uint16_t lostfpga = 0;
48 uint32_t ts0 = 0;
49 uint32_t ts1 = 0;
50 uint16_t adc[s_num_channels] = { 0 };
51 uint32_t coinc = 0;
52 };
53
54 // ===============================================================
55 // Data members
56 // ===============================================================
58 uint16_t mac5;
60
61 // ===============================================================
62 // Accessors
63 // ===============================================================
64
68 uint16_t get_adc(int i_ch) const // NOLINT(build/unsigned)
69 {
70 if (i_ch < 0 || i_ch >= s_num_channels)
71 throw std::out_of_range("ADC channel index out of range");
72
73 return data.adc[i_ch];
74 }
75
79 void set_adc(int i_ch, uint16_t val) // NOLINT(build/unsigned)
80 {
81 if (i_ch < 0 || i_ch >= s_num_channels)
82 throw std::out_of_range("ADC channel index out of range");
83
84 data.adc[i_ch] = val;
85 }
86
89 uint64_t get_timestamp() const // NOLINT(build/unsigned)
90 {
91 return daq_header.get_timestamp(); // NOLINT(build/unsigned)
92 }
93
97 void set_timestamp(const uint64_t new_timestamp) // NOLINT(build/unsigned)
98 {
99 daq_header.timestamp = new_timestamp;
100 data.ts0 = (new_timestamp % s_DTS_ticks_per_second) * s_ns_per_DTS_tick;
101 }
102
105 uint16_t get_mac5() const // NOLINT(build/unsigned)
106 {
107 return mac5; // NOLINT(build/unsigned)
108 }
109
112 void set_mac5(const uint16_t new_mac5) // NOLINT(build/unsigned)
113 {
114 mac5 = new_mac5;
115 }
116
119 uint16_t get_flags() const // NOLINT(build/unsigned)
120 {
121 return data.flags; // NOLINT(build/unsigned)
122 }
123
126 void set_flags(const uint16_t new_flags) // NOLINT(build/unsigned)
127 {
128 data.flags = new_flags;
129 }
130
133 uint16_t get_lostcpu() const // NOLINT(build/unsigned)
134 {
135 return data.lostcpu; // NOLINT(build/unsigned)
136 }
137
140 void set_lostcpu(const uint16_t new_lostcpu) // NOLINT(build/unsigned)
141 {
142 data.lostcpu = new_lostcpu;
143 }
144
147 uint16_t get_lostfpga() const // NOLINT(build/unsigned)
148 {
149 return data.lostfpga; // NOLINT(build/unsigned)
150 }
151
154 void set_lostfpga(const uint16_t new_lostfpga) // NOLINT(build/unsigned)
155 {
156 data.lostfpga = new_lostfpga;
157 }
158
161 uint32_t get_ts0() const { return data.ts0; }
162
165 void set_ts0(const uint32_t new_ts0) { data.ts0 = new_ts0; }
166
169 uint32_t get_ts1() const { return data.ts1; }
170
173 void set_ts1(const uint32_t new_ts1) { data.ts1 = new_ts1; }
174
177 uint32_t get_coinc() const { return data.coinc; }
178
181 void set_coinc(const uint32_t new_coinc) { data.coinc = new_coinc; }
182
183}; // CRTBernFrame
184
185} // namespace dunedaq::fddetdataformats
186
187#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
Class for accessing/holding raw CRT data from the 'Bern' panels ProtoDUNE-II VD.
void set_mac5(const uint16_t new_mac5)
Set the MAC5 identifier of the frame.
uint16_t get_lostcpu() const
Get the lostcpu counter of the CRTBernData.
void set_adc(int i_ch, uint16_t val)
Set the adc value for channel i_ch to val.
uint16_t get_mac5() const
Get the MAC5 identifier of the frame.
uint32_t get_ts1() const
Get the ts1 timestamp of the CRTBernData.
uint16_t get_adc(int i_ch) const
Get the adc value for channel i_ch.
static constexpr uint64_t s_ns_per_DTS_tick
void set_lostcpu(const uint16_t new_lostcpu)
Set the lostcpu counter of the CRTBernData.
void set_coinc(const uint32_t new_coinc)
Set the coinc counter of the CRTBernData.
uint32_t get_ts0() const
Get the ts0 timestamp of the CRTBernData.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
uint32_t get_coinc() const
Get the coinc counter of the CRTBernData.
static constexpr uint64_t s_DTS_ticks_per_second
detdataformats::DAQEthHeader daq_header
uint16_t get_lostfpga() const
Get the lostfpga counter of the CRTBernData.
void set_ts1(const uint32_t new_ts1)
Set the ts1 timestamp of the CRTBernData.
void set_lostfpga(const uint16_t new_lostfpga)
Set the lostfpga counter of the CRTBernData.
uint16_t get_flags() const
Get the flags field of the CRTBernData.
void set_flags(const uint16_t new_flags)
Set the flags field of the CRTBernData.
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.
void set_ts0(const uint32_t new_ts0)
Set the ts0 timestamp of the CRTBernData.
DAQEthHeader is a versioned and unified structure for every FE electronics.