DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDE16Frame.hpp
Go to the documentation of this file.
1
8#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDE16FRAME_HPP_
9#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDE16FRAME_HPP_
10
11#include <bitset>
12#include <iostream>
13#include <stdexcept>
14#include <vector>
15
16#include <fstream>
17#include <iterator>
18#include <ostream>
19#include <string>
20
22
24
25static constexpr int ticks_between_adc_samples = 32;
26static constexpr int tot_adc16_samples = 4474;
27static constexpr int n_channels_per_amc = 64;
28// static constexpr int payload16 = 8972;
29
31{
32 uint64_t channel : 8, version : 4, tde_header : 10, tde_errors : 16, reserved : 26;
33 uint64_t TAItime : 64;
34};
35
36struct Sample
37{
38 uint16_t sample : 12, reserved : 4;
39};
40
42{
44
45 uint16_t get_adc_sample(int i) const
46 {
47 if (i < 0 || i >= tot_adc16_samples) {
48 throw std::out_of_range("ADC sample index out of range");
49 }
50
51 return (uint16_t)samples_info[i].sample;
52 }
53};
54
56{
57public:
60 const TDEHeader* get_tde_header() const { return &m_tde16_header; }
62
63 // TDEHeader mutators
64 uint64_t get_timestamp() const { return m_daq_header.get_timestamp(); }
65 void set_timestamp(const uint64_t new_timestamp) { m_daq_header.timestamp = new_timestamp; }
66 uint16_t get_channel() const { return m_tde16_header.channel; }
67 void set_channel(const uint16_t new_channel) { m_tde16_header.channel = new_channel; }
68 uint16_t get_tde_errors() { return m_tde16_header.tde_errors; }
69 void set_tde_errors(const uint16_t new_tde_errors) { m_tde16_header.tde_errors = new_tde_errors; }
70 uint64_t get_TAItime() { return m_tde16_header.TAItime; }
71 void set_TAItime(const uint64_t new_TAItime) { m_tde16_header.TAItime = new_TAItime; }
72
73 // ADC16Data mutators
74 void set_adc_sample(const uint16_t new_adc_val, int sample_no)
75 {
76 m_adc16_data.samples_info[sample_no].sample = new_adc_val;
77 }
78 uint16_t get_adc_sample(int sample_no) const { return m_adc16_data.get_adc_sample(sample_no); }
79
80 friend std::ostream& operator<<(std::ostream& o, TDE16Frame const& tde16_frame);
81
82private:
86};
87
88inline std::ostream&
89operator<<(std::ostream& o, TDEHeader const& tde_header)
90{
91 return o << std::hex << "channel: " << tde_header.channel << "version: " << tde_header.version
92 << "TAItime: " << tde_header.TAItime << " tde_header: " << tde_header.tde_header
93 << " tde_errors: " << tde_header.tde_errors << std::dec << '\n';
94}
95
96inline std::ostream&
97operator<<(std::ostream& o, Sample const& sampleinfo)
98{
99 return o << "sample: " << unsigned(sampleinfo.sample) << " reserved: " << unsigned(sampleinfo.reserved) << '\n';
100}
101
102inline std::ostream&
103operator<<(std::ostream& o, TDE16Frame const& tde16frame)
104{
105 o << "Printing frame:" << '\n';
106 o << tde16frame.m_daq_header << '\n';
107 o << tde16frame.m_tde16_header << '\n';
108 return o;
109}
110
111} // namespace dunedaq::fddetdataformats
112
113#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_TDE16FRAME_HPP_
void set_tde_errors(const uint16_t new_tde_errors)
const detdataformats::DAQEthHeader * get_daq_header() const
void set_channel(const uint16_t new_channel)
friend std::ostream & operator<<(std::ostream &o, TDE16Frame const &tde16_frame)
void set_TAItime(const uint64_t new_TAItime)
void set_timestamp(const uint64_t new_timestamp)
void set_adc_sample(const uint16_t new_adc_val, int sample_no)
const TDEHeader * get_tde_header() const
uint16_t get_adc_sample(int sample_no) const
detdataformats::DAQEthHeader m_daq_header
detdataformats::DAQEthHeader * get_daq_header()
static constexpr int tot_adc16_samples
static constexpr int ticks_between_adc_samples
static constexpr int n_channels_per_amc
std::ostream & operator<<(std::ostream &o, TDEHeader const &tde_header)
DAQEthHeader is a versioned and unified structure for every FE electronics.
uint16_t get_adc_sample(int i) const
Sample samples_info[tot_adc16_samples]