DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CRTGrenobleFrame.hpp
Go to the documentation of this file.
1
11#ifndef FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_HPP_
12#define FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_HPP_
13
15
16#include <algorithm> // For std::min
17#include <cassert> // For assert()
18#include <cstdint> // For uint32_t etc
19#include <cstdio>
20#include <cstdlib>
21#include <stdexcept> // For std::out_of_range
22
24
25// NOLINTBEGIN(build/unsigned)
26
29{
30public:
31 // The definition of the format is in terms of 64-bit words
32 using word_t = uint64_t;
33
34 static constexpr int s_num_channels = 32;
35 static constexpr uint64_t s_DTS_ticks_per_second = 62'500'000;
36 static constexpr uint64_t s_ns_per_DTS_tick = 16;
37
39 {
40 unsigned int seconds : 8;
41 unsigned int minutes : 8;
42 unsigned int hours : 8;
43 unsigned int year : 8;
44
45 unsigned int day : 16;
46 unsigned int new_date_cnt : 12;
47 unsigned int irigb_dec_ver : 3;
48 unsigned int irigb_valid : 1;
49 };
50 static_assert(sizeof(TGpsDateStruct) == 8);
51
52 struct STChannel
53 {
54 int qTot = 0;
55 unsigned short n_zc = 0;
56 float cfd = 0.;
57 unsigned short flag = 0;
58 };
59
60#warning "CRTGrenobleFrame::STChannel has padding inserted"
61 // static_assert(sizeof(STChannel) == sizeof(int) + sizeof(unsigned short) + sizeof(float) + sizeof(unsigned
62 // short));
63
64 struct STEvent
65 {
66 unsigned int eventID = 0;
67 unsigned int dateInSec = 0;
68 unsigned int timestamp = 0;
70 unsigned int pps_interval = 0;
71 unsigned int FIFO_AF_duration =
72 0;
73
75 };
76
77#warning "CRTGrenobleFrame::STEvent has padding inserted"
78 // static_assert(sizeof(STEvent) == 3 * sizeof(unsigned int) + sizeof(TGpsDateStruct) + 2 * sizeof(unsigned int) +
79 // sizeof(STChannel) * s_num_channels);
80
83
85 int get_adc(const int i_ch) const
86 {
87 if (i_ch < 0 || i_ch >= s_num_channels)
88 throw std::out_of_range("ADC channel index out of range");
89
90 return event.channels[i_ch].qTot;
91 }
92
94 void set_adc(const int i_ch, const int val)
95 {
96 if (i_ch < 0 || i_ch >= s_num_channels)
97 throw std::out_of_range("ADC channel index out of range");
98
99 event.channels[i_ch].qTot = val;
100 }
101
103 uint64_t get_timestamp() const { return daq_header.get_timestamp(); }
104
106 void set_timestamp(const uint64_t new_timestamp) { daq_header.timestamp = new_timestamp; }
107
108}; // CRTGrenobleFrame
109#warning "CRTGrenobleFrame has padding inserted"
110// static_assert(sizeof(CRTGrenobleFrame) == sizeof(detdataformats::DAQEthHeader) + sizeof(CRTGrenobleFrame::STEvent));
111
112static_assert(std::endian::native == std::endian::little,
113 "The CRTGrenobleFrame bitfield layout assumes little-endian architecture");
114static_assert(std::is_trivially_copyable_v<CRTGrenobleFrame>,
115 "CRTGrenobleFrame isn't trivially copyable and can't be safely std::memcpy'd");
116static_assert(std::is_standard_layout_v<CRTGrenobleFrame>,
117 "CRTGrenobleFrame isn't standard layout; reinterpret_cast and offsetof can't safely be used with it");
118
119// NOLINTEND(build/unsigned)
120
121} // namespace dunedaq::fddetdataformats
122
123#endif // FDDETDATAFORMATS_INCLUDE_FDDETDATAFORMATS_CRTGRENOBLEFRAME_HPP_
Class for accessing/holding raw CRT data from the 'Grenoble' panels ProtoDUNE-II VD.
uint64_t get_timestamp() const
Get the starting 64-bit timestamp of the frame.
void set_adc(const int i_ch, const int val)
Set the adc value for channel i_ch to val.
int get_adc(const int i_ch) const
Get the adc value for channel i_ch.
void set_timestamp(const uint64_t new_timestamp)
Set the starting 64-bit timestamp of the frame.
DAQEthHeader is a versioned and unified structure for every FE electronics.
unsigned short flag
Flag containing trigger, trigger sum and overflow information.
unsigned int timestamp
Timestamp (4 ns) -> used to compute dt between events.
unsigned int FIFO_AF_duration
FIFO AF duration (4 ns) -> integration of Almost full fifo since last accepted trigger.
unsigned int pps_interval
IRIG-B subdivision in a second, expressed in 100 ns clock ticks.