LCOV - code coverage report
Current view: top level - artdaq/DAQrate - StatisticsHelper.hh (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 100.0 % 1 1
Test Date: 2025-09-04 00:45:34 Functions: 50.0 % 2 1

            Line data    Source code
       1              : #ifndef artdaq_Application_MPI2_StatisticsHelper_hh
       2              : #define artdaq_Application_MPI2_StatisticsHelper_hh
       3              : 
       4              : #include "artdaq-core/Core/MonitoredQuantity.hh"
       5              : #include "artdaq-core/Core/StatisticsCollection.hh"
       6              : 
       7              : namespace fhicl {
       8              : class ParameterSet;
       9              : }
      10              : 
      11              : #include <atomic>
      12              : #include <string>
      13              : #include <vector>
      14              : 
      15              : namespace artdaq {
      16              : class StatisticsHelper;
      17              : }
      18              : 
      19              : /**
      20              :  * \brief This class manages MonitoredQuantity instances for the *Core classes.
      21              :  */
      22              : class artdaq::StatisticsHelper
      23              : {
      24              : public:
      25              :         /**
      26              :          * \brief StatisticsHelper default constructor
      27              :          */
      28              :         StatisticsHelper();
      29              : 
      30              :         /**
      31              :          * \brief Copy Constructor is deleted
      32              :          */
      33              :         StatisticsHelper(StatisticsHelper const&) = delete;
      34              : 
      35              :         /**
      36              :          * \brief Default Destructor
      37              :          */
      38           15 :         virtual ~StatisticsHelper() = default;
      39              : 
      40              :         /**
      41              :          * \brief Copy Assignment operator is deleted
      42              :          * \return StatisticsHelper copy
      43              :          */
      44              :         StatisticsHelper& operator=(StatisticsHelper const&) = delete;
      45              :         StatisticsHelper(StatisticsHelper&&) = delete;             ///< Move Constructor is deleted
      46              :         StatisticsHelper& operator=(StatisticsHelper&&) = delete;  ///< Move Assignment Operator is deleted
      47              : 
      48              :         /**
      49              :          * \brief Add a MonitoredQuantity name to the list
      50              :          * \param statKey Name of the MonitoredQuantity to be added
      51              :          */
      52              :         void addMonitoredQuantityName(std::string const& statKey);
      53              : 
      54              :         /**
      55              :          * \brief Add a sample to the MonitoredQuantity with the given name
      56              :          * \param statKey Name of the MonitoredQuantity
      57              :          * \param value Value to record in the MonitoredQuantity
      58              :          */
      59              :         void addSample(std::string const& statKey, double value) const;
      60              : 
      61              :         /**
      62              :          * \brief Create MonitoredQuantity objects for all names registered with the StatisticsHelper
      63              :          * \param pset ParameterSet used to configure reporting
      64              :          * \param defaultReportIntervalFragments Default reporting interval in Fragments
      65              :          * \param defaultReportIntervalSeconds Default reporting interval in Seconds
      66              :          * \param defaultMonitorWindow Default monitoring window
      67              :          * \param primaryStatKeyName The primary (default) MonitoredQuantity
      68              :          * \return Whether the primary MonitoredQuantity exists
      69              :          *
      70              :          * StatisitcsHelper accpets the following Parameters:
      71              :          * "reporting_interval_fragments" (Default given above): The reporting interval in Fragments
      72              :          * "reporting_interval_seconds" (Default given above): The reporting interval in Seconds
      73              :          * "monitor_window" (Default given above): The monitoring window for the MonitoredQuantity
      74              :          * "monitor_binsize" (Default: 1 + ((monitorWindow - 1) / 100)): The monitoring bin size for the MonitoredQuantity
      75              :          */
      76              :         bool createCollectors(fhicl::ParameterSet const& pset,
      77              :                               int defaultReportIntervalFragments,
      78              :                               double defaultReportIntervalSeconds,
      79              :                               double defaultMonitorWindow,
      80              :                               std::string const& primaryStatKeyName);
      81              : 
      82              :         /**
      83              :          * \brief Reset all MonitoredQuantity instances
      84              :          */
      85              :         void resetStatistics();
      86              : 
      87              :         /**
      88              :          * \brief Determine if the reporting interval condition has been met
      89              :          * \return Whether the StatisticsHelper is ready to report
      90              :          */
      91              :         bool readyToReport();
      92              : 
      93              :         /**
      94              :          * \brief Determine if the MonitoredQuantity "recent" window has changed since the last time this function was called
      95              :          * \return Whether the MonitoredQuantity "recent" window has changed
      96              :          */
      97              :         bool statsRollingWindowHasMoved();
      98              : 
      99              : private:
     100              :         std::vector<std::string> monitored_quantity_name_list_;
     101              :         artdaq::MonitoredQuantityPtr primary_stat_ptr_;
     102              : 
     103              :         int reporting_interval_fragments_;
     104              :         double reporting_interval_seconds_;
     105              :         size_t previous_reporting_index_{0};
     106              :         std::atomic<MonitoredQuantityStats::TIME_POINT_T> previous_stats_calc_time_{0.0};
     107              : };
     108              : 
     109              : #endif /* artdaq_Application_MPI2_StatisticsHelper_hh */
        

Generated by: LCOV version 2.0-1