DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
tpglibs::NaiveRunSumProcessor Class Reference

Naive signal processor: Calculates the running sum of the signal. More...

#include <NaiveRunSumProcessor.hpp>

Inheritance diagram for tpglibs::NaiveRunSumProcessor:
[legend]
Collaboration diagram for tpglibs::NaiveRunSumProcessor:
[legend]

Public Member Functions

naive_array_t process (const naive_array_t &signal) override
 Calculate and store the running sum.
 
void configure (const nlohmann::json &config, const int16_t *plane_numbers) override
 Configures the R factor and S factor according to plane.
 
- Public Member Functions inherited from tpglibs::NaiveProcessor
- Public Member Functions inherited from tpglibs::AbstractProcessor< std::array< int16_t, 16 > >
virtual ~AbstractProcessor ()=default
 
ProcessorInternalStateBufferManager< std::array< int16_t, 16 > > * _get_internal_state_buffer_manager ()
 
ProcessorInternalStateNameRegistry< std::array< int16_t, 16 > > * _get_internal_state_name_registry ()
 
virtual void configure_internal_state_collection (const nlohmann::json &config)
 Configure common internal state collection parameters.
 
void set_next_processor (std::shared_ptr< AbstractProcessor< std::array< int16_t, 16 > > > next_processor)
 Setter for next processor.
 
std::shared_ptr< AbstractProcessor< std::array< int16_t, 16 > > > get_next_processor ()
 Getter for next processor.
 
virtual std::vector< std::string > get_requested_internal_state_names () const
 Get the names of requested internal states (delegates to registry).
 
virtual ProcessorMetricArray< std::array< int16_t, 16 > > read_internal_states_as_integer_array ()
 

Private Attributes

naive_array_t m_memory_factor
 The R factor in the model equation.
 
naive_array_t m_scale_factor
 The S factor in the model equation.
 
naive_array_t m_running_sum
 The RS in the model equation.
 

Additional Inherited Members

- Public Types inherited from tpglibs::NaiveProcessor
using naive_array_t = std::array<int16_t, 16>
 The naive version uses a standard array instead of __m256i.
 
- Public Types inherited from tpglibs::AbstractProcessor< std::array< int16_t, 16 > >
using signal_type_t
 Signal type to process on. General __m256i.
 
- Protected Attributes inherited from tpglibs::AbstractProcessor< std::array< int16_t, 16 > >
ProcessorInternalStateBufferManager< std::array< int16_t, 16 > > m_internal_state_buffer_manager
 
ProcessorInternalStateNameRegistry< std::array< int16_t, 16 > > m_internal_state_name_registry
 
std::atomic< uint64_t > m_samples
 
bool m_collect_internal_state_flag
 
uint64_t m_sample_period
 

Detailed Description

Naive signal processor: Calculates the running sum of the signal.

Calculates the running sum of the signal with some factors. This tries to model the following equation: RS = R * RS + S * signal, where

  • RS is the on-going running sum,
  • R is the memory factor of the on-going running sum,
  • S is the scale factor for the incoming signal to avoid overflowing,
  • signal is the incoming signal. Division is intentionally unorthodox to match what is possible in AVX.

Definition at line 29 of file NaiveRunSumProcessor.hpp.

Member Function Documentation

◆ configure()

void tpglibs::NaiveRunSumProcessor::configure ( const nlohmann::json & config,
const int16_t * plane_numbers )
overridevirtual

Configures the R factor and S factor according to plane.

Parameters
configJSON of the R and S factors to use per plane.
plane_numbersArray of plane numbers. Gives the channels to apply the R and S factors.

Implements tpglibs::AbstractProcessor< std::array< int16_t, 16 > >.

Definition at line 15 of file NaiveRunSumProcessor.cpp.

15 {
16 // Configure common metric collection parameters
17 // Register pointers to the ACTUAL member variables, not copies
18 // Use shared_ptr with no-op deleter to avoid double-free
20 std::shared_ptr<naive_array_t>(&m_memory_factor, [](auto*){}));
22 std::shared_ptr<naive_array_t>(&m_scale_factor, [](auto*){}));
24 std::shared_ptr<naive_array_t>(&m_running_sum, [](auto*){}));
25
27
28 int16_t config_memory[3] = {config["memory_factor_plane0"],
29 config["memory_factor_plane1"],
30 config["memory_factor_plane2"]};
31 int16_t config_scale[3] = {config["scale_factor_plane0"],
32 config["scale_factor_plane1"],
33 config["scale_factor_plane2"]};
34
35 for (int i = 0; i < 16; i++) {
36 m_memory_factor[i] = config_memory[plane_numbers[i]];
37 m_scale_factor[i] = config_scale[plane_numbers[i]];
38 }
39}
ProcessorInternalStateNameRegistry< std::array< int16_t, 16 > > m_internal_state_name_registry
virtual void configure_internal_state_collection(const nlohmann::json &config)
naive_array_t m_scale_factor
The S factor in the model equation.
naive_array_t m_running_sum
The RS in the model equation.
naive_array_t m_memory_factor
The R factor in the model equation.
void register_internal_state(std::string name, std::shared_ptr< signal_t > pointer_to_state)
Register an internal state.

◆ process()

NaiveRunSumProcessor::naive_array_t tpglibs::NaiveRunSumProcessor::process ( const naive_array_t & signal)
overridevirtual

Calculate and store the running sum.

Parameters
signalThe input signal to process on.
Returns
The calculated running sum.

Reimplemented from tpglibs::NaiveProcessor.

Definition at line 41 of file NaiveRunSumProcessor.cpp.

41 {
42 // Update sample counter and write internal states to buffer for harvesting
43 m_samples++;
46 }
47
48 for (int i = 0; i < 16; i++) {
49 int32_t scaled_rs = _naive_div_int16(m_running_sum[i], 10);
50 scaled_rs *= m_memory_factor[i];
51
52 int32_t scaled_signal = _naive_div_int16(signal[i], 10);
53 scaled_signal *= m_scale_factor[i];
54
55 int32_t intermediate = scaled_signal + scaled_rs;
56 m_running_sum[i] = std::min(intermediate, INT16_MAX);
57 }
59}
ProcessorInternalStateBufferManager< std::array< int16_t, 16 > > m_internal_state_buffer_manager
virtual naive_array_t process(const naive_array_t &signal) override
Simple signal pass-through on naive type.
int16_t _naive_div_int16(const int16_t &a, const int16_t &b)
Naive model of AVX division in AVXUtils.

Member Data Documentation

◆ m_memory_factor

naive_array_t tpglibs::NaiveRunSumProcessor::m_memory_factor
private

The R factor in the model equation.

Definition at line 31 of file NaiveRunSumProcessor.hpp.

◆ m_running_sum

naive_array_t tpglibs::NaiveRunSumProcessor::m_running_sum
private

The RS in the model equation.

Definition at line 37 of file NaiveRunSumProcessor.hpp.

◆ m_scale_factor

naive_array_t tpglibs::NaiveRunSumProcessor::m_scale_factor
private

The S factor in the model equation.

Definition at line 34 of file NaiveRunSumProcessor.hpp.


The documentation for this class was generated from the following files: