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

Namespaces

namespace  daphne
 
namespace  fc
 
namespace  python
 
namespace  tde
 
namespace  unpack
 
namespace  wib
 
namespace  wib2
 
namespace  wibeth
 

Functions

fddetdataformats::TDE16Frame wibtotde (fddetdataformats::WIBFrame *fr, uint64_t timestamp, uint16_t ch)
 
void wib_binary_to_tde_binary (std::string &filename, std::string &output)
 
void wib_hdf5_to_tde_binary (std::string &, std::string &)
 
fddetdataformats::WIB2Frame wibtowib2 (fddetdataformats::WIBFrame *fr, uint64_t timestamp=0)
 
void wib_binary_to_wib2_binary (std::string &filename, std::string &output)
 
void wib_hdf5_to_wib2_binary (std::string &, std::string &)
 
fddetdataformats::WIBEthFrame wibtowibeth (fddetdataformats::WIBFrame *fr, uint64_t timestamp=0, int starting_channel=0)
 
void wib_binary_to_wibeth_binary (std::string &filename, std::string &output)
 
void wib_hdf5_to_wibeth_binary (std::string &, std::string &)
 
void print_hex_fragment (daqdataformats::Fragment const &frag)
 

Function Documentation

◆ print_hex_fragment()

void dunedaq::rawdatautils::print_hex_fragment ( daqdataformats::Fragment const & frag)

Definition at line 27 of file unpack.cpp.

27 {
28 uint64_t* data = static_cast<uint64_t*>(frag.get_data());
29 size_t data_size = (frag.get_size() - sizeof(daqdataformats::FragmentHeader))/8;
30
31 for ( size_t i(0); i<data_size; ++i) {
32 fmt::print("{:06d} 0x{:016x}\n", i, data[i]);
33 }
34
35}
The header for a DUNE Fragment.

◆ wib_binary_to_tde_binary()

void dunedaq::rawdatautils::wib_binary_to_tde_binary ( std::string & filename,
std::string & output )

Definition at line 44 of file WIBtoTDE.hpp.

44 {
45 //FIXME: this is temporary.... we take 1 WIB frame and invent TDE frames from it... ADC values not set
46 std::ifstream file(filename.c_str(), std::ios::binary);
47 std::ofstream out(output.c_str(), std::ios::binary);
48 std::cout << "Transforming " << filename << " to " << output << '\n';
49 auto size = std::filesystem::file_size(filename);
50 std::vector<char> v(size);
51 file.read(v.data(), size);
52 file.close();
53 int num_frames = size / sizeof(fddetdataformats::WIBFrame);
54 if (num_frames > 10 ) num_frames = 10;
55 std::cout << "Number of frames found: "<< num_frames << '\n';
56 auto ptr = reinterpret_cast<fddetdataformats::WIBFrame*>(v.data());
57 uint64_t timestamp = ptr->get_timestamp();
58 while(num_frames--){
59 for (uint16_t i = 0; i < dunedaq::fddetdataformats::n_channels_per_amc; i++) {
60 auto tdefr = wibtotde(ptr, timestamp, i);
61 out.write(reinterpret_cast<char*>(&tdefr), sizeof(tdefr));
62 }
64 ptr++;
65 }
66 out.close();
67}
static constexpr int tot_adc16_samples
static constexpr int ticks_between_adc_samples
static constexpr int n_channels_per_amc
fddetdataformats::TDE16Frame wibtotde(fddetdataformats::WIBFrame *fr, uint64_t timestamp, uint16_t ch)
Definition WIBtoTDE.hpp:24
FELIX Initialization std::string initerror FELIX queue timed out
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size

◆ wib_binary_to_wib2_binary()

void dunedaq::rawdatautils::wib_binary_to_wib2_binary ( std::string & filename,
std::string & output )

Definition at line 38 of file WIBtoWIB2.hpp.

38 {
39 std::ifstream file(filename.c_str(), std::ios::binary);
40 std::ofstream out(output.c_str(), std::ios::binary);
41 std::cout << "Transforming " << filename << " to " << output << '\n';
42 auto size = std::filesystem::file_size(filename);
43 std::vector<char> v(size);
44 file.read(v.data(), size);
45 file.close();
46 int num_frames = size / sizeof(fddetdataformats::WIBFrame);
47 std::cout << "Number of frames found: "<< num_frames << '\n';
48 auto ptr = reinterpret_cast<fddetdataformats::WIBFrame*>(v.data());
49 uint64_t timestamp = ptr->get_timestamp();
50 while(num_frames--){
51 auto wib2fr = wibtowib2(ptr, timestamp);
52 timestamp += 32;
53 ptr++;
54 out.write(reinterpret_cast<char*>(&wib2fr), sizeof(wib2fr));
55 }
56 out.close();
57}
fddetdataformats::WIB2Frame wibtowib2(fddetdataformats::WIBFrame *fr, uint64_t timestamp=0)
Definition WIBtoWIB2.hpp:23

◆ wib_binary_to_wibeth_binary()

void dunedaq::rawdatautils::wib_binary_to_wibeth_binary ( std::string & filename,
std::string & output )

Definition at line 42 of file WIBtoWIBEth.hpp.

42 {
43 std::ifstream file(filename.c_str(), std::ios::binary);
44 std::cout << "Transforming " << filename << " to " << output << '\n';
45 auto size = std::filesystem::file_size(filename);
46 std::vector<char> v(size);
47 file.read(v.data(), size);
48 file.close();
49 std::cout << "Number of frames found: "<< size / sizeof(fddetdataformats::WIBFrame) << '\n';
50
51 std::ofstream out(output.c_str(), std::ios::binary);
52 std::vector<int> starting_channel {0, 64, 128, 192};
53 for (auto& sc : starting_channel) {
54 auto ptr = reinterpret_cast<fddetdataformats::WIBFrame*>(v.data());
55 uint64_t timestamp = ptr->get_timestamp();
56 int num_frames = size / sizeof(fddetdataformats::WIBFrame);
57 while(num_frames >= 64){
58 auto wibethfr = wibtowibeth(ptr, timestamp, sc);
59 timestamp += 32 * 64;
60 ptr += 64;
61 num_frames -= 64;
62 out.write(reinterpret_cast<char*>(&wibethfr), sizeof(wibethfr));
63 }
64 out.close();
65 }
66
67}

◆ wib_hdf5_to_tde_binary()

void dunedaq::rawdatautils::wib_hdf5_to_tde_binary ( std::string & ,
std::string &  )

Definition at line 70 of file WIBtoTDE.hpp.

70 {
71}

◆ wib_hdf5_to_wib2_binary()

void dunedaq::rawdatautils::wib_hdf5_to_wib2_binary ( std::string & ,
std::string &  )

Definition at line 60 of file WIBtoWIB2.hpp.

60 {
61}

◆ wib_hdf5_to_wibeth_binary()

void dunedaq::rawdatautils::wib_hdf5_to_wibeth_binary ( std::string & ,
std::string &  )

Definition at line 70 of file WIBtoWIBEth.hpp.

70 {
71}

◆ wibtotde()

fddetdataformats::TDE16Frame dunedaq::rawdatautils::wibtotde ( fddetdataformats::WIBFrame * fr,
uint64_t timestamp,
uint16_t ch )

Definition at line 24 of file WIBtoTDE.hpp.

24 {
26 // leave ADCs empty for now
27 for (auto i=0; i < dunedaq::fddetdataformats::tot_adc16_samples; i++) {
28 res.set_adc_sample(ch,i);
29 }
30
31 auto header = fr->get_wib_header();
32 res.get_daq_header()->version = header->version;
33 res.get_daq_header()->det_id = 11;
34 res.get_daq_header()->crate_id = header->crate_no;
35 res.get_daq_header()->slot_id = header->slot_no;
36 res.get_daq_header()->stream_id = header->fiber_no;
37 res.set_channel(ch);
38 res.set_timestamp(timestamp);
39 std::cout << " Generated frame with TS " << res.get_timestamp() << " for channel " << res.get_channel() << std::endl;
40 return res;
41}
const detdataformats::DAQEthHeader * get_daq_header() const
void set_channel(const uint16_t new_channel)
void set_timestamp(const uint64_t new_timestamp)
void set_adc_sample(const uint16_t new_adc_val, int sample_no)
const WIBHeader * get_wib_header() const
Definition WIBFrame.hpp:360

◆ wibtowib2()

fddetdataformats::WIB2Frame dunedaq::rawdatautils::wibtowib2 ( fddetdataformats::WIBFrame * fr,
uint64_t timestamp = 0 )

Definition at line 23 of file WIBtoWIB2.hpp.

23 {
25 for (int i = 0; i < 256; ++i) {
26 res.set_adc(i, fr->get_channel(i));
27 }
28 auto header = fr->get_wib_header();
29 res.header.version = header->version;
30 res.header.crate = header->crate_no;
31 res.header.slot = header->slot_no;
32 res.header.link = header->fiber_no;
33 res.set_timestamp(timestamp);
34 return res;
35}
Class for accessing raw WIB v2 frames, as used in ProtoDUNE-SP-II.
Definition WIB2Frame.hpp:31
void set_timestamp(const uint64_t new_timestamp)
Set the 64-bit timestamp of the frame.
void set_adc(int i, uint16_t val)
Set the ith ADC value in the frame to val.
uint16_t get_channel(const uint8_t block_num, const uint8_t adc, const uint8_t ch) const
Definition WIBFrame.hpp:381

◆ wibtowibeth()

fddetdataformats::WIBEthFrame dunedaq::rawdatautils::wibtowibeth ( fddetdataformats::WIBFrame * fr,
uint64_t timestamp = 0,
int starting_channel = 0 )

Definition at line 23 of file WIBtoWIBEth.hpp.

23 {
25 for (int j = 0; j < 64; ++j) {
26 for (int i = 0; i < 64; ++i) {
27 res.set_adc(i, j, (fr + j)->get_channel(starting_channel + i));
28 }
29 }
30 auto header = fr->get_wib_header();
31 res.daq_header.version = header->version; //Warning, in WIBFrames version has 5 bits and here it has 4
32 res.daq_header.crate_id = header->crate_no;
33 res.daq_header.slot_id = header->slot_no;
34 res.daq_header.stream_id = header->fiber_no;
35 res.set_channel(starting_channel);
36 res.set_timestamp(timestamp);
37 res.header.extra_data = 0xdeadbeef0badface;
38 return res;
39}
Class for accessing raw WIB eth frames, as used in ProtoDUNE-II.
void set_channel(const uint8_t new_channel)
Set the channel identifier of the frame.
void set_adc(int i, int sample, uint16_t val)
Set the ith ADC value in the frame to val.
detdataformats::DAQEthHeader daq_header
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.