11#include "TRACE/trace.h"
12#define TRACE_NAME "TAMakerADCSimpleWindowAlgorithm"
41 uint32_t n_tps_to_erase = 0;
42 for(
auto tp : tp_list){
43 if(input_tp.
time_start-tp.time_start >= window_length){
51 tp_list.erase(tp_list.begin(), tp_list.begin()+n_tps_to_erase);
74 tp_list.push_back(input_tp);
83 os <<
"Window is empty!\n";
86 <<
", end: " << window.
tp_list.back().time_start
88 <<
" ADC counts with " << window.
tp_list.size()
109 TLOG_DEBUG(TLVL_DEBUG_HIGH) <<
"[TAM:ADCSW] Window not yet complete, adding the input_tp to the window.";
117 TLOG_DEBUG(TLVL_DEBUG_LOW) <<
"[TAM:ADCSW] ADC integral in window is greater than specified threshold.";
119 TLOG_DEBUG(TLVL_DEBUG_HIGH) <<
"[TAM:ADCSW] Resetting window with input_tp.";
124 TLOG_DEBUG(TLVL_DEBUG_ALL) <<
"[TAM:ADCSW] Window is at required length but adc threshold not met, shifting window along.";
141 if (config.is_object()){
142 if (config.contains(
"window_length"))
m_window_length = config[
"window_length"];
143 if (config.contains(
"adc_threshold"))
m_adc_threshold = config[
"adc_threshold"];
146 TLOG_DEBUG(TLVL_IMPORTANT) <<
"[TAM:ADCSW] The DEFAULT values of window_length and adc_threshold are being used.";
148 TLOG_DEBUG(TLVL_IMPORTANT) <<
"[TAM:ADCSW] If the total ADC of trigger primitives with times within a "
155 TLOG_DEBUG(TLVL_DEBUG_LOW) <<
"[TAM:ADCSW] I am constructing a trigger activity!";
163 uint64_t ch_peak{last_tp.
channel};
167 std::vector<TriggerPrimitive> tp_list;
175 ch_min = std::min(ch_min, tp.channel);
176 ch_max = std::max(ch_max, tp.channel);
177 time_min = std::min(time_min, tp.time_start);
181 ch_peak = tp.channel;
185 tp_list.push_back(tp);
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
std::deque< TriggerPrimitive > tp_list
void reset(TriggerPrimitive const &input_tp)
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
void add(TriggerPrimitive const &input_tp)
uint64_t m_primitive_count
TriggerActivity construct_ta() const
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
TP processing function that creates & fills TAs.
timestamp_t m_window_length
const uint16_t k_sample_to_dts_ticks
void configure(const nlohmann::json &config)
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
dunedaq::trgdataformats::timestamp_t timestamp_t
std::ostream & operator<<(std::ostream &os, const ProtoDUNEBSMWindow &window)
std::vector< TriggerPrimitive > inputs