DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
rawdatautils
pybindsrc
TDEUnpacker.cpp
Go to the documentation of this file.
1
8
9
#include "
fddetdataformats/TDEEthFrame.hpp
"
10
#include "
daqdataformats/Fragment.hpp
"
11
12
#include <cstdint>
13
#include <pybind11/numpy.h>
14
15
namespace
py = pybind11;
16
namespace
dunedaq::rawdatautils::tde
{
17
21
uint32_t
get_n_frames
(
daqdataformats::Fragment
const
& frag){
22
return
(frag.
get_size
() -
sizeof
(
daqdataformats::FragmentHeader
)) /
sizeof
(
fddetdataformats::TDEEthFrame
);
23
}
24
30
py::array_t<uint16_t>
np_array_adc_data
(
void
* data, uint32_t n_frames){
31
32
uint32_t n_ch =
fddetdataformats::TDEEthFrame::s_num_channels
;
33
uint32_t n_smpl =
fddetdataformats::TDEEthFrame::s_time_samples_per_frame
;
34
35
py::array_t<uint16_t> result(n_ch * n_smpl * n_frames);
36
37
py::buffer_info buf_res = result.request();
38
39
auto
ptr_res =
static_cast<
uint16_t*
>
(buf_res.ptr);
40
41
for
(
size_t
i=0; i<n_frames; ++i) {
42
43
auto
fr =
reinterpret_cast<
fddetdataformats::TDEEthFrame
*
>
(
44
static_cast<
char
*
>
(data) + i *
sizeof
(
fddetdataformats::TDEEthFrame
)
45
);
46
47
for
(
size_t
j=0; j<n_smpl; ++j){
48
for
(
size_t
k=0; k<n_ch; ++k){
49
ptr_res[(n_smpl*n_ch) * i + n_ch*j + k] = fr->get_adc(k, j);
50
}
51
}
52
}
53
result.resize({n_frames*n_smpl, n_ch});
54
55
return
result;
56
}
57
63
py::array_t<long double>
np_array_timestamp_data
(
void
* data, uint32_t n_frames){
64
65
uint32_t n_smpl =
fddetdataformats::TDEEthFrame::s_time_samples_per_frame
;
66
67
py::array_t<long double> result(n_smpl*n_frames);
68
69
auto
ptr =
static_cast<
long
double
*
>
(result.request().ptr);
70
71
for
(
size_t
i=0; i<n_frames; ++i) {
72
auto
fr =
reinterpret_cast<
fddetdataformats::TDEEthFrame
*
>
(
73
static_cast<
char
*
>
(data) + i *
sizeof
(
fddetdataformats::TDEEthFrame
)
74
);
75
long
double
ts_0 = fr->
get_timestamp
();
76
for
(
size_t
j=0; j<n_smpl; ++j )
77
ptr[i*n_smpl+j] = ts_0+31.25*j;
78
}
79
80
return
result;
81
}
82
87
py::array_t<uint16_t>
np_array_adc
(
daqdataformats::Fragment
const
& frag){
88
return
np_array_adc_data
(frag.
get_data
(),
get_n_frames
(frag));
89
}
90
95
py::array_t<long double>
np_array_timestamp
(
daqdataformats::Fragment
const
& frag){
96
return
np_array_timestamp_data
(frag.
get_data
(),
get_n_frames
(frag));
97
}
98
99
}
// namespace dunedaq::rawdatautils::tde // NOLINT
Fragment.hpp
TDEEthFrame.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::tde
Definition
TDEUnpacker.cpp:16
dunedaq::rawdatautils::tde::np_array_adc
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...
Definition
TDEUnpacker.cpp:87
dunedaq::rawdatautils::tde::np_array_timestamp
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...
Definition
TDEUnpacker.cpp:95
dunedaq::rawdatautils::tde::np_array_timestamp_data
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...
Definition
TDEUnpacker.cpp:63
dunedaq::rawdatautils::tde::get_n_frames
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of TDEEthFrames in a fragment.
Definition
TDEUnpacker.cpp:21
dunedaq::rawdatautils::tde::np_array_adc_data
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 ...
Definition
TDEUnpacker.cpp:30
dunedaq::daqdataformats::FragmentHeader
The header for a DUNE Fragment.
Definition
FragmentHeader.hpp:31
dunedaq::fddetdataformats::TDEEthFrame
Struct for accessing raw TDE eth frames, as used in ProtoDUNE-II.
Definition
TDEEthFrame.hpp:42
dunedaq::fddetdataformats::TDEEthFrame::s_time_samples_per_frame
static constexpr int s_time_samples_per_frame
Definition
TDEEthFrame.hpp:48
dunedaq::fddetdataformats::TDEEthFrame::s_num_channels
static constexpr int s_num_channels
Definition
TDEEthFrame.hpp:51
dunedaq::fddetdataformats::TDEEthFrame::get_timestamp
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
Definition
TDEEthFrame.hpp:83
Generated on
for DUNE-DAQ by
1.17.0