diff --git a/include/trigger/Issues.hpp b/include/trigger/Issues.hpp index c1cffd9a..8b366f58 100644 --- a/include/trigger/Issues.hpp +++ b/include/trigger/Issues.hpp @@ -28,7 +28,7 @@ namespace dunedaq { -ERS_DECLARE_ISSUE(trigger, InvalidConfiguration, "An invalid configuration object was received", ERS_EMPTY) +ERS_DECLARE_ISSUE(trigger, InvalidConfiguration, "Invalid configuration error:" << conferror, ((std::string)conferror)) ERS_DECLARE_ISSUE(trigger, TriggerActive, "Trigger is active now", ERS_EMPTY) ERS_DECLARE_ISSUE(trigger, TriggerPaused, "Trigger is paused", ERS_EMPTY) ERS_DECLARE_ISSUE(trigger, TriggerInhibited, "Trigger is inhibited in run " << runno, ((int64_t)runno)) diff --git a/integtest/td_leakage_between_runs_test.py b/integtest/td_leakage_between_runs_test.py index 32faa588..03dd2e4d 100644 --- a/integtest/td_leakage_between_runs_test.py +++ b/integtest/td_leakage_between_runs_test.py @@ -53,20 +53,19 @@ conf_dict["trigger"]["mlt_merge_overlapping_tcs"] = True conf_dict["trigger"]["mlt_send_timed_out_tds"] = True conf_dict["trigger"]["mlt_buffer_timeout"] = 1000 -conf_dict["trigger"]["mlt_use_readout_map"] = True conf_dict["trigger"]["mlt_td_readout_map"] = [] rmap_conf = {} -rmap_conf["candidate_type"] = 1 +rmap_conf["tc_type_name"] = "kTiming" rmap_conf["time_before"] = readout_window_time_before rmap_conf["time_after"] = readout_window_time_after conf_dict["trigger"]["mlt_td_readout_map"].append(rmap_conf) rmap_conf = {} -rmap_conf["candidate_type"] = 2 +rmap_conf["tc_type_name"] = "kTPCLowE" rmap_conf["time_before"] = readout_window_time_before rmap_conf["time_after"] = readout_window_time_after conf_dict["trigger"]["mlt_td_readout_map"].append(rmap_conf) rmap_conf = {} -rmap_conf["candidate_type"] = 3 +rmap_conf["tc_type_name"] = "kSupernova" rmap_conf["time_before"] = readout_window_time_before rmap_conf["time_after"] = readout_window_time_after conf_dict["trigger"]["mlt_td_readout_map"].append(rmap_conf) diff --git a/plugins/RandomTCMakerModule.cpp b/plugins/RandomTCMakerModule.cpp index a65c28f8..6acadaf5 100644 --- a/plugins/RandomTCMakerModule.cpp +++ b/plugins/RandomTCMakerModule.cpp @@ -64,13 +64,25 @@ RandomTCMakerModule::init(std::shared_ptr mcfg) m_conf = mtrg->get_configuration(); // Get the TC out configuration - m_tc_readout = m_conf->get_tc_readout(); + const appmodel::TCReadoutMap* tc_readout = m_conf->get_tc_readout(); + m_tcout_time_before = tc_readout->get_time_before(); + m_tcout_time_after = tc_readout->get_time_after(); + m_tcout_type = static_cast( + dunedaq::trgdataformats::string_to_fragment_type_value(tc_readout->get_tc_type_name())); + + // Throw error if unknown TC type + if (m_tcout_type == TCType::kUnknown) { + throw(InvalidConfiguration(ERS_HERE, "Provided an unknown TC type output to RandomTCMakerModule!")); + } m_latency_monitoring.store( m_conf->get_latency_monitoring() ); // Get the clock speed from detector configuration m_clock_speed_hz = mcfg->configuration_manager()->session()->get_detector_configuration()->get_clock_speed_hz(); m_trigger_rate_hz.store(m_conf->get_trigger_rate_hz()); + TLOG() << "RandomTCMaker will output TC of type: " << tc_readout->get_tc_type_name(); + TLOG() << "TC window time before: " << m_tcout_time_before + << " time after: " << m_tcout_time_after; TLOG() << "Clock speed is: " << m_clock_speed_hz; TLOG() << "Output trigger rate is: " << m_trigger_rate_hz.load(); } @@ -174,16 +186,11 @@ triggeralgs::TriggerCandidate RandomTCMakerModule::create_candidate(dfmessages::timestamp_t timestamp) { triggeralgs::TriggerCandidate candidate; - candidate.time_start = (timestamp - m_tc_readout->get_time_before()); - candidate.time_end = (timestamp + m_tc_readout->get_time_after()); + candidate.time_start = (timestamp - m_tcout_time_before); + candidate.time_end = (timestamp + m_tcout_time_after); candidate.time_candidate = timestamp; candidate.detid = { 0 }; - candidate.type = static_cast(m_tc_readout->get_candidate_type()); - - // Throw error if unknown TC type - if (candidate.type == triggeralgs::TriggerCandidate::Type::kUnknown) { - throw InvalidConfiguration(ERS_HERE); - } + candidate.type = m_tcout_type; // TODO: Originally kHSIEventToTriggerCandidate candidate.algorithm = triggeralgs::TriggerCandidate::Algorithm::kCustom; diff --git a/plugins/RandomTCMakerModule.hpp b/plugins/RandomTCMakerModule.hpp index f50fca7c..c51d1eb9 100644 --- a/plugins/RandomTCMakerModule.hpp +++ b/plugins/RandomTCMakerModule.hpp @@ -72,6 +72,7 @@ class RandomTCMakerModule : public dunedaq::appfwk::DAQModule void generate_opmon_data() override; private: + using TCType = triggeralgs::TriggerCandidate::Type; // Commands void do_configure(const nlohmann::json& obj); void do_start(const nlohmann::json& obj); @@ -97,9 +98,17 @@ class RandomTCMakerModule : public dunedaq::appfwk::DAQModule std::shared_ptr> m_time_sync_source; std::shared_ptr> m_trigger_candidate_sink; - //randomtriggercandidatemaker::Conf m_conf; const appmodel::RandomTCMakerConf* m_conf; - const appmodel::TCReadoutMap* m_tc_readout; + + /// @brief Output TC type + TCType m_tcout_type; + /// @brief Output window start time, based off trigger timestamp + dfmessages::timestamp_t m_tcout_time_before; + /// @brief Output window end time, based off trigger timestamp + dfmessages::timestamp_t m_tcout_time_after; + + + /// @brief Clock speed in hz, taken from detector configuration uint64_t m_clock_speed_hz; diff --git a/src/TCProcessor.cpp b/src/TCProcessor.cpp index fb305320..9e9187df 100644 --- a/src/TCProcessor.cpp +++ b/src/TCProcessor.cpp @@ -91,7 +91,7 @@ TCProcessor::conf(const appmodel::DataHandlerModule* cfg) { auto mtrg = cfg->cast(); if (mtrg == nullptr) { - throw(InvalidConfiguration(ERS_HERE)); + throw(InvalidConfiguration(ERS_HERE, "Provided null TriggerDataHandlerModule configuration!")); } for (auto output : mtrg->get_outputs()) { try { @@ -134,31 +134,31 @@ TCProcessor::conf(const appmodel::DataHandlerModule* cfg) m_send_timed_out_tds = (m_ignore_tc_pileup) ? false : proc_conf->get_td_out_of_timeout(); m_td_readout_limit = proc_conf->get_td_readout_limit(); m_ignored_tc_types = proc_conf->get_ignore_tc(); - m_ignoring_tc_types = (m_ignored_tc_types.size() > 0) ? true : false; - m_use_readout_map = proc_conf->get_use_readout_map(); - m_use_roi_readout = proc_conf->get_use_roi_readout(); + m_ignoring_tc_types = !m_ignored_tc_types.empty(); m_use_bitwords = proc_conf->get_use_bitwords(); TLOG_DEBUG(3) << "Allow merging: " << m_tc_merging; TLOG_DEBUG(3) << "Ignore pileup: " << m_ignore_tc_pileup; TLOG_DEBUG(3) << "Buffer timeout: " << m_buffer_timeout; TLOG_DEBUG(3) << "Should send timed out TDs: " << m_send_timed_out_tds; TLOG_DEBUG(3) << "TD readout limit: " << m_td_readout_limit; - TLOG_DEBUG(3) << "Use ROI readout?: " << m_use_roi_readout; // ROI map - if(m_use_roi_readout){ - m_roi_conf_data = proc_conf->get_roi_group_conf(); + m_roi_conf_data = proc_conf->get_roi_group_conf(); + m_use_roi_readout = !m_roi_conf_data.empty(); + if (m_use_roi_readout) { parse_roi_conf(m_roi_conf_data); print_roi_conf(m_roi_conf); } + TLOG_DEBUG(3) << "Use ROI readout?: " << m_use_roi_readout; // Custom readout map - TLOG_DEBUG(3) << "Use readout map: " << m_use_readout_map; - if(m_use_readout_map){ - m_readout_window_map_data = proc_conf->get_tc_readout_map(); + m_readout_window_map_data = proc_conf->get_tc_readout_map(); + m_use_readout_map = !m_readout_window_map_data.empty(); + if (m_use_readout_map) { parse_readout_map(m_readout_window_map_data); print_readout_map(m_readout_window_map); } + TLOG_DEBUG(3) << "Use readout map: " << m_use_readout_map; // Ignoring TC types TLOG_DEBUG(3) << "Ignoring TC types: " << m_ignoring_tc_types; @@ -275,7 +275,7 @@ TCProcessor::create_decision(const PendingTD& pending_td) decision.readout_type = dfmessages::ReadoutType::kLocalized; if (m_hsi_passthrough == true) { - if (pending_td.contributing_tcs[m_earliest_tc_index].type == triggeralgs::TriggerCandidate::Type::kTiming) { + if (pending_td.contributing_tcs[m_earliest_tc_index].type == TCType::kTiming) { decision.trigger_type = pending_td.contributing_tcs[m_earliest_tc_index].detid & 0xff; } else { m_trigger_type_shifted = (static_cast(pending_td.contributing_tcs[m_earliest_tc_index].type) << 8); @@ -617,15 +617,23 @@ void TCProcessor::parse_readout_map(const std::vector& data) { for (auto readout_type : data) { - m_readout_window_map[static_cast(readout_type->get_candidate_type())] = { + TCType tc_type = static_cast( + dunedaq::trgdataformats::string_to_fragment_type_value(readout_type->get_tc_type_name())); + + // Throw error if unknown TC type + if (tc_type == TCType::kUnknown) { + throw(InvalidConfiguration(ERS_HERE, "Provided an unknown TC type in the TCReadoutMap for the TCProcessor")); + } + + m_readout_window_map[tc_type] = { readout_type->get_time_before(), readout_type->get_time_after() }; } return; } void -TCProcessor::print_readout_map(std::map> map) +TCProcessor::print_readout_map(std::map> map) { TLOG_DEBUG(3) << "MLT TD Readout map:"; for (auto const& [key, val] : map) { diff --git a/src/trigger/TCProcessor.hpp b/src/trigger/TCProcessor.hpp index e1a6e84a..56c607bb 100644 --- a/src/trigger/TCProcessor.hpp +++ b/src/trigger/TCProcessor.hpp @@ -59,7 +59,8 @@ class TCProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_readout_window_map_data; - std::map> + std::map> m_readout_window_map; void parse_readout_map(const std::vector& data); - void print_readout_map(std::map> map); // Create the next trigger decision