10 #ifndef ICARUSCODE_PMT_ALGORITHMS_DISCRETEPHOTOELECTRONPULSE_H
11 #define ICARUSCODE_PMT_ALGORITHMS_DISCRETEPHOTOELECTRONPULSE_H
24 #include "gsl/gsl_util"
29 #include <type_traits>
35 namespace icarus::opdet {
37 using namespace util::quantities::electronics_literals;
39 class DiscretePhotoelectronPulse;
69 std::is_same_v<std::decay_t<PulseFunction_t::Time>,
nanoseconds>,
70 "The type of single response function does not take nanoseconds."
85 static_assert(!std::is_same<Time_t, Tick_t>(),
86 "Time and tick must be different types!");
109 unsigned int nSubsamples = 1U,
140 {
return fSampledShape.subsample(i); }
144 decltype(
auto) subsampleFor(
Time_t time)
const
145 {
return subsample(fSampledShape.closestSubsampleIndex(time)); }
186 template <
typename Stream>
188 std::string
const& indent, std::string
const& firstIndent
190 template <
typename Stream>
191 void dump(
Stream&& out, std::string
const& indent =
"")
const
192 { dump(std::forward<Stream>(out), indent, indent); }
206 bool checkRange(ADCcount limit, std::string
const& outputCat)
const;
221 gigahertz samplingFreq,
unsigned int nSubsamples,
239 gigahertz samplingFreq,
unsigned int nSubsamples,
243 , fSamplingFreq(samplingFreq)
245 (sampleShape(shape(), fSamplingFreq, nSubsamples, samplingThreshold))
250 template <
typename Stream>
252 std::string
const& indent, std::string
const& firstIndent
255 out << firstIndent <<
"Sampled pulse waveform " << pulseLength()
256 <<
" samples long (" << duration()
257 <<
" long, sampled at " << samplingFrequency()
259 <<
"\n" << shape().toString(indent +
" ", indent);
260 fSampledShape.dump(out, indent +
" ", indent);
267 #endif // ICARUSCODE_PMT_ALGORITHMS_DISCRETEPHOTOELECTRONPULSE_H
Dimensioned variables representing frequency quantities.
PulseFunction_t const & fShape
Analytical shape of the pules.
std::size_t pulseLength() const
Returns the length of the sampled pulse in ticks.
void dump(Stream &&out, std::string const &indent, std::string const &firstIndent) const
Prints on stream the parameters of this shape.
ADCcount peakAmplitude() const
Returns the peak amplitude in ADC counts.
gsl::index SubsampleIndex_t
Type of index of subsample.
gigahertz samplingFrequency() const
Returns the sampling frequency (same units as entered).
Precomputed digitized shape of a given function.
Abstract interface of shape of a pulse from one photoelectron.
PulseFunction_t const & shape() const
gigahertz_as<> gigahertz
Type of frequency stored in gigahertz, in double precision.
SampledFunction_t fSampledShape
Pulse shape, discretized.
A value measured in the specified unit.
DiscretePhotoelectronPulse(PulseFunction_t const &pulseShape, gigahertz samplingFreq, unsigned int nSubsamples=1U, ADCcount samplingThreshold=1e-6_ADCf)
Constructor: samples the pulse.
Class for a function with precomputed values.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
Interface for a function describing a pulse from a photoelectron.
gigahertz fSamplingFreq
Sampling frequency.
nanoseconds duration() const
SubsampleIndex_t nSubsamples() const
Dimensioned variables related to electronics.
nanoseconds samplingPeriod() const
Returns the sampling period (inverse of frequency).
void dump(Stream &&out, std::string const &indent="") const
Dimensioned variables representing space or time quantities.
nanosecond_as<> nanosecond
Type of time stored in nanoseconds, in double precision.
SampledFunction_t::SubsampleData_t Subsample_t
Type of subsample data (a sampling of the full range).
nanoseconds peakTime() const
Returns the time at the peak from the beginning of sampling.
gsl::span< Y_t const > SubsampleData_t
Span of subsample data. Can be forward iterated.
nanosecond nanoseconds
Alias for common language habits.