DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
triggeralgs::TAMakerADCSimpleWindowAlgorithm Class Reference

#include <TAMakerADCSimpleWindowAlgorithm.hpp>

Inheritance diagram for triggeralgs::TAMakerADCSimpleWindowAlgorithm:
[legend]
Collaboration diagram for triggeralgs::TAMakerADCSimpleWindowAlgorithm:
[legend]

Classes

class  Window
 

Public Member Functions

void process (const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
 TP processing function that creates & fills TAs.
 
void configure (const nlohmann::json &config)
 
- Public Member Functions inherited from triggeralgs::TriggerActivityMaker
virtual ~TriggerActivityMaker ()=default
 
void operator() (const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
 
virtual bool preprocess (const TriggerPrimitive &input_tp)
 TP pre-processing/filtering.
 
virtual void postprocess (std::vector< TriggerActivity > &output_ta)
 Post-processing/filtering of the TAs, e.g. prescale.
 
virtual void flush (timestamp_t, std::vector< TriggerActivity > &)
 

Private Member Functions

TriggerActivity construct_ta () const
 

Private Attributes

Window m_current_window
 
uint64_t m_primitive_count = 0
 
uint32_t m_adc_threshold = 1200000
 
timestamp_t m_window_length = 100000
 
const uint16_t k_sample_to_dts_ticks = 32
 

Additional Inherited Members

- Public Attributes inherited from triggeralgs::TriggerActivityMaker
std::atomic< uint64_t > m_data_vs_system_time = 0
 
std::atomic< uint64_t > m_initial_offset = 0
 
uint64_t m_prescale = 1
 Configurable prescale factor.
 
uint64_t m_ta_count = 0
 TA made count for prescaling.
 
uint32_t m_max_samples_over_threshold = std::numeric_limits<uint32_t>::max()
 Time-over-threshold TP filtering.
 

Detailed Description

Definition at line 18 of file TAMakerADCSimpleWindowAlgorithm.hpp.

Member Function Documentation

◆ configure()

void triggeralgs::TAMakerADCSimpleWindowAlgorithm::configure ( const nlohmann::json & config)
virtual

Reimplemented from triggeralgs::TriggerActivityMaker.

Definition at line 136 of file TAMakerADCSimpleWindowAlgorithm.cpp.

137{
139
140 //FIXME use some schema here
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"];
144 }
145 else{
146 TLOG_DEBUG(TLVL_IMPORTANT) << "[TAM:ADCSW] The DEFAULT values of window_length and adc_threshold are being used.";
147 }
148 TLOG_DEBUG(TLVL_IMPORTANT) << "[TAM:ADCSW] If the total ADC of trigger primitives with times within a "
149 << m_window_length << " tick time window is above " << m_adc_threshold << " counts, a trigger will be issued.";
150}
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ construct_ta()

TriggerActivity triggeralgs::TAMakerADCSimpleWindowAlgorithm::construct_ta ( ) const
private

Definition at line 153 of file TAMakerADCSimpleWindowAlgorithm.cpp.

154{
155 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TAM:ADCSW] I am constructing a trigger activity!";
156 //TLOG_DEBUG(TRACE_NAME) << m_current_window;
157
158 const TriggerPrimitive& last_tp = m_current_window.tp_list.back();
159 uint64_t ch_min{last_tp.channel}, ch_max{last_tp.channel};
160 uint64_t time_min{last_tp.time_start}, time_max{last_tp.time_start + last_tp.samples_over_threshold * k_sample_to_dts_ticks};
161
162 uint64_t adc_peak{last_tp.adc_peak};
163 uint64_t ch_peak{last_tp.channel};
164 timestamp_t time_peak{last_tp.time_start + last_tp.samples_to_peak * k_sample_to_dts_ticks};
165
166
167 std::vector<TriggerPrimitive> tp_list;
168 tp_list.reserve(m_current_window.tp_list.size());
169
170
171 // Copy the queue into the vector
172 // And compute TA parameters
173 for( const auto& tp : m_current_window.tp_list ) {
174
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);
178 time_max = std::max(time_max, tp.time_start + tp.samples_over_threshold * k_sample_to_dts_ticks); // FIXME: Replace the hard-coded SOT to TOT scaling.
179 if (tp.adc_peak > adc_peak) {
180 adc_peak = tp.adc_peak;
181 ch_peak = tp.channel;
182 time_peak = tp.time_start + tp.samples_to_peak * k_sample_to_dts_ticks; // FIXME: Replace the hard-coded STP to `time_peak` conversion.
183 }
184
185 tp_list.push_back(tp);
186 }
187
189
190 ta.time_start = time_min;
191 ta.time_end = time_max;
192 ta.time_peak = time_peak;
193 ta.time_activity = time_peak;
194 ta.channel_start = ch_min;
195 ta.channel_end = ch_max;
196 ta.channel_peak = ch_peak;
197 ta.adc_integral = m_current_window.adc_integral;
198 ta.adc_peak = adc_peak;
199 ta.detid = last_tp.detid;
202 ta.inputs.swap(tp_list);
203 return ta;
204}
dunedaq::trgdataformats::timestamp_t timestamp_t
Definition Types.hpp:16
dunedaq::trgdataformats::TriggerPrimitive TriggerPrimitive

◆ process()

void triggeralgs::TAMakerADCSimpleWindowAlgorithm::process ( const TriggerPrimitive & input_tp,
std::vector< TriggerActivity > & output_ta )
virtual

TP processing function that creates & fills TAs.

Parameters
input_tp[in]Input TP for the triggering algorithm
output_ta[out]Output vector of TAs to fill by the algorithm

Implements triggeralgs::TriggerActivityMaker.

Definition at line 95 of file TAMakerADCSimpleWindowAlgorithm.cpp.

96{
97
98 // The first time operator is called, reset
99 // window object.
101 m_current_window.reset(input_tp);
103 return;
104 }
105
106 // If the difference between the current TP's start time and the start of the window
107 // is less than the specified window size, add the TP to the window.
108 if((input_tp.time_start - m_current_window.time_start) < m_window_length){
109 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TAM:ADCSW] Window not yet complete, adding the input_tp to the window.";
110 m_current_window.add(input_tp);
111 }
112 // If the addition of the current TP to the window would make it longer
113 // than the specified window length, don't add it but check whether the sum of all adc in
114 // the existing window is above the specified threshold. If it is, make a TA and start
115 // a fresh window with the current TP.
117 TLOG_DEBUG(TLVL_DEBUG_LOW) << "[TAM:ADCSW] ADC integral in window is greater than specified threshold.";
118 output_ta.push_back(construct_ta());
119 TLOG_DEBUG(TLVL_DEBUG_HIGH) << "[TAM:ADCSW] Resetting window with input_tp.";
120 m_current_window.reset(input_tp);
121 }
122 // If it is not, move the window along.
123 else{
124 TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TAM:ADCSW] Window is at required length but adc threshold not met, shifting window along.";
126 }
127
128 TLOG_DEBUG(TLVL_DEBUG_ALL) << "[TAM:ADCSW] " << m_current_window;
129
131
132 return;
133}
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)

Member Data Documentation

◆ k_sample_to_dts_ticks

const uint16_t triggeralgs::TAMakerADCSimpleWindowAlgorithm::k_sample_to_dts_ticks = 32
private

Definition at line 62 of file TAMakerADCSimpleWindowAlgorithm.hpp.

◆ m_adc_threshold

uint32_t triggeralgs::TAMakerADCSimpleWindowAlgorithm::m_adc_threshold = 1200000
private

Definition at line 57 of file TAMakerADCSimpleWindowAlgorithm.hpp.

◆ m_current_window

Window triggeralgs::TAMakerADCSimpleWindowAlgorithm::m_current_window
private

Definition at line 53 of file TAMakerADCSimpleWindowAlgorithm.hpp.

◆ m_primitive_count

uint64_t triggeralgs::TAMakerADCSimpleWindowAlgorithm::m_primitive_count = 0
private

Definition at line 54 of file TAMakerADCSimpleWindowAlgorithm.hpp.

◆ m_window_length

timestamp_t triggeralgs::TAMakerADCSimpleWindowAlgorithm::m_window_length = 100000
private

Definition at line 58 of file TAMakerADCSimpleWindowAlgorithm.hpp.


The documentation for this class was generated from the following files: