LCOV - code coverage report
Current view: top level - tpglibs/src - NaiveRunSumProcessor.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 4.8 % 21 1
Test Date: 2026-10-11 15:05:20 Functions: 25.0 % 4 1

            Line data    Source code
       1              : /**
       2              :  * @file NaiveRunSumProcessor.cpp
       3              :  *
       4              :  * @copyright This is part of the DUNE DAQ Software Suite, copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : 
       9              : #include "tpglibs/NaiveRunSumProcessor.hpp"
      10              : 
      11              : namespace tpglibs {
      12              : 
      13           13 : REGISTER_NAIVEPROCESSOR_CREATOR("NaiveRunSumProcessor", NaiveRunSumProcessor)
      14              : 
      15              : void
      16            0 : NaiveRunSumProcessor::configure(const nlohmann::json& config, const int16_t* plane_numbers)
      17              : {
      18              : #ifdef TPGLIBS_ENABLE_STATE_MONITORING
      19              :   m_internal_state_name_registry.register_internal_state(
      20              :     "r", std::shared_ptr<naive_array_t>(&m_memory_factor, [](auto*) {}));
      21              :   m_internal_state_name_registry.register_internal_state("s",
      22              :                                                          std::shared_ptr<naive_array_t>(&m_scale_factor, [](auto*) {}));
      23              :   m_internal_state_name_registry.register_internal_state("rs",
      24              :                                                          std::shared_ptr<naive_array_t>(&m_running_sum, [](auto*) {}));
      25              :   configure_internal_state_collection(config);
      26              : #endif
      27              : 
      28            0 :   int16_t config_memory[3] = { config["memory_factor_plane0"],
      29            0 :                                config["memory_factor_plane1"],
      30            0 :                                config["memory_factor_plane2"] };
      31            0 :   int16_t config_scale[3] = { config["scale_factor_plane0"],
      32            0 :                               config["scale_factor_plane1"],
      33            0 :                               config["scale_factor_plane2"] };
      34              : 
      35            0 :   for (int i = 0; i < 16; i++) {
      36            0 :     m_memory_factor[i] = config_memory[plane_numbers[i]];
      37            0 :     m_scale_factor[i] = config_scale[plane_numbers[i]];
      38              :   }
      39            0 : }
      40              : 
      41              : NaiveRunSumProcessor::naive_array_t
      42            0 : NaiveRunSumProcessor::process(const naive_array_t& signal)
      43              : {
      44              : #ifdef TPGLIBS_ENABLE_STATE_MONITORING
      45              :   m_samples++;
      46              :   if (m_collect_internal_state_flag && (m_samples % m_sample_period == 0)) {
      47              :     m_internal_state_buffer_manager.write_to_active_buffer();
      48              :   }
      49              : #endif
      50              : 
      51            0 :   for (int i = 0; i < 16; i++) {
      52            0 :     int32_t scaled_rs = _naive_div_int16(m_running_sum[i], 10);
      53            0 :     scaled_rs *= m_memory_factor[i];
      54              : 
      55            0 :     int32_t scaled_signal = _naive_div_int16(signal[i], 10);
      56            0 :     scaled_signal *= m_scale_factor[i];
      57              : 
      58            0 :     int32_t intermediate = scaled_signal + scaled_rs;
      59            0 :     m_running_sum[i] = std::min(intermediate, INT16_MAX);
      60              :   }
      61            0 :   return NaiveProcessor::process(m_running_sum);
      62              : }
      63              : 
      64              : } // namespace tpglibs
        

Generated by: LCOV version 2.0-1