DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
include
triggeralgs
TriggerCandidateMaker.hpp
Go to the documentation of this file.
1
8
9
#ifndef TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERCANDIDATEMAKER_HPP_
10
#define TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERCANDIDATEMAKER_HPP_
11
12
#include "
triggeralgs/Issues.hpp
"
13
#include "
triggeralgs/Logging.hpp
"
14
#include "
triggeralgs/TriggerActivity.hpp
"
15
#include "
triggeralgs/TriggerCandidate.hpp
"
16
#include "
triggeralgs/Types.hpp
"
17
18
#include <atomic>
19
#include <chrono>
20
#include <nlohmann/json.hpp>
21
#include <vector>
22
23
// TRACE_NAME to be defined in the derived TAMs
24
#include "TRACE/trace.h"
25
26
namespace
triggeralgs
{
27
28
class
TriggerCandidateMaker
29
{
30
public
:
31
virtual
~TriggerCandidateMaker
() =
default
;
32
void
operator()
(
const
TriggerActivity
& input_ta, std::vector<TriggerCandidate>& output_tc)
33
{
34
// Apply TP filtering
35
if
(!
preprocess
(input_ta)) {
36
return
;
37
}
38
39
// Process TP, to implement per alg triggeralgs
40
process
(input_ta, output_tc);
41
42
// Postprocess TA, e.g. prescaling
43
postprocess
(output_tc);
44
}
45
52
virtual
void
process
(
const
TriggerActivity
& input_ta, std::vector<TriggerCandidate>& output_tc) = 0;
53
63
virtual
bool
preprocess
(
const
TriggerActivity
&)
64
{
65
return
true
;
66
}
67
78
virtual
void
postprocess
(std::vector<TriggerCandidate>& output_tc)
79
{
80
// Don't post-process TCs if there's no TCs made.
81
if
(output_tc.size() == 0) {
82
return
;
83
}
84
85
// Apply prescale by erasing TCs
86
if
(
m_prescale
> 1) {
87
for
(std::vector<TriggerCandidate>::iterator iter = output_tc.begin(); iter != output_tc.end();) {
88
m_tc_count
++;
89
90
if
(
m_tc_count
%
m_prescale
!= 0) {
91
iter = output_tc.erase(iter);
92
continue
;
93
}
94
95
TLOG_DEBUG
(TLVL_DEBUG_10) <<
"Emitting prescaled TriggerCandidate "
<< (
m_tc_count
-1);
96
++iter;
97
}
98
}
99
}
100
virtual
void
flush
(
timestamp_t
/* until */
, std::vector<TriggerCandidate>&
/* output_tc */
) {}
101
virtual
void
configure
(
const
nlohmann::json& config)
102
{
103
// Don't do anyting if the config does not exist
104
if
(!config.is_object()) {
105
return
;
106
}
107
108
if
(config.contains(
"prescale"
)) {
109
m_prescale
= config[
"prescale"
];
110
}
111
112
if
(config.contains(
"tc_type_name"
)) {
113
m_tc_type_out
=
static_cast<
TriggerCandidate::Type
>
(
114
dunedaq::trgdataformats::string_to_trigger_candidate_type
(config[
"tc_type_name"
]));
115
}
116
117
if
(
m_tc_type_out
==
TriggerCandidate::Type::kUnknown
) {
118
// 27-Feb-2025, KAB: moified the following statement to check whether the configuration
119
// contains the tc_type_name parameter before trying to add it do the exception message.
120
throw
(
InvalidConfiguration
(
ERS_HERE
,
"Provided an unknown output TC type: "
+
121
(config.contains(
"tc_type_name"
) ?
122
std::string(config[
"tc_type_name"
]) :
"null"
)));
123
}
124
125
TLOG
() <<
"[TCM]: prescale : "
<<
m_prescale
;
126
TLOG
() <<
"[TCM]: TC type out: "
<< config[
"tc_type_name"
];
127
}
128
129
std::atomic<uint64_t>
m_data_vs_system_time
= 0;
130
std::atomic<uint64_t>
m_initial_offset
= 0;
131
133
uint64_t
m_prescale
= 1;
135
uint64_t
m_tc_count
= 0;
136
138
TriggerCandidate::Type
m_tc_type_out
=
TriggerCandidate::Type::kUnknown
;
139
140
};
141
142
}
// namespace triggeralgs
143
144
#endif
// TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERCANDIDATEMAKER_HPP_
ERS_HERE
#define ERS_HERE
Definition
LocalContext.hpp:141
TriggerActivity.hpp
TriggerCandidate.hpp
triggeralgs::TriggerCandidateMaker
Definition
TriggerCandidateMaker.hpp:29
triggeralgs::TriggerCandidateMaker::m_initial_offset
std::atomic< uint64_t > m_initial_offset
Definition
TriggerCandidateMaker.hpp:130
triggeralgs::TriggerCandidateMaker::m_tc_count
uint64_t m_tc_count
TC made count for prescaling.
Definition
TriggerCandidateMaker.hpp:135
triggeralgs::TriggerCandidateMaker::m_tc_type_out
TriggerCandidate::Type m_tc_type_out
Configurable TC type output.
Definition
TriggerCandidateMaker.hpp:138
triggeralgs::TriggerCandidateMaker::configure
virtual void configure(const nlohmann::json &config)
Definition
TriggerCandidateMaker.hpp:101
triggeralgs::TriggerCandidateMaker::~TriggerCandidateMaker
virtual ~TriggerCandidateMaker()=default
triggeralgs::TriggerCandidateMaker::process
virtual void process(const TriggerActivity &input_ta, std::vector< TriggerCandidate > &output_tc)=0
TA processing function that creates & fills TCs.
triggeralgs::TriggerCandidateMaker::m_data_vs_system_time
std::atomic< uint64_t > m_data_vs_system_time
Definition
TriggerCandidateMaker.hpp:129
triggeralgs::TriggerCandidateMaker::operator()
void operator()(const TriggerActivity &input_ta, std::vector< TriggerCandidate > &output_tc)
Definition
TriggerCandidateMaker.hpp:32
triggeralgs::TriggerCandidateMaker::flush
virtual void flush(timestamp_t, std::vector< TriggerCandidate > &)
Definition
TriggerCandidateMaker.hpp:100
triggeralgs::TriggerCandidateMaker::m_prescale
uint64_t m_prescale
Configurable prescale factor.
Definition
TriggerCandidateMaker.hpp:133
triggeralgs::TriggerCandidateMaker::postprocess
virtual void postprocess(std::vector< TriggerCandidate > &output_tc)
Post-processing/filtering of the TCs, e.g. prescale.
Definition
TriggerCandidateMaker.hpp:78
triggeralgs::TriggerCandidateMaker::preprocess
virtual bool preprocess(const TriggerActivity &)
TA pre-processing/filtering.
Definition
TriggerCandidateMaker.hpp:63
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
TLOG
#define TLOG(...)
Definition
macro.hpp:22
dunedaq::trgdataformats::string_to_trigger_candidate_type
int string_to_trigger_candidate_type(const std::string &name)
Definition
TriggerCandidateData.hpp:147
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::timestamp_t
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition
Types.hpp:16
dunedaq::trgdataformats::TriggerCandidateData::Type
Type
Definition
TriggerCandidateData.hpp:23
dunedaq::trgdataformats::TriggerCandidateData::Type::kUnknown
@ kUnknown
Definition
TriggerCandidateData.hpp:24
triggeralgs::TriggerActivity
Definition
TriggerActivity.hpp:20
Issues.hpp
InvalidConfiguration
Factory couldn t std::string alg_name InvalidConfiguration
Definition
Issues.hpp:33
Logging.hpp
Types.hpp
Generated on
for DUNE-DAQ by
1.17.0