LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pmtana::PMTPulseRecoBase Class Referenceabstract

#include "PMTPulseRecoBase.h"

Inheritance diagram for pmtana::PMTPulseRecoBase:
pmtana::AlgoCFD pmtana::AlgoFixedWindow pmtana::AlgoSiPM pmtana::AlgoSlidingWindow pmtana::AlgoThreshold

Public Member Functions

 PMTPulseRecoBase (const std::string name="noname")
 Default constructor with fhicl parameters. More...
 
virtual ~PMTPulseRecoBase ()=default
 Default destructor. More...
 
const std::string & Name () const
 Name getter. More...
 
bool Status () const
 Status getter. More...
 
virtual void Reset ()
 A method to be called event-wise to reset parameters. More...
 
bool Reconstruct (const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
 
const pulse_paramGetPulse (size_t index=0) const
 
const pulse_param_arrayGetPulses () const
 A getter for the whole array of pulse_param struct object. More...
 
size_t GetNPulse () const
 A getter for the number of reconstructed pulses from the input waveform. More...
 

Protected Member Functions

virtual bool RecoPulse (const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)=0
 
bool Integral (const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
 
bool Derivative (const std::vector< short > &wf, std::vector< int32_t > &diff, size_t begin=0, size_t end=0) const
 
size_t Max (const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
 
size_t Min (const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
 

Protected Attributes

pulse_param_array _pulse_v
 A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s). More...
 
pulse_param _pulse
 A subject pulse_param object to be filled with the last reconstructed pulse parameters. More...
 
std::unique_ptr< pmtana::RiseTimeCalculatorBase_risetime_calc_ptr = nullptr
 Tool for rise time calculation. More...
 

Private Attributes

std::string _name
 Unique name. More...
 
bool _status
 Status after pulse reconstruction. More...
 

Detailed Description

The base class of pulse reconstruction algorithms. All algorithms should inherit from this calss to be executed by a manager class, pulse_reco. Note that this class does not depend on the rest of the framework except for the use of constants. In order to reconstruct a pulse, all it requires is a std::vector<short> type object (i.e. raw waveform), waveform pedestal, and its standard deviation. All of these are to be provided by an executer. Reconstructed pulse parameters are stored in the pulse_param struct object.

All methods specified as "virtual" should be implemented by the inherit children class.

This class provides some basic std::vector calculation algorithms such as integral, derivative, max and min algorithms. Inherit children classes are encouraged to use these provided methods when possible.

Definition at line 66 of file PMTPulseRecoBase.h.

Constructor & Destructor Documentation

pmtana::PMTPulseRecoBase::PMTPulseRecoBase ( const std::string  name = "noname")

Default constructor with fhicl parameters.

Definition at line 15 of file PMTPulseRecoBase.cxx.

References Reset().

15  : _name(name), _status(true)
16  //*************************************************************************
17  {
18  Reset();
19  }
bool _status
Status after pulse reconstruction.
virtual void Reset()
A method to be called event-wise to reset parameters.
std::string _name
Unique name.
virtual pmtana::PMTPulseRecoBase::~PMTPulseRecoBase ( )
virtualdefault

Default destructor.

Member Function Documentation

bool pmtana::PMTPulseRecoBase::Derivative ( const std::vector< short > &  wf,
std::vector< int32_t > &  diff,
size_t  begin = 0,
size_t  end = 0 
) const
protected

A method to compute derivative, which is a simple subtraction of previous ADC sample from each sample. The result is stored in the input "diff" reference vector which is int32_t type as a derivative could be negative.

Definition at line 121 of file PMTPulseRecoBase.cxx.

References util::begin(), pmtana::CheckIndex(), and util::end().

126  {
127 
128  if (CheckIndex(wf, begin, end)) {
129 
130  diff.clear();
131  diff.reserve(end - begin);
132 
133  for (size_t index = begin; index <= end; ++index)
134 
135  diff.push_back(wf.at(index + 1) - wf.at(index));
136 
137  return true;
138  }
139 
140  return false;
141  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
size_t pmtana::PMTPulseRecoBase::GetNPulse ( ) const
inline

A getter for the number of reconstructed pulses from the input waveform.

Definition at line 101 of file PMTPulseRecoBase.h.

Referenced by opdet::LEDCalibrationAna::analyze().

101 { return _pulse_v.size(); };
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
const pulse_param & pmtana::PMTPulseRecoBase::GetPulse ( size_t  index = 0) const

A getter for the pulse_param struct object. Reconstruction algorithm may have more than one pulse reconstructed from an input waveform. Note you must, accordingly, provide an index key to specify which pulse_param object to be retrieved.

Definition at line 74 of file PMTPulseRecoBase.cxx.

References _pulse_v.

Referenced by opdet::LEDCalibrationAna::analyze().

76  {
77 
78  if (index >= _pulse_v.size()) {
79 
80  std::cerr << "\033[93m"
81  << "Invalid pulse index: " << index << "\033[00m" << std::endl;
82 
83  throw std::exception();
84  }
85 
86  else
87  return _pulse_v.at(index);
88  }
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const pulse_param_array & pmtana::PMTPulseRecoBase::GetPulses ( ) const

A getter for the whole array of pulse_param struct object.

Definition at line 91 of file PMTPulseRecoBase.cxx.

References _pulse_v.

Referenced by opdet::RunHitFinder().

93  {
94  return _pulse_v;
95  }
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
bool pmtana::PMTPulseRecoBase::Integral ( const std::vector< short > &  wf,
double &  result,
size_t  begin = 0,
size_t  end = 0 
) const
protected

A method to integrate an waveform from index "begin" to the "end". The result is filled in "result" reference. If the "end" is default (=0), then "end" is set to the last index of the waveform.

Definition at line 98 of file PMTPulseRecoBase.cxx.

References util::begin(), pmtana::CheckIndex(), and util::end().

Referenced by pmtana::AlgoFixedWindow::RecoPulse().

103  {
104 
105  if (!CheckIndex(wf, begin, end)) return false;
106 
107  std::vector<short>::const_iterator begin_iter(wf.begin());
108 
109  std::vector<short>::const_iterator end_iter(wf.begin());
110 
111  begin_iter = begin_iter + begin;
112 
113  end_iter = end_iter + end + 1;
114 
115  result = (double)(std::accumulate(begin_iter, end_iter, 0));
116 
117  return true;
118  }
intermediate_table::const_iterator const_iterator
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
size_t pmtana::PMTPulseRecoBase::Max ( const std::vector< short > &  wf,
double &  result,
size_t  begin = 0,
size_t  end = 0 
) const
protected

A method to return the maximum value of ADC sample within the index from "begin" to "end". If the "end" is default (=0), then "end" is set to the last index of the waveform.

Definition at line 144 of file PMTPulseRecoBase.cxx.

References util::begin(), pmtana::CheckIndex(), and util::end().

Referenced by pmtana::AlgoFixedWindow::RecoPulse().

149  {
150 
151  size_t target_index = wf.size() + 1;
152 
153  result = 0;
154 
155  if (CheckIndex(wf, begin, end)) {
156 
157  for (size_t index = begin; index <= end; ++index)
158 
159  if (result < wf.at(index)) {
160  target_index = index;
161  result = (double)(wf.at(index));
162  }
163  }
164 
165  return target_index;
166  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
size_t pmtana::PMTPulseRecoBase::Min ( const std::vector< short > &  wf,
double &  result,
size_t  begin = 0,
size_t  end = 0 
) const
protected

A method to return the minimum value of ADC sample within the index from "begin" to "end". If the "end" is default (=0), then "end" is set to the last index of the waveform.

Definition at line 169 of file PMTPulseRecoBase.cxx.

References util::begin(), pmtana::CheckIndex(), and util::end().

174  {
175 
176  size_t target_index = wf.size() + 1;
177 
178  result = 4096;
179 
180  if (CheckIndex(wf, begin, end)) {
181 
182  for (size_t index = begin; index <= end; ++index)
183 
184  if (result > wf.at(index)) {
185  target_index = index;
186  result = (double)(wf.at(index));
187  }
188  }
189 
190  return target_index;
191  }
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
const std::string & pmtana::PMTPulseRecoBase::Name ( ) const

Name getter.

Definition at line 22 of file PMTPulseRecoBase.cxx.

References _name.

24  {
25  return _name;
26  }
std::string _name
Unique name.
bool pmtana::PMTPulseRecoBase::Reconstruct ( const pmtana::Waveform_t wf,
const pmtana::PedestalMean_t mean_v,
const pmtana::PedestalSigma_t sigma_v 
)

A core method: this executes the algorithm and stores reconstructed parameters in the pulse_param struct object.

Definition at line 36 of file PMTPulseRecoBase.cxx.

References _status, and RecoPulse().

40  {
41  _status = this->RecoPulse(wf, mean_v, sigma_v);
42  return _status;
43  }
bool _status
Status after pulse reconstruction.
virtual bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)=0
virtual bool pmtana::PMTPulseRecoBase::RecoPulse ( const pmtana::Waveform_t ,
const pmtana::PedestalMean_t ,
const pmtana::PedestalSigma_t  
)
protectedpure virtual
void pmtana::PMTPulseRecoBase::Reset ( )
virtual

A method to be called event-wise to reset parameters.

Reimplemented in pmtana::AlgoFixedWindow, pmtana::AlgoCFD, pmtana::AlgoThreshold, pmtana::AlgoSlidingWindow, and pmtana::AlgoSiPM.

Definition at line 63 of file PMTPulseRecoBase.cxx.

References _pulse, _pulse_v, and pmtana::pulse_param::reset_param().

Referenced by PMTPulseRecoBase(), pmtana::AlgoSiPM::Reset(), pmtana::AlgoSlidingWindow::Reset(), pmtana::AlgoThreshold::Reset(), and pmtana::AlgoCFD::Reset().

65  {
67 
68  _pulse_v.clear();
69 
70  _pulse_v.reserve(3);
71  }
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
bool pmtana::PMTPulseRecoBase::Status ( ) const

Status getter.

Definition at line 29 of file PMTPulseRecoBase.cxx.

References _status.

31  {
32  return _status;
33  }
bool _status
Status after pulse reconstruction.

Member Data Documentation

std::string pmtana::PMTPulseRecoBase::_name
private

Unique name.

Definition at line 101 of file PMTPulseRecoBase.h.

Referenced by Name().

pulse_param pmtana::PMTPulseRecoBase::_pulse
protected
pulse_param_array pmtana::PMTPulseRecoBase::_pulse_v
protected
bool pmtana::PMTPulseRecoBase::_status
private

Status after pulse reconstruction.

Definition at line 108 of file PMTPulseRecoBase.h.

Referenced by Reconstruct(), and Status().


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