DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TAMakerADCSimpleWindowAlgorithm.cpp
Go to the documentation of this file.
1
10
11#include "TRACE/trace.h"
12#define TRACE_NAME "TAMakerADCSimpleWindowAlgorithm"
13
14#include <vector>
15
16
17using namespace triggeralgs;
18using Logging::TLVL_DEBUG_ALL;
19using Logging::TLVL_DEBUG_HIGH;
20using Logging::TLVL_DEBUG_LOW;
21using Logging::TLVL_IMPORTANT;
22
23void
24TAMakerADCSimpleWindowAlgorithm::process(const TriggerPrimitive& input_tp, std::vector<TriggerActivity>& output_ta)
25{
26
27 // The first time operator is called, reset
28 // window object.
30 m_current_window.reset(input_tp);
32 return;
33 }
34
35 // If the difference between the current TP's start time and the start of the window
36 // is less than the specified window size, add the TP to the window.
38 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TAM:ADCSW] Window not yet complete, adding the input_tp to the window.";
39 m_current_window.add(input_tp);
40 }
41 // If the addition of the current TP to the window would make it longer
42 // than the specified window length, don't add it but check whether the sum of all adc in
43 // the existing window is above the specified threshold. If it is, make a TA and start
44 // a fresh window with the current TP.
46 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TAM:ADCSW] ADC integral in window is greater than specified threshold.";
47 output_ta.push_back(construct_ta());
48 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TAM:ADCSW] Resetting window with input_tp.";
49 m_current_window.reset(input_tp);
50 }
51 // If it is not, move the window along.
52 else{
53 TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TAM:ADCSW] Window is at required length but adc threshold not met, shifting window along.";
55 }
56
57 TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TAM:ADCSW] " << m_current_window;
58
60
61 return;
62}
63
64void
65TAMakerADCSimpleWindowAlgorithm::configure(const nlohmann::json& config)
66{
68
69 //FIXME use some schema here
70 if (config.is_object()){
71 if (config.contains("window_length")) m_window_length = config["window_length"];
72 if (config.contains("adc_threshold")) m_adc_threshold = config["adc_threshold"];
73 }
74 else{
75 TLOG_DEBUG(TLVL_IMPORTANT) << "[TAM:ADCSW] The DEFAULT values of window_length and adc_threshold are being used.";
76 }
77 TLOG_DEBUG(TLVL_IMPORTANT) << "[TAM:ADCSW] If the total ADC of trigger primitives with times within a "
78 << m_window_length << " tick time window is above " << m_adc_threshold << " counts, a trigger will be issued.";
79}
80
83{
84 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TAM:ADCSW] I am constructing a trigger activity!";
85 //TLOG_DEBUG(TRACE_NAME) << m_current_window;
86
87 TriggerPrimitive latest_tp_in_window = m_current_window.tp_list.back();
88 // The time_peak, time_activity, channel_* and adc_peak fields of this TA are irrelevent
89 // for the purpose of this trigger alg.
92 ta.time_end = latest_tp_in_window.time_start + latest_tp_in_window.samples_over_threshold * 32; // FIXME: Replace the hard-coded SOT to TOT scaling.
93 ta.time_peak = latest_tp_in_window.samples_to_peak * 32 + latest_tp_in_window.time_start; // FIXME: Replace STP to `time_peak` conversion.
95 ta.channel_start = latest_tp_in_window.channel;
96 ta.channel_end = latest_tp_in_window.channel;
97 ta.channel_peak = latest_tp_in_window.channel;
99 ta.adc_peak = latest_tp_in_window.adc_peak;
100 ta.detid = latest_tp_in_window.detid;
104 return ta;
105}
106
107// Register algo in TA Factory
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
TP processing function that creates & fills TAs.
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TRACE_NAME
A single energy deposition on a TPC or PDS channel.
std::vector< TriggerPrimitive > inputs