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

Naive signal processor: Estimates the pedestal and subtracts. More...

#include <NaiveFrugalPedestalSubtractProcessor.hpp>

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

Public Member Functions

naive_array_t process (const naive_array_t &signal) override
 Estimate the pedestal using the given signal and subtract.
 
void configure (const nlohmann::json &config, const int16_t *plane_numbers) override
 Configure the accumulation limit according to plane number.
 
- 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_pedestal {}
 Vector of estimated pedestals for each channel.
 
naive_array_t m_accum {}
 Vector of counts that a channel's signal was above or below m_pedestal.
 
int16_t m_accum_limit {10}
 Count limit before committing to a pedestal shift.
 

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: Estimates the pedestal and subtracts.

Given a history of signals, this estimates the pedestal by shifting the current estimate when it is wrong in the same direction m_accum_limit times. For example, if the input signal is greater (less) than the estimated pedestal 10 (configurable) times in a row, then increment (decrement) the pedestal.

Definition at line 22 of file NaiveFrugalPedestalSubtractProcessor.hpp.

Member Function Documentation

◆ configure()

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

Configure the accumulation limit according to plane number.

Parameters
configJSON config for the accumulation limits per plane.
plane_numbersArray of plane numbers. Gives the channels to apply the accumulation limit.

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

Definition at line 15 of file NaiveFrugalPedestalSubtractProcessor.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_pedestal, [](auto*){}));
22 std::shared_ptr<naive_array_t>(&m_accum, [](auto*){}));
23
25
26 m_accum_limit = config["accum_limit"];
27}
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_pedestal
Vector of estimated pedestals for each channel.
int16_t m_accum_limit
Count limit before committing to a pedestal shift.
naive_array_t m_accum
Vector of counts that a channel's signal was above or below m_pedestal.
void register_internal_state(std::string name, std::shared_ptr< signal_t > pointer_to_state)
Register an internal state.

◆ process()

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

Estimate the pedestal using the given signal and subtract.

Parameters
signalA vector of channel signals.
Returns
The input signal minus the estimated pedestal.

Reimplemented from tpglibs::NaiveProcessor.

Definition at line 30 of file NaiveFrugalPedestalSubtractProcessor.cpp.

30 {
31 // Update sample counter and write internal states to buffer for harvesting
32 m_samples++;
35 }
36
37 naive_array_t subtracted_signal;
38 for (int i = 0; i < 16; i++) {
39 // Increment if above.
40 if (signal[i] > m_pedestal[i])
41 m_accum[i]++;
42
43 // Decrement if below.
44 if (signal[i] < m_pedestal[i])
45 m_accum[i]--;
46
47 // Increment pedestal if we've hit the top limit.
48 if (m_accum[i] > m_accum_limit) {
49 m_pedestal[i]++;
50 m_accum[i] = 0;
51 }
52
53 // Decrement pedestal if we've hit the low limit.
54 if (m_accum[i] < -1*m_accum_limit) {
55 m_pedestal[i]--;
56 m_accum[i] = 0;
57 }
58
59 subtracted_signal[i] = signal[i] - m_pedestal[i];
60 }
61
62 return NaiveProcessor::process(subtracted_signal);
63}
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.
std::array< int16_t, 16 > naive_array_t
The naive version uses a standard array instead of __m256i.

Member Data Documentation

◆ m_accum

naive_array_t tpglibs::NaiveFrugalPedestalSubtractProcessor::m_accum {}
private

Vector of counts that a channel's signal was above or below m_pedestal.

Definition at line 27 of file NaiveFrugalPedestalSubtractProcessor.hpp.

27{};

◆ m_accum_limit

int16_t tpglibs::NaiveFrugalPedestalSubtractProcessor::m_accum_limit {10}
private

Count limit before committing to a pedestal shift.

Definition at line 30 of file NaiveFrugalPedestalSubtractProcessor.hpp.

30{10};

◆ m_pedestal

naive_array_t tpglibs::NaiveFrugalPedestalSubtractProcessor::m_pedestal {}
private

Vector of estimated pedestals for each channel.

Definition at line 24 of file NaiveFrugalPedestalSubtractProcessor.hpp.

24{};

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