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-08-30 15:04:40 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           10 : REGISTER_NAIVEPROCESSOR_CREATOR("NaiveRunSumProcessor", NaiveRunSumProcessor)
      14              : 
      15            0 : void NaiveRunSumProcessor::configure(const nlohmann::json& config, const int16_t* plane_numbers) {
      16              : #ifdef TPGLIBS_ENABLE_STATE_MONITORING
      17              :   m_internal_state_name_registry.register_internal_state("r", 
      18              :     std::shared_ptr<naive_array_t>(&m_memory_factor, [](auto*){}));
      19              :   m_internal_state_name_registry.register_internal_state("s", 
      20              :     std::shared_ptr<naive_array_t>(&m_scale_factor, [](auto*){}));
      21              :   m_internal_state_name_registry.register_internal_state("rs", 
      22              :     std::shared_ptr<naive_array_t>(&m_running_sum, [](auto*){}));
      23              :   configure_internal_state_collection(config);
      24              : #endif
      25              : 
      26            0 :   int16_t config_memory[3] = {config["memory_factor_plane0"],
      27            0 :                               config["memory_factor_plane1"],
      28            0 :                               config["memory_factor_plane2"]};
      29            0 :   int16_t config_scale[3]  = {config["scale_factor_plane0"],
      30            0 :                               config["scale_factor_plane1"],
      31            0 :                               config["scale_factor_plane2"]};
      32              : 
      33            0 :   for (int i = 0; i < 16; i++) {
      34            0 :     m_memory_factor[i] = config_memory[plane_numbers[i]];
      35            0 :     m_scale_factor[i] = config_scale[plane_numbers[i]];
      36              :   }
      37            0 : }
      38              : 
      39            0 : NaiveRunSumProcessor::naive_array_t NaiveRunSumProcessor::process(const naive_array_t& signal) {
      40              : #ifdef TPGLIBS_ENABLE_STATE_MONITORING
      41              :   m_samples++;
      42              :   if (m_collect_internal_state_flag && (m_samples % m_sample_period == 0)) {
      43              :     m_internal_state_buffer_manager.write_to_active_buffer();
      44              :   }
      45              : #endif
      46              : 
      47            0 :   for (int i = 0; i < 16; i++) {
      48            0 :     int32_t scaled_rs = _naive_div_int16(m_running_sum[i], 10);
      49            0 :     scaled_rs *= m_memory_factor[i];
      50              : 
      51            0 :     int32_t scaled_signal = _naive_div_int16(signal[i], 10);
      52            0 :     scaled_signal *= m_scale_factor[i];
      53              : 
      54            0 :     int32_t intermediate = scaled_signal + scaled_rs;
      55            0 :     m_running_sum[i] = std::min(intermediate, INT16_MAX);
      56              :   }
      57            0 :   return NaiveProcessor::process(m_running_sum);
      58              : }
      59              : 
      60              : } // namespace tpglibs
        

Generated by: LCOV version 2.0-1