LCOV - code coverage report
Current view: top level - triggeralgs/src - TCMakerChannelDistanceAlgorithm.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 3.0 % 33 1
Test Date: 2025-12-21 13:07:08 Functions: 16.7 % 6 1

            Line data    Source code
       1              : /**
       2              :  * @file TCMakerChannelDistanceAlgorithm.cpp
       3              :  *
       4              :  * This is part of the DUNE DAQ Application Framework, copyright 2021.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : 
       9              : #include "triggeralgs/ChannelDistance/TCMakerChannelDistanceAlgorithm.hpp"
      10              : 
      11              : #include "TRACE/trace.h"
      12              : #define TRACE_NAME "TCMakerChannelDistanceAlgorithm"
      13              : 
      14              : namespace triggeralgs {
      15              : 
      16              : void
      17            0 : TCMakerChannelDistanceAlgorithm::set_new_tc(const TriggerActivity& input_ta)
      18              : {
      19            0 :   m_current_tc = TriggerCandidate();
      20            0 :   m_current_tc.inputs.push_back(input_ta);
      21            0 :   m_current_tp_count = input_ta.inputs.size();
      22            0 :   return;
      23              : }
      24              : 
      25              : void
      26            0 : TCMakerChannelDistanceAlgorithm::configure(const nlohmann::json& config)
      27              : {
      28            0 :   TriggerCandidateMaker::configure(config);
      29              : 
      30            0 :   if (config.contains("max_tp_count"))
      31            0 :     m_max_tp_count = config["max_tp_count"];
      32            0 :   return;
      33              : }
      34              : 
      35              : void
      36            0 : TCMakerChannelDistanceAlgorithm::set_tc_attributes()
      37              : {
      38            0 :   auto& first_ta = m_current_tc.inputs.front();
      39            0 :   auto& last_ta = m_current_tc.inputs.back();
      40              : 
      41            0 :   m_current_tc.time_start = first_ta.time_start;
      42            0 :   m_current_tc.time_end = last_ta.time_end;
      43            0 :   m_current_tc.time_candidate = last_ta.time_start; // Since this is the TA that closed the TC.
      44              : 
      45            0 :   m_current_tc.detid = first_ta.detid;
      46            0 :   m_current_tc.algorithm = TriggerCandidate::Algorithm::kChannelDistance;
      47            0 :   m_current_tc.type = m_tc_type_out;
      48            0 :   return;
      49              : }
      50              : 
      51              : void
      52            0 : TCMakerChannelDistanceAlgorithm::process(const TriggerActivity& input_ta,
      53              :                                               std::vector<TriggerCandidate>& output_tcs)
      54              : {
      55              : 
      56              :   // Start a new TC if not already going.
      57            0 :   if (m_current_tc.inputs.empty()) {
      58            0 :     set_new_tc(input_ta);
      59            0 :     return;
      60              :   }
      61              : 
      62              :   // Check to close the TC based on TP contents.
      63            0 :   if (input_ta.inputs.size() + m_current_tp_count > m_max_tp_count) {
      64            0 :     set_tc_attributes();
      65            0 :     output_tcs.push_back(m_current_tc);
      66              : 
      67            0 :     set_new_tc(input_ta);
      68            0 :     return;
      69              :   }
      70              : 
      71              :   // Append the new TA and increase the TP count.
      72            0 :   m_current_tc.inputs.push_back(input_ta);
      73            0 :   m_current_tp_count += input_ta.inputs.size();
      74            0 :   return;
      75              : }
      76              : 
      77              : // Register algo in TC Factory
      78           12 : REGISTER_TRIGGER_CANDIDATE_MAKER(TRACE_NAME, TCMakerChannelDistanceAlgorithm)
      79              : 
      80              : } // namespace triggeralgs
        

Generated by: LCOV version 2.0-1