11#include "TRACE/trace.h"
12#define TRACE_NAME "TCMakerMichelElectronAlgorithm"
18using Logging::TLVL_DEBUG_ALL;
19using Logging::TLVL_DEBUG_HIGH;
20using Logging::TLVL_DEBUG_LOW;
21using Logging::TLVL_DEBUG_INFO;
22using Logging::TLVL_VERY_IMPORTANT;
26 std::vector<TriggerCandidate>& output_tc)
29 std::vector<TriggerActivity::TriggerActivityData> ta_list = {
static_cast<TriggerActivity::TriggerActivityData
>(
43 TLOG_DEBUG(TLVL_DEBUG_LOW) <<
"[TCM:ME] Constructing TC.";
46 output_tc.push_back(tc);
60 TLOG_DEBUG(TLVL_DEBUG_HIGH) <<
"[TCM:ME] Window not yet complete, adding the activity to the window.";
68 TLOG_DEBUG(TLVL_DEBUG_LOW) <<
"[TCM:ME] ADC integral in window is greater than specified threshold.";
71 output_tc.push_back(tc);
72 TLOG_DEBUG(TLVL_DEBUG_HIGH) <<
"[TCM:ME] Resetting window with activity.";
83 TLOG_DEBUG(TLVL_DEBUG_INFO) <<
"[TCM:ME] Should not see this!";
87 TLOG_DEBUG(TLVL_DEBUG_HIGH) <<
"[TCM:ME] Window is at required length but specified threshold not met, shifting window along.";
106 if (config.is_object()) {
107 if (config.contains(
"trigger_on_adc"))
109 if (config.contains(
"trigger_on_n_channels"))
111 if (config.contains(
"adc_threshold"))
113 if (config.contains(
"n_channels_threshold"))
115 if (config.contains(
"window_length"))
120 TLOG_DEBUG(TLVL_VERY_IMPORTANT) <<
"[TCM:ME] Triggering on ADC count and number of channels is not supported.";
124 TLOG_DEBUG(TLVL_DEBUG_LOW) <<
"[TCM:ME] Both trigger flags are false. Passing TAs through 1:1.";
172 std::ofstream outfile;
173 outfile.open(
"window_record_tcm.csv", std::ios_base::app);
176 outfile << window.time_start <<
",";
177 outfile << window.inputs.back().time_start <<
",";
178 outfile << window.inputs.back().time_start - window.time_start <<
",";
179 outfile << window.adc_integral <<
",";
180 outfile << window.n_channels_hit() <<
",";
181 outfile << window.inputs.size() << std::endl;
#define REGISTER_TRIGGER_CANDIDATE_MAKER(tcm_name, tcm_class)
void reset(TriggerActivity const &input_ta)
uint16_t n_channels_hit()
void add(const TriggerActivity &input_ta)
void move(TriggerActivity const &input_ta, timestamp_t const &window_length)
std::vector< TriggerActivity > inputs
uint16_t m_n_channels_threshold
bool m_trigger_on_n_channels
timestamp_t m_window_length
std::vector< Window > m_window_record
void dump_window_record()
TriggerCandidate construct_tc() const
void process(const TriggerActivity &, std::vector< TriggerCandidate > &)
The function that gets call when there is a new activity.
uint64_t m_activity_count
void configure(const nlohmann::json &config)
void add_window_to_record(Window window)
bool check_adjacency() const
TriggerCandidate::Type m_tc_type_out
Configurable TC type output.
virtual void configure(const nlohmann::json &config)
#define TLOG_DEBUG(lvl,...)
std::vector< dunedaq::trgdataformats::TriggerActivityData > inputs