DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIBEthUnpacker.cpp
Go to the documentation of this file.
1
11
12#include <cstdint>
13#include <pybind11/numpy.h>
14// #include <fmt/core.h>
15// #include <iostream>
16
17namespace py = pybind11;
19
25}
26
32py::array_t<uint16_t> np_array_adc_data(void* data, uint32_t n_frames){
33
36
37 py::array_t<uint16_t> result(n_ch * n_smpl * n_frames);
38
39 py::buffer_info buf_res = result.request();
40
41 auto ptr_res = static_cast<uint16_t*>(buf_res.ptr);
42
43 for (size_t i=0; i<n_frames; ++i) {
44
45 auto fr = reinterpret_cast<fddetdataformats::WIBEthFrame*>(
46 static_cast<char*>(data) + i * sizeof(fddetdataformats::WIBEthFrame)
47 );
48
49 for (size_t j=0; j<n_smpl; ++j){
50 for (size_t k=0; k<n_ch; ++k){
51 ptr_res[(n_smpl*n_ch) * i + n_ch*j + k] = fr->get_adc(k, j);
52 }
53 }
54 }
55 result.resize({n_frames*n_smpl, n_ch});
56
57 return result;
58
59}
60
66py::array_t<uint64_t> np_array_timestamp_data(void* data, uint32_t n_frames){
67
69
70 py::array_t<uint64_t> result(n_smpl*n_frames);
71
72 auto ptr = static_cast<uint64_t*>(result.request().ptr);
73
74 for (size_t i=0; i<n_frames; ++i) {
75 auto fr = reinterpret_cast<fddetdataformats::WIBEthFrame*>(
76 static_cast<char*>(data) + i * sizeof(fddetdataformats::WIBEthFrame)
77 );
78 uint64_t ts_0 = fr->get_timestamp();
79 for(size_t j=0; j<n_smpl; ++j )
80 ptr[i*n_smpl+j] = ts_0+32*j;
81 }
82
83 return result;
84}
85
90py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag){
91 return np_array_adc_data(frag.get_data(), get_n_frames(frag));
92
93}
94
99py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag){
100 return np_array_timestamp_data(frag.get_data(), get_n_frames(frag));
101}
102
103
104} // namespace dunedaq::rawdatautils::wibeth // 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:254
fragment_size_t get_size() const
Get the total size of the Fragment.
Definition Fragment.hpp:242
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
static constexpr int s_time_samples_per_frame
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment const &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment const &frag)
Unpacks a Fragment containing WIBEthFrames into a numpy array with the ADC values and dimension (numb...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of WIBEthFrames in a fragment.
py::array_t< uint16_t > np_array_adc_data(void *data, uint32_t n_frames)
Unpacks data containing WIBEthFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint64_t > np_array_timestamp_data(void *data, uint32_t n_frames)
Unpacks data containing WIBEthFrames into a numpy array with the timestamps with dimension (number of...
The header for a DUNE Fragment.