DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TriggerPrimitive.hpp
Go to the documentation of this file.
1
11
12#ifndef TRGDATAFORMATS_INCLUDE_TRGDATAFORMATS_TRIGGERPRIMITIVE_HPP_
13#define TRGDATAFORMATS_INCLUDE_TRGDATAFORMATS_TRIGGERPRIMITIVE_HPP_
14
16
17#include <bitset>
18#include <cstddef>
19#include <cstdint>
20#include <iostream>
21#include <limits>
22#include <type_traits>
23
24// NOLINTBEGIN(build/unsigned)
25
27
32{
34 static constexpr std::size_t s_expected_bytes = 24;
35
36 static constexpr uint16_t s_invalid_samples_over_threshold = std::numeric_limits<uint16_t>::max();
37 static constexpr uint16_t s_invalid_samples_to_peak = std::numeric_limits<uint16_t>::max();
38 static constexpr channel_t s_invalid_tp_channel = 0xFFFFFF; // TP channel limit is at 24 bytes
39
40 // Metadata.
41 uint64_t version : 8;
42 uint64_t flag : 8;
43 uint64_t detid : 8;
44
45 // Physics data.
46 uint64_t channel : 24;
47
49 uint64_t time_start : 64;
50 uint64_t samples_to_peak : 16;
51
52 uint64_t adc_integral : 32;
53 uint64_t adc_peak : 16;
54
66
67 // Despite this being a struct, the getter and setter for timestamp
68 // brings the struct closer into compliance with the standard
69 // overlay
70
72 {
73 return time_start;
74 }
75
77 {
78 time_start = ts;
79 }
80
81 bool operator<(const TriggerPrimitive& other) const {
82 return std::tie(time_start, channel) < std::tie(other.time_start, other.channel);
83 }
84};
85
86// Basic checks that the bits are arranged as we hope they're arranged
87
88// TODO John Freeman (jcfree@fnal.gov), Aug-1-2026
89
90// In the next two months, take these static_asserts and write up a
91// concept which encompasses them - something like
92// SafeBitLayoutConcept - and figure out the right package to put it
93// in, so that both this and the far detector-specific overlay classes
94// can use them
95
96static_assert(sizeof(TriggerPrimitive) == TriggerPrimitive::s_expected_bytes,
97 "The actual size of the TriggerPrimitive isn't the expected size; the compiler is likely inserting padding");
98
99static_assert(std::endian::native == std::endian::little,
100 "The TriggerPrimitive bitfield layout assumes little-endian architecture");
101
102static_assert(std::is_standard_layout_v<TriggerPrimitive>);
103static_assert(std::is_trivially_copyable_v<TriggerPrimitive>);
104
105} // namespace dunedaq::trgdataformats
106
107// NOLINTEND(build/unsigned)
108
109#endif // TRGDATAFORMATS_INCLUDE_TRGDATAFORMATS_TRIGGERPRIMITIVE_HPP_
static constexpr channel_t s_invalid_tp_channel
static constexpr version_t s_trigger_primitive_version
static constexpr uint16_t s_invalid_samples_over_threshold
static constexpr std::size_t s_expected_bytes
bool operator<(const TriggerPrimitive &other) const
static constexpr uint16_t s_invalid_samples_to_peak