From 3204764d697ba21a5ed294d919e7f0e0f5510d80 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Tue, 20 Feb 2024 13:58:08 -0600 Subject: [PATCH 01/22] Syncing .github/workflows/dunedaq-v4-cpp-ci.yml --- ...velop-cpp-ci.yml => dunedaq-v4-cpp-ci.yml} | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) rename .github/workflows/{dunedaq-develop-cpp-ci.yml => dunedaq-v4-cpp-ci.yml} (57%) diff --git a/.github/workflows/dunedaq-develop-cpp-ci.yml b/.github/workflows/dunedaq-v4-cpp-ci.yml similarity index 57% rename from .github/workflows/dunedaq-develop-cpp-ci.yml rename to .github/workflows/dunedaq-v4-cpp-ci.yml index cb376c0..88e0679 100644 --- a/.github/workflows/dunedaq-develop-cpp-ci.yml +++ b/.github/workflows/dunedaq-v4-cpp-ci.yml @@ -20,17 +20,15 @@ on: jobs: - Spack_Build_against_dev_release: - name: spack_build_against_dev_on_${{ matrix.os_name }} + Build_against_dev_release: + name: build_against_dev_on_${{ matrix.os_name }} # The type of runner that the job will run on runs-on: ubuntu-latest strategy: matrix: include: - - image: "ghcr.io/dune-daq/sl7-slim-externals:spack-dev" - os_name: "c7" - - image: "ghcr.io/dune-daq/c8-slim-externals:spack-dev" - os_name: "c8" + - image: "ghcr.io/dune-daq/nightly-release-alma9:production_v4" + os_name: "a9" container: image: ${{ matrix.image }} defaults: @@ -49,42 +47,42 @@ jobs: - name: setup dev area run: | + export REPO=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh - setup_dbt latest|| true - dbt-create -n last_successful dev-${{ matrix.os_name }} - + setup_dbt latest || true + release_name="last_fddaq" + + dbt-create -n $release_name dev-${{ matrix.os_name }} + - name: checkout package for CI uses: actions/checkout@v3 with: path: ${{ github.repository }} - name: setup build env, build the repo against the development release - #- name: setup build env, build and lint the repo against the development release run: | export REPO=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') cd $GITHUB_WORKSPACE/dev-${{ matrix.os_name }} source env.sh || true - spack unload $REPO + + spack unload $REPO || true cp -pr $GITHUB_WORKSPACE/DUNE-DAQ/$REPO $GITHUB_WORKSPACE/dev-${{ matrix.os_name }}/sourcecode - dbt-build - #[[ $REPO == "daq-cmake" ]] && dbt-build || dbt-build --lint - dbt-workarea-env - #dbt-build --unittest + dbt-build # --unittest # --lint - name: upload build log file uses: actions/upload-artifact@v3 with: - name: spack_build_log_${{ matrix.os_name }} + name: build_log_${{ matrix.os_name }} path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/build*.log - #- name: upload linter output file - #uses: actions/upload-artifact@v3 - #with: - #name: spack_linting_log_${{ matrix.os_name }} - #path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/linting* + # - name: upload linter output file + # uses: actions/upload-artifact@v3 + # with: + # name: linting_log_${{ matrix.os_name }} + # path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/linting* - #- name: upload unittest output file - #uses: actions/upload-artifact@v2 - #with: - #name: spack_unit_tests_log_${{ matrix.os_name }} - #path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/unit_tests* + # - name: upload unittest output file + # uses: actions/upload-artifact@v3 + # with: + # name: unit_tests_log_${{ matrix.os_name }} + # path: ${{ github.workspace }}/dev-${{ matrix.os_name }}/log/unit_tests* From fa8d217e7fc37ebcf33f2b79594ec720ac481f34 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Wed, 13 Mar 2024 12:19:24 +0100 Subject: [PATCH 02/22] Remove ERS info for a simple TLOG() --- plugins/CTBModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 8431a34..2d2ce78 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -603,7 +603,7 @@ bool CTBModule::send_message( const std::string & msg ) { ers::warning(CTBMessage(ERS_HERE, messages[i]["message"].dump())); } else if ( type.find("info") != std::string::npos || type.find("Info") != std::string::npos || type.find("INFO") != std::string::npos) { - ers::info(CTBMessage(ERS_HERE, messages[i]["message"].dump())); + TLOG() << "Message from the board: " << messages[i]["message"].dump(); } else { std::stringstream blob; From 955e78b3e7153cb820533d5e0dd97f01ef365132 Mon Sep 17 00:00:00 2001 From: jsensenig Date: Thu, 21 Mar 2024 03:15:35 +0100 Subject: [PATCH 03/22] Add monitoring variables and schema for HLT and LLTs --- plugins/CTBModule.cpp | 67 ++++++++++++++++++++-- plugins/CTBModule.hpp | 11 +++- schema/ctbmodules/ctbmoduleinfo.jsonnet | 74 +++++++++++++++++-------- 3 files changed, 125 insertions(+), 27 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 2d2ce78..d5118e2 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -34,8 +34,11 @@ CTBModule::CTBModule(const std::string& name) : hsilibs::HSIEventSender(name) , m_is_running(false) , m_is_configured(false) - , m_n_TS_words(0) , m_error_state(false) + , m_total_hlt_counter(0) + , m_ts_word_counter(0) + , m_hlt_trigger_counter(m_hlt_range) + , m_llt_trigger_counter(m_llt_range) , m_control_ios() , m_receiver_ios() , m_control_socket(m_control_ios) @@ -247,7 +250,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) //check if it is a TS word and increment the counter if ( IsTSWord( temp_word ) ) { - m_n_TS_words++ ; + ++m_ts_word_counter; TLOG_DEBUG(9) << "Received timestamp word! TS: "+temp_word.timestamp; prev_timestamp = temp_word.timestamp; } @@ -300,6 +303,12 @@ CTBModule::do_hsi_work(std::atomic& running_flag) // TODO properly fill device id dfmessages::HSIEvent event = dfmessages::HSIEvent(0x1, hlt_word->trigger_word, hlt_word->timestamp, m_run_HLT_counter, m_run_number); send_hsi_event(event); + + // Count the total HLTs and each specific one + ++m_total_hlt_counter; + for(size_t i = 0; i < m_hlt_range; i++) { + if( (hlt_word->trigger_word >> i) & 0x1 ) ++m_hlt_trigger_counter[i]; + } } else if (temp_word.word_type == content::word::t_lt) { @@ -336,6 +345,10 @@ CTBModule::do_hsi_work(std::atomic& running_flag) // store the previous 2 LLTs so we can match to the HLT prev_prev_llt = prev_llt; prev_llt = { llt_word->timestamp, (llt_word->trigger_word & 0xFFFFFFFF) }; + + for(size_t i = 0; i < m_llt_range; i++) { + if( (llt_word->trigger_word >> i) & 0x1 ) ++m_llt_trigger_counter[i]; + } } else if (temp_word.word_type == content::word::t_ch) { @@ -654,14 +667,60 @@ void CTBModule::get_info(opmonlib::InfoCollector& ci, int /*level*/) module_info.num_control_responses_received = m_num_control_responses_received.load(); module_info.ctb_hardware_run_status = m_is_running; module_info.ctb_hardware_configuration_status = m_is_configured; - module_info.num_ts_words_received = m_n_TS_words; module_info.last_readout_timestamp = m_last_readout_hlt_timestamp.load(); - module_info.sent_hsi_events_counter = m_sent_counter.load(); module_info.failed_to_send_hsi_events_counter = m_failed_to_send_counter.load(); module_info.last_sent_timestamp = m_last_sent_timestamp.load(); module_info.average_buffer_occupancy = read_average_buffer_counts(); + module_info.total_hlt_count = m_total_hlt_counter.load(); + module_info.ts_word_count = m_ts_word_counter.load(); + + // 15 HLTs + module_info.hlt_0_count = m_hlt_trigger_counter[0].load(); + module_info.hlt_1_count = m_hlt_trigger_counter[1].load(); + module_info.hlt_2_count = m_hlt_trigger_counter[2].load(); + module_info.hlt_3_count = m_hlt_trigger_counter[3].load(); + module_info.hlt_4_count = m_hlt_trigger_counter[4].load(); + module_info.hlt_5_count = m_hlt_trigger_counter[5].load(); + module_info.hlt_6_count = m_hlt_trigger_counter[6].load(); + module_info.hlt_7_count = m_hlt_trigger_counter[7].load(); + module_info.hlt_8_count = m_hlt_trigger_counter[8].load(); + module_info.hlt_9_count = m_hlt_trigger_counter[9].load(); + module_info.hlt_10_count = m_hlt_trigger_counter[10].load(); + module_info.hlt_11_count = m_hlt_trigger_counter[11].load(); + module_info.hlt_12_count = m_hlt_trigger_counter[12].load(); + module_info.hlt_13_count = m_hlt_trigger_counter[13].load(); + module_info.hlt_14_count = m_hlt_trigger_counter[14].load(); + + // 20 LLTs + module_info.llt_0_count = m_llt_trigger_counter[0].load(); + module_info.llt_1_count = m_llt_trigger_counter[1].load(); + module_info.llt_2_count = m_llt_trigger_counter[2].load(); + module_info.llt_3_count = m_llt_trigger_counter[3].load(); + module_info.llt_4_count = m_llt_trigger_counter[4].load(); + module_info.llt_5_count = m_llt_trigger_counter[5].load(); + module_info.llt_6_count = m_llt_trigger_counter[6].load(); + module_info.llt_7_count = m_llt_trigger_counter[7].load(); + module_info.llt_8_count = m_llt_trigger_counter[8].load(); + module_info.llt_9_count = m_llt_trigger_counter[9].load(); + module_info.llt_10_count = m_llt_trigger_counter[10].load(); + module_info.llt_11_count = m_llt_trigger_counter[11].load(); + module_info.llt_12_count = m_llt_trigger_counter[12].load(); + module_info.llt_13_count = m_llt_trigger_counter[13].load(); + module_info.llt_14_count = m_llt_trigger_counter[14].load(); + module_info.llt_15_count = m_llt_trigger_counter[15].load(); + module_info.llt_16_count = m_llt_trigger_counter[16].load(); + module_info.llt_17_count = m_llt_trigger_counter[17].load(); + module_info.llt_18_count = m_llt_trigger_counter[18].load(); + module_info.llt_19_count = m_llt_trigger_counter[19].load(); + + // Reset counters + for(auto &hlt : m_hlt_trigger_counter) hlt.exchange(0); + for(auto &llt : m_llt_trigger_counter) llt.exchange(0); + + m_ts_word_counter.exchange(0); + ci.add(module_info); } diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index 23989c6..6937282 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,7 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender private: - // control variables + // control and monitoring variables std::atomic m_is_running; std::atomic m_is_configured; @@ -77,6 +78,14 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender std::atomic m_n_TS_words; std::atomic m_error_state; + std::atomic m_total_hlt_counter; + std::atomic m_ts_word_counter; + + size_t m_hlt_range = 15; + size_t m_llt_range = 20; + std::vector> m_hlt_trigger_counter; + std::vector> m_llt_trigger_counter; + boost::asio::io_service m_control_ios; boost::asio::io_service m_receiver_ios; boost::asio::ip::tcp::socket m_control_socket; diff --git a/schema/ctbmodules/ctbmoduleinfo.jsonnet b/schema/ctbmodules/ctbmoduleinfo.jsonnet index f6a38fa..ce3531d 100644 --- a/schema/ctbmodules/ctbmoduleinfo.jsonnet +++ b/schema/ctbmodules/ctbmoduleinfo.jsonnet @@ -6,30 +6,60 @@ local moo = import "moo.jsonnet"; local s = moo.oschema.schema("dunedaq.ctbmodules.ctbmoduleinfo"); local info = { - uint8 : s.number("uint8", "u8", - doc="An unsigned of 8 bytes"), - float8 : s.number("float8", "f8", - doc="A float of 8 bytes"), + uint8 : s.number("uint8", "u8", doc="An unsigned of 8 bytes"), + float8 : s.number("float8", "f8", doc="A float of 8 bytes"), choice : s.boolean("Choice"), - string : s.string("String", moo.re.ident, - doc="A string field"), - double_val: s.number("DoubleValue", "f8", - doc="A double"), + string : s.string("String", moo.re.ident, doc="A string field"), + double_val: s.number("DoubleValue", "f8", doc="A double"), info: s.record("CTBModuleInfo", [ - s.field("num_control_messages_sent", self.uint8, 0, doc="Number of control messages sent to CTB"), - s.field("num_control_responses_received", self.uint8, 0, doc="Number of control message responses received from CTB"), - s.field("ctb_hardware_run_status", self.choice, 0, doc="Run status of CTB hardware itself"), - s.field("ctb_hardware_configuration_status", self.choice, 0, doc="Configuration status of CTB hardware itself"), - s.field("num_ts_words_received", self.uint8, 0, doc="Number of ts words received from CTB"), - - s.field("sent_hsi_events_counter", self.uint8, doc="Number of sent HSIEvents so far"), - s.field("failed_to_send_hsi_events_counter", self.uint8, doc="Number of failed send attempts so far"), - s.field("last_sent_timestamp", self.uint8, doc="Timestamp of the last sent HSIEvent"), - s.field("last_readout_timestamp", self.uint8, doc="Timestamp of the last read HLT word"), - s.field("average_buffer_occupancy", self.double_val, doc="Average (word) occupancy of buffer in CTB firmware."), - - ], doc="Central Trigger Board Module Information"), + s.field("num_control_messages_sent", self.uint8, 0, doc="Number of control messages sent to CTB"), + s.field("num_control_responses_received", self.uint8, 0, doc="Number of control message responses received from CTB"), + s.field("ctb_hardware_run_status", self.choice, 0, doc="Run status of CTB hardware itself"), + s.field("ctb_hardware_configuration_status", self.choice, 0, doc="Configuration status of CTB hardware itself"), + s.field("sent_hsi_events_counter", self.uint8, 0, doc="Number of sent HSIEvents so far"), + s.field("failed_to_send_hsi_events_counter", self.uint8, 0, doc="Number of failed send attempts so far"), + s.field("last_sent_timestamp", self.uint8, 0, doc="Timestamp of the last sent HSIEvent"), + s.field("last_readout_timestamp", self.uint8, 0, doc="Timestamp of the last read HLT word"), + s.field("average_buffer_occupancy", self.double_val, 0, doc="Average (word) occupancy of buffer in CTB firmware."), + s.field("total_hlt_count", self.uint8, 0, doc="Total HLT count for a run."), + s.field("ts_word_count", self.uint8, 0, doc="Timestamp word count. Fixed frequency heartbeat."), + s.field("hlt_0_count", self.uint8, 0, doc="Random hardware trigger."), + s.field("hlt_1_count", self.uint8, 0, doc="Beam particle trigger."), + s.field("hlt_2_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP1 and LP1. (1-2GeV electrons)"), + s.field("hlt_3_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP0 and LP1. (3-5GeV pions)"), + s.field("hlt_4_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP1 and LP0."), + s.field("hlt_5_count", self.uint8, 0, doc="CRT trigger - any US and DS coincidence within 240 ns. Only enabled outside the beam spill."), + s.field("hlt_6_count", self.uint8, 0, doc="CRT trigger - any US and DS coincidence within 240 ns. Onbeam and Offbeam"), + s.field("hlt_7_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. Excludes HP1 and LP1. (1-2GeV hadrons)"), + s.field("hlt_8_count", self.uint8, 0, doc="CRT trigger - Jura-side US and DS "), + s.field("hlt_9_count", self.uint8, 0, doc="CRT trigger - Saleve-side US and DS"), + s.field("hlt_10_count", self.uint8, 0, doc="CRT trigger - Jura-side US and Saleve-side DS"), + s.field("hlt_11_count", self.uint8, 0, doc="Spare"), + s.field("hlt_12_count", self.uint8, 0, doc="Spare"), + s.field("hlt_13_count", self.uint8, 0, doc="Spare"), + s.field("hlt_14_count", self.uint8, 0, doc="Spare"), + s.field("llt_0_count", self.uint8, 0, doc="Random LLT"), + s.field("llt_1_count", self.uint8, 0, doc="Beam particle trigger."), + s.field("llt_2_count", self.uint8, 0, doc="High Pressure Cherenkov (C713)"), + s.field("llt_3_count", self.uint8, 0, doc="Low Pressure Cherenkov (C716)"), + s.field("llt_4_count", self.uint8, 0, doc="Spare"), + s.field("llt_5_count", self.uint8, 0, doc="Spare"), + s.field("llt_6_count", self.uint8, 0, doc="Beam gate"), + s.field("llt_7_count", self.uint8, 0, doc="Spare"), + s.field("llt_8_count", self.uint8, 0, doc="Spare"), + s.field("llt_9_count", self.uint8, 0, doc="Spare"), + s.field("llt_10_count", self.uint8, 0, doc="CRT pixels around beam pipe."), + s.field("llt_11_count", self.uint8, 0, doc="Spare"), + s.field("llt_12_count", self.uint8, 0, doc="Any CRT pixel on US Saleve side"), + s.field("llt_13_count", self.uint8, 0, doc="Any CRT pixel on DS Saleve side"), + s.field("llt_14_count", self.uint8, 0, doc="Spare"), + s.field("llt_15_count", self.uint8, 0, doc="Any upstream CRT pixel"), + s.field("llt_16_count", self.uint8, 0, doc="Any downstream CRT pixel"), + s.field("llt_17_count", self.uint8, 0, doc="Spare"), + s.field("llt_18_count", self.uint8, 0, doc="Any CRT on US Jura side"), + s.field("llt_19_count", self.uint8, 0, doc="Any CRT on DS Jura side") + ], doc="Central Trigger Board Module Information") }; -moo.oschema.sort_select(info) \ No newline at end of file +moo.oschema.sort_select(info) From fab52b393e76299e03ab52221f1a096f02d146fc Mon Sep 17 00:00:00 2001 From: jsensenig Date: Thu, 21 Mar 2024 04:40:54 +0100 Subject: [PATCH 04/22] Potential fix for stop run socket error. --- plugins/CTBModule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 2d2ce78..df0dd06 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -354,6 +354,8 @@ CTBModule::do_hsi_work(std::atomic& running_flag) prev_channel = { ((prev_timestamp & 0xF000000000000000) | ch_stat_word->timestamp), ((ch_stat_pds << 48) | (ch_stat_crt << 16) | ch_stat_beam) }; } + if (!running_flag.load()) break; + } // n_words loop if ( connection_closed ){ From 93e2fc9c039a6bc1ec70b74e352afb4ec89b04b4 Mon Sep 17 00:00:00 2001 From: jsensenig Date: Thu, 21 Mar 2024 13:21:53 +0100 Subject: [PATCH 05/22] Add do_config initialization for monitoring counters. --- plugins/CTBModule.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index d5118e2..564aa5f 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -93,6 +93,9 @@ CTBModule::do_configure(const data_t& args) // Initialise monitoring variables m_num_control_messages_sent = 0; m_num_control_responses_received = 0; + m_ts_word_counter.exchange = 0; + for(auto &hlt : m_hlt_trigger_counter) hlt = 0; + for(auto &llt : m_llt_trigger_counter) llt = 0; // network connection to ctb hardware control boost::asio::ip::tcp::resolver resolver( m_control_ios ); From f07ca67c9deb7c0df6d770d711afb98b811b9558 Mon Sep 17 00:00:00 2001 From: jsensenig Date: Thu, 21 Mar 2024 13:32:25 +0100 Subject: [PATCH 06/22] Remove leftover .exchange() --- plugins/CTBModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 564aa5f..fdafb07 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -93,7 +93,7 @@ CTBModule::do_configure(const data_t& args) // Initialise monitoring variables m_num_control_messages_sent = 0; m_num_control_responses_received = 0; - m_ts_word_counter.exchange = 0; + m_ts_word_counter = 0; for(auto &hlt : m_hlt_trigger_counter) hlt = 0; for(auto &llt : m_llt_trigger_counter) llt = 0; From ad8cfe61d8841bbfacc0126afed4341eb0995757 Mon Sep 17 00:00:00 2001 From: jsensenig Date: Thu, 21 Mar 2024 17:17:41 +0100 Subject: [PATCH 07/22] Switch HLT,LLT to only configured ones and loop counters in do_info --- plugins/CTBModule.cpp | 98 +++++++++++-------------- plugins/CTBModule.hpp | 8 +- schema/ctbmodules/ctbmoduleinfo.jsonnet | 42 ++--------- 3 files changed, 52 insertions(+), 96 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index fdafb07..79139c0 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -37,8 +37,8 @@ CTBModule::CTBModule(const std::string& name) , m_error_state(false) , m_total_hlt_counter(0) , m_ts_word_counter(0) - , m_hlt_trigger_counter(m_hlt_range) - , m_llt_trigger_counter(m_llt_range) + , m_hlt_trigger_counter() + , m_llt_trigger_counter() , m_control_ios() , m_receiver_ios() , m_control_socket(m_control_ios) @@ -94,8 +94,27 @@ CTBModule::do_configure(const data_t& args) m_num_control_messages_sent = 0; m_num_control_responses_received = 0; m_ts_word_counter = 0; - for(auto &hlt : m_hlt_trigger_counter) hlt = 0; - for(auto &llt : m_llt_trigger_counter) llt = 0; + + std::map id_to_idx; + for(size_t i = 0; i < m_hlt_range; i++) id_to_idx["HLT_" + std::to_string(i)] = i; + for(size_t i = 0; i < m_llt_range; i++) id_to_idx["LLT_" + std::to_string(i)] = i; + + nlohmann::json random_triggers = m_cfg.board_config.ctb.misc; + + // HLTs + // 0th HLT is random trigger that's not in HLT array + if (random_triggers["randomtrigger_1"]["enable"]) m_hlt_trigger_counter[0] = 0; + nlohmann::json trigger_array = m_cfg.board_config.ctb.HLT.trigger; + for (const auto& trigger : trigger_array) { if (trigger["enable"]) m_hlt_trigger_counter[id_to_idx[trigger["id"]]] = 0; } + + // LLTs: Beam and CRT + // 0th LLT is random trigger that's not in HLT array + if (random_triggers["randomtrigger_2"]["enable"]) m_llt_trigger_counter[0] = 0; + trigger_array = m_cfg.board_config.ctb.subsystems.crt.triggers; + for (const auto& trigger : trigger_array) { if (trigger["enable"]) m_llt_trigger_counter[id_to_idx[trigger["id"]]] = 0; } + + trigger_array = m_cfg.board_config.ctb.subsystems.beam.triggers; + for (const auto& trigger : trigger_array) { if (trigger["enable"]) m_llt_trigger_counter[id_to_idx[trigger["id"]]] = 0; } // network connection to ctb hardware control boost::asio::ip::tcp::resolver resolver( m_control_ios ); @@ -309,9 +328,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) // Count the total HLTs and each specific one ++m_total_hlt_counter; - for(size_t i = 0; i < m_hlt_range; i++) { - if( (hlt_word->trigger_word >> i) & 0x1 ) ++m_hlt_trigger_counter[i]; - } + for (auto &hlt : m_hlt_trigger_counter) { if( (hlt_word->trigger_word >> hlt.first) & 0x1 ) ++hlt.second; } } else if (temp_word.word_type == content::word::t_lt) { @@ -349,9 +366,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) prev_prev_llt = prev_llt; prev_llt = { llt_word->timestamp, (llt_word->trigger_word & 0xFFFFFFFF) }; - for(size_t i = 0; i < m_llt_range; i++) { - if( (llt_word->trigger_word >> i) & 0x1 ) ++m_llt_trigger_counter[i]; - } + for (auto &llt : m_llt_trigger_counter) { if( (llt_word->trigger_word >> llt.first) & 0x1 ) ++llt.second; } } else if (temp_word.word_type == content::word::t_ch) { @@ -677,52 +692,23 @@ void CTBModule::get_info(opmonlib::InfoCollector& ci, int /*level*/) module_info.average_buffer_occupancy = read_average_buffer_counts(); module_info.total_hlt_count = m_total_hlt_counter.load(); - module_info.ts_word_count = m_ts_word_counter.load(); - - // 15 HLTs - module_info.hlt_0_count = m_hlt_trigger_counter[0].load(); - module_info.hlt_1_count = m_hlt_trigger_counter[1].load(); - module_info.hlt_2_count = m_hlt_trigger_counter[2].load(); - module_info.hlt_3_count = m_hlt_trigger_counter[3].load(); - module_info.hlt_4_count = m_hlt_trigger_counter[4].load(); - module_info.hlt_5_count = m_hlt_trigger_counter[5].load(); - module_info.hlt_6_count = m_hlt_trigger_counter[6].load(); - module_info.hlt_7_count = m_hlt_trigger_counter[7].load(); - module_info.hlt_8_count = m_hlt_trigger_counter[8].load(); - module_info.hlt_9_count = m_hlt_trigger_counter[9].load(); - module_info.hlt_10_count = m_hlt_trigger_counter[10].load(); - module_info.hlt_11_count = m_hlt_trigger_counter[11].load(); - module_info.hlt_12_count = m_hlt_trigger_counter[12].load(); - module_info.hlt_13_count = m_hlt_trigger_counter[13].load(); - module_info.hlt_14_count = m_hlt_trigger_counter[14].load(); - - // 20 LLTs - module_info.llt_0_count = m_llt_trigger_counter[0].load(); - module_info.llt_1_count = m_llt_trigger_counter[1].load(); - module_info.llt_2_count = m_llt_trigger_counter[2].load(); - module_info.llt_3_count = m_llt_trigger_counter[3].load(); - module_info.llt_4_count = m_llt_trigger_counter[4].load(); - module_info.llt_5_count = m_llt_trigger_counter[5].load(); - module_info.llt_6_count = m_llt_trigger_counter[6].load(); - module_info.llt_7_count = m_llt_trigger_counter[7].load(); - module_info.llt_8_count = m_llt_trigger_counter[8].load(); - module_info.llt_9_count = m_llt_trigger_counter[9].load(); - module_info.llt_10_count = m_llt_trigger_counter[10].load(); - module_info.llt_11_count = m_llt_trigger_counter[11].load(); - module_info.llt_12_count = m_llt_trigger_counter[12].load(); - module_info.llt_13_count = m_llt_trigger_counter[13].load(); - module_info.llt_14_count = m_llt_trigger_counter[14].load(); - module_info.llt_15_count = m_llt_trigger_counter[15].load(); - module_info.llt_16_count = m_llt_trigger_counter[16].load(); - module_info.llt_17_count = m_llt_trigger_counter[17].load(); - module_info.llt_18_count = m_llt_trigger_counter[18].load(); - module_info.llt_19_count = m_llt_trigger_counter[19].load(); - - // Reset counters - for(auto &hlt : m_hlt_trigger_counter) hlt.exchange(0); - for(auto &llt : m_llt_trigger_counter) llt.exchange(0); - - m_ts_word_counter.exchange(0); + module_info.ts_word_count = m_ts_word_counter.exchange(0); + + for (auto &hlt : m_hlt_trigger_counter) { + opmonlib::InfoCollector tmp_ic; + dunedaq::ctbmodules::ctbmoduleinfo::LevelTriggerInfo ti; + ti.count = hlt.second.exchange(0); + tmp_ic.add(ti); + ci.add("hlt_" + std::to_string(hlt.first), tmp_ic); + } + + for (auto &llt : m_llt_trigger_counter) { + opmonlib::InfoCollector tmp_ic; + dunedaq::ctbmodules::ctbmoduleinfo::LevelTriggerInfo ti; + ti.count = llt.second.exchange(0); + tmp_ic.add(ti); + ci.add("llt_" + std::to_string(llt.first), tmp_ic); + } ci.add(module_info); } diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index 6937282..f79121f 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -81,10 +81,10 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender std::atomic m_total_hlt_counter; std::atomic m_ts_word_counter; - size_t m_hlt_range = 15; - size_t m_llt_range = 20; - std::vector> m_hlt_trigger_counter; - std::vector> m_llt_trigger_counter; + size_t m_hlt_range = 20; + size_t m_llt_range = 25; + std::map> m_hlt_trigger_counter; + std::map> m_llt_trigger_counter; boost::asio::io_service m_control_ios; boost::asio::io_service m_receiver_ios; diff --git a/schema/ctbmodules/ctbmoduleinfo.jsonnet b/schema/ctbmodules/ctbmoduleinfo.jsonnet index ce3531d..ef84f78 100644 --- a/schema/ctbmodules/ctbmoduleinfo.jsonnet +++ b/schema/ctbmodules/ctbmoduleinfo.jsonnet @@ -24,42 +24,12 @@ local info = { s.field("average_buffer_occupancy", self.double_val, 0, doc="Average (word) occupancy of buffer in CTB firmware."), s.field("total_hlt_count", self.uint8, 0, doc="Total HLT count for a run."), s.field("ts_word_count", self.uint8, 0, doc="Timestamp word count. Fixed frequency heartbeat."), - s.field("hlt_0_count", self.uint8, 0, doc="Random hardware trigger."), - s.field("hlt_1_count", self.uint8, 0, doc="Beam particle trigger."), - s.field("hlt_2_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP1 and LP1. (1-2GeV electrons)"), - s.field("hlt_3_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP0 and LP1. (3-5GeV pions)"), - s.field("hlt_4_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. HP1 and LP0."), - s.field("hlt_5_count", self.uint8, 0, doc="CRT trigger - any US and DS coincidence within 240 ns. Only enabled outside the beam spill."), - s.field("hlt_6_count", self.uint8, 0, doc="CRT trigger - any US and DS coincidence within 240 ns. Onbeam and Offbeam"), - s.field("hlt_7_count", self.uint8, 0, doc="Beam particle trigger with Cherenkov based particle selection. Excludes HP1 and LP1. (1-2GeV hadrons)"), - s.field("hlt_8_count", self.uint8, 0, doc="CRT trigger - Jura-side US and DS "), - s.field("hlt_9_count", self.uint8, 0, doc="CRT trigger - Saleve-side US and DS"), - s.field("hlt_10_count", self.uint8, 0, doc="CRT trigger - Jura-side US and Saleve-side DS"), - s.field("hlt_11_count", self.uint8, 0, doc="Spare"), - s.field("hlt_12_count", self.uint8, 0, doc="Spare"), - s.field("hlt_13_count", self.uint8, 0, doc="Spare"), - s.field("hlt_14_count", self.uint8, 0, doc="Spare"), - s.field("llt_0_count", self.uint8, 0, doc="Random LLT"), - s.field("llt_1_count", self.uint8, 0, doc="Beam particle trigger."), - s.field("llt_2_count", self.uint8, 0, doc="High Pressure Cherenkov (C713)"), - s.field("llt_3_count", self.uint8, 0, doc="Low Pressure Cherenkov (C716)"), - s.field("llt_4_count", self.uint8, 0, doc="Spare"), - s.field("llt_5_count", self.uint8, 0, doc="Spare"), - s.field("llt_6_count", self.uint8, 0, doc="Beam gate"), - s.field("llt_7_count", self.uint8, 0, doc="Spare"), - s.field("llt_8_count", self.uint8, 0, doc="Spare"), - s.field("llt_9_count", self.uint8, 0, doc="Spare"), - s.field("llt_10_count", self.uint8, 0, doc="CRT pixels around beam pipe."), - s.field("llt_11_count", self.uint8, 0, doc="Spare"), - s.field("llt_12_count", self.uint8, 0, doc="Any CRT pixel on US Saleve side"), - s.field("llt_13_count", self.uint8, 0, doc="Any CRT pixel on DS Saleve side"), - s.field("llt_14_count", self.uint8, 0, doc="Spare"), - s.field("llt_15_count", self.uint8, 0, doc="Any upstream CRT pixel"), - s.field("llt_16_count", self.uint8, 0, doc="Any downstream CRT pixel"), - s.field("llt_17_count", self.uint8, 0, doc="Spare"), - s.field("llt_18_count", self.uint8, 0, doc="Any CRT on US Jura side"), - s.field("llt_19_count", self.uint8, 0, doc="Any CRT on DS Jura side") - ], doc="Central Trigger Board Module Information") + ], doc="Central Trigger Board Module Information"), + + trigger: s.record("LevelTriggerInfo", [ + s.field("count", self.uint8, 0, doc="Count for a single level trigger"), + ], doc="Level Trigger information") + }; moo.oschema.sort_select(info) From 78924b9539fb77de81e91e79a6ca1d30a80c53bc Mon Sep 17 00:00:00 2001 From: jsensenig Date: Tue, 26 Mar 2024 01:41:46 +0100 Subject: [PATCH 08/22] Resolve issue with socket error at end of run --- plugins/CTBModule.cpp | 28 +++++++++++++++++++++------- plugins/CTBModule.hpp | 1 + 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 8cda395..7fe845c 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -33,6 +33,7 @@ namespace ctbmodules { CTBModule::CTBModule(const std::string& name) : hsilibs::HSIEventSender(name) , m_is_running(false) + , m_stop_requested(false) , m_is_configured(false) , m_error_state(false) , m_total_hlt_counter(0) @@ -153,6 +154,9 @@ CTBModule::do_start(const nlohmann::json& startobj) TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering do_start() method"; + // Set this to false early so it doesn't interfere with the start + m_stop_requested.store(false); + auto start_params = startobj.get(); m_run_number.store(start_params.run); @@ -165,8 +169,6 @@ CTBModule::do_start(const nlohmann::json& startobj) SetCalibrationStream(run.str()) ; } - - if ( send_message( "{\"command\":\"StartRun\"}" ) ) { m_is_running.store(true); TLOG_DEBUG(1) << get_name() << ": successfully started"; @@ -185,10 +187,14 @@ CTBModule::do_stop(const nlohmann::json& /*stopobj*/) TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering do_stop() method"; TLOG_DEBUG(0) << get_name() << ": Sending stop run command" << std::endl; + + // Give the do_work thread a chance to stop before stopping the CTB, + // otherwise we end up reading from an empty buffer + m_stop_requested.store(true); + std::this_thread::sleep_for(std::chrono::milliseconds(2)); if(send_message( "{\"command\":\"StopRun\"}" ) ){ TLOG_DEBUG(1) << get_name() << ": successfully stopped"; - m_is_running.store( false ) ; } else{ @@ -223,7 +229,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) std::future accepting = async( std::launch::async, [&]{ acceptor.accept(m_receiver_socket) ; } ) ; - while ( running_flag.load() ) { + while ( running_flag.load() && !m_stop_requested.load() ) { if ( accepting.wait_for( m_timeout ) == std::future_status::ready ){ break ; } @@ -241,7 +247,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) uint64_t prev_timestamp = 0; std::pair prev_channel, prev_prev_channel, prev_llt, prev_prev_llt; // pair - while (running_flag.load()) { + while (running_flag.load() && !m_stop_requested.load()) { update_calibration_file(); @@ -259,6 +265,11 @@ CTBModule::do_hsi_work(std::atomic& running_flag) update_buffer_counts(n_words); for ( unsigned int i = 0 ; i < n_words ; ++i ) { + + if (!running_flag.load() || m_stop_requested.load()) { + break; + } + //read a word if ( ! read( temp_word ) ) { connection_closed = true ; @@ -385,8 +396,6 @@ CTBModule::do_hsi_work(std::atomic& running_flag) prev_channel = { ((prev_timestamp & 0xF000000000000000) | ch_stat_word->timestamp), ((ch_stat_pds << 48) | (ch_stat_crt << 16) | ch_stat_beam) }; } - if (!running_flag.load()) break; - } // n_words loop if ( connection_closed ){ @@ -394,6 +403,11 @@ CTBModule::do_hsi_work(std::atomic& running_flag) } } + // Make sure CTB run stops before closing socket + while ( m_is_running.load() ) { + std::this_thread::sleep_for(std::chrono::microseconds(100)); + } + boost::system::error_code closing_error; if ( m_error_state.load() ) { diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index f79121f..ef78eb6 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -71,6 +71,7 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender // control and monitoring variables std::atomic m_is_running; + std::atomic m_stop_requested; std::atomic m_is_configured; /*const */unsigned int m_receiver_port; From 2f4cdf5b932cb9f6045ff715eb4eadab57e17b8f Mon Sep 17 00:00:00 2001 From: jsensenig Date: Tue, 26 Mar 2024 13:11:15 +0100 Subject: [PATCH 09/22] Reset total trigger count at run start --- plugins/CTBModule.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 7fe845c..1538f6a 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -160,6 +160,8 @@ CTBModule::do_start(const nlohmann::json& startobj) auto start_params = startobj.get(); m_run_number.store(start_params.run); + m_total_hlt_counter.store(0); + TLOG_DEBUG(0) << get_name() << ": Sending start of run command"; m_thread_.start_working_thread(); From 5b088d9d6ed6d00aa8b333d6acd2adc446d521b8 Mon Sep 17 00:00:00 2001 From: Stoyan Trilov Date: Tue, 26 Mar 2024 13:53:33 +0100 Subject: [PATCH 10/22] update hsievents connections for individual tc makers --- python/ctbmodules/apps/ctb_hsi_gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ctbmodules/apps/ctb_hsi_gen.py b/python/ctbmodules/apps/ctb_hsi_gen.py index bcc8012..b660dbe 100644 --- a/python/ctbmodules/apps/ctb_hsi_gen.py +++ b/python/ctbmodules/apps/ctb_hsi_gen.py @@ -157,7 +157,7 @@ def get_ctb_hsi_app( mgraph.add_endpoint(f"timesync_ctb_llt", f"ctb_llt_datahandler.timesync_output", "TimeSync", Direction.OUT, is_pubsub=True, toposort=False) mgraph.add_endpoint(f"timesync_ctb_hlt", f"ctb_hlt_datahandler.timesync_output", "TimeSync", Direction.OUT, is_pubsub=True, toposort=False) - mgraph.add_endpoint("hsievents", f"{nickname}.hsievents", "HSIEvent", Direction.OUT) + mgraph.add_endpoint("ctb_hsievents", f"{nickname}.hsievents", "HSIEvent", Direction.OUT) # dummy subscriber mgraph.add_endpoint(None, None, data_type="TimeSync", inout=Direction.IN, is_pubsub=True) From 84217ceecba5ecdfbc52796f39b6748e80727b63 Mon Sep 17 00:00:00 2001 From: James Shen Date: Thu, 28 Mar 2024 11:22:19 -0700 Subject: [PATCH 11/22] Bump to v2.2.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0910269..ea29250 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.12) -project(ctbmodules VERSION 2.1.0) +project(ctbmodules VERSION 2.2.0) find_package(daq-cmake REQUIRED) From c3b76fddea7522165ed94b5f1ebafd00837aa8f4 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Sat, 13 Apr 2024 17:23:10 -0500 Subject: [PATCH 12/22] Syncing .github/workflows/dunedaq-v4-cpp-ci.yml --- .github/workflows/dunedaq-v4-cpp-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dunedaq-v4-cpp-ci.yml b/.github/workflows/dunedaq-v4-cpp-ci.yml index 88e0679..0e7f823 100644 --- a/.github/workflows/dunedaq-v4-cpp-ci.yml +++ b/.github/workflows/dunedaq-v4-cpp-ci.yml @@ -5,7 +5,7 @@ name: build-develop on: push: branches: - - develop + - production/v4 - patch/* - prep-release/* paths-ignore: From 20612b30717a67d74bcf859c811b29efac6f27b9 Mon Sep 17 00:00:00 2001 From: Andrew Mogan Date: Thu, 25 Apr 2024 09:26:30 -0500 Subject: [PATCH 13/22] Syncing .github/workflows/dunedaq-v4-cpp-ci.yml --- .github/workflows/dunedaq-v4-cpp-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dunedaq-v4-cpp-ci.yml b/.github/workflows/dunedaq-v4-cpp-ci.yml index 0e7f823..7c9cc24 100644 --- a/.github/workflows/dunedaq-v4-cpp-ci.yml +++ b/.github/workflows/dunedaq-v4-cpp-ci.yml @@ -12,9 +12,9 @@ on: - 'docs/**' - '.github/**' pull_request: - branches: [ develop ] + branches: [ production/v4 ] schedule: - - cron: "0 7 * * *" + - cron: "0 9 * * *" workflow_dispatch: From 1269985e672a7cca88dd4831a81c9bbc7943f901 Mon Sep 17 00:00:00 2001 From: Andrew Mogan Date: Thu, 30 May 2024 11:47:57 -0500 Subject: [PATCH 14/22] Syncing .github/workflows/dunedaq-v4-cpp-ci.yml --- .github/workflows/dunedaq-v4-cpp-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dunedaq-v4-cpp-ci.yml b/.github/workflows/dunedaq-v4-cpp-ci.yml index 7c9cc24..cea93d9 100644 --- a/.github/workflows/dunedaq-v4-cpp-ci.yml +++ b/.github/workflows/dunedaq-v4-cpp-ci.yml @@ -49,7 +49,7 @@ jobs: run: | export REPO=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}') source /cvmfs/dunedaq.opensciencegrid.org/setup_dunedaq.sh - setup_dbt latest || true + setup_dbt latest_v4 || true release_name="last_fddaq" dbt-create -n $release_name dev-${{ matrix.os_name }} From 41258e2b30173a2e1e0a384bb3ba4dbb1e86cb44 Mon Sep 17 00:00:00 2001 From: jsensenig Date: Tue, 18 Jun 2024 10:59:39 +0200 Subject: [PATCH 15/22] Update timing endpoint address to 0xF in schema Author: jsensenig --- schema/ctbmodules/ctbmodule.jsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/ctbmodules/ctbmodule.jsonnet b/schema/ctbmodules/ctbmodule.jsonnet index 96794ed..5ab8f14 100644 --- a/schema/ctbmodules/ctbmodule.jsonnet +++ b/schema/ctbmodules/ctbmodule.jsonnet @@ -65,7 +65,7 @@ local ctbmodule = { ], doc="Central Trigger Board Pulser Configuration"), timing: s.record("Timing", [ - s.field("address", self.string, "0xF0"), + s.field("address", self.string, "0xF"), s.field("group", self.string, "0x0"), s.field("triggers", self.boolean, true), s.field("lockout", self.string, "0x10"), From 084105e7d325dcb306dbd3798de4df1fda2b3b61 Mon Sep 17 00:00:00 2001 From: JamesJieranShen Date: Tue, 18 Jun 2024 12:45:23 +0200 Subject: [PATCH 16/22] Guard against LLT matching failures for HLT0 and HLT16 Author: JamesJieranShen --- plugins/CTBModule.cpp | 17 ++++++++++++----- plugins/CTBModule.hpp | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 1538f6a..222578b 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -310,7 +310,8 @@ CTBModule::do_hsi_work(std::atomic& running_flag) m_last_readout_hlt_timestamp = hlt_word->timestamp; // Now find the associated LLT - llt_payload = MatchTriggerInput( hlt_word->timestamp, prev_llt, prev_prev_llt, true ); + // if HLT0, skip matching + llt_payload = MatchTriggerInput( hlt_word, prev_llt, prev_prev_llt, true ); // Send HSI data to a DLH std::array hsi_struct; @@ -350,7 +351,7 @@ CTBModule::do_hsi_work(std::atomic& running_flag) content::word::trigger_t * llt_word = reinterpret_cast( & temp_word ) ; // Find the matching channel status word - channel_payload = MatchTriggerInput( llt_word->timestamp, prev_channel, prev_prev_channel, false ); + channel_payload = MatchTriggerInput( llt_word, prev_channel, prev_prev_channel, false ); // Send HSI data to a DLH std::array hsi_struct; @@ -465,11 +466,13 @@ bool CTBModule::read( T &obj) { return true ; } -uint64_t CTBModule::MatchTriggerInput( const uint64_t trigger_ts, const std::pair &prev_input, const std::pair &prev_prev_input, bool hlt_matching) noexcept { +uint64_t CTBModule::MatchTriggerInput(const content::word::trigger_t * trigger, const std::pair &prev_input, const std::pair &prev_prev_input, bool hlt_matching) noexcept { // The first condition should be true the majority of the time and the "else" should never happen. // Find the matching word whcih caused the LLT or HLT and return its payload - + uint64_t trigger_ts = trigger->timestamp; + uint64_t trigger_word = trigger->trigger_word; + if ( trigger_ts == prev_input.first + 1 ) { return prev_input.second; } @@ -479,7 +482,11 @@ uint64_t CTBModule::MatchTriggerInput( const uint64_t trigger_ts, const std::pai else { std::stringstream msg; if ( hlt_matching ) { - msg << "No LLT match found for HLT TS " << trigger_ts << " (LLT TS prev=" + if (trigger_word == 0x1 || trigger_word == (0x1<<16)) { + // we don't care if fake trigger (HLT0) or the pulse train (HLT 16) have no matching LLTs + return 0; + } + msg << "No LLT m/atch found for HLT TS " << trigger_ts << " (LLT TS prev=" << prev_input.first << " prev_prev=" << prev_prev_input.first << ")"; } else { diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index ef78eb6..45a7498 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -59,7 +59,7 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender void init(const nlohmann::json& iniobj) override; - static uint64_t MatchTriggerInput(const uint64_t trigger_ts, const std::pair &prev_input, const std::pair &prev_prev_input, bool hlt_matching) noexcept; + static uint64_t MatchTriggerInput(const content::word::trigger_t * trigger, const std::pair &prev_input, const std::pair &prev_prev_input, bool hlt_matching) noexcept; static bool IsTSWord( const content::word::word_t &w ) noexcept; static bool IsFeedbackWord( const content::word::word_t &w ) noexcept; bool ErrorState() const { return m_error_state.load() ; } From 65c05391deb9883b2aa96cf154f8a35413b07bbc Mon Sep 17 00:00:00 2001 From: np04daq Date: Tue, 18 Jun 2024 17:17:08 +0200 Subject: [PATCH 17/22] Update version to 2.3.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea29250..4de089d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.12) -project(ctbmodules VERSION 2.2.0) +project(ctbmodules VERSION 2.3.0) find_package(daq-cmake REQUIRED) From 6ace888634e520c596f79af64c6f6738d9344870 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Mon, 1 Jul 2024 11:16:44 +0200 Subject: [PATCH 18/22] Initial work for the CTB module conversion to OKS. It needs a schema first, so for now I'll stop here --- plugins/CTBModule.cpp | 23 ++++++++++++++++++++--- plugins/CTBModule.hpp | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 222578b..0330426 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -10,7 +10,6 @@ #include "CTBModule.hpp" #include "CTBModuleIssues.hpp" -#include "appfwk/DAQModuleHelper.hpp" #include "iomanager/IOManager.hpp" #include "logging/Logging.hpp" #include "rcif/cmd/Nljs.hpp" @@ -69,10 +68,28 @@ CTBModule::~CTBModule(){ } void -CTBModule::init(const nlohmann::json& init_data) +CTBModule::init(std::shared_ptr mcfg) { TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method"; - HSIEventSender::init(init_data); + HSIEventSender::init(mcfg); + + /* + auto mdal = mcfg->module(get_name()); // Only need generic DaqModule for output + + if (!mdal) { + throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object"); + } + + for (auto con : mdal->get_outputs()) { + if (con->get_data_type() == datatype_to_string()) { + + m_raw_hsi_data_sender = get_iom_sender(con->UID()); + } + } + + m_params = mdal->get_configuration(); + */ + m_llt_hsi_data_sender = get_iom_sender(appfwk::connection_uid(init_data, "llt_output")); m_hlt_hsi_data_sender = get_iom_sender(appfwk::connection_uid(init_data, "hlt_output")); diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index 45a7498..cb8ac39 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -57,7 +57,7 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender CTBModule(CTBModule&&) = delete; ///< CTBModule is not move-constructible CTBModule& operator=(CTBModule&&) = delete; ///< CTBModule is not move-assignable - void init(const nlohmann::json& iniobj) override; + void init(std::shared_ptr mcfg) override; static uint64_t MatchTriggerInput(const content::word::trigger_t * trigger, const std::pair &prev_input, const std::pair &prev_prev_input, bool hlt_matching) noexcept; static bool IsTSWord( const content::word::word_t &w ) noexcept; From 3f159877ec570c5e92892debc76f04d2aaa4eab0 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Mon, 1 Jul 2024 16:01:05 +0200 Subject: [PATCH 19/22] Add new verion --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de089d..a1ac4ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.12) -project(ctbmodules VERSION 2.3.0) +project(ctbmodules VERSION 3.0.0) find_package(daq-cmake REQUIRED) From 9f7dcf4700cf57c3beaaf8b93c22b55890a9530f Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Mon, 1 Jul 2024 17:05:25 +0200 Subject: [PATCH 20/22] restore correct workflow --- .../{dunedaq-v4-cpp-ci.yml => dunedaq-develop-cpp-ci.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{dunedaq-v4-cpp-ci.yml => dunedaq-develop-cpp-ci.yml} (98%) diff --git a/.github/workflows/dunedaq-v4-cpp-ci.yml b/.github/workflows/dunedaq-develop-cpp-ci.yml similarity index 98% rename from .github/workflows/dunedaq-v4-cpp-ci.yml rename to .github/workflows/dunedaq-develop-cpp-ci.yml index 70205f5..9de6b5b 100644 --- a/.github/workflows/dunedaq-v4-cpp-ci.yml +++ b/.github/workflows/dunedaq-develop-cpp-ci.yml @@ -5,14 +5,14 @@ name: build-develop on: push: branches: - - production/v4 + - develop - patch/* - prep-release/* paths-ignore: - 'docs/**' - '.github/**' pull_request: - branches: [ production/v4 ] + branches: [ develop ] schedule: - cron: "0 9 * * *" From 58c8b82d91ac41245f8d608305370af9bfce8104 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Mon, 1 Jul 2024 17:11:41 +0200 Subject: [PATCH 21/22] restore correct workflow --- .github/workflows/dunedaq-develop-cpp-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dunedaq-develop-cpp-ci.yml b/.github/workflows/dunedaq-develop-cpp-ci.yml index 9de6b5b..b709cd5 100644 --- a/.github/workflows/dunedaq-develop-cpp-ci.yml +++ b/.github/workflows/dunedaq-develop-cpp-ci.yml @@ -14,7 +14,7 @@ on: pull_request: branches: [ develop ] schedule: - - cron: "0 9 * * *" + - cron: "0 7 * * *" workflow_dispatch: From f4c502036b8afb6756ef3807e67778af21c62a83 Mon Sep 17 00:00:00 2001 From: Marco Roda Date: Tue, 2 Jul 2024 11:59:21 +0200 Subject: [PATCH 22/22] Progress toward a working version of the CTB with OKS --- plugins/CTBModule.cpp | 32 ++++++++++++++++++++------------ plugins/CTBModule.hpp | 5 ++--- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/plugins/CTBModule.cpp b/plugins/CTBModule.cpp index 0330426..3b6d1ca 100644 --- a/plugins/CTBModule.cpp +++ b/plugins/CTBModule.cpp @@ -72,26 +72,34 @@ CTBModule::init(std::shared_ptr mcfg) { TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method"; HSIEventSender::init(mcfg); + + m_cfg = mcfg->module(get_name()); - /* - auto mdal = mcfg->module(get_name()); // Only need generic DaqModule for output - - if (!mdal) { + if (!m_cfg) { throw appfwk::CommandFailed(ERS_HERE, "init", get_name(), "Unable to retrieve configuration object"); } - for (auto con : mdal->get_outputs()) { - if (con->get_data_type() == datatype_to_string()) { + m_llt_hsi_data_sender.reset(); + m_hlt_hsi_data_sender.reset(); - m_raw_hsi_data_sender = get_iom_sender(con->UID()); + for (auto con : m_cfg->get_outputs()) { + if (con->get_data_type() == datatype_to_string()) { + if (con->UID().find("llt") != std::string::npos) { + m_llt_hsi_data_sender = get_iom_sender(con->UID()); + } + if (con->UID().find("hlt") != std::string::npos) { + m_hlt_hsi_data_sender = get_iom_sender(con->UID()); + } } } - m_params = mdal->get_configuration(); - */ - - m_llt_hsi_data_sender = get_iom_sender(appfwk::connection_uid(init_data, "llt_output")); - m_hlt_hsi_data_sender = get_iom_sender(appfwk::connection_uid(init_data, "hlt_output")); + if ( ! m_llt_hsi_data_sender ) { + // throw that the sender is not onfigured + } + + if ( ! m_hlt_hsi_data_sender ) { + // throw that the sender is not onfigured + } TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Exiting init() method"; } diff --git a/plugins/CTBModule.hpp b/plugins/CTBModule.hpp index cb8ac39..2f24ae4 100644 --- a/plugins/CTBModule.hpp +++ b/plugins/CTBModule.hpp @@ -23,8 +23,7 @@ #include "CTBPacketContent.hpp" -#include "ctbmodules/ctbmodule/Nljs.hpp" -#include "ctbmodules/ctbmoduleinfo/InfoNljs.hpp" +#include "appmodel/CTBModule.hpp" #include #include @@ -108,7 +107,7 @@ class CTBModule : public dunedaq::hsilibs::HSIEventSender bool send_message(const std::string & msg); // Configuration - dunedaq::ctbmodules::ctbmodule::Conf m_cfg; + const appmodel::CTBModule * m_cfg = nullptr; std::atomic m_run_number; // Threading