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

Class for accessing raw WIB eth frames, as used in ProtoDUNE-II. More...

#include <DAPHNEEthFrame.hpp>

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

Classes

struct  Header
 

Public Types

typedef uint64_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.
 
uint64_t get_timestamp () const
 Get the starting 64-bit timestamp of the frame.
 
void set_timestamp (const uint64_t new_timestamp)
 Set the starting 64-bit timestamp of the frame.
 
uint8_t get_channel () const
 Get the channel identifier of the frame.
 
void set_channel (const uint8_t new_channel)
 Set the channel identifier of the frame.
 

Public Attributes

detdataformats::DAQEthHeader daq_header
 
Header header
 
word_t adc_words [s_num_adc_words]
 

Static Public Attributes

static constexpr uint8_t version = 1
 
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

Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.

The canonical definition of the WIB format is given in EDMS document 2088713: https://edms.cern.ch/document/2088726

Definition at line 34 of file DAPHNEEthFrame.hpp.

Member Typedef Documentation

◆ word_t

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::DAPHNEEthFrame::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 91 of file DAPHNEEthFrame.hpp.

92{
93 if (i < 0 || i >= s_num_adcs)
94 throw std::out_of_range("ADC index out of range");
95
96 // The index of the first (and sometimes only) word containing the required ADC value
97 int word_index = s_bits_per_adc * i / s_bits_per_word;
98 assert(word_index < s_num_adc_words);
99 // Where in the word the lowest bit of our ADC value is located
100 int first_bit_position = (s_bits_per_adc * i) % s_bits_per_word;
101 // How many bits of our desired ADC are located in the `word_index`th word
102 int bits_from_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
103 uint16_t adc = adc_words[word_index] >> first_bit_position; // NOLINT
104 // If we didn't get the full 14 bits from this word, we need the rest from the next word
105 if (bits_from_first_word < s_bits_per_adc) {
106 assert(word_index + 1 < s_num_adc_words);
107 adc |= adc_words[word_index + 1] << bits_from_first_word;
108 }
109 // Mask out all but the lowest 14 bits;
110 return adc & 0x3FFFu;
111}

◆ get_channel()

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

Get the channel identifier of the frame.

Definition at line 157 of file DAPHNEEthFrame.hpp.

◆ get_timestamp()

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

Get the starting 64-bit timestamp of the frame.

Definition at line 143 of file DAPHNEEthFrame.hpp.

144 {
145 return daq_header.get_timestamp() ; // NOLINT(build/unsigned)
146 }
detdataformats::DAQEthHeader daq_header

◆ set_adc()

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

Set the ith ADC value in the frame to val.

Definition at line 117 of file DAPHNEEthFrame.hpp.

118{
119 if (i < 0 || i >= s_num_adcs)
120 throw std::out_of_range("ADC index out of range");
121 if (val >= (1 << s_bits_per_adc))
122 throw std::out_of_range("ADC value out of range");
123
124 // The index of the first (and sometimes only) word containing the required ADC value
125 int word_index = s_bits_per_adc * i / s_bits_per_word;
126 assert(word_index < s_num_adc_words);
127 // Where in the word the lowest bit of our ADC value is located
128 int first_bit_position = (s_bits_per_adc * i) % s_bits_per_word;
129 // How many bits of our desired ADC are located in the `word_index`th word
130 int bits_in_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
131 uint32_t mask = (1 << (first_bit_position)) - 1;
132 adc_words[word_index] = ((val << first_bit_position) & ~mask) | (adc_words[word_index] & mask);
133 // If we didn't put the full 14 bits in this word, we need to put the rest in the next word
134 if (bits_in_first_word < s_bits_per_adc) {
135 assert(word_index + 1 < s_num_adc_words);
136 mask = (1 << (s_bits_per_adc - bits_in_first_word)) - 1;
137 adc_words[word_index + 1] = ((val >> bits_in_first_word) & mask) | (adc_words[word_index + 1] & ~mask);
138 }
139}

◆ set_channel()

void dunedaq::fddetdataformats::DAPHNEEthFrame::set_channel ( const uint8_t new_channel)
inline

Set the channel identifier of the frame.

Definition at line 164 of file DAPHNEEthFrame.hpp.

165 {
166 header.channel = new_channel;
167 }

◆ set_timestamp()

void dunedaq::fddetdataformats::DAPHNEEthFrame::set_timestamp ( const uint64_t new_timestamp)
inline

Set the starting 64-bit timestamp of the frame.

Definition at line 150 of file DAPHNEEthFrame.hpp.

151 {
152 daq_header.timestamp = new_timestamp;
153 }

Member Data Documentation

◆ adc_words

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

Definition at line 77 of file DAPHNEEthFrame.hpp.

◆ daq_header

detdataformats::DAQEthHeader dunedaq::fddetdataformats::DAPHNEEthFrame::daq_header

Definition at line 75 of file DAPHNEEthFrame.hpp.

◆ header

Header dunedaq::fddetdataformats::DAPHNEEthFrame::header

Definition at line 76 of file DAPHNEEthFrame.hpp.

◆ s_bits_per_adc

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

Definition at line 47 of file DAPHNEEthFrame.hpp.

◆ s_bits_per_word

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

Definition at line 48 of file DAPHNEEthFrame.hpp.

◆ s_num_adc_words

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

Definition at line 50 of file DAPHNEEthFrame.hpp.

◆ s_num_adcs

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

Definition at line 49 of file DAPHNEEthFrame.hpp.

◆ version

uint8_t dunedaq::fddetdataformats::DAPHNEEthFrame::version = 1
staticconstexpr

Definition at line 45 of file DAPHNEEthFrame.hpp.


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