DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIB2Unpacker.cpp
Go to the documentation of this file.
1
11
12#include <cstdint>
13#include <pybind11/numpy.h>
14
15namespace py = pybind11;
17
23}
24
30py::array_t<uint16_t> np_array_adc_data(void* data, int nframes){
31 py::array_t<uint16_t> ret(256 * nframes);
32 auto ptr = static_cast<uint16_t*>(ret.request().ptr);
33 for (size_t i=0; i<(size_t)nframes; ++i) {
34 auto fr = reinterpret_cast<fddetdataformats::WIB2Frame*>(static_cast<char*>(data) + i * sizeof(fddetdataformats::WIB2Frame));
35 for (size_t j=0; j<256; ++j)
36 ptr[256 * i + j] = fr->get_adc(j);
37 }
38 ret.resize({nframes, 256});
39
40 return ret;
41}
42
48py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes){
49 py::array_t<uint64_t> ret(nframes);
50 auto ptr = static_cast<uint64_t*>(ret.request().ptr);
51 for (size_t i=0; i<(size_t)nframes; ++i) {
52 auto fr = reinterpret_cast<fddetdataformats::WIB2Frame*>(static_cast<char*>(data) + i * sizeof(fddetdataformats::WIB2Frame));
53 ptr[i] = fr->get_timestamp();
54 }
55
56 return ret;
57}
58
63py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag){
64 return np_array_adc_data(frag.get_data(), get_n_frames(frag));
65}
66
71py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag){
72 return np_array_timestamp_data(frag.get_data(), get_n_frames(frag));
73}
74
75
76} // namespace dunedaq::rawdatautils::wib2 // 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 v2 frames, as used in ProtoDUNE-SP-II.
Definition WIB2Frame.hpp:31
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.
Definition WIB2Frame.hpp:89
uint64_t get_timestamp() const
Get the 64-bit timestamp of the frame.
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing WIB2Frames into a numpy array with the ADC values and dimension (number of WI...
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 WIB2Frames into a numpy array with the ADC values and dimension (number...
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing WIB2Frames into a numpy array with the timestamps with dimension (number of W...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of WIB2Frames in a fragment.
The header for a DUNE Fragment.