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

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

#include <DAPHNEEthStreamFrame.hpp>

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

Classes

struct  ChannelWord
 
struct  Header
 

Public Types

typedef uint64_t word_t
 

Public Member Functions

uint16_t get_adc (uint i, uint chn) const
 Get the i ADC value of chn in the frame.
 
void set_adc (uint chn, uint i, uint16_t val)
 Set the i ADC value of chn 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 (uint ch) const
 Get the channel identifier of the frame.
 
void set_channel (uint channel_index, const uint8_t new_channel_val)
 Set the channel identifier of the frame.
 
uint8_t get_channel0 () const
 Get the channel 0 from the DAPHNE Stream frame header

 
uint8_t get_channel1 () const
 Get the channel 1 from the DAPHNE Stream frame header

 
uint8_t get_channel2 () const
 Get the channel 2 from the DAPHNE Stream frame header

 
uint8_t get_channel3 () const
 Get the channel 3 from the DAPHNE Stream frame header

 

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_adcs_per_channel = 280
 
static constexpr int s_num_channels = 4
 
static constexpr int s_num_adc_words = s_num_channels * s_adcs_per_channel * s_bits_per_adc / s_bits_per_word
 

Detailed Description

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

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

Definition at line 34 of file DAPHNEEthStreamFrame.hpp.

Member Typedef Documentation

◆ word_t

Member Function Documentation

◆ get_adc()

uint16_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_adc ( uint i,
uint chn ) const
inline

Get the i ADC value of chn in the frame.

Definition at line 79 of file DAPHNEEthStreamFrame.hpp.

80{
81
82 if (i >= s_adcs_per_channel)
83 throw std::out_of_range("ADC index out of range");
84
85 if (chn >= s_num_channels)
86 throw std::out_of_range("Channel index out of range");
87
88 // find absolute index in frame
89 uint j = i*s_num_channels+chn;
90 // The index of the first (and sometimes only) word containing the required ADC value
91 uint word_index = s_bits_per_adc * j / s_bits_per_word;
92 assert(word_index < s_num_adc_words);
93 // Where in the word the lowest bit of our ADC value is located
94 int first_bit_position = (s_bits_per_adc * j) % s_bits_per_word;
95 // How many bits of our desired ADC are located in the `word_index`th word
96 int bits_from_first_word = std::min(s_bits_per_adc, s_bits_per_word - first_bit_position);
97 uint16_t adc = adc_words[word_index] >> first_bit_position; // NOLINT(build/unsigned)
98
99 if (bits_from_first_word < s_bits_per_adc) {
100 assert(word_index + 1 < s_num_adc_words);
101 adc |= adc_words[word_index + 1] << bits_from_first_word;
102 }
103 // Mask out all but the lowest 14 bits;
104 return adc & 0x3FFFu;
105}

◆ get_channel()

uint8_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_channel ( uint ch) const
inline

Get the channel identifier of the frame.

Definition at line 157 of file DAPHNEEthStreamFrame.hpp.

158 {
159 if (ch >= s_num_channels)
160 throw std::out_of_range("Channel index out of range");
161
162 return header.channel_words[ch].channel ; // NOLINT(build/unsigned)
163 }

◆ get_channel0()

uint8_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_channel0 ( ) const
inline

Get the channel 0 from the DAPHNE Stream frame header

Definition at line 177 of file DAPHNEEthStreamFrame.hpp.

177{ return header.channel_words[0].channel; } // NOLINT(build/unsigned)

◆ get_channel1()

uint8_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_channel1 ( ) const
inline

Get the channel 1 from the DAPHNE Stream frame header

Definition at line 181 of file DAPHNEEthStreamFrame.hpp.

181{ return header.channel_words[1].channel; } // NOLINT(build/unsigned)

◆ get_channel2()

uint8_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_channel2 ( ) const
inline

Get the channel 2 from the DAPHNE Stream frame header

Definition at line 185 of file DAPHNEEthStreamFrame.hpp.

185{ return header.channel_words[2].channel; } // NOLINT(build/unsigned)

◆ get_channel3()

uint8_t dunedaq::fddetdataformats::DAPHNEEthStreamFrame::get_channel3 ( ) const
inline

Get the channel 3 from the DAPHNE Stream frame header

Definition at line 189 of file DAPHNEEthStreamFrame.hpp.

189{ return header.channel_words[3].channel; } // NOLINT(build/unsigned)

◆ get_timestamp()

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

Get the starting 64-bit timestamp of the frame.

Definition at line 143 of file DAPHNEEthStreamFrame.hpp.

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

◆ set_adc()

void dunedaq::fddetdataformats::DAPHNEEthStreamFrame::set_adc ( uint chn,
uint i,
uint16_t val )
inline

Set the i ADC value of chn in the frame to val.

Definition at line 110 of file DAPHNEEthStreamFrame.hpp.

111{
112 if (chn >= s_num_channels)
113 throw std::out_of_range("Channel index out of range");
114
115 if (i >= s_adcs_per_channel)
116 throw std::out_of_range("ADC index out of range");
117
118 if (val >= (1 << s_bits_per_adc))
119 throw std::out_of_range("ADC value out of range");
120
121
122 // find absolute index in frame
123 uint j = i*s_num_channels+chn;
124 // The index of the first (and sometimes only) word containing the required ADC value
125 int word_index = s_bits_per_adc * j / 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 * j) % 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
140 }

◆ set_channel()

void dunedaq::fddetdataformats::DAPHNEEthStreamFrame::set_channel ( uint channel_index,
const uint8_t new_channel_val )
inline

Set the channel identifier of the frame.

Definition at line 167 of file DAPHNEEthStreamFrame.hpp.

168 {
169 if (channel_index >= s_num_channels)
170 throw std::out_of_range("Channel index out of range");
171
172 header.channel_words[channel_index].channel = new_channel_val;
173 }

◆ set_timestamp()

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

Set the starting 64-bit timestamp of the frame.

Definition at line 150 of file DAPHNEEthStreamFrame.hpp.

151 {
152 daq_header.timestamp = new_timestamp;
153 }

Member Data Documentation

◆ adc_words

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

Definition at line 70 of file DAPHNEEthStreamFrame.hpp.

◆ daq_header

detdataformats::DAQEthHeader dunedaq::fddetdataformats::DAPHNEEthStreamFrame::daq_header

Definition at line 68 of file DAPHNEEthStreamFrame.hpp.

◆ header

Header dunedaq::fddetdataformats::DAPHNEEthStreamFrame::header

Definition at line 69 of file DAPHNEEthStreamFrame.hpp.

◆ s_adcs_per_channel

int dunedaq::fddetdataformats::DAPHNEEthStreamFrame::s_adcs_per_channel = 280
staticconstexpr

Definition at line 49 of file DAPHNEEthStreamFrame.hpp.

◆ s_bits_per_adc

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

Definition at line 47 of file DAPHNEEthStreamFrame.hpp.

◆ s_bits_per_word

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

Definition at line 48 of file DAPHNEEthStreamFrame.hpp.

◆ s_num_adc_words

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

Definition at line 51 of file DAPHNEEthStreamFrame.hpp.

◆ s_num_channels

int dunedaq::fddetdataformats::DAPHNEEthStreamFrame::s_num_channels = 4
staticconstexpr

Definition at line 50 of file DAPHNEEthStreamFrame.hpp.

◆ version

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

Definition at line 45 of file DAPHNEEthStreamFrame.hpp.


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