DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
WIBtoTDE.hpp
Go to the documentation of this file.
1
9#ifndef RAWDATAUTILS_INCLUDE_WIBTOTDE16_HPP_
10#define RAWDATAUTILS_INCLUDE_WIBTOTDE16_HPP_
11
12#include <cstdint>
13#include <iostream>
14#include <fstream>
15#include <filesystem>
19
20namespace dunedaq {
21namespace rawdatautils {
22
24wibtotde(fddetdataformats::WIBFrame* fr, uint64_t timestamp, uint16_t ch) {
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}
42
43void
44wib_binary_to_tde_binary(std::string& filename, std::string& output) {
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}
68
69void
70wib_hdf5_to_tde_binary(std::string& /*filename*/, std::string& /*output*/) {
71}
72
73
74} // namespace dunedaq::rawdatautils
75}
76
77#endif // RAWDATAUTILS_INCLUDE_WIBTOTDE16_HPP_
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
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
void wib_hdf5_to_tde_binary(std::string &, std::string &)
Definition WIBtoTDE.hpp:70
void wib_binary_to_tde_binary(std::string &filename, std::string &output)
Definition WIBtoTDE.hpp:44
Including Qt Headers.
FELIX Initialization std::string initerror FELIX queue timed out
FELIX Initialization std::string initerror FELIX queue timed std::string queuename Unexpected chunk size
PDS Frame with unphysical timestamp detected with ch