DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TAMakerChannelDistanceAlgorithm.cpp
Go to the documentation of this file.
1
8
10
11#include "TRACE/trace.h"
12#define TRACE_NAME "TAMakerChannelDistanceAlgorithm"
13
14namespace triggeralgs {
15
16void
25
26void
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) {
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.
50 return;
51
52 m_current_ta.inputs.push_back(input_tp);
55}
56
57void
58TAMakerChannelDistanceAlgorithm::configure(const nlohmann::json& config)
59{
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
72void
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
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
103
104} // namespace triggeralgs
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_tas)
TP processing function that creates & fills TAs.
virtual void configure(const nlohmann::json &config)
dunedaq::trgdataformats::channel_diff_t channel_diff_t
Definition Types.hpp:21
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive
#define TRACE_NAME