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

Functions

uint32_t get_n_frames (daqdataformats::Fragment const &frag)
 Gets number of WIB2Frames in a fragment.
 
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 of WIB2Frames in the Fragment, 256)
 
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 WIB2Frames, 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 const &frag)
 Unpacks the timestamps in a Fragment containing WIBFrames into a numpy array with dimension (number of WIB2Frames in the Fragment)
 
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 WIB2Frames) Warning: It doesn't check that nframes is a sensible value (can read out of bounds)
 

Function Documentation

◆ get_n_frames()

uint32_t dunedaq::rawdatautils::wib2::get_n_frames ( daqdataformats::Fragment const & frag)
extern

Gets number of WIB2Frames in a fragment.

Definition at line 21 of file WIB2Unpacker.cpp.

21 {
22 return (frag.get_size() - sizeof(daqdataformats::FragmentHeader)) / sizeof(fddetdataformats::WIB2Frame);
23}
Class for accessing raw WIB v2 frames, as used in ProtoDUNE-SP-II.
Definition WIB2Frame.hpp:31
The header for a DUNE Fragment.

◆ np_array_adc()

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

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

Definition at line 63 of file WIB2Unpacker.cpp.

63 {
64 return np_array_adc_data(frag.get_data(), get_n_frames(frag));
65}

◆ np_array_adc_data()

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

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

Definition at line 30 of file WIB2Unpacker.cpp.

30 {
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}
uint16_t get_adc(int i) const
Get the ith ADC value in the frame.
Definition WIB2Frame.hpp:89

◆ np_array_timestamp()

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

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

Definition at line 71 of file WIB2Unpacker.cpp.

71 {
72 return np_array_timestamp_data(frag.get_data(), get_n_frames(frag));
73}

◆ np_array_timestamp_data()

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

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

Definition at line 48 of file WIB2Unpacker.cpp.

48 {
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}
uint64_t get_timestamp() const
Get the 64-bit timestamp of the frame.