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

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

#include <WIBEthFrame.hpp>

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

Classes

struct  WIBEthHeader
 

Public Types

typedef uint64_t word_t
 

Public Member Functions

uint16_t get_adc (int i, int sample=0) const
 Get the ith ADC value in the frame.
 
void set_adc (int i, int sample, 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
 
WIBEthHeader header
 
word_t adc_words [s_time_samples_per_frame][s_num_adc_words_per_ts]
 

Static Public Attributes

static constexpr int s_bits_per_adc = 14
 
static constexpr int s_bits_per_word = 8 * sizeof(word_t)
 
static constexpr int s_time_samples_per_frame = 64
 
static constexpr int s_channels_per_half_femb = 64
 
static constexpr int s_half_fembs_per_frame = 1
 
static constexpr int s_num_channels = s_channels_per_half_femb * s_half_fembs_per_frame
 
static constexpr int s_num_adc_words_per_ts = s_num_channels * s_bits_per_adc / s_bits_per_word
 
static constexpr int s_num_adc_words = s_time_samples_per_frame * s_num_channels * 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/2088713

Definition at line 34 of file WIBEthFrame.hpp.

Member Typedef Documentation

◆ word_t

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::WIBEthFrame::get_adc ( int i,
int sample = 0 ) const
inline

Get the ith ADC value in the frame.

The ADC words are 14 bits long; wrod_t stored packed in the data structure. The order is: 64 channels repeated for 64 time samples

Definition at line 95 of file WIBEthFrame.hpp.

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

◆ get_channel()

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

Get the channel identifier of the frame.

Definition at line 162 of file WIBEthFrame.hpp.

163 {
164 return header.channel ; // NOLINT(build/unsigned)
165 }

◆ get_timestamp()

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

Get the starting 64-bit timestamp of the frame.

Definition at line 148 of file WIBEthFrame.hpp.

149 {
150 return daq_header.get_timestamp() ; // NOLINT(build/unsigned)
151 }
detdataformats::DAQEthHeader daq_header

◆ set_adc()

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

Set the ith ADC value in the frame to val.

Definition at line 122 of file WIBEthFrame.hpp.

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

◆ set_channel()

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

Set the channel identifier of the frame.

Definition at line 169 of file WIBEthFrame.hpp.

170 {
171 header.channel = new_channel;
172 }

◆ set_timestamp()

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

Set the starting 64-bit timestamp of the frame.

Definition at line 155 of file WIBEthFrame.hpp.

156 {
157 daq_header.timestamp = new_timestamp;
158 }

Member Data Documentation

◆ adc_words

word_t dunedaq::fddetdataformats::WIBEthFrame::adc_words[s_time_samples_per_frame][s_num_adc_words_per_ts]

Definition at line 81 of file WIBEthFrame.hpp.

◆ daq_header

detdataformats::DAQEthHeader dunedaq::fddetdataformats::WIBEthFrame::daq_header

Definition at line 78 of file WIBEthFrame.hpp.

◆ header

WIBEthHeader dunedaq::fddetdataformats::WIBEthFrame::header

Definition at line 79 of file WIBEthFrame.hpp.

◆ s_bits_per_adc

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

Definition at line 44 of file WIBEthFrame.hpp.

◆ s_bits_per_word

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

Definition at line 45 of file WIBEthFrame.hpp.

◆ s_channels_per_half_femb

int dunedaq::fddetdataformats::WIBEthFrame::s_channels_per_half_femb = 64
staticconstexpr

Definition at line 47 of file WIBEthFrame.hpp.

◆ s_half_fembs_per_frame

int dunedaq::fddetdataformats::WIBEthFrame::s_half_fembs_per_frame = 1
staticconstexpr

Definition at line 48 of file WIBEthFrame.hpp.

◆ s_num_adc_words

int dunedaq::fddetdataformats::WIBEthFrame::s_num_adc_words = s_time_samples_per_frame * s_num_channels * s_bits_per_adc / s_bits_per_word
staticconstexpr

Definition at line 51 of file WIBEthFrame.hpp.

◆ s_num_adc_words_per_ts

int dunedaq::fddetdataformats::WIBEthFrame::s_num_adc_words_per_ts = s_num_channels * s_bits_per_adc / s_bits_per_word
staticconstexpr

Definition at line 50 of file WIBEthFrame.hpp.

◆ s_num_channels

int dunedaq::fddetdataformats::WIBEthFrame::s_num_channels = s_channels_per_half_femb * s_half_fembs_per_frame
staticconstexpr

Definition at line 49 of file WIBEthFrame.hpp.

◆ s_time_samples_per_frame

int dunedaq::fddetdataformats::WIBEthFrame::s_time_samples_per_frame = 64
staticconstexpr

Definition at line 46 of file WIBEthFrame.hpp.


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