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

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.
 
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 89 of file WIB2Frame.hpp.

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

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

◆ 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 114 of file WIB2Frame.hpp.

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

◆ 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 147 of file WIB2Frame.hpp.

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

Member Data Documentation

◆ adc_words

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

Definition at line 70 of file WIB2Frame.hpp.

◆ header

Header dunedaq::fddetdataformats::WIB2Frame::header

Definition at line 69 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 71 of file WIB2Frame.hpp.


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