10#include "TRACE/trace.h"
11#define TRACE_NAME "TAMakerHorizontalMuonAlgorithm"
18using Logging::TLVL_DEBUG_ALL;
19using Logging::TLVL_DEBUG_MEDIUM;
23 std::vector<TriggerActivity>& output_ta)
33 <<
", TP Offline Channel ID: " << input_tp.
channel;
60 <<
" window ADC integral. ta.time_start=" << ta.time_start
61 <<
" ta.time_end=" << ta.time_end;
63 output_ta.push_back(ta);
74 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) <<
"[TAM:HM] Emitting multiplicity trigger with "
95 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) <<
"[TAM:HM] Emitting track and multiplicity TA with adjacency "
109 TLOG_DEBUG(TLVL_DEBUG_MEDIUM) <<
"[TAM:HM] Emitting a TA due to a TP with a very large samples over threshold: "
111 <<
", where the ADC integral of that TP is " << input_tp.
adc_integral;
129 if (config.is_object()) {
130 if (config.contains(
"trigger_on_adc"))
132 if (config.contains(
"trigger_on_n_channels"))
134 if (config.contains(
"adc_threshold"))
136 if (config.contains(
"n_channels_threshold"))
138 if (config.contains(
"window_length"))
140 if (config.contains(
"trigger_on_adjacency"))
142 if (config.contains(
"adjacency_tolerance"))
144 if (config.contains(
"adjacency_threshold"))
146 if (config.contains(
"print_tp_info"))
148 if (config.contains(
"trigger_on_sot"))
150 if (config.contains(
"sot_threshold"))
178 for(
const auto& tp : ta.
inputs ) {
180 ta.
time_end = std::max(ta.
time_end, tp.time_start + tp.samples_over_threshold * 32);
184 ta.
time_peak = tp.samples_to_peak * 32 + tp.time_start;
204 unsigned int channel = 0;
205 unsigned int next_channel = 0;
206 unsigned int next = 0;
207 unsigned int tol_count = 0;
210 std::vector<int> chanList;
212 chanList.push_back(
channel_t(tp.channel));
214 std::sort(chanList.begin(), chanList.end());
222 for (
int i = 0; i < chanList.size(); ++i) {
224 next = (i + 1) % chanList.size();
225 channel = chanList.at(i);
226 next_channel = chanList.at(next);
229 if (next_channel == 0) {
230 next_channel = channel - 1;
234 if (next_channel == channel) {
239 else if (next_channel == channel + 1) {
245 else if (((next_channel == channel + 2) || (next_channel == channel + 3) || (next_channel == channel + 4) ||
246 (next_channel == channel + 5)) &&
249 for (
int i = 0; i < next_channel - channel; ++i) {
282 std::ofstream outfile;
283 outfile.open(
"window_record_tam.csv", std::ios_base::app);
286 outfile << window.time_start <<
",";
287 outfile << window.inputs.back().time_start <<
",";
288 outfile << window.inputs.back().time_start - window.time_start <<
",";
289 outfile << window.adc_integral <<
",";
290 outfile << window.n_channels_hit() <<
",";
291 outfile << window.inputs.size() <<
",";
292 outfile << window.inputs.back().channel <<
",";
293 outfile << window.inputs.front().channel <<
",";
308 std::ofstream outfile;
309 outfile.open(
"coldbox_tps.txt", std::ios_base::app);
315 outfile << input_tp.
channel <<
" ";
317 outfile << input_tp.
adc_peak <<
" ";
318 outfile << input_tp.
detid <<
" ";
331 window_sot += tp.samples_over_threshold;
#define REGISTER_TRIGGER_ACTIVITY_MAKER(tam_name, tam_class)
timestamp_t m_window_length
uint16_t check_adjacency() const
void dump_tp(TriggerPrimitive const &input_tp)
std::vector< TPWindow > m_window_record
void configure(const nlohmann::json &config)
uint16_t m_adjacency_threshold
bool m_trigger_on_adjacency
void dump_window_record()
uint16_t m_n_channels_threshold
void process(const TriggerPrimitive &input_tp, std::vector< TriggerActivity > &output_ta)
TP processing function that creates & fills TAs.
TPWindow m_current_window
void add_window_to_record(TPWindow window)
TriggerActivity construct_ta() const
bool m_trigger_on_n_channels
void reset(TriggerPrimitive const &input_tp)
void add(TriggerPrimitive const &input_tp)
std::vector< TriggerPrimitive > inputs
void move(TriggerPrimitive const &input_tp, timestamp_t const &window_length)
uint16_t n_channels_hit()
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
dunedaq::trgdataformats::channel_t channel_t
std::vector< TriggerPrimitive > inputs