DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::rawdatautils::daphneeth Namespace Reference

Functions

uint32_t get_n_frames (daqdataformats::Fragment const &frag)
 Gets number of DAPHNEFrames in a fragment.
uint32_t get_n_frames_stream (daqdataformats::Fragment const &frag)
 Gets number of DAPHNEStreamFrames in a fragment.
py::array_t< uint8_t > np_array_channels_stream_data (void *data, int nframes)
 Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes, s_channels_per_frame).
py::array_t< uint8_t > np_array_channels_data (void *data, int nframes)
 Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).
py::array_t< uint8_t > np_array_channels (daqdataformats::Fragment &frag)
 Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions.
py::array_t< uint8_t > np_array_channels_stream (daqdataformats::Fragment &frag)
 Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensions.
py::array_t< uint16_t > np_array_adc_data (void *data, int nframes)
 Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of DAPHNEFrames, channels_per_daphne) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).
py::array_t< uint16_t > np_array_adc_stream_data (void *data, int nframes)
 Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (number of DAPHNEStreamFrames * adcs_per_channel (64), channels_per_frame (4)) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).
py::array_t< uint64_t > np_array_timestamp_data (void *data, int nframes)
 Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of DAPHNEFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).
py::array_t< uint64_t > np_array_timestamp_stream_data (void *data, int nframes)
 Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (number of DAPHNEStreamFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).
py::array_t< uint16_t > np_array_adc (daqdataformats::Fragment &frag)
 Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of DAPHNEFrames in the Fragment, 320).
py::array_t< uint16_t > np_array_adc_stream (daqdataformats::Fragment &frag)
 Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (number of DAPHNEStreamFrames in the Fragment, 4).
py::array_t< uint64_t > np_array_timestamp (daqdataformats::Fragment &frag)
 Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number of DAPHNEFrames in the Fragment).
py::array_t< uint64_t > np_array_timestamp_stream (daqdataformats::Fragment &frag)
 Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimension (number of DAPHNEStreamFrames in the Fragment).

Function Documentation

◆ get_n_frames()

uint32_t dunedaq::rawdatautils::daphneeth::get_n_frames ( daqdataformats::Fragment const & frag)

Gets number of DAPHNEFrames in a fragment.

Definition at line 23 of file DAPHNEEthUnpacker.cpp.

24{
25 return (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / sizeof(fddetdataformats::DAPHNEEthFrame);
26}
The header for a DUNE Fragment.
Struct for accessing raw DAPHNE eth frames.

◆ get_n_frames_stream()

uint32_t dunedaq::rawdatautils::daphneeth::get_n_frames_stream ( daqdataformats::Fragment const & frag)

Gets number of DAPHNEStreamFrames in a fragment.

Definition at line 32 of file DAPHNEEthUnpacker.cpp.

33{
34 return (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / sizeof(fddetdataformats::DAPHNEEthStreamFrame);
35}
Struct for accessing raw DAPHNE eth stream frames.

◆ np_array_adc()

py::array_t< uint16_t > dunedaq::rawdatautils::daphneeth::np_array_adc ( daqdataformats::Fragment & frag)

Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of DAPHNEFrames in the Fragment, 320).

Definition at line 208 of file DAPHNEEthUnpacker.cpp.

209{
210 return np_array_adc_data(frag.get_data(),
211 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
213}
void * get_data() const
Get a pointer to the data payload in the Fragmnet.
Definition Fragment.hpp:153
fragment_size_t get_size() const
Get the total size of the Fragment in bytes, including header and all payload pieces.
Definition Fragment.hpp:147
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...

◆ np_array_adc_data()

py::array_t< uint16_t > dunedaq::rawdatautils::daphneeth::np_array_adc_data ( void * data,
int nframes )

Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of DAPHNEFrames, channels_per_daphne) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).

Definition at line 111 of file DAPHNEEthUnpacker.cpp.

112{
113
114 const auto adcs_per_channel = fddetdataformats::DAPHNEEthFrame::s_num_adcs;
115
116 py::array_t<uint16_t> ret(nframes * adcs_per_channel);
117 auto ptr = static_cast<uint16_t*>(ret.request().ptr);
118 for (size_t i = 0; i < (size_t)nframes; ++i) {
119 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthFrame*>(static_cast<char*>(data) +
121 for (size_t j = 0; j < adcs_per_channel; ++j) {
122 ptr[i * adcs_per_channel + j] = fr->get_adc(j);
123 }
124 // for (size_t j=0; j<channels_per_daphne; ++j)
125 }
126 ret.resize({ nframes, adcs_per_channel });
127
128 return ret;
129}

◆ np_array_adc_stream()

py::array_t< uint16_t > dunedaq::rawdatautils::daphneeth::np_array_adc_stream ( daqdataformats::Fragment & frag)

Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (number of DAPHNEStreamFrames in the Fragment, 4).

Definition at line 220 of file DAPHNEEthUnpacker.cpp.

221{
223 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
225}
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (numb...

◆ np_array_adc_stream_data()

py::array_t< uint16_t > dunedaq::rawdatautils::daphneeth::np_array_adc_stream_data ( void * data,
int nframes )

Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (number of DAPHNEStreamFrames * adcs_per_channel (64), channels_per_frame (4)) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).

Definition at line 137 of file DAPHNEEthUnpacker.cpp.

138{
139
140 const auto channels_per_daphne = fddetdataformats::DAPHNEEthStreamFrame::s_num_channels;
142
143 py::array_t<uint16_t> ret(channels_per_daphne * nframes * adcs_per_channel);
144 auto ptr = static_cast<uint16_t*>(ret.request().ptr);
145 for (size_t i = 0; i < (size_t)nframes; ++i) {
146 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthStreamFrame*>(
147 static_cast<char*>(data) + i * sizeof(fddetdataformats::DAPHNEEthStreamFrame));
148 for (size_t j = 0; j < adcs_per_channel; ++j)
149 for (size_t k = 0; k < channels_per_daphne; ++k)
150 ptr[channels_per_daphne * (adcs_per_channel * i + j) + k] = fr->get_adc(j, k);
151 }
152 ret.resize({ nframes * adcs_per_channel, channels_per_daphne });
153
154 return ret;
155}
uint16_t get_adc(int i_adc, int i_channel) const
Get the i_adc-th ADC value of i_channel-th channel in the frame.

◆ np_array_channels()

py::array_t< uint8_t > dunedaq::rawdatautils::daphneeth::np_array_channels ( daqdataformats::Fragment & frag)

Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions.

Definition at line 87 of file DAPHNEEthUnpacker.cpp.

88{
89 return np_array_channels_data(frag.get_data(),
90 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
92}
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).

◆ np_array_channels_data()

py::array_t< uint8_t > dunedaq::rawdatautils::daphneeth::np_array_channels_data ( void * data,
int nframes )

Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes).

Definition at line 69 of file DAPHNEEthUnpacker.cpp.

70{
71
72 py::array_t<uint8_t> channels(nframes);
73 auto ptr = static_cast<uint8_t*>(channels.request().ptr);
74
75 for (size_t i = 0; i < (size_t)nframes; ++i) {
76 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthFrame*>(static_cast<char*>(data) +
78 ptr[i] = fr->get_channel();
79 }
80
81 return channels;
82}
uint8_t get_channel() const
Get the channel identifier of the frame.

◆ np_array_channels_stream()

py::array_t< uint8_t > dunedaq::rawdatautils::daphneeth::np_array_channels_stream ( daqdataformats::Fragment & frag)

Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensions.

Definition at line 98 of file DAPHNEEthUnpacker.cpp.

99{
101 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
103}
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes,...

◆ np_array_channels_stream_data()

py::array_t< uint8_t > dunedaq::rawdatautils::daphneeth::np_array_channels_stream_data ( void * data,
int nframes )

Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes, s_channels_per_frame).

Definition at line 43 of file DAPHNEEthUnpacker.cpp.

44{
45
46 const auto channels_per_daphne = fddetdataformats::DAPHNEEthStreamFrame::s_num_channels;
47 py::array_t<uint8_t> channels(channels_per_daphne * nframes);
48 auto ptr = static_cast<uint8_t*>(channels.request().ptr);
49
50 for (size_t i = 0; i < (size_t)nframes; ++i) {
51 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthStreamFrame*>(
52 static_cast<char*>(data) + i * sizeof(fddetdataformats::DAPHNEEthStreamFrame));
53
54 ptr[i * channels_per_daphne + 0] = fr->get_channel0();
55 ptr[i * channels_per_daphne + 1] = fr->get_channel1();
56 ptr[i * channels_per_daphne + 2] = fr->get_channel2();
57 ptr[i * channels_per_daphne + 3] = fr->get_channel3();
58 }
59 channels.resize({ nframes, channels_per_daphne });
60
61 return channels;
62}
uint8_t get_channel0() const
Get the channel 0 from the DAPHNE Stream frame header.

◆ np_array_timestamp()

py::array_t< uint64_t > dunedaq::rawdatautils::daphneeth::np_array_timestamp ( daqdataformats::Fragment & frag)

Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number of DAPHNEFrames in the Fragment).

Definition at line 232 of file DAPHNEEthUnpacker.cpp.

233{
234 return np_array_timestamp_data(frag.get_data(),
235 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
237}
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...

◆ np_array_timestamp_data()

py::array_t< uint64_t > dunedaq::rawdatautils::daphneeth::np_array_timestamp_data ( void * data,
int nframes )

Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of DAPHNEFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).

Definition at line 164 of file DAPHNEEthUnpacker.cpp.

165{
166
167 py::array_t<uint64_t> ret(nframes);
168 auto ptr = static_cast<uint64_t*>(ret.request().ptr);
169 for (size_t i = 0; i < (size_t)nframes; ++i) {
170 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthFrame*>(static_cast<char*>(data) +
172 ptr[i] = fr->get_timestamp();
173 }
174
175 return ret;
176}
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.

◆ np_array_timestamp_stream()

py::array_t< uint64_t > dunedaq::rawdatautils::daphneeth::np_array_timestamp_stream ( daqdataformats::Fragment & frag)

Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimension (number of DAPHNEStreamFrames in the Fragment).

Definition at line 244 of file DAPHNEEthUnpacker.cpp.

245{
247 (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) /
249}
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (num...

◆ np_array_timestamp_stream_data()

py::array_t< uint64_t > dunedaq::rawdatautils::daphneeth::np_array_timestamp_stream_data ( void * data,
int nframes )

Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (number of DAPHNEStreamFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds).

Definition at line 184 of file DAPHNEEthUnpacker.cpp.

185{
186
188 const size_t ticks_per_adc = 1;
189
190 py::array_t<uint64_t> ret(nframes * adcs_per_channel);
191
192 auto ptr = static_cast<uint64_t*>(ret.request().ptr);
193 for (size_t i = 0; i < (size_t)nframes; ++i) {
194 auto fr = reinterpret_cast<fddetdataformats::DAPHNEEthStreamFrame*>(
195 static_cast<char*>(data) + i * sizeof(fddetdataformats::DAPHNEEthStreamFrame));
196 for (size_t j = 0; j < adcs_per_channel; ++j)
197 ptr[i * adcs_per_channel + j] = fr->get_timestamp() + j * ticks_per_adc;
198 }
199
200 return ret;
201}
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.