diff --git a/include/trigger/AlgorithmPlugins.hpp b/include/trigger/AlgorithmPlugins.hpp index d7516911..39b53e74 100644 --- a/include/trigger/AlgorithmPlugins.hpp +++ b/include/trigger/AlgorithmPlugins.hpp @@ -11,10 +11,10 @@ #ifndef TRIGGER_INCLUDE_TRIGGER_ALGORITHMPLUGINS_HPP_ #define TRIGGER_INCLUDE_TRIGGER_ALGORITHMPLUGINS_HPP_ -#include "triggeralgs/TriggerDecisionMaker.hpp" +#include "trigger/Issues.hpp" #include "triggeralgs/TriggerActivityFactory.hpp" #include "triggeralgs/TriggerCandidateFactory.hpp" -#include "trigger/Issues.hpp" +#include "triggeralgs/TriggerDecisionMaker.hpp" #include "cetlib/BasicPluginFactory.h" @@ -71,7 +71,7 @@ make_tc_maker(std::string const& plugin_name) { \ std::unique_ptr make() \ { \ - return std::unique_ptr(new klass()); \ + return std::unique_ptr(new klass()); \ } \ } diff --git a/include/trigger/Issues.hpp b/include/trigger/Issues.hpp index f69f921e..da7fbf26 100644 --- a/include/trigger/Issues.hpp +++ b/include/trigger/Issues.hpp @@ -13,12 +13,12 @@ #include "daqdataformats/SourceID.hpp" #include "daqdataformats/Types.hpp" #include "ers/Issue.hpp" -#include "triggeralgs/Types.hpp" -#include "trigger/serialize.hpp" #include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG< #include +#include // NOLINTNEXTLINE(build/define_used) #define TLVL_ENTER_EXIT_METHODS 10 @@ -161,19 +161,19 @@ ERS_DECLARE_ISSUE_BASE(trigger, ERS_DECLARE_ISSUE_BASE(trigger, TCOutOfTimeout, appfwk::GeneralDAQModuleIssue, - "TC of type " << tc_type << ", timestamp " << tc_timestamp << " overlaps with previous TD readout window: [" << td_start << ", " << td_end << "]", + "TC of type " << tc_type << ", timestamp " << tc_timestamp + << " overlaps with previous TD readout window: [" << td_start << ", " << td_end + << "]", ((std::string)name), - ((int)tc_type) - ((triggeralgs::timestamp_t)tc_timestamp) - ((triggeralgs::timestamp_t)td_start) - ((triggeralgs::timestamp_t)td_end)) + ((int)tc_type)((triggeralgs::timestamp_t)tc_timestamp)((triggeralgs::timestamp_t)td_start)( + (triggeralgs::timestamp_t)td_end)) ERS_DECLARE_ISSUE_BASE(trigger, TCTimestampsSizeError, appfwk::GeneralDAQModuleIssue, "There are no next timestamps!", ((std::string)name), - ((int)size)) + ((int)size)) ERS_DECLARE_ISSUE_BASE(trigger, InvalidHSIEventRunNumber, @@ -194,17 +194,11 @@ ERS_DECLARE_ISSUE_BASE(trigger, ERS_DECLARE_ISSUE(trigger, TADropped, "TA timestamp " << time << " for channel " << channel, - ((uint64_t)time) ((uint64_t)channel)) + ((uint64_t)time)((uint64_t)channel)) -ERS_DECLARE_ISSUE(trigger, - TCDropped, - "TC timestamp " << time << " for src " << src, - ((uint64_t)time) ((uint64_t)src)) +ERS_DECLARE_ISSUE(trigger, TCDropped, "TC timestamp " << time << " for src " << src, ((uint64_t)time)((uint64_t)src)) -ERS_DECLARE_ISSUE(trigger, - TDDropped, - "TD trigger number " << tn << " time stamp " << ts, - ((uint64_t)tn) ((uint64_t)ts)) +ERS_DECLARE_ISSUE(trigger, TDDropped, "TD trigger number " << tn << " time stamp " << ts, ((uint64_t)tn)((uint64_t)ts)) ERS_DECLARE_ISSUE_BASE(trigger, MLTConfigurationProblem, @@ -267,7 +261,7 @@ ERS_DECLARE_ISSUE_BASE(trigger, appfwk::GeneralDAQModuleIssue, "No valid files to use!", ((std::string)name), - ERS_EMPTY) + ERS_EMPTY) ERS_DECLARE_ISSUE_BASE(trigger, ReplayNoValidTPs, @@ -279,9 +273,8 @@ ERS_DECLARE_ISSUE_BASE(trigger, ERS_DECLARE_ISSUE_BASE(trigger, ReplayStreamFileError, appfwk::GeneralDAQModuleIssue, - "Duplicate stream index " << index - << " for file: " << filename - << " (original: " << original << ")", + "Duplicate stream index " << index << " for file: " << filename << " (original: " << original + << ")", ((std::string)name), ((int)index)((std::string)filename)((std::string)original)) diff --git a/include/trigger/Set.hpp b/include/trigger/Set.hpp index b21aead5..187f31e5 100644 --- a/include/trigger/Set.hpp +++ b/include/trigger/Set.hpp @@ -43,10 +43,10 @@ class Set // The current run number daqdataformats::run_number_t run_number{ 0 }; - + // Identify the instance creator/stream/source of this set. origin_t origin{ daqdataformats::SourceID(daqdataformats::SourceID::Subsystem::kTrigger, - daqdataformats::SourceID::s_invalid_id) }; + daqdataformats::SourceID::s_invalid_id) }; // Whether this Set is a regular bag-of-objects or a heartbeat Type type{ kUnknown }; diff --git a/include/trigger/TASet.hpp b/include/trigger/TASet.hpp index 3b98fe4b..860da7ea 100644 --- a/include/trigger/TASet.hpp +++ b/include/trigger/TASet.hpp @@ -22,6 +22,14 @@ using TASet = Set; } // namespace dunedaq::trigger DUNE_DAQ_SERIALIZE_ENUM(dunedaq::trigger::TASet::Type) -DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, TASet, seqno, run_number, origin, type, start_time, end_time, objects) +DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, + TASet, + seqno, + run_number, + origin, + type, + start_time, + end_time, + objects) #endif // TRIGGER_INCLUDE_TRIGGER_TASET_HPP_ diff --git a/include/trigger/TAWrapper.hpp b/include/trigger/TAWrapper.hpp index 68c18953..d83e3597 100644 --- a/include/trigger/TAWrapper.hpp +++ b/include/trigger/TAWrapper.hpp @@ -11,78 +11,72 @@ #include "daqdataformats/Fragment.hpp" #include "iomanager/Receiver.hpp" +#include "triggeralgs/TriggerActivity.hpp" #include "triggeralgs/TriggerObjectOverlay.hpp" #include "triggeralgs/TriggerPrimitive.hpp" -#include "triggeralgs/TriggerActivity.hpp" namespace dunedaq { namespace trigger { - struct TAWrapper +struct TAWrapper +{ + + using FrameType = TAWrapper; + + triggeralgs::TriggerActivity activity; + std::vector activity_overlay_buffer; + + // Don't really want this default ctor, but IterableQueueModel requires it + // TAWrapper() {} + + TAWrapper(triggeralgs::TriggerActivity a = triggeralgs::TriggerActivity()) + : activity(a) + { + populate_buffer(); + } + + void populate_buffer() + { + activity_overlay_buffer.resize(triggeralgs::get_overlay_nbytes(activity)); + triggeralgs::write_overlay(activity, activity_overlay_buffer.data()); + } + + // comparable based on first timestamp + bool operator<(const TAWrapper& other) const { + return std::tie(this->activity.time_start, this->activity.channel_start) < + std::tie(other.activity.time_start, other.activity.channel_start); + } + + uint64_t get_timestamp() const // NOLINT(build/unsigned) + { + return activity.time_start; + } + + void set_timestamp(uint64_t ts) // NOLINT(build/unsigned) + { + activity.time_start = ts; + } + + void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned) + { + activity.time_start = first_timestamp; + populate_buffer(); + } + + size_t get_payload_size() { return activity_overlay_buffer.size(); } + + size_t get_num_frames() { return 1; } + + size_t get_frame_size() { return get_payload_size(); } + + TAWrapper* begin() { return (TAWrapper*)(activity_overlay_buffer.data()); } - using FrameType = TAWrapper; - - triggeralgs::TriggerActivity activity; - std::vector activity_overlay_buffer; - - // Don't really want this default ctor, but IterableQueueModel requires it - //TAWrapper() {} - - TAWrapper(triggeralgs::TriggerActivity a = triggeralgs::TriggerActivity()) - : activity(a) - { - populate_buffer(); - } - - void populate_buffer() - { - activity_overlay_buffer.resize(triggeralgs::get_overlay_nbytes(activity)); - triggeralgs::write_overlay(activity, activity_overlay_buffer.data()); - } - - // comparable based on first timestamp - bool operator<(const TAWrapper& other) const - { - return std::tie(this->activity.time_start, this->activity.channel_start) < std::tie(other.activity.time_start, other.activity.channel_start); - } - - uint64_t get_timestamp() const // NOLINT(build/unsigned) - { - return activity.time_start; - } - - void set_timestamp(uint64_t ts) // NOLINT(build/unsigned) - { - activity.time_start = ts; - } - - void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned) - { - activity.time_start = first_timestamp; - populate_buffer(); - } - - size_t get_payload_size() { return activity_overlay_buffer.size(); } - - size_t get_num_frames() { return 1; } - - size_t get_frame_size() { return get_payload_size(); } - - TAWrapper* begin() - { - return (TAWrapper*)(activity_overlay_buffer.data()); - } - - TAWrapper* end() - { - return (TAWrapper*)(activity_overlay_buffer.data()+activity_overlay_buffer.size()); - } - - static const constexpr daqdataformats::SourceID::Subsystem subsystem = daqdataformats::SourceID::Subsystem::kTrigger; - static const constexpr daqdataformats::FragmentType fragment_type = daqdataformats::FragmentType::kTriggerActivity; - // No idea what this should really be set to - static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned) + TAWrapper* end() { return (TAWrapper*)(activity_overlay_buffer.data() + activity_overlay_buffer.size()); } + static const constexpr daqdataformats::SourceID::Subsystem subsystem = daqdataformats::SourceID::Subsystem::kTrigger; + static const constexpr daqdataformats::FragmentType fragment_type = daqdataformats::FragmentType::kTriggerActivity; + // No idea what this should really be set to + static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned) }; } // namespace trigger diff --git a/include/trigger/TCSet.hpp b/include/trigger/TCSet.hpp index 9d95f88c..20a9ca18 100644 --- a/include/trigger/TCSet.hpp +++ b/include/trigger/TCSet.hpp @@ -22,6 +22,14 @@ using TCSet = Set; } // namespace dunedaq::trigger DUNE_DAQ_SERIALIZE_ENUM(dunedaq::trigger::TCSet::Type) -DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, TCSet, seqno, run_number, origin, type, start_time, end_time, objects) +DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, + TCSet, + seqno, + run_number, + origin, + type, + start_time, + end_time, + objects) #endif // TRIGGER_INCLUDE_TRIGGER_TCSET_HPP_ diff --git a/include/trigger/TCWrapper.hpp b/include/trigger/TCWrapper.hpp index 7a86ab62..d68a72ba 100644 --- a/include/trigger/TCWrapper.hpp +++ b/include/trigger/TCWrapper.hpp @@ -11,76 +11,70 @@ #include "daqdataformats/Fragment.hpp" -#include "triggeralgs/TriggerObjectOverlay.hpp" #include "triggeralgs/TriggerActivity.hpp" #include "triggeralgs/TriggerCandidate.hpp" +#include "triggeralgs/TriggerObjectOverlay.hpp" namespace dunedaq { namespace trigger { - struct TCWrapper +struct TCWrapper +{ + using FrameType = TCWrapper; + triggeralgs::TriggerCandidate candidate; + std::vector candidate_overlay_buffer; + // Don't really want this default ctor, but IterableQueueModel requires it + // TCWrapper() {} + + TCWrapper(triggeralgs::TriggerCandidate c = triggeralgs::TriggerCandidate()) + : candidate(c) + { + populate_buffer(); + } + + void populate_buffer() + { + candidate_overlay_buffer.resize(triggeralgs::get_overlay_nbytes(candidate)); + triggeralgs::write_overlay(candidate, candidate_overlay_buffer.data()); + } + + // comparable based on first timestamp + bool operator<(const TCWrapper& other) const + { + return std::tie(this->candidate.time_start, this->candidate.type) < + std::tie(other.candidate.time_start, other.candidate.type); + } + + uint64_t get_timestamp() const // NOLINT(build/unsigned) { - using FrameType = TCWrapper; - triggeralgs::TriggerCandidate candidate; - std::vector candidate_overlay_buffer; - // Don't really want this default ctor, but IterableQueueModel requires it - //TCWrapper() {} - - TCWrapper(triggeralgs::TriggerCandidate c = triggeralgs::TriggerCandidate()) - : candidate(c) - { - populate_buffer(); - } - - void populate_buffer() - { - candidate_overlay_buffer.resize(triggeralgs::get_overlay_nbytes(candidate)); - triggeralgs::write_overlay(candidate, candidate_overlay_buffer.data()); - } - - // comparable based on first timestamp - bool operator<(const TCWrapper& other) const - { - return std::tie(this->candidate.time_start, this->candidate.type) < std::tie(other.candidate.time_start, other.candidate.type); - } - - uint64_t get_timestamp() const // NOLINT(build/unsigned) - { - return candidate.time_start; - } - - void set_timestamp(uint64_t ts) // NOLINT(build/unsigned) - { - candidate.time_start = ts; - } - - void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned) - { - candidate.time_start = first_timestamp; - populate_buffer(); - } - - size_t get_payload_size() { return candidate_overlay_buffer.size(); } - - size_t get_num_frames() { return 1; } - - size_t get_frame_size() { return get_payload_size(); } - - TCWrapper* begin() - { - return (TCWrapper*)(candidate_overlay_buffer.data()); - } - - TCWrapper* end() - { - return (TCWrapper*)(candidate_overlay_buffer.data()+candidate_overlay_buffer.size()); - } - - //static const constexpr size_t fixed_payload_size = 5568; - static const constexpr daqdataformats::SourceID::Subsystem subsystem = daqdataformats::SourceID::Subsystem::kTrigger; - static const constexpr daqdataformats::FragmentType fragment_type = daqdataformats::FragmentType::kTriggerCandidate; - // No idea what this should really be set to - static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned) + return candidate.time_start; + } + + void set_timestamp(uint64_t ts) // NOLINT(build/unsigned) + { + candidate.time_start = ts; + } + + void fake_timestamps(uint64_t first_timestamp, uint64_t /*offset */ = 0) // NOLINT(build/unsigned) + { + candidate.time_start = first_timestamp; + populate_buffer(); + } + + size_t get_payload_size() { return candidate_overlay_buffer.size(); } + + size_t get_num_frames() { return 1; } + + size_t get_frame_size() { return get_payload_size(); } + + TCWrapper* begin() { return (TCWrapper*)(candidate_overlay_buffer.data()); } + + TCWrapper* end() { return (TCWrapper*)(candidate_overlay_buffer.data() + candidate_overlay_buffer.size()); } + // static const constexpr size_t fixed_payload_size = 5568; + static const constexpr daqdataformats::SourceID::Subsystem subsystem = daqdataformats::SourceID::Subsystem::kTrigger; + static const constexpr daqdataformats::FragmentType fragment_type = daqdataformats::FragmentType::kTriggerCandidate; + // No idea what this should really be set to + static const constexpr uint64_t expected_tick_difference = 1; // NOLINT(build/unsigned) }; } // namespace trigger } // namespace dunedaq diff --git a/include/trigger/TPSet.hpp b/include/trigger/TPSet.hpp index 90b5e165..d049a7ee 100644 --- a/include/trigger/TPSet.hpp +++ b/include/trigger/TPSet.hpp @@ -11,9 +11,9 @@ #include "dfmessages/SourceID_serialization.hpp" #include "serialization/Serialization.hpp" +#include "trgdataformats/TriggerPrimitive.hpp" #include "trigger/Set.hpp" #include "trigger/TriggerPrimitive_serialization.hpp" -#include "trgdataformats/TriggerPrimitive.hpp" namespace dunedaq::trigger { @@ -22,6 +22,14 @@ using TPSet = Set; } // namespace dunedaq::trigger DUNE_DAQ_SERIALIZE_ENUM(dunedaq::trigger::TPSet::Type) -DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, TPSet, seqno, run_number, origin, type, start_time, end_time, objects) +DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(dunedaq::trigger, + TPSet, + seqno, + run_number, + origin, + type, + start_time, + end_time, + objects) #endif // TRIGGER_INCLUDE_TRIGGER_TPSET_HPP_ diff --git a/include/trigger/TriggerCandidate_serialization.hpp b/include/trigger/TriggerCandidate_serialization.hpp index bbadec8f..78c0c605 100644 --- a/include/trigger/TriggerCandidate_serialization.hpp +++ b/include/trigger/TriggerCandidate_serialization.hpp @@ -21,7 +21,6 @@ DUNE_DAQ_SERIALIZE_ENUM(triggeralgs::TriggerCandidate::Type) DUNE_DAQ_SERIALIZE_ENUM(triggeralgs::TriggerCandidate::Algorithm) - DUNE_DAQ_SERIALIZE_NON_INTRUSIVE(triggeralgs, TriggerCandidate, time_start, diff --git a/include/trigger/TriggerPrimitiveTypeAdapter.hpp b/include/trigger/TriggerPrimitiveTypeAdapter.hpp index 0119c57e..bf67ee11 100644 --- a/include/trigger/TriggerPrimitiveTypeAdapter.hpp +++ b/include/trigger/TriggerPrimitiveTypeAdapter.hpp @@ -1,17 +1,16 @@ #ifndef TRIGGER_INCLUDE_TRIGGER_TRIGGERPRIMITIVETYPEADAPTER_HPP_ #define TRIGGER_INCLUDE_TRIGGER_TRIGGERPRIMITIVETYPEADAPTER_HPP_ - #include "daqdataformats/FragmentHeader.hpp" #include "daqdataformats/SourceID.hpp" #include "trgdataformats/TriggerPrimitive.hpp" #include "trgdataformats/Types.hpp" #include // uint_t types +#include // memcpy #include // unique_ptr +#include // tie #include -#include // memcpy -#include // tie namespace dunedaq { namespace trigger { diff --git a/plugins/DataSubscriberModule.cpp b/plugins/DataSubscriberModule.cpp index a8fb094e..f2bac880 100644 --- a/plugins/DataSubscriberModule.cpp +++ b/plugins/DataSubscriberModule.cpp @@ -8,18 +8,18 @@ #include "DataSubscriberModule.hpp" #include "logging/Logging.hpp" -#include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/DataSubscriberModel.hpp" #include "trigger/HSISourceModel.hpp" #include "appmodel/DataSubscriberModule.hpp" -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" +#include "trgdataformats/TriggerPrimitive.hpp" #include "trigger/TAWrapper.hpp" #include "trigger/TCWrapper.hpp" #include "trigger/TPSet.hpp" -#include "trgdataformats/TriggerPrimitive.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "triggeralgs/TriggerActivity.hpp" #include "triggeralgs/TriggerCandidate.hpp" @@ -27,8 +27,7 @@ using namespace dunedaq::datahandlinglibs::logging; namespace dunedaq { - -//DUNE_DAQ_TYPESTRING(dunedaq::trigger::TPSet, "TPSet") +// DUNE_DAQ_TYPESTRING(dunedaq::trigger::TPSet, "TPSet") DUNE_DAQ_TYPESTRING(dunedaq::trigger::TriggerPrimitiveTypeAdapter, "TriggerPrimitive") DUNE_DAQ_TYPESTRING(std::vector, "TriggerPrimitiveVector") DUNE_DAQ_TYPESTRING(dunedaq::trigger::TAWrapper, "TriggerActivity") @@ -37,7 +36,8 @@ DUNE_DAQ_TYPESTRING(dunedaq::trigger::TCWrapper, "TriggerCandidate") namespace trigger { DataSubscriberModule::DataSubscriberModule(const std::string& name) - : DAQModule(name), m_source_concept(nullptr) + : DAQModule(name) + , m_source_concept(nullptr) { inherited_mod::register_command("start", &DataSubscriberModule::do_start); @@ -56,9 +56,9 @@ DataSubscriberModule::init(std::shared_ptr cfg) throw datahandlinglibs::InitializationError(ERS_HERE, "Only 1 input supported for subscribers"); } m_source_concept = create_data_subscriber(ini); - register_node(get_name(), m_source_concept); + register_node(get_name(), m_source_concept); m_source_concept->init(ini); - TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << ": Exiting init() method"; + TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << ": Exiting init() method"; } void @@ -76,10 +76,10 @@ DataSubscriberModule::do_stop(const CommandData_t& /*args*/) std::shared_ptr DataSubscriberModule::create_data_subscriber(const confmodel::DaqModule* cfg) { - + auto datatypes = cfg->get_outputs()[0]->get_data_type(); auto raw_dt = cfg->get_inputs()[0]->get_data_type(); - + if (raw_dt == "TPSet") { TLOG_DEBUG(1) << "Creating trigger primitives subscriber"; auto source_model = @@ -89,22 +89,19 @@ DataSubscriberModule::create_data_subscriber(const confmodel::DaqModule* cfg) if (raw_dt == "TriggerActivity") { TLOG_DEBUG(1) << "Creating trigger activities subscriber"; - auto source_model = - std::make_shared>(); + auto source_model = std::make_shared>(); return source_model; } if (raw_dt == "TriggerCandidate") { TLOG_DEBUG(1) << "Creating trigger candidates subscriber"; - auto source_model = - std::make_shared>(); + auto source_model = std::make_shared>(); return source_model; } - if (raw_dt == "HSIEvent") { + if (raw_dt == "HSIEvent") { TLOG_DEBUG(1) << "Creating trigger candidates subscriber"; - auto source_model = - std::make_shared(); + auto source_model = std::make_shared(); return source_model; } return nullptr; diff --git a/plugins/DataSubscriberModule.hpp b/plugins/DataSubscriberModule.hpp index f2c5ccb1..fb45626f 100644 --- a/plugins/DataSubscriberModule.hpp +++ b/plugins/DataSubscriberModule.hpp @@ -8,12 +8,12 @@ #ifndef TRIGGER_PLUGINS_DATASUBSCRIBER_HPP_ #define TRIGGER_PLUGINS_DATASUBSCRIBER_HPP_ -//#include "appfwk/cmd/Nljs.hpp" -//#include "appfwk/app/Nljs.hpp" -//#include "appfwk/cmd/Structs.hpp" +// #include "appfwk/cmd/Nljs.hpp" +// #include "appfwk/app/Nljs.hpp" +// #include "appfwk/cmd/Structs.hpp" -#include "appfwk/DAQModule.hpp" #include "appfwk/ConfigurationManager.hpp" +#include "appfwk/DAQModule.hpp" #include "datahandlinglibs/concepts/SourceConcept.hpp" @@ -32,21 +32,22 @@ class DataSubscriberModule : public dunedaq::appfwk::DAQModule */ explicit DataSubscriberModule(const std::string& name); - DataSubscriberModule(const DataSubscriberModule&) = delete; ///< DataSubscriberModule is not copy-constructible - DataSubscriberModule& operator=(const DataSubscriberModule&) = delete; ///< DataSubscriberModule is not copy-assignable - DataSubscriberModule(DataSubscriberModule&&) = delete; ///< DataSubscriberModule is not move-constructible - DataSubscriberModule& operator=(DataSubscriberModule&&) = delete; ///< DataSubscriberModule is not move-assignable + DataSubscriberModule(const DataSubscriberModule&) = delete; ///< DataSubscriberModule is not copy-constructible + DataSubscriberModule& operator=(const DataSubscriberModule&) = + delete; ///< DataSubscriberModule is not copy-assignable + DataSubscriberModule(DataSubscriberModule&&) = delete; ///< DataSubscriberModule is not move-constructible + DataSubscriberModule& operator=(DataSubscriberModule&&) = delete; ///< DataSubscriberModule is not move-assignable void init(std::shared_ptr cfg) override; std::shared_ptr create_data_subscriber(const confmodel::DaqModule* cfg); + private: void do_start(const CommandData_t& /*args*/); void do_stop(const CommandData_t& /*args*/); // Internal std::shared_ptr m_source_concept; - }; } // namespace trigger diff --git a/plugins/FixedTimeTCMakerModule.cpp b/plugins/FixedTimeTCMakerModule.cpp old mode 100755 new mode 100644 index 6639c890..bd58819d --- a/plugins/FixedTimeTCMakerModule.cpp +++ b/plugins/FixedTimeTCMakerModule.cpp @@ -8,13 +8,13 @@ #include "FixedTimeTCMakerModule.hpp" +#include "appmodel/FixedTimeTCConf.hpp" #include "appmodel/FixedTimeTCMakerModule.hpp" #include "appmodel/FixedTimeTCMakerModuleConf.hpp" -#include "appmodel/FixedTimeTCConf.hpp" #include "appmodel/SourceIDConf.hpp" +#include "trigger/TriggerCandidate_serialization.hpp" #include "trigger/opmon/latency_info.pb.h" #include "trigger/opmon/randomtcmaker_info.pb.h" -#include "trigger/TriggerCandidate_serialization.hpp" namespace dunedaq::trigger { FixedTimeTCMakerModule::FixedTimeTCMakerModule(const std::string& module_name) @@ -84,8 +84,6 @@ FixedTimeTCMakerModule::do_disable_triggers(const CommandData_t& /*cmd*/) m_send_trigger_candidates_thread.stop_working_thread(); } - - triggeralgs::TriggerCandidate FixedTimeTCMakerModule::create_candidate(dfmessages::timestamp_t time_start, dfmessages::timestamp_t time_end) { @@ -116,7 +114,7 @@ FixedTimeTCMakerModule::send_trigger_candidates(std::atomic& running_flag) if (m_latency_monitoring.load()) m_latency_instance.update_latency_out(candidate.time_candidate); - + try { m_trigger_sender->send(std::move(candidate), std::chrono::milliseconds(10)); m_tc_sent_count++; diff --git a/plugins/FixedTimeTCMakerModule.hpp b/plugins/FixedTimeTCMakerModule.hpp old mode 100755 new mode 100644 index 6315b324..7543bd60 --- a/plugins/FixedTimeTCMakerModule.hpp +++ b/plugins/FixedTimeTCMakerModule.hpp @@ -10,24 +10,22 @@ #define TRIGGER_PLUGINS_FixedTimeTCMakerMODULE_HPP_ #include "appfwk/DAQModule.hpp" -#include "triggeralgs/TriggerCandidate.hpp" #include "appmodel/FixedTimeTCMakerModuleConf.hpp" -#include "utilities/WorkerThread.hpp" #include "dfmessages/Types.hpp" #include "iomanager/IOManager.hpp" #include "trigger/Latency.hpp" +#include "triggeralgs/TriggerCandidate.hpp" +#include "utilities/WorkerThread.hpp" namespace dunedaq::trigger { class FixedTimeTCMakerModule : public appfwk::DAQModule { public: explicit FixedTimeTCMakerModule(const std::string& module_name); - FixedTimeTCMakerModule(const FixedTimeTCMakerModule&) = - delete; ///< FixedTimeTCMakerModule is not copy-constructible + FixedTimeTCMakerModule(const FixedTimeTCMakerModule&) = delete; ///< FixedTimeTCMakerModule is not copy-constructible FixedTimeTCMakerModule& operator=(const FixedTimeTCMakerModule&) = - delete; ///< FixedTimeTCMakerModule is not copy-assignable - FixedTimeTCMakerModule(FixedTimeTCMakerModule&&) = - delete; ///< FixedTimeTCMakerModule is not move-constructible + delete; ///< FixedTimeTCMakerModule is not copy-assignable + FixedTimeTCMakerModule(FixedTimeTCMakerModule&&) = delete; ///< FixedTimeTCMakerModule is not move-constructible FixedTimeTCMakerModule& operator=(FixedTimeTCMakerModule&&) = delete; ///< FixedTimeTCMakerModule is not move-assignable diff --git a/plugins/MLTModule.cpp b/plugins/MLTModule.cpp index 3b7fc214..afbb3587 100644 --- a/plugins/MLTModule.cpp +++ b/plugins/MLTModule.cpp @@ -84,7 +84,7 @@ MLTModule::do_configure(const CommandData_t& /*obj*/) // Get the inputs for (auto con : m_mtrg->get_inputs()) { if (con->get_data_type() == datatype_to_string()) { - m_decision_input = get_iom_receiver(con->UID()); + m_decision_input = get_iom_receiver(con->UID()); } else if (con->get_data_type() == datatype_to_string()) { m_inhibit_input = get_iom_receiver(con->UID()); } diff --git a/plugins/RandomTCMakerModule.cpp b/plugins/RandomTCMakerModule.cpp index 9724d383..85828811 100644 --- a/plugins/RandomTCMakerModule.cpp +++ b/plugins/RandomTCMakerModule.cpp @@ -105,7 +105,8 @@ RandomTCMakerModule::do_configure(const CommandData_t& /*obj*/) m_tcout_time_before_ts = m_conf->get_candidate_window_before_ts(); m_tcout_time_after_ts = m_conf->get_candidate_window_after_ts(); - m_tcout_type = static_cast(dunedaq::trgdataformats::string_to_trigger_candidate_type(m_conf->get_candidate_type_name())); + m_tcout_type = + static_cast(dunedaq::trgdataformats::string_to_trigger_candidate_type(m_conf->get_candidate_type_name())); // Throw error if unknown TC type if (m_tcout_type == TCType::kUnknown) { @@ -208,8 +209,8 @@ RandomTCMakerModule::create_candidate(dfmessages::timestamp_t timestamp) { triggeralgs::TriggerCandidate candidate; candidate.time_candidate = timestamp - m_tcout_time_backshift_ts; - candidate.time_start = candidate.time_candidate-m_tcout_time_before_ts; - candidate.time_end = candidate.time_candidate+m_tcout_time_after_ts; + candidate.time_start = candidate.time_candidate - m_tcout_time_before_ts; + candidate.time_end = candidate.time_candidate + m_tcout_time_after_ts; candidate.detid = { 0 }; candidate.type = m_tcout_type; @@ -262,7 +263,7 @@ RandomTCMakerModule::send_trigger_candidates() std::this_thread::sleep_for(std::chrono::milliseconds(100)); continue; } - + dfmessages::timestamp_t actual_timestamp; if (m_timestamp_estimator->wait_for_requested_timestamp(next_trigger_timestamp, m_running_flag, actual_timestamp) == utilities::TimestampEstimatorBase::kInterrupted) { @@ -272,8 +273,8 @@ RandomTCMakerModule::send_trigger_candidates() m_tc_made_count++; - TLOG_DEBUG(1) << get_name() << " at timestamp " << actual_timestamp - << ", pushing a candidate with timestamp " << candidate.time_candidate; + TLOG_DEBUG(1) << get_name() << " at timestamp " << actual_timestamp << ", pushing a candidate with timestamp " + << candidate.time_candidate; if (m_latency_monitoring.load()) m_latency_instance.update_latency_out(candidate.time_candidate); diff --git a/plugins/TriggerDataHandlerModule.cpp b/plugins/TriggerDataHandlerModule.cpp index b505e881..48dbbeb4 100644 --- a/plugins/TriggerDataHandlerModule.cpp +++ b/plugins/TriggerDataHandlerModule.cpp @@ -7,22 +7,21 @@ */ #include "TriggerDataHandlerModule.hpp" -#include "logging/Logging.hpp" #include "iomanager/IOManager.hpp" +#include "logging/Logging.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" #include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/DataHandlingModel.hpp" -#include "datahandlinglibs/models/SkipListLatencyBufferModel.hpp" #include "datahandlinglibs/models/DefaultSkipListRequestHandler.hpp" +#include "datahandlinglibs/models/SkipListLatencyBufferModel.hpp" #include "trigger/TPRequestHandler.hpp" -#include "trigger/TriggerDataHandlingModel.hpp" -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" -#include "trigger/TPProcessor.hpp" #include "trigger/TAProcessor.hpp" #include "trigger/TCProcessor.hpp" - +#include "trigger/TPProcessor.hpp" +#include "trigger/TriggerDataHandlingModel.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include #include @@ -43,8 +42,8 @@ namespace trigger { TriggerDataHandlerModule::TriggerDataHandlerModule(const std::string& name) : DAQModule(name) , RawDataHandlerBase(name) -{ - //inherited_dlh::m_readout_creator = make_readout_creator("fd"); +{ + // inherited_dlh::m_readout_creator = make_readout_creator("fd"); inherited_mod::register_command("conf", &inherited_dlh::do_conf); inherited_mod::register_command("scrap", &inherited_dlh::do_scrap); @@ -67,63 +66,63 @@ TriggerDataHandlerModule::create_readout(const appmodel::DataHandlerModule* modc { namespace rol = dunedaq::datahandlinglibs; - // Acquire DataType + // Acquire DataType std::string raw_dt = modconf->get_module_configuration()->get_input_data_type(); TLOG() << "Choosing specializations for DataHandlingModel with data_type:" << raw_dt << ']'; // IF TriggerPrimitiveVector (TP vector) if (raw_dt.find("TriggerPrimitiveVector") != std::string::npos) { TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerPrimitiveVector"; - auto readout_model = std::make_shared, - TPProcessor, - std::vector>>(run_marker); - register_node("TPProcessor", readout_model); + auto readout_model = + std::make_shared, + TPProcessor, + std::vector>>(run_marker); + register_node("TPProcessor", readout_model); readout_model->init(modconf); return readout_model; - } + } // IF TriggerPrimitive (TP) if (raw_dt.find("TriggerPrimitive") != std::string::npos) { TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerPrimitive"; - auto readout_model = std::make_shared, - TPProcessor>>(run_marker); - register_node("TPProcessor", readout_model); + auto readout_model = + std::make_shared, + TPProcessor>>(run_marker); + register_node("TPProcessor", readout_model); readout_model->init(modconf); return readout_model; } - // IF TriggerActivity (TA) + // IF TriggerActivity (TA) if (raw_dt.find("TriggerActivity") != std::string::npos) { TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerActivity"; - auto readout_model = std::make_shared, - rol::SkipListLatencyBufferModel, - TAProcessor, - triggeralgs::TriggerActivity>>(run_marker); - register_node("TAProcessor", readout_model); - + auto readout_model = + std::make_shared, + rol::SkipListLatencyBufferModel, + TAProcessor, + triggeralgs::TriggerActivity>>(run_marker); + register_node("TAProcessor", readout_model); + readout_model->init(modconf); return readout_model; } - // No processing, only buffering to respond to data requests + // No processing, only buffering to respond to data requests if (raw_dt.find("TriggerCandidate") != std::string::npos) { TLOG(TLVL_WORK_STEPS) << "Creating readout for TriggerCandidate"; - auto readout_model = std::make_shared, - rol::SkipListLatencyBufferModel, - TCProcessor, - triggeralgs::TriggerCandidate>>(run_marker); - register_node("TCProcessor", readout_model); - + auto readout_model = + std::make_shared, + rol::SkipListLatencyBufferModel, + TCProcessor, + triggeralgs::TriggerCandidate>>(run_marker); + register_node("TCProcessor", readout_model); + readout_model->init(modconf); return readout_model; } diff --git a/plugins/TriggerDataHandlerModule.hpp b/plugins/TriggerDataHandlerModule.hpp index 54a86a8e..cba91d94 100644 --- a/plugins/TriggerDataHandlerModule.hpp +++ b/plugins/TriggerDataHandlerModule.hpp @@ -17,8 +17,9 @@ namespace dunedaq { namespace trigger { -class TriggerDataHandlerModule : public dunedaq::appfwk::DAQModule, - public dunedaq::datahandlinglibs::RawDataHandlerBase +class TriggerDataHandlerModule + : public dunedaq::appfwk::DAQModule + , public dunedaq::datahandlinglibs::RawDataHandlerBase { public: using inherited_dlh = dunedaq::datahandlinglibs::RawDataHandlerBase; @@ -29,16 +30,18 @@ class TriggerDataHandlerModule : public dunedaq::appfwk::DAQModule, */ explicit TriggerDataHandlerModule(const std::string& name); - TriggerDataHandlerModule(const TriggerDataHandlerModule&) = delete; ///< TriggerDataHandlerModule is not copy-constructible - TriggerDataHandlerModule& operator=(const TriggerDataHandlerModule&) = delete; ///< TriggerDataHandlerModule is not copy-assignable - TriggerDataHandlerModule(TriggerDataHandlerModule&&) = delete; ///< TriggerDataHandlerModule is not move-constructible - TriggerDataHandlerModule& operator=(TriggerDataHandlerModule&&) = delete; ///< TriggerDataHandlerModule is not move-assignable + TriggerDataHandlerModule(const TriggerDataHandlerModule&) = + delete; ///< TriggerDataHandlerModule is not copy-constructible + TriggerDataHandlerModule& operator=(const TriggerDataHandlerModule&) = + delete; ///< TriggerDataHandlerModule is not copy-assignable + TriggerDataHandlerModule(TriggerDataHandlerModule&&) = delete; ///< TriggerDataHandlerModule is not move-constructible + TriggerDataHandlerModule& operator=(TriggerDataHandlerModule&&) = + delete; ///< TriggerDataHandlerModule is not move-assignable void init(std::shared_ptr cfg) override; - std::shared_ptr - create_readout(const appmodel::DataHandlerModule* modconf, std::atomic& run_marker) override; - + std::shared_ptr create_readout(const appmodel::DataHandlerModule* modconf, + std::atomic& run_marker) override; }; } // namespace trigger diff --git a/src/LivetimeCounter.cpp b/src/LivetimeCounter.cpp index a5a2e8ab..272d8bd5 100644 --- a/src/LivetimeCounter.cpp +++ b/src/LivetimeCounter.cpp @@ -11,14 +11,14 @@ LivetimeCounter::LivetimeCounter(LivetimeCounter::State state) , m_last_state_change_time(now()) { TLOG_DEBUG(1) << "Starting LivetimeCounter in state " << get_state_name(state); - m_state_times[State::kLive]=0; - m_state_times[State::kDead]=0; - m_state_times[State::kPaused]=0; + m_state_times[State::kLive] = 0; + m_state_times[State::kDead] = 0; + m_state_times[State::kPaused] = 0; } LivetimeCounter::~LivetimeCounter() { - std::string report=get_report_string(); + std::string report = get_report_string(); TLOG() << "LivetimeCounter stopping. Counts: " << report; } @@ -26,20 +26,19 @@ void LivetimeCounter::update_map() { // Caller must lock the mutex, so we don't here - auto current_time=now(); - auto delta=(current_time-m_last_state_change_time); - m_state_times[m_state]+=delta; - m_last_state_change_time=current_time; + auto current_time = now(); + auto delta = (current_time - m_last_state_change_time); + m_state_times[m_state] += delta; + m_last_state_change_time = current_time; } - void LivetimeCounter::set_state(LivetimeCounter::State state) { std::lock_guard l(m_mutex); update_map(); // Add the time to the old state TLOG_DEBUG(1) << "Changing state from " << get_state_name(m_state) << " to " << get_state_name(state); - m_state=state; + m_state = state; } std::map @@ -71,22 +70,24 @@ LivetimeCounter::get_report_string() std::lock_guard l(m_mutex); update_map(); std::ostringstream oss; - for(auto const& [state, t]: m_state_times){ + for (auto const& [state, t] : m_state_times) { oss << get_state_name(state) << ": " << t << "ms "; } return oss.str(); } - std::string LivetimeCounter::get_state_name(LivetimeCounter::State state) const { - switch(state){ - case State::kLive: return "live"; - case State::kDead: return "dead"; - case State::kPaused: return "paused"; - default: - return "UNKNOWN"; + switch (state) { + case State::kLive: + return "live"; + case State::kDead: + return "dead"; + case State::kPaused: + return "paused"; + default: + return "UNKNOWN"; } } diff --git a/src/TAProcessor.cpp b/src/TAProcessor.cpp index 9038670d..b65fd236 100644 --- a/src/TAProcessor.cpp +++ b/src/TAProcessor.cpp @@ -7,16 +7,16 @@ */ #include "trigger/TAProcessor.hpp" // NOLINT(build/include) -//#include "appfwk/DAQModuleHelper.hpp" +// #include "appfwk/DAQModuleHelper.hpp" #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/IterableQueueModel.hpp" -//#include "detchannelmaps/TPCChannelMap.hpp" +// #include "detchannelmaps/TPCChannelMap.hpp" #include "trigger/TAWrapper.hpp" #include "triggeralgs/TriggerActivity.hpp" @@ -36,13 +36,13 @@ DUNE_DAQ_TYPESTRING(dunedaq::trigger::TAWrapper, "TriggerActivity") namespace dunedaq { namespace trigger { -TAProcessor::TAProcessor(std::unique_ptr& error_registry, bool post_processing_enabled) +TAProcessor::TAProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled) : datahandlinglibs::TaskRawDataProcessorModel(error_registry, post_processing_enabled) { } -TAProcessor::~TAProcessor() -{} +TAProcessor::~TAProcessor() {} void TAProcessor::start(const appfwk::DAQModule::CommandData_t& args) @@ -80,9 +80,9 @@ TAProcessor::conf(const appmodel::DataHandlerModule* conf) TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TAProcessor: Entering conf() method"; for (auto output : conf->get_outputs()) { - try { + try { if (output->get_data_type() == "TriggerCandidate") { - m_tc_sink = get_iom_sender(output->UID()); + m_tc_sink = get_iom_sender(output->UID()); } } catch (const ers::Issue& excpt) { ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "tc", "DefaultRequestHandlerModel", excpt)); @@ -94,11 +94,11 @@ TAProcessor::conf(const appmodel::DataHandlerModule* conf) std::vector tc_algorithms; auto dp = conf->get_module_configuration()->get_data_processor(); auto proc_conf = dp->cast(); - if (proc_conf != nullptr && m_post_processing_enabled ) { + if (proc_conf != nullptr && m_post_processing_enabled) { tc_algorithms = proc_conf->get_algorithms(); - } + } - for (auto algo : tc_algorithms) { + for (auto algo : tc_algorithms) { TLOG() << "Selected TC algorithm: " << algo->UID(); std::shared_ptr maker = make_tc_maker(algo->class_name()); nlohmann::json algo_json = algo->to_json(true); @@ -106,7 +106,7 @@ TAProcessor::conf(const appmodel::DataHandlerModule* conf) inherited::add_postprocess_task(std::bind(&TAProcessor::find_tc, this, std::placeholders::_1, maker)); m_tcms.push_back(maker); } - m_latency_monitoring.store( dp->get_latency_monitoring() ); + m_latency_monitoring.store(dp->get_latency_monitoring()); inherited::conf(conf); TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TAProcessor: Exiting conf() method"; @@ -127,18 +127,18 @@ TAProcessor::generate_opmon_data() { opmon::TAProcessorInfo info; - info.set_ta_received_count( m_ta_received_count.load() ); - info.set_tc_made_count( m_tc_made_count.load() ); - info.set_tc_sent_count( m_tc_sent_count.load() ); - info.set_tc_failed_sent_count( m_tc_failed_sent_count.load() ); + info.set_ta_received_count(m_ta_received_count.load()); + info.set_tc_made_count(m_tc_made_count.load()); + info.set_tc_sent_count(m_tc_sent_count.load()); + info.set_tc_failed_sent_count(m_tc_failed_sent_count.load()); this->publish(std::move(info)); - if ( m_latency_monitoring.load() && m_running_flag.load() ) { + if (m_latency_monitoring.load() && m_running_flag.load()) { opmon::TriggerLatency lat_info; - lat_info.set_latency_in( m_latency_instance.get_latency_in() ); - lat_info.set_latency_out( m_latency_instance.get_latency_out() ); + lat_info.set_latency_in(m_latency_instance.get_latency_in()); + lat_info.set_latency_out(m_latency_instance.get_latency_out()); this->publish(std::move(lat_info)); } @@ -148,19 +148,21 @@ TAProcessor::generate_opmon_data() * Pipeline Stage 2.: Do software TPG * */ void -TAProcessor::find_tc(const TAWrapper* ta, std::shared_ptr tca) +TAProcessor::find_tc(const TAWrapper* ta, std::shared_ptr tca) { - //time_activity gave 0 :/ - if (m_latency_monitoring.load()) m_latency_instance.update_latency_in( ta->activity.time_start ); + // time_activity gave 0 :/ + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_in(ta->activity.time_start); m_ta_received_count++; std::vector tcs; tca->operator()(ta->activity, tcs); for (auto tc : tcs) { m_tc_made_count++; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_out( tc.time_candidate ); - if(!m_tc_sink->try_send(std::move(tc), iomanager::Sender::s_no_block)) { - ers::warning(TCDropped(ERS_HERE, tc.time_start, m_sourceid.id)); - m_tc_failed_sent_count++; + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_out(tc.time_candidate); + if (!m_tc_sink->try_send(std::move(tc), iomanager::Sender::s_no_block)) { + ers::warning(TCDropped(ERS_HERE, tc.time_start, m_sourceid.id)); + m_tc_failed_sent_count++; } else { m_tc_sent_count++; } diff --git a/src/TCProcessor.cpp b/src/TCProcessor.cpp index b43d48d4..f60ed4fb 100644 --- a/src/TCProcessor.cpp +++ b/src/TCProcessor.cpp @@ -10,8 +10,8 @@ #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/IterableQueueModel.hpp" #include "trigger/TCWrapper.hpp" @@ -29,13 +29,13 @@ DUNE_DAQ_TYPESTRING(dunedaq::trigger::TCWrapper, "TriggerCandidate") namespace dunedaq { namespace trigger { -TCProcessor::TCProcessor(std::unique_ptr& error_registry, bool post_processing_enabled) +TCProcessor::TCProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled) : datahandlinglibs::TaskRawDataProcessorModel(error_registry, post_processing_enabled) { } -TCProcessor::~TCProcessor() -{} +TCProcessor::~TCProcessor() {} void TCProcessor::start(const appfwk::DAQModule::CommandData_t& args) @@ -97,14 +97,14 @@ TCProcessor::conf(const appmodel::DataHandlerModule* cfg) { TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TCProcessor: Entering conf() method"; - auto mtrg = cfg->cast(); + auto mtrg = cfg->cast(); if (mtrg == nullptr) { throw(InvalidConfiguration(ERS_HERE, "Provided null TriggerDataHandlerModule configuration!")); } for (auto output : mtrg->get_outputs()) { - try { + try { if (output->get_data_type() == "TriggerDecision") { - m_td_sink = get_iom_sender(output->UID()); + m_td_sink = get_iom_sender(output->UID()); } } catch (const ers::Issue& excpt) { ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "td", "DefaultRequestHandlerModel", excpt)); @@ -115,38 +115,34 @@ TCProcessor::conf(const appmodel::DataHandlerModule* cfg) auto proc_conf = dp->cast(); // Add all Source IDs to mandatoy links for now... - for(auto const& link : mtrg->get_mandatory_source_ids()){ + for (auto const& link : mtrg->get_mandatory_source_ids()) { m_mandatory_links.push_back( - dfmessages::SourceID{ - daqdataformats::SourceID::string_to_subsystem(link->get_subsystem()), - link->get_sid()}); - } - for(auto const& link : mtrg->get_enabled_source_ids()){ + dfmessages::SourceID{ daqdataformats::SourceID::string_to_subsystem(link->get_subsystem()), link->get_sid() }); + } + for (auto const& link : mtrg->get_enabled_source_ids()) { m_mandatory_links.push_back( - dfmessages::SourceID{ - daqdataformats::SourceID::string_to_subsystem(link->get_subsystem()), - link->get_sid()}); + dfmessages::SourceID{ daqdataformats::SourceID::string_to_subsystem(link->get_subsystem()), link->get_sid() }); } // TODO: Group links! - //m_group_links_data = conf->get_groups_links(); + // m_group_links_data = conf->get_groups_links(); parse_group_links(m_group_links_data); print_group_links(); m_total_group_links = m_group_links.size(); TLOG_DEBUG(3) << "Total group links: " << m_total_group_links; - m_tc_merging = proc_conf->get_merge_overlapping_tcs(); + m_tc_merging = proc_conf->get_merge_overlapping_tcs(); m_ignore_tc_pileup = proc_conf->get_ignore_overlapping_tcs(); - m_buffer_timeout = proc_conf->get_buffer_timeout(); + m_buffer_timeout = proc_conf->get_buffer_timeout(); 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_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.empty(); // Trigger bitwords std::vector bitwords = proc_conf->get_trigger_bitwords(); m_use_bitwords = !bitwords.empty(); - if(m_use_bitwords){ + if (m_use_bitwords) { set_trigger_bitwords(bitwords); print_trigger_bitwords(); } @@ -177,14 +173,14 @@ TCProcessor::conf(const appmodel::DataHandlerModule* cfg) // Ignoring TC types TLOG_DEBUG(3) << "Ignoring TC types: " << m_ignoring_tc_types; - if(m_ignoring_tc_types){ + if (m_ignoring_tc_types) { TLOG_DEBUG(3) << "TC types to ignore: "; for (std::vector::iterator it = m_ignored_tc_types.begin(); it != m_ignored_tc_types.end();) { TLOG_DEBUG(3) << *it; ++it; } } - m_latency_monitoring.store( dp->get_latency_monitoring() ); + m_latency_monitoring.store(dp->get_latency_monitoring()); inherited::add_postprocess_task(std::bind(&TCProcessor::make_td, this, std::placeholders::_1)); inherited::conf(mtrg); @@ -208,11 +204,11 @@ TCProcessor::scrap(const appfwk::DAQModule::CommandData_t& args) m_readout_window_map_data.clear(); m_readout_window_map.clear(); m_ignored_tc_types.clear(); - + m_td_sink.reset(); - + m_group_links_data.clear(); - + inherited::scrap(args); TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TCProcessor: Exiting scrap() method"; @@ -223,26 +219,26 @@ TCProcessor::generate_opmon_data() { opmon::TCProcessorInfo info; - info.set_tds_created_count( m_tds_created_count.load() ); - info.set_tds_sent_count( m_tds_sent_count.load() ); - info.set_tds_dropped_count( m_tds_dropped_count.load() ); - info.set_tds_failed_bitword_count( m_tds_failed_bitword_count.load() ); - info.set_tds_cleared_count( m_tds_cleared_count.load() ); - info.set_tc_received_count( m_tc_received_count.load() ); - info.set_tc_ignored_count( m_tc_ignored_count.load() ); - info.set_tds_created_tc_count( m_tds_created_tc_count.load() ); - info.set_tds_sent_tc_count( m_tds_sent_tc_count.load() ); - info.set_tds_dropped_tc_count( m_tds_dropped_tc_count.load() ); - info.set_tds_failed_bitword_tc_count( m_tds_failed_bitword_tc_count.load() ); - info.set_tds_cleared_tc_count( m_tds_cleared_tc_count.load() ); + info.set_tds_created_count(m_tds_created_count.load()); + info.set_tds_sent_count(m_tds_sent_count.load()); + info.set_tds_dropped_count(m_tds_dropped_count.load()); + info.set_tds_failed_bitword_count(m_tds_failed_bitword_count.load()); + info.set_tds_cleared_count(m_tds_cleared_count.load()); + info.set_tc_received_count(m_tc_received_count.load()); + info.set_tc_ignored_count(m_tc_ignored_count.load()); + info.set_tds_created_tc_count(m_tds_created_tc_count.load()); + info.set_tds_sent_tc_count(m_tds_sent_tc_count.load()); + info.set_tds_dropped_tc_count(m_tds_dropped_tc_count.load()); + info.set_tds_failed_bitword_tc_count(m_tds_failed_bitword_tc_count.load()); + info.set_tds_cleared_tc_count(m_tds_cleared_tc_count.load()); this->publish(std::move(info)); - if ( m_latency_monitoring.load() && m_running_flag.load() ) { + if (m_latency_monitoring.load() && m_running_flag.load()) { opmon::TriggerLatency lat_info; - lat_info.set_latency_in( m_latency_instance.get_latency_in() ); - lat_info.set_latency_out( m_latency_instance.get_latency_out() ); + lat_info.set_latency_in(m_latency_instance.get_latency_in()); + lat_info.set_latency_out(m_latency_instance.get_latency_out()); this->publish(std::move(lat_info)); } @@ -254,19 +250,20 @@ TCProcessor::generate_opmon_data() void TCProcessor::make_td(const TCWrapper* tcw) { - + auto tc = tcw->candidate; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_in( tc.time_start ); + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_in(tc.time_start); m_tc_received_count++; - if ( (m_use_readout_map) && (m_readout_window_map.count(tc.type)) ) { + if ((m_use_readout_map) && (m_readout_window_map.count(tc.type))) { TLOG_DEBUG(3) << "Got TC of type " << static_cast(tc.type) << ", timestamp " << tc.time_candidate - << ", start/end " << tc.time_start << "/" << tc.time_end << ", readout start/end " - << tc.time_candidate - m_readout_window_map[tc.type].first << "/" - << tc.time_candidate + m_readout_window_map[tc.type].second; + << ", start/end " << tc.time_start << "/" << tc.time_end << ", readout start/end " + << tc.time_candidate - m_readout_window_map[tc.type].first << "/" + << tc.time_candidate + m_readout_window_map[tc.type].second; } else { TLOG_DEBUG(3) << "Got TC of type " << static_cast(tc.type) << ", timestamp " << tc.time_candidate - << ", start/end " << tc.time_start << "/" << tc.time_end; + << ", start/end " << tc.time_start << "/" << tc.time_end; } // Option to ignore TC types (if given by config) @@ -274,16 +271,15 @@ TCProcessor::make_td(const TCWrapper* tcw) TLOG_DEBUG(3) << " Ignore TC type: " << static_cast(tc.type); m_tc_ignored_count++; - /*FIXME: comment out this block: if a TC is to be ignored it shall just be ignored! - if (m_tc_merging) { - // Still need to check for overlap with existing TD, if overlaps, include in the TD, but don't extend - // readout - std::lock_guard lock(m_td_vector_mutex); - add_tc_ignored(*tc); - } - */ - } - else { + /*FIXME: comment out this block: if a TC is to be ignored it shall just be ignored! + if (m_tc_merging) { + // Still need to check for overlap with existing TD, if overlaps, include in the TD, but don't extend + // readout + std::lock_guard lock(m_td_vector_mutex); + add_tc_ignored(*tc); + } + */ + } else { std::lock_guard lock(m_td_vector_mutex); add_tc(tc); m_cv.notify_one(); @@ -305,16 +301,16 @@ TCProcessor::create_decision(const PendingTD& pending_td) dfmessages::TriggerDecision decision; decision.trigger_number = 0; // filled by MLT - decision.run_number = 0; // filled by MLT + decision.run_number = 0; // filled by MLT decision.trigger_timestamp = pending_td.contributing_tcs[m_earliest_tc_index].time_candidate; decision.readout_type = dfmessages::ReadoutType::kLocalized; TDBitset td_bitword = get_TD_bitword(pending_td); TLOG_DEBUG(5) << "[MLT] TD has bitword: " << td_bitword << " " - << static_cast(td_bitword.to_ulong()); + << static_cast(td_bitword.to_ulong()); decision.trigger_type = static_cast(td_bitword.to_ulong()); // m_trigger_type; - //decision.trigger_type = 1; // m_trigger_type; + // decision.trigger_type = 1; // m_trigger_type; TLOG_DEBUG(3) << ", TC detid: " << pending_td.contributing_tcs[m_earliest_tc_index].detid << ", TC type: " << static_cast(pending_td.contributing_tcs[m_earliest_tc_index].type) @@ -344,23 +340,23 @@ TCProcessor::create_decision(const PendingTD& pending_td) return decision; } - void -TCProcessor::send_trigger_decisions() { - // A unique lock that can be locked and unlocked - std::unique_lock lock(m_td_vector_mutex); +TCProcessor::send_trigger_decisions() +{ + // A unique lock that can be locked and unlocked + std::unique_lock lock(m_td_vector_mutex); - while (m_running_flag) { + while (m_running_flag) { // TODO: think about better implementation (notify?, something event driven) m_cv.wait_for(lock, std::chrono::microseconds(100)); auto ready_tds = get_ready_tds(m_pending_tds); TLOG_DEBUG(10) << "ready tds: " << ready_tds.size() << ", updated pending tds: " << m_pending_tds.size(); for (std::vector::iterator it = ready_tds.begin(); it != ready_tds.end();) { - call_tc_decision(*it); - ++it; + call_tc_decision(*it); + ++it; } - } + } } void @@ -382,19 +378,18 @@ TCProcessor::call_tc_decision(const TCProcessor::PendingTD& pending_td) auto tn = decision.trigger_number; auto td_ts = decision.trigger_timestamp; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_out( pending_td.contributing_tcs.front().time_start ); - if(!m_td_sink->try_send(std::move(decision), iomanager::Sender::s_no_block)) { + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_out(pending_td.contributing_tcs.front().time_start); + if (!m_td_sink->try_send(std::move(decision), iomanager::Sender::s_no_block)) { ers::warning(TDDropped(ERS_HERE, tn, td_ts)); m_tds_dropped_count++; m_tds_dropped_tc_count += pending_td.contributing_tcs.size(); - } - else { + } else { m_tds_sent_count++; m_tds_sent_tc_count += pending_td.contributing_tcs.size(); } } - void TCProcessor::add_tc(const triggeralgs::TriggerCandidate tc) { @@ -420,9 +415,9 @@ TCProcessor::add_tc(const triggeralgs::TriggerCandidate tc) } // If we're here, TC merging must be on, in which case we're actually - // going to merge the TC into the TD. + // going to merge the TC into the TD. it->contributing_tcs.push_back(tc); - if ( (m_use_readout_map) && (m_readout_window_map.count(tc.type)) ){ + if ((m_use_readout_map) && (m_readout_window_map.count(tc.type))) { TLOG_DEBUG(3) << "TC with start/end times " << tc.time_candidate - m_readout_window_map[tc.type].first << "/" << tc.time_candidate + m_readout_window_map[tc.type].second << " overlaps with pending TD with start/end times " << it->readout_start << "/" @@ -454,7 +449,7 @@ TCProcessor::add_tc(const triggeralgs::TriggerCandidate tc) // Create a new TD out of the TC PendingTD td_candidate; td_candidate.contributing_tcs.push_back(tc); - if ( (m_use_readout_map) && (m_readout_window_map.count(tc.type)) ){ + if ((m_use_readout_map) && (m_readout_window_map.count(tc.type))) { td_candidate.readout_start = tc.time_candidate - m_readout_window_map[tc.type].first; td_candidate.readout_end = tc.time_candidate + m_readout_window_map[tc.type].second; } else { @@ -470,7 +465,7 @@ TCProcessor::add_tc_ignored(const triggeralgs::TriggerCandidate tc) { for (std::vector::iterator it = m_pending_tds.begin(); it != m_pending_tds.end();) { if (check_overlap(tc, *it)) { - if ( (m_use_readout_map) && (m_readout_window_map.count(tc.type)) ) { + if ((m_use_readout_map) && (m_readout_window_map.count(tc.type))) { TLOG_DEBUG(3) << "!Ignored! TC with start/end times " << tc.time_candidate - m_readout_window_map[tc.type].first << "/" << tc.time_candidate + m_readout_window_map[tc.type].second << " overlaps with pending TD with start/end times " << it->readout_start << "/" @@ -491,7 +486,7 @@ TCProcessor::add_tc_ignored(const triggeralgs::TriggerCandidate tc) bool TCProcessor::check_overlap(const triggeralgs::TriggerCandidate& tc, const PendingTD& pending_td) { - if ( (m_use_readout_map) && (m_readout_window_map.count(tc.type)) ) { + if ((m_use_readout_map) && (m_readout_window_map.count(tc.type))) { return !(((tc.time_candidate + m_readout_window_map[tc.type].second) < pending_td.readout_start) || ((tc.time_candidate - m_readout_window_map[tc.type].first > pending_td.readout_end))); } else { @@ -539,7 +534,8 @@ TCProcessor::get_earliest_tc_index(const PendingTD& pending_td) return earliest_tc_index; } -bool TCProcessor::check_td_readout_length(const PendingTD& pending_td) +bool +TCProcessor::check_td_readout_length(const PendingTD& pending_td) { bool td_too_long = false; if (static_cast(pending_td.readout_end - pending_td.readout_start) >= m_td_readout_limit) { @@ -556,12 +552,10 @@ TCProcessor::clear_td_vectors() std::lock_guard lock(m_td_vector_mutex); m_tds_cleared_count += m_pending_tds.size(); // Use std::accumulate to sum up the sizes of all contributing_tcs vectors - size_t tds_cleared_tc_count = std::accumulate( - m_pending_tds.begin(), m_pending_tds.end(), 0, - [](size_t sum, const PendingTD& ptd) { + size_t tds_cleared_tc_count = + std::accumulate(m_pending_tds.begin(), m_pending_tds.end(), 0, [](size_t sum, const PendingTD& ptd) { return sum + ptd.contributing_tcs.size(); - } - ); + }); m_tds_cleared_tc_count += tds_cleared_tc_count; m_pending_tds.clear(); } @@ -609,7 +603,7 @@ TCProcessor::set_trigger_bitwords(const std::vectorget_bitword()) { + for (const std::string& tctype_str : bitword->get_bitword()) { TCType tc_type = static_cast(dunedaq::trgdataformats::string_to_trigger_candidate_type(tctype_str)); if (tc_type == TCType::kUnknown) { @@ -627,23 +621,20 @@ void TCProcessor::parse_readout_map(const std::vector& data) { for (auto readout_type : data) { - TCType tc_type = static_cast( - dunedaq::trgdataformats::string_to_trigger_candidate_type(readout_type->get_tc_type_name())); + TCType tc_type = + static_cast(dunedaq::trgdataformats::string_to_trigger_candidate_type(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")); - } + // 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() - }; + 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) { @@ -682,8 +673,8 @@ TCProcessor::print_group_links() } dfmessages::ComponentRequest TCProcessor::create_request_for_link(dfmessages::SourceID link, - triggeralgs::timestamp_t start, - triggeralgs::timestamp_t end) + triggeralgs::timestamp_t start, + triggeralgs::timestamp_t end) { dfmessages::ComponentRequest request; request.component = link; @@ -698,8 +689,8 @@ TCProcessor::create_request_for_link(dfmessages::SourceID link, std::vector TCProcessor::create_all_decision_requests(std::vector links, - triggeralgs::timestamp_t start, - triggeralgs::timestamp_t end) + triggeralgs::timestamp_t start, + triggeralgs::timestamp_t end) { std::vector requests; for (auto link : links) { @@ -710,7 +701,7 @@ TCProcessor::create_all_decision_requests(std::vector link void TCProcessor::add_requests_to_decision(dfmessages::TriggerDecision& decision, - std::vector requests) + std::vector requests) { for (auto request : requests) { decision.components.push_back(request); @@ -725,9 +716,9 @@ TCProcessor::parse_roi_conf(const std::vector& da for (auto group : data) { roi_group temp_roi_group; temp_roi_group.n_links = group->get_number_of_link_groups(); - temp_roi_group.prob = group->get_probability(); - temp_roi_group.time_window = group->get_time_window(); - temp_roi_group.mode = group->get_groups_selection_mode(); + temp_roi_group.prob = group->get_probability(); + temp_roi_group.time_window = group->get_time_window(); + temp_roi_group.mode = group->get_groups_selection_mode(); m_roi_conf.insert({ counter, temp_roi_group }); m_roi_conf_ids.push_back(counter); m_roi_conf_probs.push_back(group->get_probability()); @@ -812,9 +803,8 @@ TCProcessor::roi_readout_make_requests(dfmessages::TriggerDecision& decision) TLOG_DEBUG(10) << "group window: " << this_group.time_window; // Once the components are prepared, create requests and append them to decision - std::vector requests = - create_all_decision_requests(links, decision.trigger_timestamp - this_group.time_window, - decision.trigger_timestamp + this_group.time_window); + std::vector requests = create_all_decision_requests( + links, decision.trigger_timestamp - this_group.time_window, decision.trigger_timestamp + this_group.time_window); add_requests_to_decision(decision, requests); links.clear(); } @@ -847,7 +837,8 @@ TCProcessor::print_opmon_stats() TLOG() << "TDs created: \t\t\t" << m_tds_created_count << " \t(" << m_tds_created_tc_count << " TCs)"; TLOG() << "TDs sent: \t\t\t" << m_tds_sent_count << " \t(" << m_tds_sent_tc_count << " TCs)"; TLOG() << "TDs dropped: \t\t\t" << m_tds_dropped_count << " \t(" << m_tds_dropped_tc_count << " TCs)"; - TLOG() << "TDs failed bitword check: \t" << m_tds_failed_bitword_count << " \t(" << m_tds_failed_bitword_tc_count << " TCs)"; + TLOG() << "TDs failed bitword check: \t" << m_tds_failed_bitword_count << " \t(" << m_tds_failed_bitword_tc_count + << " TCs)"; TLOG() << "TDs cleared: \t\t\t" << m_tds_cleared_count << " \t(" << m_tds_cleared_tc_count << " TCs)"; TLOG() << "------------------------------"; TLOG() << "TCs received: \t" << m_tc_received_count; diff --git a/src/TPProcessor.cpp b/src/TPProcessor.cpp index 0f4e81ea..b6c09580 100644 --- a/src/TPProcessor.cpp +++ b/src/TPProcessor.cpp @@ -6,13 +6,13 @@ * received with this code. */ #include "trigger/TPProcessor.hpp" // NOLINT(build/include) -#include "trigger/Issues.hpp" // NOLINT(build/include) +#include "trigger/Issues.hpp" // NOLINT(build/include) #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/IterableQueueModel.hpp" @@ -21,8 +21,8 @@ #include "trigger/AlgorithmPlugins.hpp" #include "triggeralgs/TriggerActivityMaker.hpp" -#include "appmodel/TPDataProcessor.hpp" #include "appmodel/TAAlgorithm.hpp" +#include "appmodel/TPDataProcessor.hpp" using dunedaq::datahandlinglibs::logging::TLVL_BOOKKEEPING; using dunedaq::datahandlinglibs::logging::TLVL_TAKE_NOTE; @@ -34,13 +34,13 @@ DUNE_DAQ_TYPESTRING(std::vector, namespace dunedaq { namespace trigger { -TPProcessor::TPProcessor(std::unique_ptr& error_registry, bool post_processing_enabled) +TPProcessor::TPProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled) : TaskRawDataProcessorModel(error_registry, post_processing_enabled) { } -TPProcessor::~TPProcessor() -{} +TPProcessor::~TPProcessor() {} void TPProcessor::start(const appfwk::DAQModule::CommandData_t& args) @@ -64,7 +64,7 @@ void TPProcessor::stop(const appfwk::DAQModule::CommandData_t& args) { TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TPProcessor: Entering stop() method"; - + inherited::stop(args); m_running_flag.store(false); print_opmon_stats(); @@ -78,9 +78,9 @@ TPProcessor::conf(const appmodel::DataHandlerModule* conf) TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TPProcessor: Entering conf() method"; for (auto output : conf->get_outputs()) { - try { + try { if (output->get_data_type() == "TriggerActivity") { - m_ta_sink = get_iom_sender(output->UID()); + m_ta_sink = get_iom_sender(output->UID()); } } catch (const ers::Issue& excpt) { ers::error(datahandlinglibs::ResourceQueueError(ERS_HERE, "ta", "DefaultRequestHandlerModel", excpt)); @@ -89,15 +89,15 @@ TPProcessor::conf(const appmodel::DataHandlerModule* conf) m_sourceid.id = conf->get_source_id(); m_sourceid.subsystem = TriggerPrimitiveTypeAdapter::subsystem; - + std::vector ta_algorithms; auto dp = conf->get_module_configuration()->get_data_processor(); auto proc_conf = dp->cast(); if (proc_conf != nullptr && m_post_processing_enabled) { ta_algorithms = proc_conf->get_algorithms(); - } + } - for (auto algo : ta_algorithms) { + for (auto algo : ta_algorithms) { TLOG() << "Selected TA algorithm: " << algo->UID() << " from class " << algo->class_name(); std::shared_ptr maker = make_ta_maker(algo->class_name()); nlohmann::json algo_json = algo->to_json(true); @@ -108,7 +108,7 @@ TPProcessor::conf(const appmodel::DataHandlerModule* conf) inherited::add_postprocess_task(std::bind(&TPProcessor::find_ta, this, std::placeholders::_1, maker)); m_tams.push_back(maker); } - m_latency_monitoring.store( dp->get_latency_monitoring() ); + m_latency_monitoring.store(dp->get_latency_monitoring()); inherited::conf(conf); TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << "TPProcessor: Exiting conf() method"; @@ -129,18 +129,18 @@ TPProcessor::generate_opmon_data() { opmon::TPProcessorInfo info; - info.set_tp_received_count( m_tp_received_count.load() ); - info.set_ta_made_count( m_ta_made_count.load() ); - info.set_ta_sent_count( m_ta_sent_count.load() ); - info.set_ta_failed_sent_count( m_ta_failed_sent_count.load() ); + info.set_tp_received_count(m_tp_received_count.load()); + info.set_ta_made_count(m_ta_made_count.load()); + info.set_ta_sent_count(m_ta_sent_count.load()); + info.set_ta_failed_sent_count(m_ta_failed_sent_count.load()); this->publish(std::move(info)); - if ( m_latency_monitoring.load() && m_running_flag.load() ) { + if (m_latency_monitoring.load() && m_running_flag.load()) { opmon::TriggerLatency lat_info; - lat_info.set_latency_in( m_latency_instance.get_latency_in() ); - lat_info.set_latency_out( m_latency_instance.get_latency_out() ); + lat_info.set_latency_in(m_latency_instance.get_latency_in()); + lat_info.set_latency_out(m_latency_instance.get_latency_out()); this->publish(std::move(lat_info)); } @@ -150,23 +150,25 @@ TPProcessor::generate_opmon_data() * Pipeline Stage 2.: Do software TPG * */ void -TPProcessor::find_ta(const TriggerPrimitiveTypeAdapter* tp, std::shared_ptr taa) +TPProcessor::find_ta(const TriggerPrimitiveTypeAdapter* tp, std::shared_ptr taa) { - if (m_latency_monitoring.load()) m_latency_instance.update_latency_in( tp->tp.time_start ); // time_start or time_peak ? - m_tp_received_count++; + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_in(tp->tp.time_start); // time_start or time_peak ? + m_tp_received_count++; std::vector tas; taa->operator()(tp->tp, tas); while (tas.size()) { - m_ta_made_count++; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_out( tas.back().time_start ); - if (!m_ta_sink->try_send(std::move(tas.back()), iomanager::Sender::s_no_block)) { - ers::warning(TADropped(ERS_HERE, tp->tp.time_start, m_sourceid.id)); - m_ta_failed_sent_count++; - } else { - m_ta_sent_count++; - } - tas.pop_back(); + m_ta_made_count++; + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_out(tas.back().time_start); + if (!m_ta_sink->try_send(std::move(tas.back()), iomanager::Sender::s_no_block)) { + ers::warning(TADropped(ERS_HERE, tp->tp.time_start, m_sourceid.id)); + m_ta_failed_sent_count++; + } else { + m_ta_sent_count++; + } + tas.pop_back(); } m_last_processed_daq_ts = tp->tp.time_start; return; diff --git a/src/TPRequestHandler.cpp b/src/TPRequestHandler.cpp index cd1dded2..4fa7b578 100644 --- a/src/TPRequestHandler.cpp +++ b/src/TPRequestHandler.cpp @@ -8,18 +8,19 @@ namespace dunedaq { namespace trigger { void -TPRequestHandler::conf(const appmodel::DataHandlerModule* conf) { - - for (auto output : conf->get_outputs()) { - if (output->get_data_type() == "TPSet") { - try { - m_tpset_sink = iomanager::IOManager::get()->get_sender(output->UID()); - } catch (const ers::Issue& excpt) { - throw datahandlinglibs::ResourceQueueError(ERS_HERE, "tp queue", "DefaultRequestHandlerModel", excpt); - } +TPRequestHandler::conf(const appmodel::DataHandlerModule* conf) +{ + + for (auto output : conf->get_outputs()) { + if (output->get_data_type() == "TPSet") { + try { + m_tpset_sink = iomanager::IOManager::get()->get_sender(output->UID()); + } catch (const ers::Issue& excpt) { + throw datahandlinglibs::ResourceQueueError(ERS_HERE, "tp queue", "DefaultRequestHandlerModel", excpt); } - } - inherited2::conf(conf); + } + } + inherited2::conf(conf); } void @@ -29,93 +30,94 @@ TPRequestHandler::scrap(const appfwk::DAQModule::CommandData_t& args) inherited2::scrap(args); } -void +void TPRequestHandler::start(const appfwk::DAQModule::CommandData_t& args) { - m_oldest_ts=0; - m_newest_ts=0; - m_start_win_ts=0; - m_end_win_ts=0; - m_first_cycle = true; - - inherited2::start(args); - rcif::cmd::StartParams start_params = args.get(); - m_run_number = start_params.run; + m_oldest_ts = 0; + m_newest_ts = 0; + m_start_win_ts = 0; + m_end_win_ts = 0; + m_first_cycle = true; + inherited2::start(args); + rcif::cmd::StartParams start_params = args.get(); + m_run_number = start_params.run; } void -TPRequestHandler::periodic_data_transmission() { - - if (m_tpset_sink == nullptr) return; - - dunedaq::dfmessages::DataRequest dr; - - { - std::unique_lock lock(m_cv_mutex); - m_cv.wait(lock, [&] { return !m_cleanup_requested; }); - m_requests_running++; - } - m_cv.notify_all(); - if(m_latency_buffer->occupancy() != 0) { - // Prepare response - RequestResult rres(ResultCode::kUnknown, dr); - std::vector> frag_pieces; - - // Get the newest TP - SkipListAcc acc(inherited2::m_latency_buffer->get_skip_list()); - auto tail = acc.last(); - auto head = acc.first(); - m_newest_ts = (*tail).get_timestamp(); - m_oldest_ts = (*head).get_timestamp(); - - if (m_first_cycle) { - m_start_win_ts = m_oldest_ts; - m_first_cycle = false; - } - if (m_newest_ts - m_start_win_ts > m_ts_set_sender_offset_ticks) { - m_end_win_ts = m_newest_ts - m_ts_set_sender_offset_ticks; - frag_pieces = get_fragment_pieces(m_start_win_ts, m_end_win_ts, rres); - auto num_tps = frag_pieces.size(); - trigger::TPSet tpset; - tpset.run_number = m_run_number; - tpset.type = num_tps>0 ? trigger::TPSet::Type::kPayload : trigger::TPSet::Type::kHeartbeat; - tpset.origin = m_sourceid; - tpset.start_time = m_start_win_ts; // provisory timestamp, will be filled with first TP - tpset.end_time = m_end_win_ts; // provisory timestamp, will be filled with last TP - tpset.seqno = m_next_tpset_seqno++; // NOLINT(runtime/increment_decrement) - // reserve the space for efficiency - if (num_tps > 0) { - tpset.objects.reserve(frag_pieces.size()); - bool first_tp = true; - for( auto f : frag_pieces) { - trgdataformats::TriggerPrimitive tp = *(static_cast(f.first)); - - if(first_tp) { - tpset.start_time = tp.time_start; - first_tp = false; - } - tpset.end_time = tp.time_start; - tpset.objects.emplace_back(std::move(tp)); - } - } - if(!m_tpset_sink->try_send(std::move(tpset), iomanager::Sender::s_no_block)) { - ers::warning(DroppedTPSet(ERS_HERE, m_start_win_ts, m_end_win_ts)); - m_num_periodic_send_failed++; - } - m_num_periodic_sent++; - - //remember what we sent for the next loop - m_start_win_ts = m_end_win_ts; - } +TPRequestHandler::periodic_data_transmission() +{ + + if (m_tpset_sink == nullptr) + return; + + dunedaq::dfmessages::DataRequest dr; + + { + std::unique_lock lock(m_cv_mutex); + m_cv.wait(lock, [&] { return !m_cleanup_requested; }); + m_requests_running++; + } + m_cv.notify_all(); + if (m_latency_buffer->occupancy() != 0) { + // Prepare response + RequestResult rres(ResultCode::kUnknown, dr); + std::vector> frag_pieces; + + // Get the newest TP + SkipListAcc acc(inherited2::m_latency_buffer->get_skip_list()); + auto tail = acc.last(); + auto head = acc.first(); + m_newest_ts = (*tail).get_timestamp(); + m_oldest_ts = (*head).get_timestamp(); + + if (m_first_cycle) { + m_start_win_ts = m_oldest_ts; + m_first_cycle = false; } - { - std::lock_guard lock(m_cv_mutex); - m_requests_running--; + if (m_newest_ts - m_start_win_ts > m_ts_set_sender_offset_ticks) { + m_end_win_ts = m_newest_ts - m_ts_set_sender_offset_ticks; + frag_pieces = get_fragment_pieces(m_start_win_ts, m_end_win_ts, rres); + auto num_tps = frag_pieces.size(); + trigger::TPSet tpset; + tpset.run_number = m_run_number; + tpset.type = num_tps > 0 ? trigger::TPSet::Type::kPayload : trigger::TPSet::Type::kHeartbeat; + tpset.origin = m_sourceid; + tpset.start_time = m_start_win_ts; // provisory timestamp, will be filled with first TP + tpset.end_time = m_end_win_ts; // provisory timestamp, will be filled with last TP + tpset.seqno = m_next_tpset_seqno++; // NOLINT(runtime/increment_decrement) + // reserve the space for efficiency + if (num_tps > 0) { + tpset.objects.reserve(frag_pieces.size()); + bool first_tp = true; + for (auto f : frag_pieces) { + trgdataformats::TriggerPrimitive tp = *(static_cast(f.first)); + + if (first_tp) { + tpset.start_time = tp.time_start; + first_tp = false; + } + tpset.end_time = tp.time_start; + tpset.objects.emplace_back(std::move(tp)); + } + } + if (!m_tpset_sink->try_send(std::move(tpset), iomanager::Sender::s_no_block)) { + ers::warning(DroppedTPSet(ERS_HERE, m_start_win_ts, m_end_win_ts)); + m_num_periodic_send_failed++; + } + m_num_periodic_sent++; + + // remember what we sent for the next loop + m_start_win_ts = m_end_win_ts; } - m_cv.notify_all(); - return; + } + { + std::lock_guard lock(m_cv_mutex); + m_requests_running--; + } + m_cv.notify_all(); + return; } } // namespace fdreadoutlibs diff --git a/src/trigger/HSISourceModel.hpp b/src/trigger/HSISourceModel.hpp index 52916630..2e107811 100644 --- a/src/trigger/HSISourceModel.hpp +++ b/src/trigger/HSISourceModel.hpp @@ -8,25 +8,25 @@ #ifndef TRIGGER_PLUGINS_HSISOURCEMODEL_HPP_ #define TRIGGER_PLUGINS_HSISOURCEMODEL_HPP_ -#include #include "datahandlinglibs/concepts/SourceConcept.hpp" #include "detdataformats/DetID.hpp" #include "dfmessages/HSIEvent.hpp" -#include "triggeralgs/TriggerCandidate.hpp" #include "trigger/Issues.hpp" #include "trigger/Latency.hpp" #include "trigger/opmon/hsisourcemodel_info.pb.h" #include "trigger/opmon/latency_info.pb.h" +#include "triggeralgs/TriggerCandidate.hpp" +#include +#include "appmodel/DataProcessor.hpp" +#include "appmodel/DataSubscriberModule.hpp" +#include "appmodel/HSI2TCTranslatorConf.hpp" +#include "appmodel/HSISignalWindow.hpp" +#include "confmodel/DaqModule.hpp" #include "iomanager/IOManager.hpp" -#include "iomanager/Sender.hpp" #include "iomanager/Receiver.hpp" +#include "iomanager/Sender.hpp" #include "logging/Logging.hpp" -#include "confmodel/DaqModule.hpp" -#include "appmodel/DataSubscriberModule.hpp" -#include "appmodel/HSI2TCTranslatorConf.hpp" -#include "appmodel/HSISignalWindow.hpp" -#include "appmodel/DataProcessor.hpp" namespace dunedaq::trigger { @@ -43,14 +43,17 @@ struct HSISignal class HSISourceModel : public datahandlinglibs::SourceConcept { -public: +public: using inherited = datahandlinglibs::SourceConcept; /** * @brief SourceModel Constructor * @param name Instance name for this SourceModel instance */ - HSISourceModel(): datahandlinglibs::SourceConcept() {} + HSISourceModel() + : datahandlinglibs::SourceConcept() + { + } ~HSISourceModel() override { m_data_receiver.reset(); @@ -82,7 +85,7 @@ class HSISourceModel : public datahandlinglibs::SourceConcept for (auto win : hsi_conf->get_signals()) { triggeralgs::TriggerCandidate::Type tc_type; tc_type = static_cast( - dunedaq::trgdataformats::string_to_trigger_candidate_type(win->get_tc_type_name())); + dunedaq::trgdataformats::string_to_trigger_candidate_type(win->get_tc_type_name())); // Throw error if unknown TC type if (tc_type == triggeralgs::TriggerCandidate::Type::kUnknown) { @@ -92,24 +95,23 @@ class HSISourceModel : public datahandlinglibs::SourceConcept // Throw error if already exists uint32_t signal = win->get_signal_type(); if (m_signals.count(signal)) { - throw datahandlinglibs::InitializationError(ERS_HERE, "Provided more than one of the same HSI signal ID input to HSISourceModel"); + throw datahandlinglibs::InitializationError( + ERS_HERE, "Provided more than one of the same HSI signal ID input to HSISourceModel"); } // Fill the signal-tctype map - m_signals[signal] = { tc_type, - win->get_time_before(), - win->get_time_after() }; + m_signals[signal] = { tc_type, win->get_time_before(), win->get_time_after() }; - TLOG() << "Will cover HSI signal id: " << signal << " to TC type: " << win->get_tc_type_name() + TLOG() << "Will cover HSI signal id: " << signal << " to TC type: " << win->get_tc_type_name() << " window before: " << win->get_time_before() << " window after: " << win->get_time_after(); } m_prescale = hsi_conf->get_prescale(); - m_latency_monitoring.store( hsi_conf->get_latency_monitoring() ); - + m_latency_monitoring.store(hsi_conf->get_latency_monitoring()); } - void start() { + void start() + { m_data_receiver->add_callback(std::bind(&HSISourceModel::handle_payload, this, std::placeholders::_1)); m_running_flag.store(true); @@ -118,9 +120,10 @@ class HSISourceModel : public datahandlinglibs::SourceConcept m_tcs_made_count.store(0); m_tcs_sent_count.store(0); m_tcs_dropped_count.store(0); - } + } - void stop() { + void stop() + { m_data_receiver->remove_callback(); m_running_flag.store(false); print_opmon_stats(); @@ -129,7 +132,8 @@ class HSISourceModel : public datahandlinglibs::SourceConcept bool handle_payload(dfmessages::HSIEvent& data) // NOLINT(build/unsigned) { m_received_events_count++; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_in( data.timestamp ); + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_in(data.timestamp); // Prescale after n-hsi received if (m_received_events_count % m_prescale != 0) { @@ -147,7 +151,7 @@ class HSISourceModel : public datahandlinglibs::SourceConcept // Throw an error if we don't have this signal bit configured if (!m_signals.count(signal)) { - throw dunedaq::trigger::SignalTypeError(ERS_HERE, "HSI subscriber" , data.signal_map); + throw dunedaq::trigger::SignalTypeError(ERS_HERE, "HSI subscriber", data.signal_map); } // Create the trigger candidate @@ -156,44 +160,44 @@ class HSISourceModel : public datahandlinglibs::SourceConcept candidate.time_end = data.timestamp + m_signals[signal].time_after; candidate.time_candidate = data.timestamp; // throw away bits 31-16 of header, that's OK for now - candidate.detid = (uint)detdataformats::DetID::Subdetector::kDAQ ; // NOLINT(build/unsigned) + candidate.detid = (uint)detdataformats::DetID::Subdetector::kDAQ; // NOLINT(build/unsigned) candidate.type = m_signals[signal].type; candidate.algorithm = triggeralgs::TriggerCandidate::Algorithm::kHSIEventToTriggerCandidate; candidate.inputs = {}; - m_tcs_made_count++; + m_tcs_made_count++; - if (m_latency_monitoring.load()) m_latency_instance.update_latency_out( candidate.time_candidate ); + if (m_latency_monitoring.load()) + m_latency_instance.update_latency_out(candidate.time_candidate); // Send the TC if (!m_data_sender->try_send(std::move(candidate), iomanager::Sender::s_no_block)) { m_tcs_dropped_count++; - } - else { + } else { m_tcs_sent_count++; } // Clear the least significant bit signal_map &= signal_map - 1; } - + return true; } void generate_opmon_data() override { opmon::HSISourceModelInfo info; - - info.set_received_events_count( m_received_events_count ); - info.set_tcs_made_count( m_tcs_made_count ); - info.set_tcs_sent_count( m_tcs_sent_count ); - info.set_tcs_dropped_count( m_tcs_dropped_count ); + + info.set_received_events_count(m_received_events_count); + info.set_tcs_made_count(m_tcs_made_count); + info.set_tcs_sent_count(m_tcs_sent_count); + info.set_tcs_dropped_count(m_tcs_dropped_count); this->publish(std::move(info)); - if ( m_latency_monitoring.load() && m_running_flag.load() ) { + if (m_latency_monitoring.load() && m_running_flag.load()) { opmon::TriggerLatency lat_info; - lat_info.set_latency_in( m_latency_instance.get_latency_in() ); - lat_info.set_latency_out( m_latency_instance.get_latency_out() ); + lat_info.set_latency_in(m_latency_instance.get_latency_in()); + lat_info.set_latency_out(m_latency_instance.get_latency_out()); this->publish(std::move(lat_info)); } @@ -220,12 +224,12 @@ class HSISourceModel : public datahandlinglibs::SourceConcept /// @brief map of HSI signal ID bits to TC output configurations std::map m_signals; - //Stats + // Stats using metric_counter_type = uint64_t; - std::atomic m_received_events_count{0}; - std::atomic m_tcs_made_count{0}; - std::atomic m_tcs_sent_count{0}; - std::atomic m_tcs_dropped_count{0}; + std::atomic m_received_events_count{ 0 }; + std::atomic m_tcs_made_count{ 0 }; + std::atomic m_tcs_sent_count{ 0 }; + std::atomic m_tcs_dropped_count{ 0 }; /// @brief {rescale for the input HSIEvents, default 1 uint64_t m_prescale; diff --git a/src/trigger/LivetimeCounter.hpp b/src/trigger/LivetimeCounter.hpp index c195710d..4dad4d3c 100644 --- a/src/trigger/LivetimeCounter.hpp +++ b/src/trigger/LivetimeCounter.hpp @@ -18,63 +18,61 @@ namespace dunedaq::trigger { class LivetimeCounter { public: - enum class State { + enum class State + { kLive, // Live to triggers kDead, // Dead to triggers due to a problem kPaused // Triggers paused (so we are dead to triggers, but intentionally) }; - /** - ** @brief A type to store a time duration in milliseconds - **/ + /** + ** @brief A type to store a time duration in milliseconds + **/ using state_time_t = uint64_t; - - /** - ** @brief Construct a LivetimeCounter in the given state - ** - ** Counting the time in the initial state begins immediately - **/ + /** + ** @brief Construct a LivetimeCounter in the given state + ** + ** Counting the time in the initial state begins immediately + **/ LivetimeCounter(State state); ~LivetimeCounter(); - - /** - ** @brief Set the current state to @a state - ** - ** Updates the accumulated time in the previous state and switches the state - **/ + /** + ** @brief Set the current state to @a state + ** + ** Updates the accumulated time in the previous state and switches the state + **/ void set_state(State state); - /** - ** @brief Get a map of accumulated time in milliseconds in each state - **/ + /** + ** @brief Get a map of accumulated time in milliseconds in each state + **/ std::map get_time_map(); - /** - ** @brief Get the accumulated time in milliseconds spent in a particular state - **/ + /** + ** @brief Get the accumulated time in milliseconds spent in a particular state + **/ state_time_t get_time(State state); - /** - ** @brief Get a nicely-formatted string of the time spent in each state - **/ + /** + ** @brief Get a nicely-formatted string of the time spent in each state + **/ std::string get_report_string(); std::string get_state_name(State state) const; - + private: state_time_t now() const; // Precondition: m_mutex is locked by caller - void update_map(); - - std::mutex m_mutex; - State m_state; - std::map m_state_times; - state_time_t m_last_state_change_time; - + void update_map(); + + std::mutex m_mutex; + State m_state; + std::map m_state_times; + state_time_t m_last_state_change_time; }; } // namespace dunedaq::trigger - + #endif // TRIGGER_PLUGINS_LIVETIMECOUNTER_HPP_ diff --git a/src/trigger/TAProcessor.hpp b/src/trigger/TAProcessor.hpp index e867aab1..f29cbe32 100644 --- a/src/trigger/TAProcessor.hpp +++ b/src/trigger/TAProcessor.hpp @@ -17,14 +17,14 @@ #include "datahandlinglibs/models/TaskRawDataProcessorModel.hpp" #include "trigger/Issues.hpp" -#include "trigger/TAWrapper.hpp" #include "trigger/Latency.hpp" -#include "trigger/opmon/taprocessor_info.pb.h" +#include "trigger/TAWrapper.hpp" #include "trigger/opmon/latency_info.pb.h" +#include "trigger/opmon/taprocessor_info.pb.h" #include "triggeralgs/TriggerCandidate.hpp" -#include "triggeralgs/Types.hpp" #include "triggeralgs/TriggerCandidateMaker.hpp" +#include "triggeralgs/Types.hpp" namespace dunedaq { namespace trigger { @@ -37,8 +37,8 @@ class TAProcessor : public datahandlinglibs::TaskRawDataProcessorModel& error_registry, bool post_processing_enabled); + explicit TAProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled); ~TAProcessor(); @@ -63,8 +63,7 @@ class TAProcessor : public datahandlinglibs::TaskRawDataProcessorModel tcm); - private: - +private: std::vector> m_tcms; std::shared_ptr> m_tc_sink; @@ -72,7 +71,7 @@ class TAProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_ta_received_count{ 0 }; // NOLINT(build/unsigned) + std::atomic m_ta_received_count{ 0 }; // NOLINT(build/unsigned) std::atomic m_tc_made_count{ 0 }; std::atomic m_tc_sent_count{ 0 }; std::atomic m_tc_failed_sent_count{ 0 }; @@ -84,7 +83,6 @@ class TAProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_latency_in{ 0 }; std::atomic m_latency_out{ 0 }; - }; } // namespace trigger diff --git a/src/trigger/TCProcessor.hpp b/src/trigger/TCProcessor.hpp index f56909c3..a2ae3584 100644 --- a/src/trigger/TCProcessor.hpp +++ b/src/trigger/TCProcessor.hpp @@ -13,19 +13,19 @@ #include "logging/Logging.hpp" #include "appmodel/DataHandlerModule.hpp" -#include "appmodel/TCReadoutMap.hpp" #include "appmodel/ROIGroupConf.hpp" #include "appmodel/SourceIDConf.hpp" -#include "appmodel/TriggerDataHandlerModule.hpp" +#include "appmodel/TCReadoutMap.hpp" #include "appmodel/TriggerBitword.hpp" +#include "appmodel/TriggerDataHandlerModule.hpp" #include "datahandlinglibs/models/TaskRawDataProcessorModel.hpp" #include "trigger/Issues.hpp" -#include "trigger/TCWrapper.hpp" #include "trigger/Latency.hpp" -#include "trigger/opmon/tcprocessor_info.pb.h" +#include "trigger/TCWrapper.hpp" #include "trigger/opmon/latency_info.pb.h" +#include "trigger/opmon/tcprocessor_info.pb.h" #include "daqdataformats/SourceID.hpp" #include "dfmessages/TriggerDecision.hpp" @@ -47,7 +47,8 @@ class TCProcessor : public datahandlinglibs::TaskRawDataProcessorModel; - explicit TCProcessor(std::unique_ptr& error_registry, bool post_processing_enabled); + explicit TCProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled); ~TCProcessor(); @@ -62,7 +63,6 @@ class TCProcessor : public datahandlinglibs::TaskRawDataProcessorModel get_ready_tds(std::vector& pending_tds); @@ -155,12 +155,10 @@ class TCProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_readout_window_map_data; - std::map> - m_readout_window_map; + std::vector m_readout_window_map_data; + std::map> m_readout_window_map; void parse_readout_map(const std::vector& data); - void print_readout_map(std::map> map); + void print_readout_map(std::map> map); // Create the next trigger decision dfmessages::TriggerDecision create_decision(const PendingTD& pending_td); @@ -171,13 +169,12 @@ class TCProcessor : public datahandlinglibs::TaskRawDataProcessorModel> m_td_sink; // opmon - using metric_counter_type = uint64_t; - std::atomic m_tds_created_count{ 0 }; // NOLINT(build/unsigned) + using metric_counter_type = uint64_t; + std::atomic m_tds_created_count{ 0 }; // NOLINT(build/unsigned) std::atomic m_tds_sent_count{ 0 }; std::atomic m_tds_dropped_count{ 0 }; std::atomic m_tds_failed_bitword_count{ 0 }; diff --git a/src/trigger/TPProcessor.hpp b/src/trigger/TPProcessor.hpp index 497c5eb0..8842984b 100644 --- a/src/trigger/TPProcessor.hpp +++ b/src/trigger/TPProcessor.hpp @@ -14,15 +14,15 @@ #include "datahandlinglibs/models/TaskRawDataProcessorModel.hpp" -//#include "triggger/Issues.hpp" -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" +// #include "triggger/Issues.hpp" #include "trigger/Latency.hpp" -#include "trigger/opmon/tpprocessor_info.pb.h" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "trigger/opmon/latency_info.pb.h" +#include "trigger/opmon/tpprocessor_info.pb.h" #include "triggeralgs/TriggerActivity.hpp" -#include "triggeralgs/Types.hpp" #include "triggeralgs/TriggerActivityMaker.hpp" +#include "triggeralgs/Types.hpp" #include "appmodel/DataHandlerModule.hpp" @@ -37,8 +37,8 @@ class TPProcessor : public datahandlinglibs::TaskRawDataProcessorModel& error_registry, bool post_processing_enabled); + explicit TPProcessor(std::unique_ptr& error_registry, + bool post_processing_enabled); ~TPProcessor(); @@ -61,10 +61,9 @@ class TPProcessor : public datahandlinglibs::TaskRawDataProcessorModel tam); - - private: + void find_ta(const TriggerPrimitiveTypeAdapter* tp, std::shared_ptr tam); +private: std::vector> m_tams; std::shared_ptr> m_ta_sink; @@ -72,7 +71,7 @@ class TPProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_tp_received_count{ 0 }; // NOLINT(build/unsigned) + std::atomic m_tp_received_count{ 0 }; // NOLINT(build/unsigned) std::atomic m_ta_made_count{ 0 }; std::atomic m_ta_sent_count{ 0 }; std::atomic m_ta_failed_sent_count{ 0 }; @@ -84,7 +83,6 @@ class TPProcessor : public datahandlinglibs::TaskRawDataProcessorModel m_latency_in{ 0 }; std::atomic m_latency_out{ 0 }; - }; } // namespace trigger diff --git a/src/trigger/TPRequestHandler.hpp b/src/trigger/TPRequestHandler.hpp index 74f94c00..45bf92af 100644 --- a/src/trigger/TPRequestHandler.hpp +++ b/src/trigger/TPRequestHandler.hpp @@ -1,5 +1,5 @@ /** - * @file TPRequestHandler.hpp Trigger matching mechanism + * @file TPRequestHandler.hpp Trigger matching mechanism * used for skip list based LBs in readout models * * This is part of the DUNE DAQ , copyright 2020. @@ -14,34 +14,28 @@ #include "appmodel/DataHandlerModule.hpp" -#include "datahandlinglibs/ReadoutLogging.hpp" -#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/DataHandlingIssues.hpp" +#include "datahandlinglibs/FrameErrorRegistry.hpp" #include "datahandlinglibs/ReadoutLogging.hpp" #include "datahandlinglibs/models/DefaultSkipListRequestHandler.hpp" -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "trigger/TPSet.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG< #include #include using dunedaq::datahandlinglibs::logging::TLVL_WORK_STEPS; - namespace dunedaq { ERS_DECLARE_ISSUE(trigger, DroppedTPSet, "Failed to send TPs from " << s_ts << " to " << e_ts, - ((uint64_t)s_ts) - ((uint64_t)e_ts)) -ERS_DECLARE_ISSUE(trigger, - TPHandlerMsg, - infomsg, - ((std::string) infomsg)) + ((uint64_t)s_ts)((uint64_t)e_ts)) +ERS_DECLARE_ISSUE(trigger, TPHandlerMsg, infomsg, ((std::string)infomsg)) namespace trigger { @@ -52,37 +46,34 @@ class TPRequestHandler : public dunedaq::datahandlinglibs::DefaultSkipListReques // Constructor that binds LB and error registry - TPRequestHandler(std::shared_ptr>& latency_buffer, - std::unique_ptr& error_registry) - : datahandlinglibs::DefaultSkipListRequestHandler( - latency_buffer, - error_registry) + TPRequestHandler( + std::shared_ptr>& latency_buffer, + std::unique_ptr& error_registry) + : datahandlinglibs::DefaultSkipListRequestHandler(latency_buffer, error_registry) { TLOG_DEBUG(TLVL_WORK_STEPS) << "TPRequestHandler created..."; } - + void conf(const appmodel::DataHandlerModule* conf) override; void start(const appfwk::DAQModule::CommandData_t& args) override; void scrap(const appfwk::DAQModule::CommandData_t& args) override; void periodic_data_transmission() override; - + private: using timestamp_t = std::uint64_t; std::shared_ptr> m_tpset_sink; uint64_t m_run_number; uint64_t m_next_tpset_seqno; - timestamp_t m_oldest_ts=0; - timestamp_t m_newest_ts=0; - timestamp_t m_start_win_ts=0; - timestamp_t m_end_win_ts=0; + timestamp_t m_oldest_ts = 0; + timestamp_t m_newest_ts = 0; + timestamp_t m_start_win_ts = 0; + timestamp_t m_end_win_ts = 0; bool m_first_cycle = true; uint64_t m_ts_set_sender_offset_ticks = 6250000; // 100 ms delay in transmission - }; } // namespace trigger } // namespace dunedaq - #endif // TRIGGER_SRC_TRIGGER_TPREQUESTHANDLER_HPP_ diff --git a/src/trigger/TriggerGenericMaker.hpp b/src/trigger/TriggerGenericMaker.hpp index cd1c21b4..c7ffe218 100644 --- a/src/trigger/TriggerGenericMaker.hpp +++ b/src/trigger/TriggerGenericMaker.hpp @@ -18,11 +18,11 @@ #include "appfwk/DAQModule.hpp" #include "daqdataformats/SourceID.hpp" #include "dfmessages/Types.hpp" -#include "trgdataformats/Types.hpp" #include "iomanager/IOManager.hpp" #include "iomanager/Receiver.hpp" #include "iomanager/Sender.hpp" #include "logging/Logging.hpp" +#include "trgdataformats/Types.hpp" #include "utilities/WorkerThread.hpp" #include @@ -75,12 +75,12 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule TriggerGenericMaker(TriggerGenericMaker&&) = delete; TriggerGenericMaker& operator=(TriggerGenericMaker&&) = delete; - //void init(const CommandData_t& obj) override + // void init(const CommandData_t& obj) override //{ - // // TODO: Reimplement as OKS - // //m_input_queue = get_iom_receiver(appfwk::connection_uid(obj, "input")); - // //m_output_queue = get_iom_sender(appfwk::connection_uid(obj, "output")); - //} + // // TODO: Reimplement as OKS + // //m_input_queue = get_iom_receiver(appfwk::connection_uid(obj, "input")); + // //m_output_queue = get_iom_sender(appfwk::connection_uid(obj, "output")); + // } void get_info(opmonlib::InfoCollector& ci, int /*level*/) override { @@ -88,12 +88,14 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule i.received_count = m_received_count.load(); i.sent_count = m_sent_count.load(); - if (m_maker) { i.data_vs_system_ms = m_maker->m_data_vs_system_time; } - else i.data_vs_system_ms = 0; + if (m_maker) { + i.data_vs_system_ms = m_maker->m_data_vs_system_time; + } else + i.data_vs_system_ms = 0; ci.add(i); } - + protected: void set_algorithm_name(const std::string& name) { m_algorithm_name = name; } @@ -135,7 +137,7 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule std::unique_ptr m_maker; nlohmann::json m_maker_conf; - + TriggerGenericWorker worker; // This should return a unique_ptr to the MAKER created from conf command arguments. @@ -152,10 +154,7 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule m_run_number = startobj.value("run", 0); } - void do_stop(const CommandData_t& /*obj*/) - { - m_thread.stop_working_thread(); - } + void do_stop(const CommandData_t& /*obj*/) { m_thread.stop_working_thread(); } void do_configure(const CommandData_t& obj) { @@ -165,7 +164,7 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule // persist between runs and hold onto its state from the previous // run m_maker_conf = obj; - + // worker should be notified that configuration potentially changed worker.reconfigure(); } @@ -187,8 +186,8 @@ class TriggerGenericMaker : public dunedaq::appfwk::DAQModule IN in; while (receive(in)) { if (m_running_flag.load()) { - worker.process(in); - } + worker.process(in); + } } } // P. Rodrigues 2022-06-01. The argument here is whether to drop @@ -245,16 +244,16 @@ class TriggerGenericWorker { public: explicit TriggerGenericWorker(TriggerGenericMaker& parent) - : m_parent(parent), m_low_level_input_count(0) - {} + : m_parent(parent) + , m_low_level_input_count(0) + { + } TriggerGenericMaker& m_parent; void reconfigure() {} - void reset() { - m_low_level_input_count = 0; - } + void reset() { m_low_level_input_count = 0; } void process(IN& in) { @@ -279,7 +278,7 @@ class TriggerGenericWorker void drain(bool) {} - size_t get_low_level_input_count() {return m_low_level_input_count;} + size_t get_low_level_input_count() { return m_low_level_input_count; } size_t m_low_level_input_count; }; @@ -294,7 +293,8 @@ class TriggerGenericWorker, Set, MAKER> , m_in_buffer(parent.get_name(), parent.m_algorithm_name) , m_out_buffer(parent.get_name(), parent.m_algorithm_name, parent.m_buffer_time) , m_low_level_input_count(0) - {} + { + } TriggerGenericMaker, Set, MAKER>& m_parent; @@ -371,8 +371,7 @@ class TriggerGenericWorker, Set, MAKER> heartbeat.type = Set::Type::kHeartbeat; heartbeat.start_time = in.start_time; heartbeat.end_time = in.end_time; - heartbeat.origin = daqdataformats::SourceID( - daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); + heartbeat.origin = daqdataformats::SourceID(daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); TLOG_DEBUG(4) << "Buffering heartbeat with start time " << heartbeat.start_time; m_out_buffer.buffer_heartbeat(heartbeat); @@ -398,15 +397,14 @@ class TriggerGenericWorker, Set, MAKER> m_out_buffer.buffer(elems); } - size_t n_output_windows=0; + size_t n_output_windows = 0; // emit completed windows while (m_out_buffer.ready()) { ++n_output_windows; Set out; m_out_buffer.flush(out); out.seqno = m_parent.m_sent_count; - out.origin = daqdataformats::SourceID( - daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); + out.origin = daqdataformats::SourceID(daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); if (out.type == Set::Type::kHeartbeat) { TLOG_DEBUG(4) << "Sending heartbeat with start time " << out.start_time; @@ -448,11 +446,10 @@ class TriggerGenericWorker, Set, MAKER> Set out; m_out_buffer.flush(out); out.seqno = m_parent.m_sent_count; - out.origin = daqdataformats::SourceID( - daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); + out.origin = daqdataformats::SourceID(daqdataformats::SourceID::Subsystem::kTrigger, m_parent.m_sourceid); if (out.type == Set::Type::kHeartbeat) { - if(!drop) { + if (!drop) { if (!m_parent.send(std::move(out))) { ers::error(AlgorithmFailedToSend(ERS_HERE, m_parent.get_name(), m_parent.m_algorithm_name)); // out is dropped @@ -473,7 +470,7 @@ class TriggerGenericWorker, Set, MAKER> } } - size_t get_low_level_input_count() {return m_low_level_input_count;} + size_t get_low_level_input_count() { return m_low_level_input_count; } size_t m_low_level_input_count; }; @@ -487,7 +484,8 @@ class TriggerGenericWorker, OUT, MAKER> : m_parent(parent) , m_in_buffer(parent.get_name(), parent.m_algorithm_name) , m_low_level_input_count(0) - {} + { + } TriggerGenericMaker, OUT, MAKER>& m_parent; @@ -495,9 +493,7 @@ class TriggerGenericWorker, OUT, MAKER> void reconfigure() {} - void reset() { - m_low_level_input_count = 0; - } + void reset() { m_low_level_input_count = 0; } void process_slice(const std::vector& time_slice, std::vector& out_vec) { @@ -583,12 +579,12 @@ class TriggerGenericWorker, OUT, MAKER> // out.back() is dropped } } - out_vec.pop_back(); + out_vec.pop_back(); } } } - size_t get_low_level_input_count() {return m_low_level_input_count;} + size_t get_low_level_input_count() { return m_low_level_input_count; } size_t m_low_level_input_count; }; diff --git a/test/apps/print_ds_fragments.cxx b/test/apps/print_ds_fragments.cxx index 2f2a2371..95bf7b3f 100644 --- a/test/apps/print_ds_fragments.cxx +++ b/test/apps/print_ds_fragments.cxx @@ -7,9 +7,9 @@ */ #include "CLI/CLI.hpp" +#include "hdf5libs/HDF5RawDataFile.hpp" #include "trgdataformats/TriggerObjectOverlay.hpp" #include "trgdataformats/TriggerPrimitive.hpp" -#include "hdf5libs/HDF5RawDataFile.hpp" #include #include diff --git a/test/apps/print_trigger_type.cxx b/test/apps/print_trigger_type.cxx index 6eaa4ded..603ec463 100644 --- a/test/apps/print_trigger_type.cxx +++ b/test/apps/print_trigger_type.cxx @@ -1,5 +1,6 @@ /** - * @file check_fragment_TPs.cxx Read TP fragments from file and check that they have start times within the request window + * @file check_fragment_TPs.cxx Read TP fragments from file and check that they have start times within the request + * window * * This is part of the DUNE DAQ Application Framework, copyright 2020. * Licensing/copyright details are in the COPYING file that you should have @@ -7,8 +8,8 @@ */ #include "CLI/CLI.hpp" -#include "trgdataformats/TriggerPrimitive.hpp" #include "hdf5libs/HDF5RawDataFile.hpp" +#include "trgdataformats/TriggerPrimitive.hpp" #include #include @@ -29,11 +30,12 @@ main(int argc, char** argv) dunedaq::hdf5libs::HDF5RawDataFile decoder(filename); auto trigger_record_ids = decoder.get_all_trigger_record_ids(); - - for (auto trigger_record_id : trigger_record_ids){ + + for (auto trigger_record_id : trigger_record_ids) { auto trigger_number = trigger_record_id.first; auto header = decoder.get_trh_ptr(trigger_number); - std::cout << "Trigger record " << trigger_number << " has type 0x" << std::hex << header->get_trigger_type() << std::dec << std::endl; + std::cout << "Trigger record " << trigger_number << " has type 0x" << std::hex << header->get_trigger_type() + << std::dec << std::endl; } } diff --git a/test/apps/set_serialization_speed.cxx b/test/apps/set_serialization_speed.cxx index 081b6150..6700c472 100644 --- a/test/apps/set_serialization_speed.cxx +++ b/test/apps/set_serialization_speed.cxx @@ -8,10 +8,10 @@ #include "logging/Logging.hpp" #include "serialization/Serialization.hpp" +#include "trgdataformats/Types.hpp" #include "trigger/TASet.hpp" #include "trigger/TPSet.hpp" #include "triggeralgs/TriggerPrimitive.hpp" -#include "trgdataformats/Types.hpp" #include #include diff --git a/test/plugins/TASetSink.cpp b/test/plugins/TASetSink.cpp index 52412b2d..4cc9a552 100644 --- a/test/plugins/TASetSink.cpp +++ b/test/plugins/TASetSink.cpp @@ -27,16 +27,14 @@ TASetSink::TASetSink(const std::string& name) register_command("conf", &TASetSink::do_conf); } -void -TASetSink::init(std::shared_ptr) -{}; +void TASetSink::init(std::shared_ptr){}; -//void -//TASetSink::init(const CommandData_t& obj) +// void +// TASetSink::init(const CommandData_t& obj) //{ -// // TODO: Reimplement as OKS -// //m_taset_source = get_iom_receiver(appfwk::connection_uid(obj, "taset_source")); -//} +// // TODO: Reimplement as OKS +// //m_taset_source = get_iom_receiver(appfwk::connection_uid(obj, "taset_source")); +// } void TASetSink::do_start(const CommandData_t& /*obj*/) @@ -56,16 +54,14 @@ TASetSink::do_stop(const CommandData_t& /*obj*/) void TASetSink::do_conf(const CommandData_t& obj) { - m_conf=obj; + m_conf = obj; if (m_conf.output_filename != "") { m_outfile.open(m_conf.output_filename); - } - else { + } else { TLOG() << "Output filename is null, so not opening an output file"; } } - void TASetSink::do_work() { @@ -93,7 +89,7 @@ TASetSink::do_work() } TASet taset = *taset_opt; - + ++n_taset_received; if (m_outfile.is_open()) { for (auto const& ta : taset.objects) { @@ -132,7 +128,7 @@ TASetSink::do_work() } // end if(m_conf.do_checks) last_seqno = taset.seqno; - + if (first_timestamp == 0) { first_timestamp = taset.start_time; } diff --git a/test/plugins/TASetSink.hpp b/test/plugins/TASetSink.hpp index 4636055e..90a85813 100644 --- a/test/plugins/TASetSink.hpp +++ b/test/plugins/TASetSink.hpp @@ -55,7 +55,7 @@ class TASetSink : public dunedaq::appfwk::DAQModule std::atomic m_running_flag{ false }; std::thread m_thread; std::ofstream m_outfile; - + tasetsink::Conf m_conf; // Queue sources and sinks using source_t = iomanager::ReceiverConcept; diff --git a/test/plugins/TPSetSink.cpp b/test/plugins/TPSetSink.cpp index 69c43bf5..88d2210f 100644 --- a/test/plugins/TPSetSink.cpp +++ b/test/plugins/TPSetSink.cpp @@ -27,16 +27,14 @@ TPSetSink::TPSetSink(const std::string& name) register_command("stop", &TPSetSink::do_stop); } -void -TPSetSink::init(std::shared_ptr) -{}; +void TPSetSink::init(std::shared_ptr){}; -//void -//TPSetSink::init(const CommandData_t& obj) +// void +// TPSetSink::init(const CommandData_t& obj) //{ -// // TODO Reimplement as OKS -// // m_tpset_source = get_iom_receiver(appfwk::connection_uid(obj, "tpset_source")); -//} +// // TODO Reimplement as OKS +// // m_tpset_source = get_iom_receiver(appfwk::connection_uid(obj, "tpset_source")); +// } void TPSetSink::do_start(const CommandData_t& /*obj*/) diff --git a/unittest/AlgorithmPlugins_test.cxx b/unittest/AlgorithmPlugins_test.cxx index 0eff4e47..394aebcf 100644 --- a/unittest/AlgorithmPlugins_test.cxx +++ b/unittest/AlgorithmPlugins_test.cxx @@ -10,7 +10,7 @@ /** * @brief Name of this test module */ -#define BOOST_TEST_MODULE AlgorithmPlugins_test //NOLINT +#define BOOST_TEST_MODULE AlgorithmPlugins_test // NOLINT #include "boost/test/unit_test.hpp" @@ -21,10 +21,14 @@ BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE); BOOST_AUTO_TEST_CASE(TAFactory) { // Get a few algorithms - std::unique_ptr prescale_maker = trigger::make_ta_maker("TAMakerPrescaleAlgorithm"); - std::unique_ptr h_muon_maker = trigger::make_ta_maker("TAMakerHorizontalMuonAlgorithm"); - std::unique_ptr dbscan_maker = trigger::make_ta_maker("TriggerActivityMakerDBSCANPlugin"); - std::unique_ptr fake_maker = trigger::make_ta_maker("TriggerActivityMakerFakerPlugin"); + std::unique_ptr prescale_maker = + trigger::make_ta_maker("TAMakerPrescaleAlgorithm"); + std::unique_ptr h_muon_maker = + trigger::make_ta_maker("TAMakerHorizontalMuonAlgorithm"); + std::unique_ptr dbscan_maker = + trigger::make_ta_maker("TriggerActivityMakerDBSCANPlugin"); + std::unique_ptr fake_maker = + trigger::make_ta_maker("TriggerActivityMakerFakerPlugin"); // Only the fake_maker should be nullptr BOOST_TEST(static_cast(prescale_maker != nullptr)); @@ -41,11 +45,11 @@ BOOST_AUTO_TEST_CASE(TAFactory) for (int idx = 0; idx < 10; idx++) { tp.time_start = idx; - tp.samples_to_peak = 1+idx; + tp.samples_to_peak = 1 + idx; tp.samples_over_threshold = 2; - tp.adc_integral = 1000+idx; - tp.adc_peak = 1000+idx; - tp.channel = 0+idx; + tp.adc_integral = 1000 + idx; + tp.adc_peak = 1000 + idx; + tp.channel = 0 + idx; tp.detid = 0; (*prescale_maker)(tp, prescale_ta); (*h_muon_maker)(tp, h_muon_ta); diff --git a/unittest/TokenManager_test.cxx b/unittest/TokenManager_test.cxx index f85f1376..1a0eabfb 100644 --- a/unittest/TokenManager_test.cxx +++ b/unittest/TokenManager_test.cxx @@ -43,10 +43,7 @@ struct IOManagerTestFixture dunedaq::iomanager::Connection{ cid, "inproc://foo", dunedaq::iomanager::ConnectionType::kSendRecv }); get_iomanager()->configure({}, connections, false, 0ms); // Not using ConfigClient } - ~IOManagerTestFixture() - { - get_iomanager()->reset(); - } + ~IOManagerTestFixture() { get_iomanager()->reset(); } IOManagerTestFixture(IOManagerTestFixture const&) = default; IOManagerTestFixture(IOManagerTestFixture&&) = default; diff --git a/unittest/TriggerObjectOverlay_test.cxx b/unittest/TriggerObjectOverlay_test.cxx index 67c649c4..37d91261 100644 --- a/unittest/TriggerObjectOverlay_test.cxx +++ b/unittest/TriggerObjectOverlay_test.cxx @@ -8,8 +8,8 @@ #include "triggeralgs/TriggerActivity.hpp" #include "triggeralgs/TriggerCandidate.hpp" -#include "triggeralgs/TriggerPrimitive.hpp" #include "triggeralgs/TriggerObjectOverlay.hpp" +#include "triggeralgs/TriggerPrimitive.hpp" /** * @brief Name of this test module @@ -35,7 +35,8 @@ BOOST_TEST_DONT_PRINT_LOG_VALUE(TriggerCandidateData::Type) BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE) -BOOST_AUTO_TEST_CASE(TriggerCandidateOverlay_in_out) { +BOOST_AUTO_TEST_CASE(TriggerCandidateOverlay_in_out) +{ triggeralgs::TriggerCandidate candidate; candidate.time_start = 5; candidate.time_end = 6; @@ -44,25 +45,23 @@ BOOST_AUTO_TEST_CASE(TriggerCandidateOverlay_in_out) { candidate.type = TriggerCandidateData::Type::kSupernova; candidate.algorithm = TriggerCandidateData::Algorithm::kPrescale; - const size_t n_activity = 5; - - for(size_t i=0; i(buffer); - BOOST_CHECK_EQUAL(candidate.time_start, candidate_overlay.data.time_start); - - triggeralgs::TriggerCandidate candidate_read = triggeralgs::read_overlay_from_buffer(buffer); + BOOST_CHECK_EQUAL(candidate.time_start, candidate_overlay.data.time_start); - BOOST_CHECK_EQUAL(candidate.time_start, candidate_read.time_start); - BOOST_CHECK_EQUAL(candidate.time_end, candidate_read.time_end); + triggeralgs::TriggerCandidate candidate_read = + triggeralgs::read_overlay_from_buffer(buffer); + + BOOST_CHECK_EQUAL(candidate.time_start, candidate_read.time_start); + BOOST_CHECK_EQUAL(candidate.time_end, candidate_read.time_end); BOOST_CHECK_EQUAL(candidate.time_candidate, candidate_read.time_candidate); - BOOST_CHECK_EQUAL(candidate.detid, candidate_read.detid); - BOOST_CHECK_EQUAL(candidate.type, candidate_read.type); - BOOST_CHECK_EQUAL(candidate.algorithm, candidate_read.algorithm); - BOOST_CHECK_EQUAL(candidate.version, candidate_read.version); - - for(size_t i=0; i(buffer); - - BOOST_CHECK_EQUAL(activity.time_start, activity_read.time_start); - BOOST_CHECK_EQUAL(activity.time_end, activity_read.time_end); - BOOST_CHECK_EQUAL(activity.time_peak, activity_read.time_peak); - BOOST_CHECK_EQUAL(activity.time_activity, activity_read.time_activity); - BOOST_CHECK_EQUAL(activity.channel_start, activity_read.channel_start); - BOOST_CHECK_EQUAL(activity.channel_end, activity_read.channel_end); - BOOST_CHECK_EQUAL(activity.channel_peak, activity_read.channel_peak); - BOOST_CHECK_EQUAL(activity.adc_integral, activity_read.adc_integral); - BOOST_CHECK_EQUAL(activity.adc_peak, activity_read.adc_peak); - BOOST_CHECK_EQUAL(activity.detid, activity_read.detid); - BOOST_CHECK_EQUAL(activity.type, activity_read.type); - BOOST_CHECK_EQUAL(activity.algorithm, activity_read.algorithm); - BOOST_CHECK_EQUAL(activity.version, activity_read.version); - - for(size_t i=0; i(buffer); + + BOOST_CHECK_EQUAL(activity.time_start, activity_read.time_start); + BOOST_CHECK_EQUAL(activity.time_end, activity_read.time_end); + BOOST_CHECK_EQUAL(activity.time_peak, activity_read.time_peak); + BOOST_CHECK_EQUAL(activity.time_activity, activity_read.time_activity); + BOOST_CHECK_EQUAL(activity.channel_start, activity_read.channel_start); + BOOST_CHECK_EQUAL(activity.channel_end, activity_read.channel_end); + BOOST_CHECK_EQUAL(activity.channel_peak, activity_read.channel_peak); + BOOST_CHECK_EQUAL(activity.adc_integral, activity_read.adc_integral); + BOOST_CHECK_EQUAL(activity.adc_peak, activity_read.adc_peak); + BOOST_CHECK_EQUAL(activity.detid, activity_read.detid); + BOOST_CHECK_EQUAL(activity.type, activity_read.type); + BOOST_CHECK_EQUAL(activity.algorithm, activity_read.algorithm); + BOOST_CHECK_EQUAL(activity.version, activity_read.version); + + for (size_t i = 0; i < n_primitive; ++i) { + BOOST_CHECK_EQUAL(activity.inputs[i].time_start, activity_read.inputs[i].time_start); BOOST_CHECK_EQUAL(activity.inputs[i].samples_over_threshold, activity_read.inputs[i].samples_over_threshold); - BOOST_CHECK_EQUAL(activity.inputs[i].samples_to_peak, activity_read.inputs[i].samples_to_peak); - BOOST_CHECK_EQUAL(activity.inputs[i].channel, activity_read.inputs[i].channel); - BOOST_CHECK_EQUAL(activity.inputs[i].adc_integral, activity_read.inputs[i].adc_integral); - BOOST_CHECK_EQUAL(activity.inputs[i].adc_peak, activity_read.inputs[i].adc_peak); - BOOST_CHECK_EQUAL(activity.inputs[i].detid, activity_read.inputs[i].detid); - BOOST_CHECK_EQUAL(activity.inputs[i].type, activity_read.inputs[i].type); - BOOST_CHECK_EQUAL(activity.inputs[i].algorithm, activity_read.inputs[i].algorithm); - BOOST_CHECK_EQUAL(activity.inputs[i].version, activity_read.inputs[i].version); - BOOST_CHECK_EQUAL(activity.inputs[i].flag, activity_read.inputs[i].flag); + BOOST_CHECK_EQUAL(activity.inputs[i].samples_to_peak, activity_read.inputs[i].samples_to_peak); + BOOST_CHECK_EQUAL(activity.inputs[i].channel, activity_read.inputs[i].channel); + BOOST_CHECK_EQUAL(activity.inputs[i].adc_integral, activity_read.inputs[i].adc_integral); + BOOST_CHECK_EQUAL(activity.inputs[i].adc_peak, activity_read.inputs[i].adc_peak); + BOOST_CHECK_EQUAL(activity.inputs[i].detid, activity_read.inputs[i].detid); + BOOST_CHECK_EQUAL(activity.inputs[i].type, activity_read.inputs[i].type); + BOOST_CHECK_EQUAL(activity.inputs[i].algorithm, activity_read.inputs[i].algorithm); + BOOST_CHECK_EQUAL(activity.inputs[i].version, activity_read.inputs[i].version); + BOOST_CHECK_EQUAL(activity.inputs[i].flag, activity_read.inputs[i].flag); } delete[] buffer; diff --git a/unittest/TriggerTypeAdapters_test.cxx b/unittest/TriggerTypeAdapters_test.cxx index 1b43aab4..12f377ad 100644 --- a/unittest/TriggerTypeAdapters_test.cxx +++ b/unittest/TriggerTypeAdapters_test.cxx @@ -10,12 +10,12 @@ #define BOOST_TEST_MODULE TriggerTypeAdapters_test // NOLINT -#include "trigger/TriggerPrimitiveTypeAdapter.hpp" #include "trigger/TAWrapper.hpp" #include "trigger/TCWrapper.hpp" +#include "trigger/TriggerPrimitiveTypeAdapter.hpp" -#include "datahandlinglibs/testutils/TestUtilities.hpp" #include "datahandlinglibs/models/SkipListLatencyBufferModel.hpp" +#include "datahandlinglibs/testutils/TestUtilities.hpp" #include "boost/test/unit_test.hpp" @@ -23,42 +23,34 @@ BOOST_AUTO_TEST_SUITE(TriggerTypeAdapters_test) BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TriggerPrimitiveTypeAdapter_TestQueue) { - dunedaq::datahandlinglibs::test::test_queue_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TriggerPrimitiveTypeAdapter>(); + dunedaq::datahandlinglibs::test::test_queue_model(); } BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TriggerPrimitiveTypeAdapter_TestRequest) { - dunedaq::datahandlinglibs::test::test_request_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TriggerPrimitiveTypeAdapter>(); + dunedaq::datahandlinglibs::test::test_request_model(); } BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TAWrapper_TestQueue) { - dunedaq::datahandlinglibs::test::test_queue_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TAWrapper>(); + dunedaq::datahandlinglibs::test::test_queue_model(); } BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TAWrapper_TestRequest) { - dunedaq::datahandlinglibs::test::test_request_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TAWrapper>(); + dunedaq::datahandlinglibs::test::test_request_model(); } BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TCWrapper_TestQueue) { - dunedaq::datahandlinglibs::test::test_queue_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TCWrapper>(); + dunedaq::datahandlinglibs::test::test_queue_model(); } BOOST_AUTO_TEST_CASE(SkipListLatencyBufferModel_TCWrapper_TestRequest) { - dunedaq::datahandlinglibs::test::test_request_model< - dunedaq::datahandlinglibs::SkipListLatencyBufferModel, - dunedaq::trigger::TCWrapper>(); + dunedaq::datahandlinglibs::test::test_request_model(); } BOOST_AUTO_TEST_SUITE_END() - -