DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
rawdatautils
pybindsrc
WIBEthUnpacker.cpp
Go to the documentation of this file.
1
8
9
#include "
daqdataformats/Fragment.hpp
"
10
#include "
fddetdataformats/WIBEthFrame.hpp
"
11
12
#include <cstdint>
13
#include <pybind11/numpy.h>
14
// #include <fmt/core.h>
15
// #include <iostream>
16
17
namespace
py = pybind11;
18
namespace
dunedaq::rawdatautils::wibeth
{
19
23
uint32_t
24
get_n_frames
(
daqdataformats::Fragment
const
& frag)
25
{
26
return
(frag.
get_size
() -
sizeof
(
daqdataformats::FragmentHeader
)) /
sizeof
(
fddetdataformats::WIBEthFrame
);
27
}
28
34
py::array_t<uint16_t>
35
np_array_adc_data
(
void
* data, uint32_t n_frames)
36
{
37
38
uint32_t n_ch =
fddetdataformats::WIBEthFrame::s_num_channels
;
39
uint32_t n_smpl =
fddetdataformats::WIBEthFrame::s_time_samples_per_frame
;
40
41
py::array_t<uint16_t> result(n_ch * n_smpl * n_frames);
42
43
py::buffer_info buf_res = result.request();
44
45
auto
ptr_res =
static_cast<
uint16_t*
>
(buf_res.ptr);
46
47
for
(
size_t
i = 0; i < n_frames; ++i) {
48
49
auto
fr =
reinterpret_cast<
fddetdataformats::WIBEthFrame
*
>
(
static_cast<
char
*
>
(data) +
50
i *
sizeof
(
fddetdataformats::WIBEthFrame
));
51
52
for
(
size_t
j = 0; j < n_smpl; ++j) {
53
for
(
size_t
k = 0; k < n_ch; ++k) {
54
ptr_res[(n_smpl * n_ch) * i + n_ch * j + k] = fr->get_adc(k, j);
55
}
56
}
57
}
58
result.resize({ n_frames * n_smpl, n_ch });
59
60
return
result;
61
}
62
68
py::array_t<uint64_t>
69
np_array_timestamp_data
(
void
* data, uint32_t n_frames)
70
{
71
72
uint32_t n_smpl =
fddetdataformats::WIBEthFrame::s_time_samples_per_frame
;
73
74
py::array_t<uint64_t> result(n_smpl * n_frames);
75
76
auto
ptr =
static_cast<
uint64_t*
>
(result.request().ptr);
77
78
for
(
size_t
i = 0; i < n_frames; ++i) {
79
auto
fr =
reinterpret_cast<
fddetdataformats::WIBEthFrame
*
>
(
static_cast<
char
*
>
(data) +
80
i *
sizeof
(
fddetdataformats::WIBEthFrame
));
81
uint64_t ts_0 = fr->
get_timestamp
();
82
for
(
size_t
j = 0; j < n_smpl; ++j)
83
ptr[i * n_smpl + j] = ts_0 + 32 * j;
84
}
85
86
return
result;
87
}
88
93
py::array_t<uint16_t>
94
np_array_adc
(
daqdataformats::Fragment
const
& frag)
95
{
96
return
np_array_adc_data
(frag.
get_data
(),
get_n_frames
(frag));
97
}
98
103
py::array_t<uint64_t>
104
np_array_timestamp
(
daqdataformats::Fragment
const
& frag)
105
{
106
return
np_array_timestamp_data
(frag.
get_data
(),
get_n_frames
(frag));
107
}
108
109
}
// namespace dunedaq::rawdatautils::wibeth // NOLINT
Fragment.hpp
WIBEthFrame.hpp
dunedaq::daqdataformats::Fragment
C++ Representation of a DUNE Fragment, wrapping the flat byte array that is the Fragment's "actual" f...
Definition
Fragment.hpp:38
dunedaq::daqdataformats::Fragment::get_data
void * get_data() const
Get a pointer to the data payload in the Fragmnet.
Definition
Fragment.hpp:153
dunedaq::daqdataformats::Fragment::get_size
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
dunedaq::rawdatautils::wibeth
Definition
unpack.cpp:38
dunedaq::rawdatautils::wibeth::np_array_timestamp
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...
Definition
WIBEthUnpacker.cpp:104
dunedaq::rawdatautils::wibeth::np_array_adc
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...
Definition
WIBEthUnpacker.cpp:94
dunedaq::rawdatautils::wibeth::get_n_frames
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of WIBEthFrames in a fragment.
Definition
WIBEthUnpacker.cpp:24
dunedaq::rawdatautils::wibeth::np_array_adc_data
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 ...
Definition
WIBEthUnpacker.cpp:35
dunedaq::rawdatautils::wibeth::np_array_timestamp_data
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...
Definition
WIBEthUnpacker.cpp:69
dunedaq::daqdataformats::FragmentHeader
The header for a DUNE Fragment.
Definition
FragmentHeader.hpp:31
dunedaq::fddetdataformats::WIBEthFrame
struct for accessing raw WIB eth frames, as used in ProtoDUNE-II
Definition
WIBEthFrame.hpp:40
dunedaq::fddetdataformats::WIBEthFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
WIBEthFrame.hpp:93
dunedaq::fddetdataformats::WIBEthFrame::s_time_samples_per_frame
static constexpr int s_time_samples_per_frame
Definition
WIBEthFrame.hpp:47
dunedaq::fddetdataformats::WIBEthFrame::s_num_channels
static constexpr int s_num_channels
Definition
WIBEthFrame.hpp:50
Generated on
for DUNE-DAQ by
1.18.0