10 #ifndef ICARUSALG_UTILITIES_WAVEFORMOPERATIONS_H
11 #define ICARUSALG_UTILITIES_WAVEFORMOPERATIONS_H
15 #include <type_traits>
26 namespace icarus::waveform_operations {
31 template <
typename Sample,
int Polarity,
typename =
void>
34 template <
typename Sample,
int Polarity>
36 static constexpr Sample
transform(Sample sample) {
return sample; }
39 template <
typename Sample,
int Polarity>
40 struct FlipImpl<Sample, Polarity,
std::
enable_if_t<(Polarity < 0)>> {
41 static constexpr Sample
transform(Sample sample) {
return -sample; }
44 template <
int Polarity,
typename Sample>
45 constexpr Sample flip(Sample sample)
68 template <
typename Sample, Sample Transform(Sample)>
69 struct WaveformTransformedOperations {
71 using Sample_t = Sample;
75 WaveformTransformedOperations() =
default;
78 constexpr WaveformTransformedOperations(Sample_t
baseline)
91 constexpr Sample_t shiftFromBaseline(Sample_t
shift)
const
95 constexpr Sample_t subtractBaseline(Sample_t sample)
const
96 {
return subtractBaseline(sample,
fBaseline); }
107 static constexpr Sample_t
distance(Sample_t
from, Sample_t to)
111 static constexpr Sample_t shiftBy(Sample_t
baseline, Sample_t
shift)
115 static constexpr Sample_t subtractBaseline
116 (Sample_t sample, Sample_t
baseline)
117 {
return distance(baseline, sample); }
127 static constexpr
bool lessThan(Sample_t
a, Sample_t b)
129 static constexpr
bool greaterThan(Sample_t
a, Sample_t b)
131 static constexpr
bool noLessThan(Sample_t
a, Sample_t b)
146 {
return Transform(sample); }
168 template <
typename Sample,
int Polarity>
169 using Operations = details::WaveformTransformedOperations
170 <Sample, details::flip<Polarity, Sample>>;
173 template <
typename Sample>
177 template <
typename Sample>
187 #endif // ICARUSALG_UTILITIES_WAVEFORMOPERATIONS_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
typename std::enable_if< B, T >::type enable_if_t
bool greaterThan(CluLen c1, CluLen c2)
bool lessThan(CluLen c1, CluLen c2)