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

#include "AlgoSiPM.h"

Inheritance diagram for pmtana::AlgoSiPM:
pmtana::PMTPulseRecoBase

Public Member Functions

 AlgoSiPM (const fhicl::ParameterSet &pset, std::unique_ptr< pmtana::RiseTimeCalculatorBase > risetimecalculator=nullptr, const std::string name="AlgoSiPM")
 
void Reset ()
 A method to be called event-wise to reset parameters. 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 &)
 
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

double _adc_thres
 
int _min_width
 
double _2nd_thres
 
double _pedestal
 
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

Definition at line 24 of file AlgoSiPM.h.

Constructor & Destructor Documentation

pmtana::AlgoSiPM::AlgoSiPM ( const fhicl::ParameterSet pset,
std::unique_ptr< pmtana::RiseTimeCalculatorBase risetimecalculator = nullptr,
const std::string  name = "AlgoSiPM" 
)

Definition at line 12 of file AlgoSiPM.cxx.

References _2nd_thres, _adc_thres, _min_width, _pedestal, pmtana::PMTPulseRecoBase::_risetime_calc_ptr, fhicl::ParameterSet::get(), and Reset().

15  : PMTPulseRecoBase(name)
16  {
17 
18  _adc_thres = pset.get<float>("ADCThreshold");
19  _min_width = pset.get<float>("MinWidth");
20  _2nd_thres = pset.get<float>("SecondThreshold");
21  _pedestal = pset.get<float>("Pedestal");
22 
23  _risetime_calc_ptr = std::move(risetimecalculator);
24 
25  // _nsigma = 5;
26 
27  Reset();
28  }
double _adc_thres
Definition: AlgoSiPM.h:47
double _2nd_thres
Definition: AlgoSiPM.h:53
T get(std::string const &key) const
Definition: ParameterSet.h:314
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:31
double _pedestal
Definition: AlgoSiPM.h:56
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.

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 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
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 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
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::AlgoSiPM::RecoPulse ( const pmtana::Waveform_t wf,
const pmtana::PedestalMean_t ped_mean,
const pmtana::PedestalSigma_t ped_rms 
)
protectedvirtual

Implements pmtana::PMTPulseRecoBase.

Definition at line 37 of file AlgoSiPM.cxx.

References _2nd_thres, _adc_thres, _min_width, pmtana::PMTPulseRecoBase::_pulse, pmtana::PMTPulseRecoBase::_pulse_v, pmtana::PMTPulseRecoBase::_risetime_calc_ptr, pmtana::pulse_param::area, util::counter(), pmtana::pulse_param::peak, Reset(), pmtana::pulse_param::reset_param(), pmtana::pulse_param::t_end, pmtana::pulse_param::t_max, pmtana::pulse_param::t_rise, pmtana::pulse_param::t_start, and value.

40  {
41 
42  bool fire = false;
43  bool record_hit = false;
44  int counter = 0;
45  // double threshold = (_2nd_thres > (_nsigma*_ped_rms) ? _2nd_thres
46  // : (_nsigma*_ped_rms));
47  //double pedestal = _pedestal;
48  double pedestal =
49  ped_mean
50  .front(); //Switch pedestal definition to incoroprate pedestal finder - K.S. 04/18/2019
51 
52  double threshold = _adc_thres;
53  threshold += pedestal;
54  double pre_threshold = _2nd_thres;
55  pre_threshold += pedestal;
56 
57  Reset();
58 
59  for (short const& value : wf) {
60 
61  if (!fire && (double(value) >= pre_threshold)) {
62 
63  // Found a new pulse
64  fire = true;
65  record_hit = false;
67  }
68 
69  if (fire && (double(value) < pre_threshold)) {
70 
71  // Found the end of a pulse
72  fire = false;
73  _pulse.t_end = counter - 1;
74  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width)) {
76  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
77  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
78  {ped_mean.begin() + _pulse.t_start, ped_mean.begin() + _pulse.t_end},
79  true);
80 
81  _pulse_v.push_back(_pulse);
82  record_hit = false;
83  }
85  }
86 
87  if (fire) {
88 
89  // We want to record the hit only if _adc_thres is reached
90  if (!record_hit && (double(value) >= threshold)) record_hit = true;
91 
92  // Add this ADC count to the integral
93  _pulse.area += (double(value) - double(pedestal));
94 
95  if (_pulse.peak < (double(value) - double(pedestal))) {
96 
97  // Found a new maximum
98  _pulse.peak = (double(value) - double(pedestal));
100  }
101  }
102 
103  counter++;
104  }
105 
106  if (fire) {
107 
108  // Take care of a pulse that did not finish within the readout window
109  fire = false;
110  _pulse.t_end = counter - 1;
111  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width)) {
112  if (_risetime_calc_ptr)
113  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
114  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
115  {ped_mean.begin() + _pulse.t_start, ped_mean.begin() + _pulse.t_end},
116  true);
117 
118  _pulse_v.push_back(_pulse);
119  record_hit = false;
120  }
122  }
123 
124  return true;
125  }
double _adc_thres
Definition: AlgoSiPM.h:47
double _2nd_thres
Definition: AlgoSiPM.h:53
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
double value
Definition: spectrum.C:18
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:31
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
void pmtana::AlgoSiPM::Reset ( )
virtual

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

Reimplemented from pmtana::PMTPulseRecoBase.

Definition at line 31 of file AlgoSiPM.cxx.

References pmtana::PMTPulseRecoBase::Reset().

Referenced by AlgoSiPM(), and RecoPulse().

32  {
34  }
virtual void Reset()
A method to be called event-wise to reset parameters.
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

double pmtana::AlgoSiPM::_2nd_thres
protected

Definition at line 53 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

double pmtana::AlgoSiPM::_adc_thres
protected

Definition at line 47 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

int pmtana::AlgoSiPM::_min_width
protected

Definition at line 50 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

double pmtana::AlgoSiPM::_pedestal
protected

Definition at line 56 of file AlgoSiPM.h.

Referenced by AlgoSiPM().

pulse_param pmtana::PMTPulseRecoBase::_pulse
protectedinherited

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