DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
triggeralgs
src
TAMakerChannelDistanceAlgorithm.cpp
Go to the documentation of this file.
1
8
9
#include "
triggeralgs/ChannelDistance/TAMakerChannelDistanceAlgorithm.hpp
"
10
11
#include "TRACE/trace.h"
12
#define TRACE_NAME "TAMakerChannelDistanceAlgorithm"
13
14
namespace
triggeralgs
{
15
16
void
17
TAMakerChannelDistanceAlgorithm::set_new_ta
(
const
TriggerPrimitive
& input_tp)
18
{
19
m_current_ta
=
TriggerActivity
();
20
m_current_ta
.inputs.push_back(input_tp);
21
m_current_lower_bound
= input_tp.
channel
-
m_max_channel_distance
;
22
m_current_upper_bound
= input_tp.
channel
+
m_max_channel_distance
;
23
return
;
24
}
25
26
void
27
TAMakerChannelDistanceAlgorithm::process
(
const
TriggerPrimitive
& input_tp,
28
std::vector<TriggerActivity>& output_tas)
29
{
30
31
// Start a new TA if not already going.
32
if
(
m_current_ta
.inputs.empty()) {
33
set_new_ta
(input_tp);
34
return
;
35
}
36
37
// Check to close the TA based on time.
38
if
(input_tp.
time_start
-
m_current_ta
.inputs.front().time_start >
m_window_length
) {
39
// Check to block the TA based on min TPs.
40
if
(
m_current_ta
.inputs.size() >=
m_min_tps
) {
41
set_ta_attributes
();
42
output_tas.push_back(
m_current_ta
);
43
}
44
set_new_ta
(input_tp);
45
return
;
46
}
47
48
// Check to skip the TP if it's outside the current channel bounds.
49
if
(input_tp.
channel
>
m_current_upper_bound
|| input_tp.
channel
<
m_current_lower_bound
)
50
return
;
51
52
m_current_ta
.inputs.push_back(input_tp);
53
m_current_lower_bound
= std::min(
m_current_lower_bound
,
channel_diff_t
(input_tp.
channel
) -
m_max_channel_distance
);
54
m_current_upper_bound
= std::max(
m_current_upper_bound
,
channel_diff_t
(input_tp.
channel
) +
m_max_channel_distance
);
55
}
56
57
void
58
TAMakerChannelDistanceAlgorithm::configure
(
const
nlohmann::json& config)
59
{
60
TriggerActivityMaker::configure
(config);
61
62
if
(config.contains(
"min_tps"
))
63
m_min_tps
= config[
"min_tps"
];
64
if
(config.contains(
"window_length"
))
65
m_window_length
= config[
"window_length"
];
66
if
(config.contains(
"max_channel_distance"
))
67
m_max_channel_distance
= config[
"max_channel_distance"
];
68
69
return
;
70
}
71
72
void
73
TAMakerChannelDistanceAlgorithm::set_ta_attributes
()
74
{
75
TriggerPrimitive
first_tp =
m_current_ta
.inputs.front();
76
TriggerPrimitive
last_tp =
m_current_ta
.inputs.back();
77
78
m_current_ta
.channel_start = first_tp.
channel
;
79
m_current_ta
.channel_end = last_tp.
channel
;
80
81
m_current_ta
.time_start = first_tp.
time_start
;
82
m_current_ta
.time_end = last_tp.
time_start
;
83
84
m_current_ta
.detid = first_tp.
detid
;
85
86
m_current_ta
.algorithm =
TriggerActivity::Algorithm::kChannelDistance
;
87
m_current_ta
.type =
TriggerActivity::Type::kTPC
;
88
89
m_current_ta
.adc_peak = 0;
90
for
(
const
TriggerPrimitive
& tp :
m_current_ta
.inputs) {
91
m_current_ta
.adc_integral += tp.
adc_integral
;
92
if
(tp.
adc_peak
<=
m_current_ta
.adc_peak)
93
continue
;
94
m_current_ta
.adc_peak = tp.
adc_peak
;
95
m_current_ta
.channel_peak = tp.
channel
;
96
m_current_ta
.time_peak = tp.
samples_to_peak
* 32 + tp.
time_start
;
// FIXME: Replace STP to `time_peak` conversion.
97
}
98
m_current_ta
.time_activity =
m_current_ta
.time_peak;
99
}
100
101
// Register algo in TA Factory
102
REGISTER_TRIGGER_ACTIVITY_MAKER
(
TRACE_NAME
,
TAMakerChannelDistanceAlgorithm
)
103
104
}
// namespace triggeralgs
TRACE_NAME
#define TRACE_NAME
Definition
TimestampEstimatorTimeSync.cpp:17
REGISTER_TRIGGER_ACTIVITY_MAKER
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
Definition
TriggerActivityFactory.hpp:14
TriggerActivity
TriggerActivity
Definition
TriggerActivity_serialization.hpp:37
triggeralgs::TAMakerChannelDistanceAlgorithm
Definition
TAMakerChannelDistanceAlgorithm.hpp:17
triggeralgs::TAMakerChannelDistanceAlgorithm::process
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_tas)
TP processing function that creates & fills TAs.
Definition
TAMakerChannelDistanceAlgorithm.cpp:27
triggeralgs::TAMakerChannelDistanceAlgorithm::m_current_upper_bound
uint32_t m_current_upper_bound
Definition
TAMakerChannelDistanceAlgorithm.hpp:30
triggeralgs::TAMakerChannelDistanceAlgorithm::m_current_ta
TriggerActivity m_current_ta
Definition
TAMakerChannelDistanceAlgorithm.hpp:25
triggeralgs::TAMakerChannelDistanceAlgorithm::set_ta_attributes
void set_ta_attributes()
Definition
TAMakerChannelDistanceAlgorithm.cpp:73
triggeralgs::TAMakerChannelDistanceAlgorithm::m_current_lower_bound
uint32_t m_current_lower_bound
Definition
TAMakerChannelDistanceAlgorithm.hpp:29
triggeralgs::TAMakerChannelDistanceAlgorithm::m_window_length
uint64_t m_window_length
Definition
TAMakerChannelDistanceAlgorithm.hpp:27
triggeralgs::TAMakerChannelDistanceAlgorithm::configure
void configure(const nlohmann::json &config)
Definition
TAMakerChannelDistanceAlgorithm.cpp:58
triggeralgs::TAMakerChannelDistanceAlgorithm::m_max_channel_distance
uint32_t m_max_channel_distance
Definition
TAMakerChannelDistanceAlgorithm.hpp:26
triggeralgs::TAMakerChannelDistanceAlgorithm::m_min_tps
uint16_t m_min_tps
Definition
TAMakerChannelDistanceAlgorithm.hpp:28
triggeralgs::TAMakerChannelDistanceAlgorithm::set_new_ta
void set_new_ta(const TriggerPrimitive &input_tp)
Definition
TAMakerChannelDistanceAlgorithm.cpp:17
triggeralgs::TriggerActivityMaker::configure
virtual void configure(const nlohmann::json &config)
Definition
TriggerActivityMaker.hpp:111
triggeralgs
Definition
AbstractFactory.hpp:18
triggeralgs::channel_diff_t
dunedaq::trgdataformats::channel_diff_t channel_diff_t
Definition
Types.hpp:21
triggeralgs::TriggerPrimitive
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
Definition
TriggerPrimitive.hpp:22
TAMakerChannelDistanceAlgorithm.hpp
dunedaq::trgdataformats::TriggerActivityData::Type::kTPC
@ kTPC
Definition
TriggerActivityData.hpp:22
dunedaq::trgdataformats::TriggerActivityData::Algorithm::kChannelDistance
@ kChannelDistance
Definition
TriggerActivityData.hpp:36
dunedaq::trgdataformats::TriggerPrimitive::detid
uint64_t detid
Definition
TriggerPrimitive.hpp:33
dunedaq::trgdataformats::TriggerPrimitive::channel
uint64_t channel
Definition
TriggerPrimitive.hpp:36
dunedaq::trgdataformats::TriggerPrimitive::adc_peak
uint64_t adc_peak
Definition
TriggerPrimitive.hpp:43
dunedaq::trgdataformats::TriggerPrimitive::time_start
uint64_t time_start
Definition
TriggerPrimitive.hpp:39
dunedaq::trgdataformats::TriggerPrimitive::samples_to_peak
uint64_t samples_to_peak
Definition
TriggerPrimitive.hpp:40
dunedaq::trgdataformats::TriggerPrimitive::adc_integral
uint64_t adc_integral
Definition
TriggerPrimitive.hpp:42
Generated on
for DUNE-DAQ by
1.17.0