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

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

#include <WIB2Frame.hpp>

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

Classes

struct  Header
struct  Trailer

Public Types

using word_t = uint32_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 64-bit timestamp of the frame.
void set_timestamp (const uint64_t new_timestamp)
 Set the 64-bit timestamp of the frame.

Public Attributes

Header header
word_t adc_words [s_num_adc_words]
Trailer trailer

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_u_channels_per_femb = 40
static constexpr int s_v_channels_per_femb = 40
static constexpr int s_x_channels_per_femb = 48
static constexpr int s_channels_per_femb = s_u_channels_per_femb + s_v_channels_per_femb + s_x_channels_per_femb
static constexpr int s_fembs_per_frame = 2
static constexpr int s_num_channels = s_fembs_per_frame * s_channels_per_femb
static constexpr int s_num_adc_words = s_num_channels * s_bits_per_adc / s_bits_per_word
static constexpr int s_num_ch_per_frame = s_channels_per_femb * s_fembs_per_frame

Detailed Description

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

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

Definition at line 30 of file WIB2Frame.hpp.

Member Typedef Documentation

◆ word_t

Definition at line 38 of file WIB2Frame.hpp.

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::WIB2Frame::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:

  • 40 values from FEMB0 U channels
  • 40 values from FEMB0 V channels
  • 48 values from FEMB0 X channels (collection)
  • 40 values from FEMB1 U channels
  • 40 values from FEMB1 V channels
  • 48 values from FEMB1 X channels (collection)

Definition at line 88 of file WIB2Frame.hpp.

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

◆ get_timestamp()

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

Get the 64-bit timestamp of the frame.

Definition at line 139 of file WIB2Frame.hpp.

140 {
141 return (uint64_t)header.timestamp_1 | ((uint64_t)header.timestamp_2 << 32); // NOLINT(build/unsigned)
142 }

◆ set_adc()

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

Set the ith ADC value in the frame to val.

Definition at line 113 of file WIB2Frame.hpp.

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

◆ set_timestamp()

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

Set the 64-bit timestamp of the frame.

Definition at line 146 of file WIB2Frame.hpp.

147 {
148 header.timestamp_1 = new_timestamp;
149 header.timestamp_2 = new_timestamp >> 32;
150 }

Member Data Documentation

◆ adc_words

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

Definition at line 69 of file WIB2Frame.hpp.

◆ header

Header dunedaq::fddetdataformats::WIB2Frame::header

Definition at line 68 of file WIB2Frame.hpp.

◆ s_bits_per_adc

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

Definition at line 40 of file WIB2Frame.hpp.

◆ s_bits_per_word

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

Definition at line 41 of file WIB2Frame.hpp.

◆ s_channels_per_femb

int dunedaq::fddetdataformats::WIB2Frame::s_channels_per_femb = s_u_channels_per_femb + s_v_channels_per_femb + s_x_channels_per_femb
staticconstexpr

Definition at line 45 of file WIB2Frame.hpp.

◆ s_fembs_per_frame

int dunedaq::fddetdataformats::WIB2Frame::s_fembs_per_frame = 2
staticconstexpr

Definition at line 46 of file WIB2Frame.hpp.

◆ s_num_adc_words

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

Definition at line 48 of file WIB2Frame.hpp.

◆ s_num_ch_per_frame

int dunedaq::fddetdataformats::WIB2Frame::s_num_ch_per_frame = s_channels_per_femb * s_fembs_per_frame
staticconstexpr

Definition at line 49 of file WIB2Frame.hpp.

◆ s_num_channels

int dunedaq::fddetdataformats::WIB2Frame::s_num_channels = s_fembs_per_frame * s_channels_per_femb
staticconstexpr

Definition at line 47 of file WIB2Frame.hpp.

◆ s_u_channels_per_femb

int dunedaq::fddetdataformats::WIB2Frame::s_u_channels_per_femb = 40
staticconstexpr

Definition at line 42 of file WIB2Frame.hpp.

◆ s_v_channels_per_femb

int dunedaq::fddetdataformats::WIB2Frame::s_v_channels_per_femb = 40
staticconstexpr

Definition at line 43 of file WIB2Frame.hpp.

◆ s_x_channels_per_femb

int dunedaq::fddetdataformats::WIB2Frame::s_x_channels_per_femb = 48
staticconstexpr

Definition at line 44 of file WIB2Frame.hpp.

◆ trailer

Trailer dunedaq::fddetdataformats::WIB2Frame::trailer

Definition at line 70 of file WIB2Frame.hpp.


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