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 <vector>
14#include <stdexcept>
15
16#include <ostream>
17#include <string>
18#include <fstream>
19#include <iterator>
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) { throw std::out_of_range("ADC sample index out of range"); }
48
49 return (uint16_t)samples_info[i].sample;
50 }
51};
52
54{
55public:
58 const TDEHeader* get_tde_header() const { return &m_tde16_header; }
60
61 // TDEHeader mutators
62 uint64_t get_timestamp() const { return m_daq_header.get_timestamp(); }
63 void set_timestamp(const uint64_t new_timestamp) { m_daq_header.timestamp = new_timestamp; }
64 uint16_t get_channel() const { return m_tde16_header.channel; }
65 void set_channel(const uint16_t new_channel) { m_tde16_header.channel=new_channel; }
67 void set_tde_errors(const uint16_t new_tde_errors) { m_tde16_header.tde_errors = new_tde_errors; }
68 uint64_t get_TAItime() { return m_tde16_header.TAItime; }
69 void set_TAItime(const uint64_t new_TAItime) { m_tde16_header.TAItime = new_TAItime; }
70
71 // ADC16Data mutators
72 void set_adc_sample(const uint16_t new_adc_val, int sample_no) { m_adc16_data.samples_info[sample_no].sample = new_adc_val; }
73 uint16_t get_adc_sample(int sample_no) const { return m_adc16_data.get_adc_sample(sample_no); }
74
75 friend std::ostream& operator<<(std::ostream& o, TDE16Frame const& tde16_frame);
76
77private:
81};
82
83inline std::ostream&
84operator<<(std::ostream& o, TDEHeader const& tde_header)
85{
86 return o << std::hex << "channel: " << tde_header.channel << "version: " << tde_header.version
87 << "TAItime: " << tde_header.TAItime
88 << " tde_header: " << tde_header.tde_header<< " tde_errors: " << tde_header.tde_errors << std::dec << '\n';
89}
90
91inline std::ostream&
92operator<<(std::ostream& o, Sample const& sampleinfo)
93{
94 return o << "sample: " << unsigned(sampleinfo.sample) << " reserved: " << unsigned(sampleinfo.reserved) << '\n';
95}
96
97inline std::ostream&
98operator<<(std::ostream& o, TDE16Frame const& tde16frame)
99{
100 o << "Printing frame:" << '\n';
101 o << tde16frame.m_daq_header << '\n';
102 o << tde16frame.m_tde16_header << '\n';
103 return o;
104}
105
106} // namespace dunedaq::fddetdataformats
107
108#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]