DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
unpack.cpp
Go to the documentation of this file.
1
17
18#include <pybind11/numpy.h>
19#include <pybind11/pybind11.h>
20#include <pybind11/stl.h>
21
22#include <fmt/core.h>
23
24namespace py = pybind11;
25
26namespace dunedaq {
27namespace rawdatautils {
28
30 uint64_t* data = static_cast<uint64_t*>(frag.get_data());
31 size_t data_size = (frag.get_size() - sizeof(daqdataformats::FragmentHeader))/8;
32
33 for ( size_t i(0); i<data_size; ++i) {
34 fmt::print("{:06d} 0x{:016x}\n", i, data[i]);
35 }
36
37}
38
39
40namespace wib {
41 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment& frag);
42 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
43 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment& frag);
44 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
45}
46
47namespace wib2 {
48 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
49 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
50 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
51 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag);
52 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
53}
54
55namespace wibeth {
56 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
57 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
58 extern py::array_t<uint16_t> np_array_adc_data(void* data, uint32_t n_frames);
59 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment const& frag);
60 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, uint32_t n_frames);
61}
62
63
64namespace daphne {
65 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
66 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment& frag);
67 extern py::array_t<uint8_t> np_array_channels(daqdataformats::Fragment& frag);
68 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
69 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment& frag);
70 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
71 extern py::array_t<uint8_t> np_array_channels_data(void* data, int nframes);
72
73 extern uint32_t get_n_frames_stream(daqdataformats::Fragment const& frag);
74 extern py::array_t<uint16_t> np_array_adc_stream(daqdataformats::Fragment& frag);
75 extern py::array_t<uint8_t> np_array_channels_stream(daqdataformats::Fragment& frag);
76 extern py::array_t<uint16_t> np_array_adc_stream_data(void* data, int nframes);
77 extern py::array_t<uint64_t> np_array_timestamp_stream(daqdataformats::Fragment& frag);
78 extern py::array_t<uint64_t> np_array_timestamp_stream_data(void* data, int nframes);
79 extern py::array_t<uint8_t> np_array_channels_stream_data(void* data, int nframes);
80
81}
82
83namespace daphneeth {
84 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
85 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment& frag);
86 extern py::array_t<uint8_t> np_array_channels(daqdataformats::Fragment& frag);
87 extern py::array_t<uint16_t> np_array_adc_data(void* data, int nframes);
88 extern py::array_t<uint64_t> np_array_timestamp(daqdataformats::Fragment& frag);
89 extern py::array_t<uint64_t> np_array_timestamp_data(void* data, int nframes);
90 extern py::array_t<uint8_t> np_array_channels_data(void* data, int nframes);
91
92 extern uint32_t get_n_frames_stream(daqdataformats::Fragment const& frag);
93 extern py::array_t<uint16_t> np_array_adc_stream(daqdataformats::Fragment& frag);
94 extern py::array_t<uint8_t> np_array_channels_stream(daqdataformats::Fragment& frag);
95 extern py::array_t<uint16_t> np_array_adc_stream_data(void* data, int nframes);
96 extern py::array_t<uint64_t> np_array_timestamp_stream(daqdataformats::Fragment& frag);
97 extern py::array_t<uint64_t> np_array_timestamp_stream_data(void* data, int nframes);
98 extern py::array_t<uint8_t> np_array_channels_stream_data(void* data, int nframes);
99
100}
101
102namespace tde {
103 extern uint32_t get_n_frames(daqdataformats::Fragment const& frag);
104 extern py::array_t<uint16_t> np_array_adc(daqdataformats::Fragment const& frag);
105 extern py::array_t<uint16_t> np_array_adc_data(void* data, uint32_t n_frames);
106 extern py::array_t<long double> np_array_timestamp(daqdataformats::Fragment const& frag);
107 extern py::array_t<long double> np_array_timestamp_data(void* data, uint32_t n_frames);
108
109}
110
111namespace unpack {
112namespace python {
113
114void
115register_unpack(py::module& m) {
116
117 m.def("print_hex_fragment", &print_hex_fragment);
118
119 py::module_ wib_module = m.def_submodule("wib");
120 wib_module.def("np_array_adc", &wib::np_array_adc);
121 wib_module.def("np_array_timestamp", &wib::np_array_timestamp);
122 wib_module.def("np_array_adc_data", &wib::np_array_adc_data);
123 wib_module.def("np_array_timestamp_data", &wib::np_array_timestamp_data);
124
125 py::module_ wib2_module = m.def_submodule("wib2");
126 wib2_module.def("get_n_frames", &wib2::get_n_frames);
127 wib2_module.def("np_array_adc", &wib2::np_array_adc);
128 wib2_module.def("np_array_timestamp", &wib2::np_array_timestamp);
129 wib2_module.def("np_array_adc_data", &wib2::np_array_adc_data);
130 wib2_module.def("np_array_timestamp_data", &wib2::np_array_timestamp_data);
131
132 py::module_ wibeth_module = m.def_submodule("wibeth");
133 wibeth_module.def("get_n_frames", &wibeth::get_n_frames);
134 wibeth_module.def("np_array_adc", &wibeth::np_array_adc);
135 wibeth_module.def("np_array_timestamp", &wibeth::np_array_timestamp);
136 wibeth_module.def("np_array_adc_data", &wibeth::np_array_adc_data);
137 wibeth_module.def("np_array_timestamp_data", &wibeth::np_array_timestamp_data);
138
139 py::module_ daphne_module = m.def_submodule("daphne");
140 daphne_module.def("get_n_frames", &daphne::get_n_frames);
141 daphne_module.def("np_array_adc", &daphne::np_array_adc);
142 daphne_module.def("np_array_timestamp", &daphne::np_array_timestamp);
143 daphne_module.def("np_array_adc_data", &daphne::np_array_adc_data);
144 daphne_module.def("np_array_timestamp_data", &daphne::np_array_timestamp_data);
145 daphne_module.def("np_array_channels_data", &daphne::np_array_channels_data);
146 daphne_module.def("np_array_channels", &daphne::np_array_channels);
147
148 daphne_module.def("get_n_frames_stream", &daphne::get_n_frames_stream);
149 daphne_module.def("np_array_adc_stream", &daphne::np_array_adc_stream);
150 daphne_module.def("np_array_timestamp_stream", &daphne::np_array_timestamp_stream);
151 daphne_module.def("np_array_adc_stream_data", &daphne::np_array_adc_stream_data);
152 daphne_module.def("np_array_timestamp_stream_data", &daphne::np_array_timestamp_stream_data);
153 daphne_module.def("np_array_channels_stream_data", &daphne::np_array_channels_stream_data);
154 daphne_module.def("np_array_channels_stream", &daphne::np_array_channels_stream);
155
156 py::module_ daphneeth_module = m.def_submodule("daphneeth");
157 daphneeth_module.def("get_n_frames", &daphneeth::get_n_frames);
158 daphneeth_module.def("np_array_adc", &daphneeth::np_array_adc);
159 daphneeth_module.def("np_array_timestamp", &daphneeth::np_array_timestamp);
160 daphneeth_module.def("np_array_adc_data", &daphneeth::np_array_adc_data);
161 daphneeth_module.def("np_array_timestamp_data", &daphneeth::np_array_timestamp_data);
162 daphneeth_module.def("np_array_channels_data", &daphneeth::np_array_channels_data);
163 daphneeth_module.def("np_array_channels", &daphneeth::np_array_channels);
164
165 daphneeth_module.def("get_n_frames_stream", &daphneeth::get_n_frames_stream);
166 daphneeth_module.def("np_array_adc_stream", &daphneeth::np_array_adc_stream);
167 daphneeth_module.def("np_array_timestamp_stream", &daphneeth::np_array_timestamp_stream);
168 daphneeth_module.def("np_array_adc_stream_data", &daphneeth::np_array_adc_stream_data);
169 daphneeth_module.def("np_array_timestamp_stream_data", &daphneeth::np_array_timestamp_stream_data);
170 daphneeth_module.def("np_array_channels_stream_data", &daphneeth::np_array_channels_stream_data);
171 daphneeth_module.def("np_array_channels_stream", &daphneeth::np_array_channels_stream);
172
173 py::module_ tde_module = m.def_submodule("tde");
174 tde_module.def("get_n_frames", &tde::get_n_frames);
175 tde_module.def("np_array_adc", &tde::np_array_adc);
176 tde_module.def("np_array_timestamp", &tde::np_array_timestamp);
177 tde_module.def("np_array_adc_data", &tde::np_array_adc_data);
178 tde_module.def("np_array_timestamp_data", &tde::np_array_timestamp_data);
179
180}
181
182} // namespace python
183} // namespace rawdatautils
184} // namespace dunedaq
185}
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
dict unpack(dict j, str block)
py::array_t< uint16_t > np_array_adc_stream(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimensi...
py::array_t< uint8_t > np_array_channels_stream(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensi...
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (n...
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (nu...
py::array_t< uint64_t > np_array_timestamp_stream(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimensio...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes)
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEStreamFrames into a numpy array with dimensions (nframes,...
py::array_t< uint8_t > np_array_channels(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &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 &frag)
Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint16_t > np_array_adc_stream(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEStreamFrames into a numpy array with the ADC values and dimensi...
uint32_t get_n_frames(daqdataformats::Fragment const &frag)
Gets number of DAPHNEFrames in a fragment
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number o...
py::array_t< uint8_t > np_array_channels_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEFrames into a numpy array with dimensions (nframes)
py::array_t< uint8_t > np_array_channels(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEFrames into a numpy array with dimensions
uint32_t get_n_frames_stream(daqdataformats::Fragment const &frag)
Gets number of DAPHNEStreamFrames in a fragment
py::array_t< uint64_t > np_array_timestamp_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the timestamps with dimension (number of...
py::array_t< uint16_t > np_array_adc_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the ADC values and dimension (nu...
py::array_t< uint8_t > np_array_channels_stream(daqdataformats::Fragment &frag)
Unpacks channel numbers for Fragment that contains DAPHNEStreamFrames into a numpy array with dimensi...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing DAPHNEFrames into a numpy array with the ADC values and dimension (number of ...
py::array_t< uint16_t > np_array_adc(daqdataformats::Fragment &frag)
Unpacks a Fragment containing DAPHNEFrames into a numpy array with the ADC values and dimension (numb...
py::array_t< uint8_t > np_array_channels_stream_data(void *data, int nframes)
Unpacks channel numbers for DAPHNEEthStreamFrames into a numpy array with dimensions (nframes,...
py::array_t< uint64_t > np_array_timestamp_stream_data(void *data, int nframes)
Unpacks data containing DAPHNEStreamFrames into a numpy array with the timestamps with dimension (n...
py::array_t< uint64_t > np_array_timestamp_stream(daqdataformats::Fragment &frag)
Unpacks the timestamps in a Fragment containing DAPHNEStreamFrames into a numpy array with dimensio...
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 ...
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.
py::array_t< uint64_t > np_array_timestamp(daqdataformats::Fragment &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 &frag)
Unpacks a Fragment containing WIBFrames 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 WIBFrames into a numpy array with the timestamps with dimension (number of WI...
py::array_t< uint16_t > np_array_adc_data(void *data, int nframes)
Unpacks data containing WIBFrames into a numpy array with the ADC values and dimension (number of WIB...
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...
void print_hex_fragment(daqdataformats::Fragment const &frag)
Definition unpack.cpp:29
The DUNE-DAQ namespace.
Definition wib.pb.cc:23
The header for a DUNE Fragment.