DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
include
triggeralgs
TriggerActivityMaker.hpp
Go to the documentation of this file.
1
8
9
#ifndef TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERACTIVITYMAKER_HPP_
10
#define TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERACTIVITYMAKER_HPP_
11
12
#include "
triggeralgs/Issues.hpp
"
13
#include "
triggeralgs/Logging.hpp
"
14
#include "
triggeralgs/TriggerActivity.hpp
"
15
#include "
triggeralgs/TriggerPrimitive.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
TriggerActivityMaker
29
{
30
public
:
31
virtual
~TriggerActivityMaker
() =
default
;
32
void
operator()
(
const
TriggerPrimitive
& input_tp, std::vector<TriggerActivity>& output_ta)
33
{
34
// Apply TP filtering
35
if
(!
preprocess
(input_tp)) {
36
return
;
37
}
38
39
// Process TP, to implement per alg triggeralgs
40
process
(input_tp, output_ta);
41
42
// Postprocess TA, e.g. prescaling
43
postprocess
(output_ta);
44
}
45
52
virtual
void
process
(
const
TriggerPrimitive
& input_tp, std::vector<TriggerActivity>& output_ta) = 0;
53
66
virtual
bool
preprocess
(
const
TriggerPrimitive
& input_tp)
67
{
68
if
(input_tp.
samples_over_threshold
>
m_max_samples_over_threshold
) {
69
return
false
;
70
}
71
72
return
true
;
73
}
74
85
virtual
void
postprocess
(std::vector<TriggerActivity>& output_ta)
86
{
87
// Don't post-process TAs if there's no TAs made.
88
if
(output_ta.size() == 0) {
89
return
;
90
}
91
92
// Apply prescale by erasing TAs
93
if
(
m_prescale
> 1) {
94
for
(std::vector<TriggerActivity>::iterator iter = output_ta.begin(); iter != output_ta.end();) {
95
m_ta_count
++;
96
97
if
(
m_ta_count
%
m_prescale
!= 0) {
98
iter = output_ta.erase(iter);
99
continue
;
100
}
101
102
TLOG_DEBUG
(
TLVL_DEBUG_MEDIUM
) <<
"Emitting prescaled TriggerActivity "
<< (
m_ta_count
-1)
103
<<
" with time start/end/activity: "
<< iter->time_start
104
<<
" "
<< iter->time_end <<
" "
<< iter->time_activity;
105
++iter;
106
}
107
}
108
}
109
110
virtual
void
flush
(
timestamp_t
/* until */
, std::vector<TriggerActivity>&) {}
111
virtual
void
configure
(
const
nlohmann::json& config)
112
{
113
// Don't do anyting if the config does not exist
114
if
(!config.is_object()) {
115
return
;
116
}
117
118
if
(config.contains(
"prescale"
))
119
m_prescale
= config[
"prescale"
];
120
if
(config.contains(
"max_samples_over_threshold"
))
121
m_max_samples_over_threshold
= config[
"max_samples_over_threshold"
];
122
123
TLOG
() <<
"[TAM]: max sot : "
<<
m_max_samples_over_threshold
;
124
TLOG
() <<
"[TAM]: prescale : "
<<
m_prescale
;
125
}
126
127
std::atomic<uint64_t>
m_data_vs_system_time
= 0;
128
std::atomic<uint64_t>
m_initial_offset
= 0;
129
131
uint64_t
m_prescale
= 1;
133
uint64_t
m_ta_count
= 0;
134
136
uint32_t
m_max_samples_over_threshold
= std::numeric_limits<uint32_t>::max();
137
};
138
139
}
// namespace triggeralgs
140
141
#endif
// TRIGGERALGS_INCLUDE_TRIGGERALGS_TRIGGERACTIVITYMAKER_HPP_
TriggerActivity.hpp
triggeralgs::TriggerActivityMaker
Definition
TriggerActivityMaker.hpp:29
triggeralgs::TriggerActivityMaker::flush
virtual void flush(timestamp_t, std::vector< TriggerActivity > &)
Definition
TriggerActivityMaker.hpp:110
triggeralgs::TriggerActivityMaker::m_data_vs_system_time
std::atomic< uint64_t > m_data_vs_system_time
Definition
TriggerActivityMaker.hpp:127
triggeralgs::TriggerActivityMaker::configure
virtual void configure(const nlohmann::json &config)
Definition
TriggerActivityMaker.hpp:111
triggeralgs::TriggerActivityMaker::m_ta_count
uint64_t m_ta_count
TA made count for prescaling.
Definition
TriggerActivityMaker.hpp:133
triggeralgs::TriggerActivityMaker::~TriggerActivityMaker
virtual ~TriggerActivityMaker()=default
triggeralgs::TriggerActivityMaker::process
virtual void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)=0
TP processing function that creates & fills TAs.
triggeralgs::TriggerActivityMaker::postprocess
virtual void postprocess(std::vector< TriggerActivity > &output_ta)
Post-processing/filtering of the TAs, e.g. prescale.
Definition
TriggerActivityMaker.hpp:85
triggeralgs::TriggerActivityMaker::m_max_samples_over_threshold
uint32_t m_max_samples_over_threshold
Time-over-threshold TP filtering.
Definition
TriggerActivityMaker.hpp:136
triggeralgs::TriggerActivityMaker::m_initial_offset
std::atomic< uint64_t > m_initial_offset
Definition
TriggerActivityMaker.hpp:128
triggeralgs::TriggerActivityMaker::preprocess
virtual bool preprocess(const TriggerPrimitive &input_tp)
TP pre-processing/filtering.
Definition
TriggerActivityMaker.hpp:66
triggeralgs::TriggerActivityMaker::m_prescale
uint64_t m_prescale
Configurable prescale factor.
Definition
TriggerActivityMaker.hpp:131
triggeralgs::TriggerActivityMaker::operator()
void operator()(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
Definition
TriggerActivityMaker.hpp:32
TLOG_DEBUG
#define TLOG_DEBUG(lvl,...)
Definition
Logging.hpp:112
TLOG
#define TLOG(...)
Definition
macro.hpp:22
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::TLVL_DEBUG_MEDIUM
@ TLVL_DEBUG_MEDIUM
Definition
Logging.hpp:23
triggeralgs::timestamp_t
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition
Types.hpp:16
triggeralgs::TriggerPrimitive
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
Definition
TriggerPrimitive.hpp:22
dunedaq::trgdataformats::TriggerPrimitive::samples_over_threshold
uint64_t samples_over_threshold
Definition
TriggerPrimitive.hpp:38
Issues.hpp
Logging.hpp
TriggerPrimitive.hpp
Types.hpp
Generated on
for DUNE-DAQ by
1.17.0