All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DiscretePhotoelectronPulse.cxx
Go to the documentation of this file.
1 /**
2  * @file icaruscode/PMT/Algorithms/DiscretePhotoelectronPulse.cxx
3  * @brief Sampling of a photoelectron pulse (implementation file).
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date March 17, 2020
6  * @see `icaruscode/PMT/Algorithms/DiscretePhotoelectronPulse.h`
7  *
8  */
9 
10 // library header
13 
14 // framework libraries
15 #include "messagefacility/MessageLogger/MessageLogger.h"
16 
17 // C++ standard library
18 #include <functional> // std::function
19 #include <utility> // std::cref()
20 
21 
22 // -----------------------------------------------------------------------------
23 // --- icarus::opdet::DiscretePhotoelectronPulse
24 // -----------------------------------------------------------------------------
26  PulseFunction_t const& pulseShape,
27  gigahertz samplingFreq, unsigned int nSubsamples,
28  ADCcount threshold
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()
80 
81 
82 // -----------------------------------------------------------------------------
84  (ADCcount limit, std::string const& outputCat /* = "" */) const
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()
110 
111 
112 // -----------------------------------------------------------------------------
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
Operations< Sample,-1 > NegativePolarityOperations
Waveform operations for negative polarity waveforms.
bool checkRange(ADCcount limit, std::string const &outputCat) const
Checks that the waveform tails not sampled are negligible.
A value measured in the specified unit.
Definition: quantities.h:566
BEGIN_PROLOG baseline
static SampledFunction_t sampleShape(PulseFunction_t const &pulseShape, gigahertz samplingFreq, unsigned int nSubsamples, ADCcount threshold)
Builds the sampling cache.
Interface for a function describing a pulse from a photoelectron.
Operations on waveform samples.
Sampling of a photoelectron pulse.
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.
nanosecond nanoseconds
Alias for common language habits.
Definition: spacetime.h:139