All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
icarus::WaveformBaseline Struct Reference

Class containing a waveform baseline value. More...

#include <WaveformBaseline.h>

Public Types

using Baseline_t = float
 Type of baseline value. More...
 

Public Member Functions

 WaveformBaseline ()=default
 Constructor: default baseline (0). More...
 
 WaveformBaseline (Baseline_t baseline)
 Constructor: sets the baseline. More...
 
Access to the baseline

In addition to the direct method (baseline()) a few candies are offered: a function-like operator for baseline access.

Baseline_t baseline () const
 
Baseline_t operator() () const
 Returns the current baseline value. More...
 

Public Attributes

Baseline_t fBaseline {}
 The current value of the baseline. More...
 

Detailed Description

Class containing a waveform baseline value.

The baseline is stored as a floating point value, not to lose precision.

This class is a data product wrapper for a simple value, with some usability candies attached.

Example of simple usage

std::cout << "Baseline: " << baseline << " ADC" << std::endl;

will print Baseline: 1.2 ADC.

Example of usage with quantity values

The following is a more complex example showing baseline subtraction. We assume we are using the type util::quantities::counts as ADC count type (defined in lardataalg/Utilities/quantities/electronics.h) for the waveform.

using ADCCount_t = util::quantities::counts;
std::vector<ADCCount_t> subtractBaseline
(std::vector<ADCCount_t> const& data, icarus::WaveformBaseline const& baseline)
{
waveOps { baseline() };
std::vector<ADCCount_t> subtracted;
subtracted.reserve(data.size());
for (auto sample: data) {
subtracted.emplace_back
(std::round(waveOps.subtractBaseline(sample.value())));
}
return subtracted;
} // subtractBaseline()

The subtracted waveform is positive and baseline-subtracted. We use ICARUS utilities to manage the polarity of the waveform (hard-coded negative). Note that the subtraction is less than trivial because of the integral type waveform on top of the floating point baseline. The samples are converted into floating point for the subtraction, then reconverted (rounded) back.

Definition at line 84 of file WaveformBaseline.h.

Member Typedef Documentation

Type of baseline value.

Definition at line 86 of file WaveformBaseline.h.

Constructor & Destructor Documentation

icarus::WaveformBaseline::WaveformBaseline ( )
default

Constructor: default baseline (0).

icarus::WaveformBaseline::WaveformBaseline ( Baseline_t  baseline)
inline

Constructor: sets the baseline.

Definition at line 97 of file WaveformBaseline.h.

97 : fBaseline(baseline) {}
Baseline_t fBaseline
The current value of the baseline.
Baseline_t baseline() const

Member Function Documentation

Baseline_t icarus::WaveformBaseline::baseline ( ) const
inline

Returns the current baseline value.

Definition at line 112 of file WaveformBaseline.h.

112 { return fBaseline; }
Baseline_t fBaseline
The current value of the baseline.
Baseline_t icarus::WaveformBaseline::operator() ( ) const
inline

Returns the current baseline value.

Definition at line 115 of file WaveformBaseline.h.

115 { return baseline(); }
Baseline_t baseline() const

Member Data Documentation

Baseline_t icarus::WaveformBaseline::fBaseline {}

The current value of the baseline.

Definition at line 88 of file WaveformBaseline.h.


The documentation for this struct was generated from the following file: