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

Functions

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

Function Documentation

◆ get_n_frames()

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

Gets number of TDEEthFrames in a fragment.

Definition at line 21 of file TDEUnpacker.cpp.

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

◆ np_array_adc()

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

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

Definition at line 87 of file TDEUnpacker.cpp.

87 {
88 return np_array_adc_data(frag.get_data(), get_n_frames(frag));
89}

◆ np_array_adc_data()

py::array_t< uint16_t > dunedaq::rawdatautils::tde::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 TDEEthFrames, 64) Warning: It doesn't check that n_frames is a sensible value (can read out of bounds)

Definition at line 30 of file TDEUnpacker.cpp.

30 {
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}

◆ np_array_timestamp()

py::array_t< long double > dunedaq::rawdatautils::tde::np_array_timestamp ( daqdataformats::Fragment const & frag)

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

Definition at line 95 of file TDEUnpacker.cpp.

95 {
96 return np_array_timestamp_data(frag.get_data(), get_n_frames(frag));
97}

◆ np_array_timestamp_data()

py::array_t< long double > dunedaq::rawdatautils::tde::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 TDEEthFrames) Warning: It doesn't check that n_frames is a sensible value (can read out of bounds)

Definition at line 63 of file TDEUnpacker.cpp.

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