DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::rawdatautils::wib Namespace Reference

Functions

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 of WIBFrames in the Fragment, 256)
 
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 WIBFrames, 256) Warning: It doesn't check that nframes is a sensible value (can read out of bounds)
 
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 of WIBFrames in the Fragment)
 
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 WIBFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds)
 

Function Documentation

◆ np_array_adc()

py::array_t< uint16_t > dunedaq::rawdatautils::wib::np_array_adc ( daqdataformats::Fragment & frag)
extern

Unpacks a Fragment containing WIBFrames into a numpy array with the ADC values and dimension (number of WIBFrames in the Fragment, 256)

Definition at line 56 of file WIBUnpacker.cpp.

56 {
57 return np_array_adc_data(frag.get_data(), (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / sizeof(fddetdataformats::WIBFrame));
58}
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
The header for a DUNE Fragment.

◆ np_array_adc_data()

py::array_t< uint16_t > dunedaq::rawdatautils::wib::np_array_adc_data ( void * data,
int nframes )
extern

Unpacks data containing WIBFrames into a numpy array with the ADC values and dimension (number of WIBFrames, 256) Warning: It doesn't check that nframes is a sensible value (can read out of bounds)

Definition at line 23 of file WIBUnpacker.cpp.

23 {
24 py::array_t<uint16_t> ret(256 * nframes);
25 auto ptr = static_cast<uint16_t*>(ret.request().ptr);
26 for (size_t i=0; i<(size_t)nframes; ++i) {
27 auto fr = reinterpret_cast<fddetdataformats::WIBFrame*>(static_cast<char*>(data) + i * sizeof(fddetdataformats::WIBFrame));
28 for (size_t j=0; j<256; ++j)
29 ptr[256 * i + j] = fr->get_channel(j);
30 }
31 ret.resize({nframes, 256});
32
33 return ret;
34}
uint16_t get_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:381

◆ np_array_timestamp()

py::array_t< uint64_t > dunedaq::rawdatautils::wib::np_array_timestamp ( daqdataformats::Fragment & frag)
extern

Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number of WIBFrames in the Fragment)

Definition at line 64 of file WIBUnpacker.cpp.

64 {
65 return np_array_timestamp_data(frag.get_data(), (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / sizeof(fddetdataformats::WIBFrame));
66}

◆ np_array_timestamp_data()

py::array_t< uint64_t > dunedaq::rawdatautils::wib::np_array_timestamp_data ( void * data,
int nframes )
extern

Unpacks data containing WIBFrames into a numpy array with the timestamps with dimension (number of WIBFrames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds)

Definition at line 41 of file WIBUnpacker.cpp.

41 {
42 py::array_t<uint64_t> ret(nframes);
43 auto ptr = static_cast<uint64_t*>(ret.request().ptr);
44 for (size_t i=0; i<(size_t)nframes; ++i) {
45 auto fr = reinterpret_cast<fddetdataformats::WIBFrame*>(static_cast<char*>(data) + i * sizeof(fddetdataformats::WIBFrame));
46 ptr[i] = fr->get_timestamp();
47 }
48
49 return ret;
50}