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

#include <DAPHNEFrame.hpp>

Collaboration diagram for dunedaq::fddetdataformats::DAPHNEFrame:
[legend]

Classes

struct  Header
 
struct  PeakDescriptorData
 

Public Types

typedef uint32_t word_t
 

Public Member Functions

uint16_t get_adc (int i) const
 Get the ith ADC value in the frame.
 
void set_adc (int i, uint16_t val)
 Set the ith ADC value in the frame to val.
 
uint8_t get_channel () const
 
void set_channel (uint8_t val)
 
uint64_t get_timestamp () const
 Get the 64-bit timestamp of the frame.
 

Public Attributes

detdataformats::DAQHeader daq_header
 
Header header
 
word_t adc_words [s_num_adc_words]
 
PeakDescriptorData peaks_data
 

Static Public Attributes

static constexpr uint8_t version = 2
 
static constexpr int s_bits_per_adc = 14
 
static constexpr int s_bits_per_word = 8 * sizeof(word_t)
 
static constexpr int s_num_adcs = 1024
 
static constexpr int s_num_adc_words = s_num_adcs * s_bits_per_adc / s_bits_per_word
 

Detailed Description

Definition at line 28 of file DAPHNEFrame.hpp.

Member Typedef Documentation

◆ word_t

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::DAPHNEFrame::get_adc ( int i) const
inline

Get the ith ADC value in the frame.

The ADC words are 14 bits long, stored packed in the data structure. The order is:

  • 1024 adc values from one daphne channel

Definition at line 227 of file DAPHNEFrame.hpp.

228{
229 if (i < 0 || i >= s_num_adcs)
230 throw std::out_of_range("ADC index out of range");
231
232 // The index of the first (and sometimes only) word containing the required ADC value
233 int word_index = s_bits_per_adc * i / s_bits_per_word;
234 assert(word_index < s_num_adc_words);
235 // Where in the word the lowest bit of our ADC value is located
236 int first_bit_position = (s_bits_per_adc * i) % s_bits_per_word;
237 // How many bits of our desired ADC are located in the `word_index`th word
238 int bits_from_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
239 uint16_t adc = adc_words[word_index] >> first_bit_position; // NOLINT
240 // If we didn't get the full 14 bits from this word, we need the rest from the next word
241 if (bits_from_first_word < s_bits_per_adc) {
242 assert(word_index + 1 < s_num_adc_words);
243 adc |= adc_words[word_index + 1] << bits_from_first_word;
244 }
245 // Mask out all but the lowest 14 bits;
246 return adc & 0x3FFFu;
247}

◆ get_channel()

uint8_t dunedaq::fddetdataformats::DAPHNEFrame::get_channel ( ) const
inline

Definition at line 203 of file DAPHNEFrame.hpp.

◆ get_timestamp()

uint64_t dunedaq::fddetdataformats::DAPHNEFrame::get_timestamp ( ) const
inline

Get the 64-bit timestamp of the frame.

Definition at line 208 of file DAPHNEFrame.hpp.

209 {
210 return daq_header.get_timestamp();
211 }
detdataformats::DAQHeader daq_header

◆ set_adc()

void dunedaq::fddetdataformats::DAPHNEFrame::set_adc ( int i,
uint16_t val )
inline

Set the ith ADC value in the frame to val.

Definition at line 253 of file DAPHNEFrame.hpp.

254{
255 if (i < 0 || i >= s_num_adcs)
256 throw std::out_of_range("ADC index out of range");
257 if (val >= (1 << s_bits_per_adc))
258 throw std::out_of_range("ADC value out of range");
259
260 // The index of the first (and sometimes only) word containing the required ADC value
261 int word_index = s_bits_per_adc * i / s_bits_per_word;
262 assert(word_index < s_num_adc_words);
263 // Where in the word the lowest bit of our ADC value is located
264 int first_bit_position = (s_bits_per_adc * i) % s_bits_per_word;
265 // How many bits of our desired ADC are located in the `word_index`th word
266 int bits_in_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
267 uint32_t mask = (1 << (first_bit_position)) - 1;
268 adc_words[word_index] = ((val << first_bit_position) & ~mask) | (adc_words[word_index] & mask);
269 // If we didn't put the full 14 bits in this word, we need to put the rest in the next word
270 if (bits_in_first_word < s_bits_per_adc) {
271 assert(word_index + 1 < s_num_adc_words);
272 mask = (1 << (s_bits_per_adc - bits_in_first_word)) - 1;
273 adc_words[word_index + 1] = ((val >> bits_in_first_word) & mask) | (adc_words[word_index + 1] & ~mask);
274 }
275}

◆ set_channel()

void dunedaq::fddetdataformats::DAPHNEFrame::set_channel ( uint8_t val)
inline

Definition at line 204 of file DAPHNEFrame.hpp.

204{ header.channel = val & 0x3Fu; } // NOLINT(build/unsigned)

Member Data Documentation

◆ adc_words

word_t dunedaq::fddetdataformats::DAPHNEFrame::adc_words[s_num_adc_words]

Definition at line 186 of file DAPHNEFrame.hpp.

◆ daq_header

detdataformats::DAQHeader dunedaq::fddetdataformats::DAPHNEFrame::daq_header

Definition at line 184 of file DAPHNEFrame.hpp.

◆ header

Header dunedaq::fddetdataformats::DAPHNEFrame::header

Definition at line 185 of file DAPHNEFrame.hpp.

◆ peaks_data

PeakDescriptorData dunedaq::fddetdataformats::DAPHNEFrame::peaks_data

Definition at line 187 of file DAPHNEFrame.hpp.

◆ s_bits_per_adc

int dunedaq::fddetdataformats::DAPHNEFrame::s_bits_per_adc = 14
staticconstexpr

Definition at line 41 of file DAPHNEFrame.hpp.

◆ s_bits_per_word

int dunedaq::fddetdataformats::DAPHNEFrame::s_bits_per_word = 8 * sizeof(word_t)
staticconstexpr

Definition at line 42 of file DAPHNEFrame.hpp.

◆ s_num_adc_words

int dunedaq::fddetdataformats::DAPHNEFrame::s_num_adc_words = s_num_adcs * s_bits_per_adc / s_bits_per_word
staticconstexpr

Definition at line 44 of file DAPHNEFrame.hpp.

◆ s_num_adcs

int dunedaq::fddetdataformats::DAPHNEFrame::s_num_adcs = 1024
staticconstexpr

Definition at line 43 of file DAPHNEFrame.hpp.

◆ version

uint8_t dunedaq::fddetdataformats::DAPHNEFrame::version = 2
staticconstexpr

Definition at line 39 of file DAPHNEFrame.hpp.


The documentation for this class was generated from the following file: