DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
trgdataformats
include
trgdataformats
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
15
#include "
trgdataformats/Types.hpp
"
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
26
namespace
dunedaq::trgdataformats
{
27
31
struct
TriggerPrimitive
32
{
33
static
constexpr
version_t
s_trigger_primitive_version
= 2;
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
48
uint64_t
samples_over_threshold
: 16;
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
55
TriggerPrimitive
()
56
:
version
(
s_trigger_primitive_version
)
57
,
flag
(0)
58
,
detid
(
TypeDefaults
::s_invalid_detid)
59
,
channel
(
s_invalid_tp_channel
)
60
,
samples_over_threshold
(
s_invalid_samples_over_threshold
)
61
,
time_start
(
TypeDefaults
::s_invalid_timestamp)
62
,
samples_to_peak
(
s_invalid_samples_to_peak
)
63
,
adc_integral
(0)
64
,
adc_peak
(0)
65
{}
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
71
timestamp_t
get_timestamp
()
const
72
{
73
return
time_start
;
74
}
75
76
void
set_timestamp
(
timestamp_t
ts)
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
96
static_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
99
static_assert
(std::endian::native == std::endian::little,
100
"The TriggerPrimitive bitfield layout assumes little-endian architecture"
);
101
102
static_assert
(std::is_standard_layout_v<TriggerPrimitive>);
103
static_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_
dunedaq::trgdataformats
Definition
TriggerCandidateData.hxx:2
dunedaq::trgdataformats::version_t
uint8_t version_t
Definition
Types.hpp:59
dunedaq::trgdataformats::channel_t
uint32_t channel_t
Definition
Types.hpp:56
dunedaq::trgdataformats::timestamp_t
uint64_t timestamp_t
Definition
Types.hpp:38
dunedaq::trgdataformats::TriggerPrimitive::TriggerPrimitive
TriggerPrimitive()
Definition
TriggerPrimitive.hpp:55
dunedaq::trgdataformats::TriggerPrimitive::s_invalid_tp_channel
static constexpr channel_t s_invalid_tp_channel
Definition
TriggerPrimitive.hpp:38
dunedaq::trgdataformats::TriggerPrimitive::detid
uint64_t detid
Definition
TriggerPrimitive.hpp:43
dunedaq::trgdataformats::TriggerPrimitive::channel
uint64_t channel
Definition
TriggerPrimitive.hpp:46
dunedaq::trgdataformats::TriggerPrimitive::samples_over_threshold
uint64_t samples_over_threshold
Definition
TriggerPrimitive.hpp:48
dunedaq::trgdataformats::TriggerPrimitive::adc_peak
uint64_t adc_peak
Definition
TriggerPrimitive.hpp:53
dunedaq::trgdataformats::TriggerPrimitive::time_start
uint64_t time_start
Definition
TriggerPrimitive.hpp:49
dunedaq::trgdataformats::TriggerPrimitive::s_trigger_primitive_version
static constexpr version_t s_trigger_primitive_version
Definition
TriggerPrimitive.hpp:33
dunedaq::trgdataformats::TriggerPrimitive::s_invalid_samples_over_threshold
static constexpr uint16_t s_invalid_samples_over_threshold
Definition
TriggerPrimitive.hpp:36
dunedaq::trgdataformats::TriggerPrimitive::samples_to_peak
uint64_t samples_to_peak
Definition
TriggerPrimitive.hpp:50
dunedaq::trgdataformats::TriggerPrimitive::s_expected_bytes
static constexpr std::size_t s_expected_bytes
Definition
TriggerPrimitive.hpp:34
dunedaq::trgdataformats::TriggerPrimitive::operator<
bool operator<(const TriggerPrimitive &other) const
Definition
TriggerPrimitive.hpp:81
dunedaq::trgdataformats::TriggerPrimitive::flag
uint64_t flag
Definition
TriggerPrimitive.hpp:42
dunedaq::trgdataformats::TriggerPrimitive::set_timestamp
void set_timestamp(timestamp_t ts)
Definition
TriggerPrimitive.hpp:76
dunedaq::trgdataformats::TriggerPrimitive::s_invalid_samples_to_peak
static constexpr uint16_t s_invalid_samples_to_peak
Definition
TriggerPrimitive.hpp:37
dunedaq::trgdataformats::TriggerPrimitive::get_timestamp
timestamp_t get_timestamp() const
Definition
TriggerPrimitive.hpp:71
dunedaq::trgdataformats::TriggerPrimitive::adc_integral
uint64_t adc_integral
Definition
TriggerPrimitive.hpp:52
dunedaq::trgdataformats::TriggerPrimitive::version
uint64_t version
Definition
TriggerPrimitive.hpp:41
dunedaq::trgdataformats::TypeDefaults
Definition
Types.hpp:62
Types.hpp
Generated on
for DUNE-DAQ by
1.18.0