LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pmtana::AlgoFixedWindow Class Reference

#include "AlgoFixedWindow.h"

Inheritance diagram for pmtana::AlgoFixedWindow:
pmtana::PMTPulseRecoBase

Public Member Functions

 AlgoFixedWindow (const std::string name="FixedWindow")
 Default ctor. More...
 
 AlgoFixedWindow (const fhicl::ParameterSet &pset, std::unique_ptr< pmtana::RiseTimeCalculatorBase > risetimecalculator=nullptr, const std::string name="FixedWindow")
 Alternative ctor. More...
 
void Reset ()
 Implementation of AlgoFixedWindow::reset() method. More...
 
const std::string & Name () const
 Name getter. More...
 
bool Status () const
 Status getter. 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

bool RecoPulse (const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
 Implementation of AlgoFixedWindow::reco() method. More...
 
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

size_t _index_start
 index marker for the beginning of the pulse time window More...
 
size_t _index_end
 index marker for the end of pulse time window More...
 
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...
 

Detailed Description

This class implements fixed_window algorithm to AlgoFixedWindow class. The algorithm defines a pulse in user-specified time window. A typical usage is to set the beginning of the window to be 0 (= start of the waveform) and integrate over the time of interest. By default, the ending is set to index=0, in which case it uses the ending index of the input waveform (i.e. full integration).

Definition at line 38 of file AlgoFixedWindow.h.

Constructor & Destructor Documentation

pmtana::AlgoFixedWindow::AlgoFixedWindow ( const std::string  name = "FixedWindow")

Default ctor.

Definition at line 14 of file AlgoFixedWindow.cxx.

References _index_end, _index_start, and Reset().

14  : PMTPulseRecoBase(name)
15  //*******************************************************************************
16  {
17  Reset();
18 
19  _index_start = 0;
20 
21  _index_end = 0;
22  }
size_t _index_end
index marker for the end of pulse time window
size_t _index_start
index marker for the beginning of the pulse time window
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
void Reset()
Implementation of AlgoFixedWindow::reset() method.
pmtana::AlgoFixedWindow::AlgoFixedWindow ( const fhicl::ParameterSet pset,
std::unique_ptr< pmtana::RiseTimeCalculatorBase risetimecalculator = nullptr,
const std::string  name = "FixedWindow" 
)

Alternative ctor.

Definition at line 25 of file AlgoFixedWindow.cxx.

References _index_end, _index_start, pmtana::PMTPulseRecoBase::_risetime_calc_ptr, fhicl::ParameterSet::get(), and Reset().

30  : PMTPulseRecoBase(name)
31  //****************************************************************************************
32  {
33  _risetime_calc_ptr = std::move(risetimecalculator);
34 
35  Reset();
36 
37  _index_start = pset.get<size_t>("StartIndex");
38 
39  _index_end = pset.get<size_t>("EndIndex");
40  }
size_t _index_end
index marker for the end of pulse time window
size_t _index_start
index marker for the beginning of the pulse time window
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
void Reset()
Implementation of AlgoFixedWindow::reset() method.

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
protectedinherited

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
inlineinherited

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
inherited

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 pmtana::PMTPulseRecoBase::_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
inherited

A getter for the whole array of pulse_param struct object.

Definition at line 91 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_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
protectedinherited

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 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
protectedinherited

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 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
protectedinherited

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
inherited

Name getter.

Definition at line 22 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_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 
)
inherited

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 pmtana::PMTPulseRecoBase::_status, and pmtana::PMTPulseRecoBase::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
bool pmtana::AlgoFixedWindow::RecoPulse ( const pmtana::Waveform_t wf,
const pmtana::PedestalMean_t mean_v,
const pmtana::PedestalSigma_t sigma_v 
)
protectedvirtual

Implementation of AlgoFixedWindow::reco() method.

Implements pmtana::PMTPulseRecoBase.

Definition at line 52 of file AlgoFixedWindow.cxx.

References _index_end, _index_start, pmtana::PMTPulseRecoBase::_pulse, pmtana::PMTPulseRecoBase::_pulse_v, pmtana::PMTPulseRecoBase::_risetime_calc_ptr, pmtana::PMTPulseRecoBase::Integral(), pmtana::PMTPulseRecoBase::Max(), Reset(), pmtana::pulse_param::t_end, and pmtana::pulse_param::t_start.

56  {
57  this->Reset();
58 
59  if (_index_start >= wf.size()) return true;
60 
61  _pulse_v[0].t_start = (double)(_index_start);
62 
63  _pulse_v[0].ped_mean = mean_v.front();
64 
65  _pulse_v[0].ped_sigma = sigma_v.front();
66 
67  if (!_index_end)
68 
69  _pulse_v[0].t_end = (double)(wf.size() - 1);
70 
71  else if (_index_end < wf.size())
72 
73  _pulse_v[0].t_end = (double)_index_end;
74 
75  else
76 
77  _pulse_v[0].t_end = wf.size() - 1;
78 
79  _pulse_v[0].t_max =
80  PMTPulseRecoBase::Max(wf, _pulse_v[0].peak, _index_start, _pulse_v[0].t_end);
81 
82  _pulse_v[0].peak -= mean_v.front();
83 
85 
86  _pulse_v[0].area =
87  _pulse_v[0].area - (_pulse_v[0].t_end - _pulse_v[0].t_start + 1) * mean_v.front();
88 
90  _pulse_v[0].t_rise = _risetime_calc_ptr->RiseTime(
91  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
92  {mean_v.begin() + _pulse.t_start, mean_v.begin() + _pulse.t_end},
93  true);
94 
95  return true;
96  }
bool Integral(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
size_t _index_end
index marker for the end of pulse time window
size_t _index_start
index marker for the beginning of the pulse time window
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
size_t Max(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
void Reset()
Implementation of AlgoFixedWindow::reset() method.
void pmtana::AlgoFixedWindow::Reset ( )
virtual

Implementation of AlgoFixedWindow::reset() method.

Reimplemented from pmtana::PMTPulseRecoBase.

Definition at line 43 of file AlgoFixedWindow.cxx.

References pmtana::PMTPulseRecoBase::_pulse, and pmtana::PMTPulseRecoBase::_pulse_v.

Referenced by AlgoFixedWindow(), and RecoPulse().

45  {
46  if (!(_pulse_v.size())) _pulse_v.push_back(_pulse);
47 
48  _pulse_v[0].reset_param();
49  }
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
inherited

Status getter.

Definition at line 29 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_status.

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

Member Data Documentation

size_t pmtana::AlgoFixedWindow::_index_end
protected

index marker for the end of pulse time window

Definition at line 60 of file AlgoFixedWindow.h.

Referenced by AlgoFixedWindow(), and RecoPulse().

size_t pmtana::AlgoFixedWindow::_index_start
protected

index marker for the beginning of the pulse time window

Definition at line 59 of file AlgoFixedWindow.h.

Referenced by AlgoFixedWindow(), and RecoPulse().

pulse_param pmtana::PMTPulseRecoBase::_pulse
protectedinherited
pulse_param_array pmtana::PMTPulseRecoBase::_pulse_v
protectedinherited

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