DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::fddetdataformats Namespace Reference

Namespaces

namespace  python

Classes

class  CRTBernFrame
 Class for accessing/holding raw CRT data from the 'Bern' panels ProtoDUNE-II VD. More...
class  CRTGrenobleFrame
 Class for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD. More...
class  DAPHNEEthFrame
 Class for accessing raw WIB eth frames, as used in ProtoDUNE-II. More...
class  DAPHNEEthStreamFrame
 Class for accessing raw DAPHNE eth stream frames, as used in ProtoDUNE-II. More...
class  DAPHNEFrame
class  DAPHNEStreamFrame
struct  TDEHeader
struct  Sample
struct  ADC16Data
class  TDE16Frame
class  TDEEthFrame
 Class for accessing raw WIB eth frames, as used in ProtoDUNE-II. More...
class  WIB2Frame
 Class for accessing raw WIB v2 frames, as used in ProtoDUNE-SP-II. More...
class  WIBEthFrame
 Class for accessing raw WIB eth frames, as used in ProtoDUNE-II. More...
struct  WIBHeader
 WIB header struct. More...
struct  ColdataHeader
 COLDATA header struct. More...
struct  ColdataSegment
 COLDATA segment struct. More...
struct  ColdataBlock
 COLDATA block struct. More...
class  WIBFrame
 FELIX frame. More...

Typedefs

using word_t = uint32_t
using adc_t = uint16_t

Functions

std::ostream & operator<< (std::ostream &o, TDEHeader const &tde_header)
std::ostream & operator<< (std::ostream &o, Sample const &sampleinfo)
std::ostream & operator<< (std::ostream &o, TDE16Frame const &tde16frame)
template<typename WordType, int NWords, int BitsPerADC, int ADCSPerChannel, int NChannels>
WordType get_adc_2d_as_1d (const int i_adc, const int i_channel, const WordType(&adc_matrix)[NWords])
template<typename WordType, int NWords, int BitsPerADC, int ADCSPerChannel, int NChannels>
void set_adc_2d_as_1d (const int i_adc, const int i_channel, const WordType adc_val, WordType(&adc_matrix)[NWords])
template<typename WordType, int NWords, int BitsPerADC>
WordType get_adc_1d (const int i_adc, const WordType(&adc_array)[NWords])
template<typename WordType, int Rows, int Columns, int BitsPerADC>
WordType get_adc_2d (const int i_sample, const int i_adc, const WordType(&adc_matrix)[Rows][Columns])
template<typename WordType, int NWords, int BitsPerADC>
void set_adc_1d (const int i_adc, WordType adc_val, WordType(&adc_array)[NWords])
template<typename WordType, int Rows, int Columns, int BitsPerADC>
void set_adc_2d (const int i_sample, const int i_adc, WordType adc_val, WordType(&adc_matrix)[Rows][Columns])
std::ostream & operator<< (std::ostream &o, WIBHeader const &h)
std::ostream & operator<< (std::ostream &o, ColdataHeader const &hdr)
std::ostream & operator<< (std::ostream &o, const ColdataBlock &block)
std::ostream & operator<< (std::ostream &o, WIBFrame const &frame)

Variables

static constexpr int ticks_between_adc_samples = 32
static constexpr int tot_adc16_samples = 4474
static constexpr int n_channels_per_amc = 64

Typedef Documentation

◆ adc_t

Definition at line 23 of file WIBFrame.hpp.

◆ word_t

Definition at line 22 of file WIBFrame.hpp.

Function Documentation

◆ get_adc_1d()

template<typename WordType, int NWords, int BitsPerADC>
WordType dunedaq::fddetdataformats::get_adc_1d ( const int i_adc,
const WordType(&) adc_array[NWords] )

Definition at line 156 of file Utils.hpp.

157{
158
159 static_assert(std::is_integral_v<WordType> && std::is_unsigned_v<WordType>,
160 "WordType must be an unsigned integral type");
161
162 constexpr int bits_per_word = std::numeric_limits<WordType>::digits; // Fine since we know integer is unsigned
163
164 static_assert(BitsPerADC > 0);
165 constexpr int num_adcs = NWords * bits_per_word / BitsPerADC;
166
168}
WordType get_adc_2d_as_1d(const int i_adc, const int i_channel, const WordType(&adc_matrix)[NWords])
Definition Utils.hpp:40

◆ get_adc_2d()

template<typename WordType, int Rows, int Columns, int BitsPerADC>
WordType dunedaq::fddetdataformats::get_adc_2d ( const int i_sample,
const int i_adc,
const WordType(&) adc_matrix[Rows][Columns] )

Definition at line 179 of file Utils.hpp.

180{
181
182 if (i_sample < 0 || i_sample >= Rows) {
183 throw std::out_of_range(
184 std::format("Requested index of {}th 1-d ADC array is outside of allowed range 0-{}", i_sample, Rows - 1));
185 }
186
187 return get_adc_1d<WordType, Columns, BitsPerADC>(i_adc, adc_matrix[i_sample]);
188}
WordType get_adc_1d(const int i_adc, const WordType(&adc_array)[NWords])
Definition Utils.hpp:156

◆ get_adc_2d_as_1d()

template<typename WordType, int NWords, int BitsPerADC, int ADCSPerChannel, int NChannels>
WordType dunedaq::fddetdataformats::get_adc_2d_as_1d ( const int i_adc,
const int i_channel,
const WordType(&) adc_matrix[NWords] )

Definition at line 40 of file Utils.hpp.

41{
42
43 static_assert(std::is_integral_v<WordType> && std::is_unsigned_v<WordType>,
44 "WordType must be an unsigned integral type");
45
46 constexpr int bits_per_word = std::numeric_limits<WordType>::digits; // Fine since we know integer is unsigned
47
48 static_assert(BitsPerADC > 0 && BitsPerADC <= bits_per_word);
49 static_assert(ADCSPerChannel * NChannels * BitsPerADC == NWords * bits_per_word);
50
51 if (i_channel < 0 || i_channel >= NChannels) {
52 throw std::out_of_range(
53 std::format("Requested channel of {} is out of channel range 0-{}", i_channel, NChannels - 1));
54 }
55
56 if (i_adc < 0 || i_adc >= ADCSPerChannel) {
57 throw std::out_of_range(std::format("Requested ADC index of {} if out of range 0-{}", i_adc, ADCSPerChannel - 1));
58 }
59
60 // find absolute index in frame
61 int i_abs = i_adc * NChannels + i_channel;
62
63 if constexpr (BitsPerADC == bits_per_word) {
64 return adc_matrix[i_abs];
65 } else {
66
67 // The index of the first (and sometimes only) word containing the required ADC value
68 int i_word = BitsPerADC * i_abs / bits_per_word;
69 assert(i_word < NWords);
70
71 // Where in the word the lowest bit of our ADC value is located
72 int first_bit_position = (BitsPerADC * i_abs) % bits_per_word;
73
74 // How many bits of our desired ADC are located in the `i_word`th word
75 int bits_from_first_word = std::min(BitsPerADC, bits_per_word - first_bit_position);
76
77 WordType adc_val = adc_matrix[i_word] >> first_bit_position; // NOLINT(build/unsigned)
78
79 if (bits_from_first_word < BitsPerADC) {
80 assert(i_word < NWords - 1);
81 adc_val |= adc_matrix[i_word + 1] << bits_from_first_word;
82 }
83
84 // Mask out all but the lowest BitsPerADC bits;
85 return adc_val & ((static_cast<WordType>(1) << BitsPerADC) - 1);
86
87 } // if BitsPerADC != bits_per_word
88}

◆ operator<<() [1/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
ColdataHeader const & hdr )
inline

Definition at line 192 of file WIBFrame.hpp.

194{
195 o << "s1_error:" << unsigned(hdr.s1_error) << " s2_error:" << unsigned(hdr.s2_error)
196 << " checksum_a1:" << unsigned(hdr.checksum_a_1) << " checksum_b1:" << unsigned(hdr.checksum_b_1)
197 << " checksum_a2:" << unsigned(hdr.checksum_a_2) << " checksum_b1:" << unsigned(hdr.checksum_b_2)
198 << " coldata_convert_count:" << unsigned(hdr.coldata_convert_count)
199 << " error_register:" << unsigned(hdr.error_register) << " hdr_1:" << unsigned(hdr.hdr_1)
200 << " hdr_2:" << unsigned(hdr.hdr_2) << " hdr_3:" << unsigned(hdr.hdr_3) << " hdr_4:" << unsigned(hdr.hdr_4)
201 << " hdr_5:" << unsigned(hdr.hdr_5) << " hdr_6:" << unsigned(hdr.hdr_6) << " hdr_7:" << unsigned(hdr.hdr_7)
202 << " hdr_8:" << unsigned(hdr.hdr_8);
203 return o << '\n';
204}

◆ operator<<() [2/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
const ColdataBlock & block )
inline

Definition at line 328 of file WIBFrame.hpp.

330{
331 o << block.head;
332
333 // Note that this is an ADC-centric view, whereas ColdataBlock uses a channel-centric view
334 o << "\t\t0\t1\t2\t3\t4\t5\t6\t7\n";
335 for (int adc = 0; adc < 8; adc++) {
336 o << "Stream " << adc << ":\t";
337 for (int ch = 0; ch < 8; ch++) {
338 o << std::hex << block.get_channel(adc, ch) << '\t';
339 }
340 o << std::dec << '\n';
341 }
342 return o;
343}
uint16_t get_channel(const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:305

◆ operator<<() [3/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
Sample const & sampleinfo )
inline

Definition at line 96 of file TDE16Frame.hpp.

98{
99 return o << "sample: " << unsigned(sampleinfo.sample) << " reserved: " << unsigned(sampleinfo.reserved) << '\n';
100}

◆ operator<<() [4/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
TDE16Frame const & tde16frame )
inline

Definition at line 102 of file TDE16Frame.hpp.

104{
105 o << "Printing frame:" << '\n';
106 o << tde16frame.m_daq_header << '\n';
107 o << tde16frame.m_tde16_header << '\n';
108 return o;
109}

◆ operator<<() [5/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
TDEHeader const & tde_header )
inline

Definition at line 88 of file TDE16Frame.hpp.

90{
91 return o << std::hex << "channel: " << tde_header.channel << "version: " << tde_header.version
92 << "TAItime: " << tde_header.TAItime << " tde_header: " << tde_header.tde_header
93 << " tde_errors: " << tde_header.tde_errors << std::dec << '\n';
94}

◆ operator<<() [6/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
WIBFrame const & frame )
inline

Definition at line 429 of file WIBFrame.hpp.

431{
432 o << "Printing frame:" << '\n';
433 o << frame.m_head << '\n';
434 for (auto b : frame.m_blocks) {
435 o << b;
436 }
437 return o;
438}

◆ operator<<() [7/7]

std::ostream & dunedaq::fddetdataformats::operator<< ( std::ostream & o,
WIBHeader const & h )
inline

Definition at line 78 of file WIBFrame.hpp.

80{
81 return o << "SOF:" << unsigned(h.sof) << " version:" << unsigned(h.version) << " fiber:" << unsigned(h.fiber_no)
82 << " slot:" << unsigned(h.slot_no) << " crate:" << unsigned(h.crate_no) << " mm:" << unsigned(h.mm)
83 << " oos:" << unsigned(h.oos) << " wib_errors:" << unsigned(h.wib_errors)
84 << " timestamp: " << h.get_timestamp() << '\n';
85}

◆ set_adc_1d()

template<typename WordType, int NWords, int BitsPerADC>
void dunedaq::fddetdataformats::set_adc_1d ( const int i_adc,
WordType adc_val,
WordType(&) adc_array[NWords] )

Definition at line 195 of file Utils.hpp.

196{
197 static_assert(std::is_integral_v<WordType> && std::is_unsigned_v<WordType>,
198 "WordType must be an unsigned integral type");
199
200 constexpr int bits_per_word = std::numeric_limits<WordType>::digits; // Fine since we know integer is unsigned
201
202 static_assert(BitsPerADC > 0 && BitsPerADC <= bits_per_word);
203 static_assert((NWords * bits_per_word) % BitsPerADC == 0);
204
205 constexpr int num_adcs = NWords * bits_per_word / BitsPerADC;
206
208}
void set_adc_2d_as_1d(const int i_adc, const int i_channel, const WordType adc_val, WordType(&adc_matrix)[NWords])
Definition Utils.hpp:94

◆ set_adc_2d()

template<typename WordType, int Rows, int Columns, int BitsPerADC>
void dunedaq::fddetdataformats::set_adc_2d ( const int i_sample,
const int i_adc,
WordType adc_val,
WordType(&) adc_matrix[Rows][Columns] )

Definition at line 216 of file Utils.hpp.

217{
218 if (i_sample < 0 || i_sample >= Rows) {
219 throw std::out_of_range(
220 std::format("Requested index of {}th 1-d ADC array is outside of allowed range 0-{}", i_sample, Rows - 1));
221 }
222
223 set_adc_1d<WordType, Columns, BitsPerADC>(i_adc, adc_val, adc_matrix[i_sample]);
224}
void set_adc_1d(const int i_adc, WordType adc_val, WordType(&adc_array)[NWords])
Definition Utils.hpp:195

◆ set_adc_2d_as_1d()

template<typename WordType, int NWords, int BitsPerADC, int ADCSPerChannel, int NChannels>
void dunedaq::fddetdataformats::set_adc_2d_as_1d ( const int i_adc,
const int i_channel,
const WordType adc_val,
WordType(&) adc_matrix[NWords] )

Definition at line 94 of file Utils.hpp.

95{
96 static_assert(std::is_integral_v<WordType> && std::is_unsigned_v<WordType>,
97 "WordType must be an unsigned integral type");
98
99 constexpr int bits_per_word = std::numeric_limits<WordType>::digits; // Fine since we know integer is unsigned
100
101 static_assert(BitsPerADC > 0 && BitsPerADC <= bits_per_word);
102 static_assert(ADCSPerChannel * NChannels * BitsPerADC == NWords * bits_per_word);
103
104 if (i_channel < 0 || i_channel >= NChannels) {
105 throw std::out_of_range(
106 std::format("Requested channel of {} is out of channel range 0-{}", i_channel, NChannels - 1));
107 }
108
109 if (i_adc < 0 || i_adc >= ADCSPerChannel) {
110 throw std::out_of_range(std::format("Requested ADC index of {} is out of range 0-{}", i_adc, ADCSPerChannel - 1));
111 }
112
113 if constexpr (BitsPerADC < bits_per_word) {
114 if (adc_val >= (static_cast<WordType>(1) << BitsPerADC)) {
115 throw std::out_of_range(std::format(
116 "Requested ADC value of {} exceeds max value of {}", adc_val, (static_cast<WordType>(1) << BitsPerADC) - 1));
117 }
118 }
119
120 // find absolute index in frame
121 int i_abs = i_adc * NChannels + i_channel;
122
123 if constexpr (BitsPerADC == bits_per_word) {
124 adc_matrix[i_abs] = adc_val;
125 } else {
126
127 // The index of the first (and sometimes only) word containing the required ADC value
128 int i_word = BitsPerADC * i_abs / bits_per_word;
129 assert(i_word < NWords);
130
131 // Where in the word the lowest bit of our ADC value is located
132 int first_bit_position = (BitsPerADC * i_abs) % bits_per_word;
133
134 // How many bits of our desired ADC are located in the `i_word`th word
135 int bits_in_first_word = std::min(BitsPerADC, bits_per_word - first_bit_position);
136
137 WordType mask = ((static_cast<WordType>(1) << bits_in_first_word) - 1) << first_bit_position;
138
139 adc_matrix[i_word] = (adc_matrix[i_word] & ~mask) | ((static_cast<WordType>(adc_val) << first_bit_position) & mask);
140
141 // If we didn't put the full 14 bits in this word, we need to put the rest in the next word
142 if (bits_in_first_word < BitsPerADC) {
143 assert(i_word < NWords - 1);
144 int bits_in_second_word = BitsPerADC - bits_in_first_word;
145 WordType mask2 = (static_cast<WordType>(1) << bits_in_second_word) - 1;
146 adc_matrix[i_word + 1] = (adc_matrix[i_word + 1] & ~mask2) | ((adc_val >> bits_in_first_word) & mask2);
147 }
148 } // BitsPerADC != bits_per_word
149}

Variable Documentation

◆ n_channels_per_amc

int dunedaq::fddetdataformats::n_channels_per_amc = 64
staticconstexpr

Definition at line 27 of file TDE16Frame.hpp.

◆ ticks_between_adc_samples

int dunedaq::fddetdataformats::ticks_between_adc_samples = 32
staticconstexpr

Definition at line 25 of file TDE16Frame.hpp.

◆ tot_adc16_samples

int dunedaq::fddetdataformats::tot_adc16_samples = 4474
staticconstexpr

Definition at line 26 of file TDE16Frame.hpp.