DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDEUnpacker.cpp
Go to the documentation of this file.
1
8
11
12#include <cstdint>
13#include <pybind11/numpy.h>
14
15namespace py = pybind11;
17
21uint32_t
26
32py::array_t<uint16_t>
33np_array_adc_data(void* data, uint32_t n_frames)
34{
35
38
39 py::array_t<uint16_t> result(n_ch * n_smpl * n_frames);
40
41 py::buffer_info buf_res = result.request();
42
43 auto ptr_res = static_cast<uint16_t*>(buf_res.ptr);
44
45 for (size_t i = 0; i < n_frames; ++i) {
46
47 auto fr = reinterpret_cast<fddetdataformats::TDEEthFrame*>(static_cast<char*>(data) +
49
50 for (size_t j = 0; j < n_smpl; ++j) {
51 for (size_t k = 0; k < n_ch; ++k) {
52 ptr_res[(n_smpl * n_ch) * i + n_ch * j + k] = fr->get_adc(k, j);
53 }
54 }
55 }
56 result.resize({ n_frames * n_smpl, n_ch });
57
58 return result;
59}
60
66py::array_t<long double>
67np_array_timestamp_data(void* data, uint32_t n_frames)
68{
69
71
72 py::array_t<long double> result(n_smpl * n_frames);
73
74 auto ptr = static_cast<long double*>(result.request().ptr);
75
76 for (size_t i = 0; i < n_frames; ++i) {
77 auto fr = reinterpret_cast<fddetdataformats::TDEEthFrame*>(static_cast<char*>(data) +
79 long double ts_0 = fr->get_timestamp();
80 for (size_t j = 0; j < n_smpl; ++j)
81 ptr[i * n_smpl + j] = ts_0 + 31.25 * j;
82 }
83
84 return result;
85}
86
91py::array_t<uint16_t>
93{
94 return np_array_adc_data(frag.get_data(), get_n_frames(frag));
95}
96
101py::array_t<long double>
106
107} // namespace dunedaq::rawdatautils::tde // NOLINT
C++ Representation of a DUNE Fragment, wrapping the flat byte array that is the Fragment's "actual" f...
Definition Fragment.hpp:38
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(daqdataformats::Fragment const &frag)
Unpacks a Fragment containing TDEEthFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< long double > np_array_timestamp(daqdataformats::Fragment const &frag)
Unpacks the timestamps in a Fragment containing TDEEthFrames into a numpy array with dimension (numbe...
py::array_t< long double > np_array_timestamp_data(void *data, uint32_t n_frames)
Unpacks data containing TDEEthFrames into a numpy array with the timestamps with dimension (number of...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of TDEEthFrames in a fragment.
py::array_t< uint16_t > np_array_adc_data(void *data, uint32_t n_frames)
Unpacks data containing TDEEthFrames into a numpy array with the ADC values and dimension (number of ...
The header for a DUNE Fragment.
Struct for accessing raw TDE eth frames, as used in ProtoDUNE-II.
static constexpr int s_time_samples_per_frame
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.