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
 
void set_next_processor (std::shared_ptr< AbstractProcessor< std::array< int16_t, 16 > > > next_processor)
 Setter for next processor.
 

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.
 

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 int16_t config_memory[3] = {config["memory_factor_plane0"],
17 config["memory_factor_plane1"],
18 config["memory_factor_plane2"]};
19 int16_t config_scale[3] = {config["scale_factor_plane0"],
20 config["scale_factor_plane1"],
21 config["scale_factor_plane2"]};
22
23 for (int i = 0; i < 16; i++) {
24 m_memory_factor[i] = config_memory[plane_numbers[i]];
25 m_scale_factor[i] = config_scale[plane_numbers[i]];
26 }
27}
naive_array_t m_scale_factor
The S factor in the model equation.
naive_array_t m_memory_factor
The R factor in the model equation.

◆ 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 29 of file NaiveRunSumProcessor.cpp.

29 {
30 for (int i = 0; i < 16; i++) {
31 int32_t scaled_rs = _naive_div_int16(m_running_sum[i], 10);
32 scaled_rs *= m_memory_factor[i];
33
34 int32_t scaled_signal = _naive_div_int16(signal[i], 10);
35 scaled_signal *= m_scale_factor[i];
36
37 int32_t intermediate = scaled_signal + scaled_rs;
38 m_running_sum[i] = std::min(intermediate, INT16_MAX);
39 }
41}
virtual naive_array_t process(const naive_array_t &signal) override
Simple signal pass-through on naive type.
naive_array_t m_running_sum
The RS in the model equation.
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: