DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEEthFrame.hpp
Go to the documentation of this file.
1
14
15#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
16#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
17
20
22
23#include <algorithm> // For std::min
24#include <cassert> // For assert()
25#include <cstdint> // For uint32_t etc
26#include <cstdio>
27#include <cstdlib>
28#include <limits>
29#include <stdexcept> // For std::out_of_range
30
32
33// NOLINTBEGIN(build/unsigned)
34
42{
43 // The definition of the format is in terms of 64-bit words
44 using word_t = uint64_t;
45
46 static constexpr int s_bits_per_adc = 14;
47 static constexpr int s_bits_per_word = 8 * sizeof(word_t);
48 static constexpr int s_time_samples_per_frame = 64;
49 static constexpr int s_channels_per_half_femb = 64;
50 static constexpr int s_half_fembs_per_frame = 1;
53
55 {
56 static constexpr size_t s_expected_bytes { 8 + 8 }; // bitfields + TAItime
57
58 uint64_t reserved : 26;
59 uint64_t tde_errors : 16;
60 uint64_t tde_header : 10;
61 uint64_t version : 4;
62 uint64_t channel : 8;
63 uint64_t TAItime : 64;
64 };
65 static_assert(sizeof(TDEEthHeader) == TDEEthHeader::s_expected_bytes);
66
68
69
77 uint16_t get_adc(int i_channel, int i_sample = 0) const;
78
80 void set_adc(int i_channel, int i_sample, uint16_t val);
81
83 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
84
86 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
87
89 uint8_t get_channel() const { return header.channel; }
90
92 void set_channel(const uint8_t new_channel) { header.channel = new_channel; }
93
94 bool operator<(const TDEEthFrame& other) const {
95 return this->get_timestamp() < other.get_timestamp();
96 }
97
101};
102
103 static_assert(std::endian::native == std::endian::little,
104 "The TDEEthFrame bitfield layout assumes little-endian architecture");
105
106 static_assert(AdaptableFrameConcept<TDEEthFrame>, "TDEEthFrame does not satisfy the AdaptableFrameConcept");
107
108} // namespace dunedaq::fddetdataformats
109
110#include "detail/TDEEthFrame.hxx"
111
112// NOLINTEND(build/unsigned)
113
114#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDEETHFRAME_HPP_
DAQEthHeader is a versioned and unified structure for every FE electronics.
Struct for accessing raw TDE eth frames, as used in ProtoDUNE-II.
static constexpr int s_channels_per_half_femb
static constexpr size_t s_expected_bytes
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
uint16_t get_adc(int i_channel, int i_sample=0) const
Get the i_channel-th ADC value in the i_sample-th time sample.
void set_adc(int i_channel, int i_sample, uint16_t val)
Set the i_channel-th ADC value in the i_sample-th time sample to val.
static constexpr int s_time_samples_per_frame
uint8_t get_channel() const
Get the channel identifier of the frame.
static constexpr int s_num_adc_words_per_ts
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
detdataformats::DAQEthHeader daq_header
bool operator<(const TDEEthFrame &other) const
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
word_t adc_words[s_time_samples_per_frame][s_num_adc_words_per_ts]
static constexpr int s_half_fembs_per_frame