DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CRTBernFrame.hpp
Go to the documentation of this file.
1
10#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
11#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTBERNFRAME_HPP_
12
14
15#include <algorithm> // For std::min
16#include <cassert> // For assert()
17#include <cstdint> // For uint32_t etc
18#include <cstdio>
19#include <cstdlib>
20#include <stdexcept> // For std::out_of_range
21
23
29 {
30 public:
31 // ===============================================================
32 // Preliminaries
33 // ===============================================================
34
35 // The definition of the format is in terms of 64-bit words
36 typedef uint64_t word_t; // NOLINT
37
38 static constexpr int s_num_channels = 32;
39 static constexpr uint64_t s_DTS_ticks_per_second = 62'500'000;
40 static constexpr uint64_t s_ns_per_DTS_tick = 16;
41
42 static constexpr int s_bits_per_adc = 16;
43 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
44 static constexpr int s_num_adcs = 64;
45
47 {
48 uint16_t flags = 0;
49 uint16_t lostcpu = 0;
50 uint16_t lostfpga = 0;
51 uint32_t ts0 = 0;
52 uint32_t ts1 = 0;
53 uint16_t adc[32] = {0};
54 uint32_t coinc = 0;
55 };
56
57 // ===============================================================
58 // Data members
59 // ===============================================================
61 uint16_t mac5;
63
64 // ===============================================================
65 // Accessors
66 // ===============================================================
67
71 uint16_t get_adc(int i_ch) const // NOLINT(build/unsigned)
72 {
73 if (i_ch < 0 || i_ch >= s_num_channels)
74 throw std::out_of_range("ADC channel index out of range");
75
76 return data.adc[i_ch];
77 }
78
82 void set_adc(int i_ch, uint16_t val) // NOLINT(build/unsigned)
83 {
84 if (i_ch < 0 || i_ch >= s_num_channels)
85 throw std::out_of_range("ADC channel index out of range");
86
87 data.adc[i_ch]=val;
88 }
89
92 uint64_t get_timestamp() const // NOLINT(build/unsigned)
93 {
94 return daq_header.get_timestamp() ; // NOLINT(build/unsigned)
95 }
96
100 void set_timestamp(const uint64_t new_timestamp) // NOLINT(build/unsigned)
101 {
102 daq_header.timestamp = new_timestamp;
103 data.ts0 = (new_timestamp % s_DTS_ticks_per_second) * s_ns_per_DTS_tick;
104 }
105
108 uint16_t get_mac5() const // NOLINT(build/unsigned)
109 {
110 return mac5 ; // NOLINT(build/unsigned)
111 }
112
115 void set_mac5(const uint16_t new_mac5) // NOLINT(build/unsigned)
116 {
117 mac5 = new_mac5;
118 }
119
122 uint16_t get_flags() const // NOLINT(build/unsigned)
123 {
124 return data.flags; // NOLINT(build/unsigned)
125 }
126
129 void set_flags(const uint16_t new_flags) // NOLINT(build/unsigned)
130 {
131 data.flags = new_flags;
132 }
133
136 uint16_t get_lostcpu() const // NOLINT(build/unsigned)
137 {
138 return data.lostcpu; // NOLINT(build/unsigned)
139 }
140
143 void set_lostcpu(const uint16_t new_lostcpu) // NOLINT(build/unsigned)
144 {
145 data.lostcpu = new_lostcpu;
146 }
147
150 uint16_t get_lostfpga() const // NOLINT(build/unsigned)
151 {
152 return data.lostfpga; // NOLINT(build/unsigned)
153 }
154
157 void set_lostfpga(const uint16_t new_lostfpga) // NOLINT(build/unsigned)
158 {
159 data.lostfpga = new_lostfpga;
160 }
161
164 uint32_t get_ts0() const
165 {
166 return data.ts0;
167 }
168
171 void set_ts0(const uint32_t new_ts0)
172 {
173 data.ts0 = new_ts0;
174 }
175
178 uint32_t get_ts1() const
179 {
180 return data.ts1;
181 }
182
185 void set_ts1(const uint32_t new_ts1)
186 {
187 data.ts1 = new_ts1;
188 }
189
190
193 uint32_t get_coinc() const
194 {
195 return data.coinc;
196 }
197
200 void set_coinc(const uint32_t new_coinc)
201 {
202 data.coinc = new_coinc;
203 }
204
205
206 }; //CRTBernFrame
207
208} // namespace dunedaq::fddetdataformats
209
210
211#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.