All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
icarus::opdet::DiscretePhotoelectronPulse Class Reference

Precomputed digitized shape of a given function. More...

#include <DiscretePhotoelectronPulse.h>

Public Types

using gigahertz = util::quantities::gigahertz
 
using nanoseconds = util::quantities::nanosecond
 
using PulseFunction_t = PhotoelectronPulseFunction< nanoseconds >
 Type of shape (times are in nanoseconds). More...
 
using ADCcount = PulseFunction_t::ADCcount
 
using Time_t = nanoseconds
 
using Tick_t = util::quantities::tick
 
using SubsampleIndex_t = gsl::index
 Type of index of subsample. More...
 
using Subsample_t = SampledFunction_t::SubsampleData_t
 Type of subsample data (a sampling of the full range). More...
 

Public Member Functions

 DiscretePhotoelectronPulse (PulseFunction_t const &pulseShape, gigahertz samplingFreq, unsigned int nSubsamples=1U, ADCcount samplingThreshold=1e-6_ADCf)
 Constructor: samples the pulse. More...
 
std::size_t pulseLength () const
 Returns the length of the sampled pulse in ticks. More...
 
ADCcount operator() (Time_t time) const
 Evaluates the shape at the specified time. More...
 
bool checkRange (ADCcount limit, std::string const &outputCat) const
 Checks that the waveform tails not sampled are negligible. More...
 
Access to subsamples.

A subsample is represented by a forward-iterable object. For example:

using namespace util::quantities::time_literals;
auto const& subsample = dpp.subsampleFor(5_ns);
for (auto sample: subsample) // ...
Note
Direct iterator access is currently not implemented because the underlying implementation of the subsample object (gsl::span) does not support "borrowing" the data. See the note in util::SampledFunction for more details. The issue should be solved with C++20.
decltype(auto) subsample (SubsampleIndex_t i) const
 Returns the subsample specified by index i, undefined if invalid. More...
 
decltype(auto) subsampleFor (Time_t time) const
 
SubsampleIndex_t nSubsamples () const
 
Functional shape

Returns the function which was sampled.

PulseFunction_t const & shape () const
 
ADCcount peakAmplitude () const
 Returns the peak amplitude in ADC counts. More...
 
nanoseconds peakTime () const
 Returns the time at the peak from the beginning of sampling. More...
 
gigahertz samplingFrequency () const
 Returns the sampling frequency (same units as entered). More...
 
nanoseconds samplingPeriod () const
 Returns the sampling period (inverse of frequency). More...
 
nanoseconds duration () const
 
template<typename Stream >
void dump (Stream &&out, std::string const &indent, std::string const &firstIndent) const
 Prints on stream the parameters of this shape. More...
 
template<typename Stream >
void dump (Stream &&out, std::string const &indent="") const
 

Private Types

using SampledFunction_t = util::SampledFunction< nanoseconds, ADCcount >
 Internal discretized representation of the sampled pulse shape. More...
 

Static Private Member Functions

static SampledFunction_t sampleShape (PulseFunction_t const &pulseShape, gigahertz samplingFreq, unsigned int nSubsamples, ADCcount threshold)
 Builds the sampling cache. More...
 

Private Attributes

PulseFunction_t const & fShape
 Analytical shape of the pules. More...
 
gigahertz fSamplingFreq
 Sampling frequency. More...
 
SampledFunction_t fSampledShape
 Pulse shape, discretized. More...
 

Detailed Description

Precomputed digitized shape of a given function.

Multiple samplings ("subsamples") are performed with sub-tick offsets.

The sampled function is of type PhotoelectronPulseFunction<util::quantities::nanosecond> (polymorphic implementations are supported).

A reference to the sampled function is kept available, so that function needs to be valid for the lifetime of this object.

Definition at line 58 of file DiscretePhotoelectronPulse.h.

Member Typedef Documentation

Definition at line 65 of file DiscretePhotoelectronPulse.h.

Definition at line 60 of file DiscretePhotoelectronPulse.h.

Definition at line 61 of file DiscretePhotoelectronPulse.h.

Type of shape (times are in nanoseconds).

Definition at line 64 of file DiscretePhotoelectronPulse.h.

Internal discretized representation of the sampled pulse shape.

Definition at line 74 of file DiscretePhotoelectronPulse.h.

Type of subsample data (a sampling of the full range).

Definition at line 83 of file DiscretePhotoelectronPulse.h.

Type of index of subsample.

Definition at line 80 of file DiscretePhotoelectronPulse.h.

Definition at line 78 of file DiscretePhotoelectronPulse.h.

Definition at line 77 of file DiscretePhotoelectronPulse.h.

Constructor & Destructor Documentation

icarus::opdet::DiscretePhotoelectronPulse::DiscretePhotoelectronPulse ( PulseFunction_t const &  pulseShape,
gigahertz  samplingFreq,
unsigned int  nSubsamples = 1U,
ADCcount  samplingThreshold = 1e-6_ADCf 
)
inline

Constructor: samples the pulse.

Parameters
pulseShapethe shape to be pulsed; times in nanoseconds
samplingFreqfrequency of samples [gigahertz]
nSubsamples(default: 1) the number of samples within a tick
samplingThreshold(default: 10^-6^) pulse shape ends when its value is below this threshold

Samples start from time 0, which is the time of the start of the first tick. This time is expected to be the arrival time of the photoelectron.

The length of the sampling is determined by the sampling threshold: at the first tick after the peak time where the shape function is below threshold, the sampling ends (that tick under threshold itself is also discarded).

The ownership of pulseShape is acquired by this object.

Definition at line 237 of file DiscretePhotoelectronPulse.h.

242  : fShape(pulseShape)
243  , fSamplingFreq(samplingFreq)
244  , fSampledShape
245  (sampleShape(shape(), fSamplingFreq, nSubsamples, samplingThreshold))
246  {}
PulseFunction_t const & fShape
Analytical shape of the pules.
SampledFunction_t fSampledShape
Pulse shape, discretized.
static SampledFunction_t sampleShape(PulseFunction_t const &pulseShape, gigahertz samplingFreq, unsigned int nSubsamples, ADCcount threshold)
Builds the sampling cache.

Member Function Documentation

bool icarus::opdet::DiscretePhotoelectronPulse::checkRange ( ADCcount  limit,
std::string const &  outputCat 
) const

Checks that the waveform tails not sampled are negligible.

Parameters
limitthreshold below which the waveform is considered negligible
outputCat_(default: empty)_ message facility output category to use for messages
Returns
whether the two tails are negligible

If outputCat is empty (default) no message is printed. Otherwise, in case of failure a message is sent to message facility (under category outputCat) describing the failure(s).

Definition at line 84 of file DiscretePhotoelectronPulse.cxx.

85 {
86  assert(pulseLength() > 0);
87  auto const low = *(fSampledShape.subsample(0).begin());
88  auto const high
89  = *(fSampledShape.subsample(fSampledShape.nSubsamples() - 1).rbegin());
90 
91  bool const bLowOk = (low.abs() < limit);
92  bool const bHighOk = (high.abs() < limit);
93  if (bLowOk && bHighOk) return true;
94  if (!outputCat.empty()) {
95  mf::LogWarning log(outputCat);
96  log << "Check on sampled photoelectron waveform template failed!";
97  if (!bLowOk) {
98  log << "\n => low tail at the starting of sampling is already " << low;
99  }
100  if (!bHighOk) {
101  log
102  << "\n => high tail at the end of sampling ("
103  << duration() << ") is still at " << high
104  ;
105  }
106  log << "\nShape parameters:" << shape().toString(" ", "");
107  } // if writing a message on failure
108  return false;
109 } // icarus::opdet::DiscretePhotoelectronPulse::checkRange()
gsl::index nSubsamples() const
Returns the number of subsamples.
std::size_t pulseLength() const
Returns the length of the sampled pulse in ticks.
standard_dbscan3dalg useful for diagnostics hits not in a line will not be clustered on on only for track like only for track like on on the smaller the less shower like tracks low
SampledFunction_t fSampledShape
Pulse shape, discretized.
SubsampleData_t subsample(gsl::index const n) const
Returns the data of the subsample with the specified index n.
std::string toString(std::string const &indent, std::string const &firstIndent) const
Returns the parameters of this shape as a descriptive string.
template<typename Stream >
void icarus::opdet::DiscretePhotoelectronPulse::dump ( Stream &&  out,
std::string const &  indent,
std::string const &  firstIndent 
) const

Prints on stream the parameters of this shape.

Template Parameters
Streamtype of stream to write into
Parameters
outthe stream to write into
indentindentation string, prepended to all lines except first
firstIndentindentation string prepended to the first line

Definition at line 251 of file DiscretePhotoelectronPulse.h.

254 {
255  out << firstIndent << "Sampled pulse waveform " << pulseLength()
256  << " samples long (" << duration()
257  << " long, sampled at " << samplingFrequency()
258  << ");"
259  << "\n" << shape().toString(indent + " ", indent);
260  fSampledShape.dump(out, indent + " ", indent);
261 } // icarus::opdet::DiscretePhotoelectronPulse::dump()
std::size_t pulseLength() const
Returns the length of the sampled pulse in ticks.
gigahertz samplingFrequency() const
Returns the sampling frequency (same units as entered).
SampledFunction_t fSampledShape
Pulse shape, discretized.
void dump(Stream &&out, std::string const &indent, std::string const &firstIndent) const
Dumps the full content of the sampling into out stream.
std::string toString(std::string const &indent, std::string const &firstIndent) const
Returns the parameters of this shape as a descriptive string.
template<typename Stream >
void icarus::opdet::DiscretePhotoelectronPulse::dump ( Stream &&  out,
std::string const &  indent = "" 
) const
inline

Definition at line 191 of file DiscretePhotoelectronPulse.h.

192  { dump(std::forward<Stream>(out), indent, indent); }
void dump(Stream &&out, std::string const &indent, std::string const &firstIndent) const
Prints on stream the parameters of this shape.
nanoseconds icarus::opdet::DiscretePhotoelectronPulse::duration ( ) const
inline

Returns the duration of the waveform in time units.

See Also
pulseLength()

Definition at line 172 of file DiscretePhotoelectronPulse.h.

172 { return pulseLength() * samplingPeriod(); }
std::size_t pulseLength() const
Returns the length of the sampled pulse in ticks.
nanoseconds samplingPeriod() const
Returns the sampling period (inverse of frequency).
SubsampleIndex_t icarus::opdet::DiscretePhotoelectronPulse::nSubsamples ( ) const
inline

Definition at line 147 of file DiscretePhotoelectronPulse.h.

147 { return fSampledShape.nSubsamples(); }
gsl::index nSubsamples() const
Returns the number of subsamples.
SampledFunction_t fSampledShape
Pulse shape, discretized.
ADCcount icarus::opdet::DiscretePhotoelectronPulse::operator() ( Time_t  time) const
inline

Evaluates the shape at the specified time.

Definition at line 117 of file DiscretePhotoelectronPulse.h.

117 { return shape()(time); }
ADCcount icarus::opdet::DiscretePhotoelectronPulse::peakAmplitude ( ) const
inline

Returns the peak amplitude in ADC counts.

Definition at line 159 of file DiscretePhotoelectronPulse.h.

159 { return shape().peakAmplitude(); }
ADCcount peakAmplitude() const
Returns the amplitude of the first peak in ADC counts.
nanoseconds icarus::opdet::DiscretePhotoelectronPulse::peakTime ( ) const
inline

Returns the time at the peak from the beginning of sampling.

Definition at line 162 of file DiscretePhotoelectronPulse.h.

162 { return shape().peakTime(); }
Time peakTime() const
Returns the time at which the first peak is found.
std::size_t icarus::opdet::DiscretePhotoelectronPulse::pulseLength ( ) const
inline

Returns the length of the sampled pulse in ticks.

Definition at line 114 of file DiscretePhotoelectronPulse.h.

114 { return fSampledShape.size(); }
gsl::index size() const
Returns the number of samples (in each subsample).
SampledFunction_t fSampledShape
Pulse shape, discretized.
auto icarus::opdet::DiscretePhotoelectronPulse::sampleShape ( PulseFunction_t const &  pulseShape,
gigahertz  samplingFreq,
unsigned int  nSubsamples,
ADCcount  threshold 
)
staticprivate

Builds the sampling cache.

Definition at line 25 of file DiscretePhotoelectronPulse.cxx.

30 {
31  using namespace util::quantities::time_literals;
32  using namespace icarus::waveform_operations;
33 
34  // pick the function according to polarity;
35  // the pulse polarity is included in the values,
36  // the two functions (lambda) are of different type, so they are being wrapped
37  // in the common `std::function` type
38 
39  // FIXME Clang 7.0.0 can't figure out the parameters of std::function
40  // (GCC 8.2 can): specifying them explicitly...
41  auto const isBelowThreshold = (pulseShape.polarity() == +1)
42 #if defined(__clang__) && (__clang_major__ < 8)
43  ? std::function<bool(nanoseconds, ADCcount)>(
44 #else // not Clang <8
45  ? std::function(
46 #endif // defined(__clang__) && (__clang_major__ < 8)
47  [baseline=pulseShape.baseline(), threshold](nanoseconds, ADCcount s)
48  {
49  return
51  < threshold
52  ;
53  }
54  )
55 #if defined(__clang__) && (__clang_major__ < 8)
56  : std::function<bool(nanoseconds, ADCcount)>(
57 #else // not Clang <8
58  : std::function(
59 #endif // defined(__clang__) && (__clang_major__ < 8)
60  [baseline=pulseShape.baseline(), threshold](nanoseconds, ADCcount s)
61  {
62  return
64  < threshold
65  ;
66  }
67  )
68  ;
69 
70  return SampledFunction_t{
71  std::cref(pulseShape), // function to sample (by reference because abstract)
72  0.0_ns, // sampling start time
73  1.0 / samplingFreq, // tick duration
74  isBelowThreshold, // when to stop the sampling
75  static_cast<gsl::index>(nSubsamples), // how many subsamples per tick
76  pulseShape.peakTime() // sample at least until here
77  };
78 
79 } // icarus::opdet::DiscretePhotoelectronPulse::sampleShape()
util::SampledFunction< nanoseconds, ADCcount > SampledFunction_t
Internal discretized representation of the sampled pulse shape.
Operations< Sample,-1 > NegativePolarityOperations
Waveform operations for negative polarity waveforms.
BEGIN_PROLOG baseline
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not defined
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
Operations< Sample,+1 > PositivePolarityOperations
Waveform operations for positive polarity waveforms.
gigahertz icarus::opdet::DiscretePhotoelectronPulse::samplingFrequency ( ) const
inline

Returns the sampling frequency (same units as entered).

Definition at line 165 of file DiscretePhotoelectronPulse.h.

165 { return fSamplingFreq; }
nanoseconds icarus::opdet::DiscretePhotoelectronPulse::samplingPeriod ( ) const
inline

Returns the sampling period (inverse of frequency).

Definition at line 168 of file DiscretePhotoelectronPulse.h.

168 { return 1.0 / samplingFrequency(); }
gigahertz samplingFrequency() const
Returns the sampling frequency (same units as entered).
PulseFunction_t const& icarus::opdet::DiscretePhotoelectronPulse::shape ( ) const
inline

Definition at line 156 of file DiscretePhotoelectronPulse.h.

156 { return fShape; }
PulseFunction_t const & fShape
Analytical shape of the pules.
decltype(auto) icarus::opdet::DiscretePhotoelectronPulse::subsample ( SubsampleIndex_t  i) const
inline

Returns the subsample specified by index i, undefined if invalid.

Definition at line 139 of file DiscretePhotoelectronPulse.h.

140  { return fSampledShape.subsample(i); }
SampledFunction_t fSampledShape
Pulse shape, discretized.
SubsampleData_t subsample(gsl::index const n) const
Returns the data of the subsample with the specified index n.
decltype(auto) icarus::opdet::DiscretePhotoelectronPulse::subsampleFor ( Time_t  time) const
inline

Returns the index of the subsample whose tick left limit is closest to time (see util::SampledFunction::closestSubsampleIndex()).

Definition at line 144 of file DiscretePhotoelectronPulse.h.

SampledFunction_t fSampledShape
Pulse shape, discretized.
gsl::index closestSubsampleIndex(X_t x) const
Returns the subsample closest to the value x.
decltype(auto) subsample(SubsampleIndex_t i) const
Returns the subsample specified by index i, undefined if invalid.

Member Data Documentation

SampledFunction_t icarus::opdet::DiscretePhotoelectronPulse::fSampledShape
private

Pulse shape, discretized.

Definition at line 215 of file DiscretePhotoelectronPulse.h.

gigahertz icarus::opdet::DiscretePhotoelectronPulse::fSamplingFreq
private

Sampling frequency.

Definition at line 212 of file DiscretePhotoelectronPulse.h.

PulseFunction_t const& icarus::opdet::DiscretePhotoelectronPulse::fShape
private

Analytical shape of the pules.

Definition at line 211 of file DiscretePhotoelectronPulse.h.


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