Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
srcs
sbnobj
sbnobj
ICARUS
PMT
Data
WaveformBaseline.h
Go to the documentation of this file.
1
/**
2
* @file icaruscode/PMT/Data/WaveformBaseline.h
3
* @brief A baseline for a waveform.
4
* @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5
* @date September 11, 2020
6
* @see icaruscode/PMT/Data/WaveformBaseline.cxx
7
*/
8
9
#ifndef ICARUSCODE_PMT_DATA_WAVEFORMBASELINE_H
10
#define ICARUSCODE_PMT_DATA_WAVEFORMBASELINE_H
11
12
13
// C/C++ standard libraries
14
#include <iosfwd>
// std::ostream
15
#include <cmath>
// std::round()
16
17
18
//------------------------------------------------------------------------------
19
namespace
icarus {
20
21
struct
WaveformBaseline;
22
23
/// Prints the value of the baseline into a stream.
24
std::ostream&
operator
<<
25
(std::ostream& out,
icarus::WaveformBaseline
const
&
baseline
);
26
27
}
// namespace icarus
28
29
/**
30
* @brief Class containing a waveform baseline value.
31
*
32
* The baseline is stored as a floating point value, not to lose precision.
33
*
34
* This class is a data product wrapper for a simple value, with some usability
35
* candies attached.
36
*
37
*
38
* Example of simple usage
39
* ------------------------
40
*
41
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
42
*
43
* icarus::WaveformBaseline const baseline { 1.2f };
44
*
45
* std::cout << "Baseline: " << baseline << " ADC" << std::endl;
46
*
47
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
* will print `Baseline: 1.2 ADC`.
49
*
50
*
51
* Example of usage with quantity values
52
* --------------------------------------
53
*
54
* The following is a more complex example showing baseline subtraction.
55
* We assume we are using the type `util::quantities::counts` as ADC count type
56
* (defined in `lardataalg/Utilities/quantities/electronics.h`) for the
57
* waveform.
58
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
59
* using ADCCount_t = util::quantities::counts;
60
* std::vector<ADCCount_t> subtractBaseline
61
* (std::vector<ADCCount_t> const& data, icarus::WaveformBaseline const& baseline)
62
* {
63
*
64
* icarus::waveform_operations::NegativePolarityOperations<float> const
65
* waveOps { baseline() };
66
*
67
* std::vector<ADCCount_t> subtracted;
68
* subtracted.reserve(data.size());
69
* for (auto sample: data) {
70
* subtracted.emplace_back
71
* (std::round(waveOps.subtractBaseline(sample.value())));
72
* }
73
*
74
* return subtracted;
75
* } // subtractBaseline()
76
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77
* The `subtracted` waveform is positive and baseline-subtracted.
78
* We use ICARUS utilities to manage the polarity of the waveform
79
* (hard-coded negative). Note that the subtraction is less than trivial because
80
* of the integral type waveform on top of the floating point baseline.
81
* The samples are converted into floating point for the subtraction, then
82
* reconverted (rounded) back.
83
*/
84
struct
icarus::WaveformBaseline
{
85
86
using
Baseline_t
= float;
///< Type of baseline value.
87
88
Baseline_t
fBaseline
{};
///< The current value of the baseline.
89
90
91
// --- BEGIN -- Constructors -------------------------------------------------
92
93
/// Constructor: default baseline (`0`).
94
WaveformBaseline
() =
default
;
95
96
/// Constructor: sets the baseline.
97
WaveformBaseline
(
Baseline_t
baseline
):
fBaseline
(baseline) {}
98
99
// --- END -- Constructors ---------------------------------------------------
100
101
102
// --- BEGIN -- Access to the baseline ---------------------------------------
103
/**
104
* @name Access to the baseline
105
*
106
* In addition to the direct method (`baseline()`) a few candies are offered:
107
* a function-like operator for baseline access.
108
*
109
*/
110
/// @{
111
/// Returns the current baseline value.
112
Baseline_t
baseline
()
const
{
return
fBaseline
; }
113
114
/// Returns the current baseline value.
115
Baseline_t
operator()
()
const
{
return
baseline
(); }
116
117
// --- END -- Access to the baseline -----------------------------------------
118
119
};
// icarus::trigger::WaveformBaseline
120
121
122
//------------------------------------------------------------------------------
123
124
#endif // ICARUSCODE_PMT_DATA_WAVEFORMBASELINE_H
icarus::WaveformBaseline::WaveformBaseline
WaveformBaseline(Baseline_t baseline)
Constructor: sets the baseline.
Definition:
WaveformBaseline.h:97
icarus::WaveformBaseline::operator()
Baseline_t operator()() const
Returns the current baseline value.
Definition:
WaveformBaseline.h:115
icarus::WaveformBaseline::WaveformBaseline
WaveformBaseline()=default
Constructor: default baseline (0).
icarus::WaveformBaseline::Baseline_t
float Baseline_t
Type of baseline value.
Definition:
WaveformBaseline.h:86
baseline
BEGIN_PROLOG baseline
Definition:
OnlineDecoder.fcl:14
icarus::WaveformBaseline
Class containing a waveform baseline value.
Definition:
WaveformBaseline.h:84
icarus::WaveformBaseline::fBaseline
Baseline_t fBaseline
The current value of the baseline.
Definition:
WaveformBaseline.h:88
icarus::WaveformBaseline::baseline
Baseline_t baseline() const
Definition:
WaveformBaseline.h:112
Generated by
1.8.5