LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
pmtana::AlgoSlidingWindow Class Reference

#include "AlgoSlidingWindow.h"

Inheritance diagram for pmtana::AlgoSlidingWindow:
pmtana::PMTPulseRecoBase

Public Member Functions

 AlgoSlidingWindow (const std::string name="SlidingWindow")
 Default constructor. More...
 
 AlgoSlidingWindow (const fhicl::ParameterSet &pset, const std::string name="SlidingWindow")
 Alternative ctor. More...
 
virtual ~AlgoSlidingWindow ()
 Default destructor. More...
 
void Reset ()
 Implementation of AlgoSlidingWindow::reset() method. More...
 
const std::string & Name () const
 Name getter. More...
 
const 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 AlgoSlidingWindow::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

float _adc_thres
 A variable holder for a user-defined absolute ADC threshold value. More...
 
float _end_adc_thres
 
float _nsigma
 A variable holder for a multiplicative factor for the pedestal standard deviation to define the threshold. More...
 
float _end_nsigma
 
bool _verbose
 
size_t _num_presample
 
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...
 

Detailed Description

This class implements threshold algorithm to AlgoSlidingWindow class.

Definition at line 29 of file AlgoSlidingWindow.h.

Constructor & Destructor Documentation

pmtana::AlgoSlidingWindow::AlgoSlidingWindow ( const std::string  name = "SlidingWindow")

Default constructor.

Definition at line 15 of file AlgoSlidingWindow.cxx.

16  : PMTPulseRecoBase(name)
17  //*********************************************************************
18  {}
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
pmtana::AlgoSlidingWindow::AlgoSlidingWindow ( const fhicl::ParameterSet pset,
const std::string  name = "SlidingWindow" 
)

Alternative ctor.

Definition at line 21 of file AlgoSlidingWindow.cxx.

References _adc_thres, _end_adc_thres, _end_nsigma, _nsigma, _num_presample, _verbose, fhicl::ParameterSet::get(), and Reset().

24  : PMTPulseRecoBase(name)
25  //*********************************************************************
26  {
27 
28  _adc_thres = pset.get<float>("ADCThreshold");
29 
30  _end_adc_thres = pset.get<float>("EndADCThreshold");
31 
32  _nsigma = pset.get<float>("NSigmaThreshold");
33 
34  _end_nsigma = pset.get<float>("EndNSigmaThreshold");
35 
36  _verbose = pset.get<bool>("Verbosity");
37 
38  _num_presample = pset.get<size_t>("NumPreSample");
39 
40  Reset();
41 
42  }
float _nsigma
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
T get(std::string const &key) const
Definition: ParameterSet.h:231
void Reset()
Implementation of AlgoSlidingWindow::reset() method.
float _adc_thres
A variable holder for a user-defined absolute ADC threshold value.
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
pmtana::AlgoSlidingWindow::~AlgoSlidingWindow ( )
virtual

Default destructor.

Definition at line 45 of file AlgoSlidingWindow.cxx.

47  {}

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 122 of file PMTPulseRecoBase.cxx.

References evd::details::begin(), pmtana::CheckIndex(), and evd::details::end().

127  {
128 
129  if(CheckIndex(wf,begin,end)){
130 
131  diff.clear();
132  diff.reserve(end - begin);
133 
134  for(size_t index = begin ; index <= end ; ++index)
135 
136  diff.push_back(wf.at(index+1) - wf.at(index));
137 
138  return true;
139  }
140 
141  return false;
142 
143  }
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
size_t pmtana::PMTPulseRecoBase::GetNPulse ( ) const
inlineinherited

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

Definition at line 106 of file PMTPulseRecoBase.h.

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

106 {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 73 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_pulse_v.

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

75  {
76 
77  if(index >= _pulse_v.size()) {
78 
79  std::cerr << "\033[93m"
80  << "Invalid pulse index: " << index
81  << "\033[00m"
82  << std::endl;
83 
84  throw std::exception();
85  }
86 
87  else return _pulse_v.at(index);
88 
89  }
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 92 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_pulse_v.

Referenced by opdet::RunHitFinder().

94  {
95  return _pulse_v;
96  }
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 99 of file PMTPulseRecoBase.cxx.

References evd::details::begin(), pmtana::CheckIndex(), and evd::details::end().

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

104  {
105 
106  if(!CheckIndex(wf,begin,end)) return false;
107 
108  std::vector<short>::const_iterator begin_iter(wf.begin());
109 
110  std::vector<short>::const_iterator end_iter(wf.begin());
111 
112  begin_iter = begin_iter + begin;
113 
114  end_iter = end_iter + end + 1;
115 
116  result = (double)(std::accumulate(begin_iter, end_iter, 0));
117 
118  return true;
119  }
intermediate_table::const_iterator const_iterator
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
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 146 of file PMTPulseRecoBase.cxx.

References evd::details::begin(), pmtana::CheckIndex(), and evd::details::end().

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

151  {
152 
153  size_t target_index = wf.size() + 1;
154 
155  result = 0;
156 
157  if(CheckIndex(wf,begin,end)) {
158 
159  for(size_t index = begin; index <= end; ++index)
160 
161  if( result < wf.at(index)) { target_index = index; result = (double)(wf.at(index)); }
162 
163  }
164 
165  return target_index;
166 
167  }
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
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 170 of file PMTPulseRecoBase.cxx.

References evd::details::begin(), pmtana::CheckIndex(), and evd::details::end().

175  {
176 
177  size_t target_index = wf.size() + 1;
178 
179  result = 4096;
180 
181  if(CheckIndex(wf,begin,end)) {
182 
183  for(size_t index = begin; index <= end; ++index)
184 
185  if( result > wf.at(index)) { target_index = index; result = (double)(wf.at(index)); }
186 
187  }
188 
189  return target_index;
190 
191  }
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
const std::string & pmtana::PMTPulseRecoBase::Name ( ) const
inherited

Name getter.

Definition at line 21 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_name.

23  { return _name; }
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::AlgoSlidingWindow::RecoPulse ( const pmtana::Waveform_t wf,
const pmtana::PedestalMean_t mean_v,
const pmtana::PedestalSigma_t sigma_v 
)
protectedvirtual

Implementation of AlgoSlidingWindow::reco() method.

Implements pmtana::PMTPulseRecoBase.

Definition at line 57 of file AlgoSlidingWindow.cxx.

References _adc_thres, _end_adc_thres, _end_nsigma, _nsigma, _num_presample, pmtana::PMTPulseRecoBase::_pulse, pmtana::PMTPulseRecoBase::_pulse_v, _verbose, pmtana::pulse_param::area, pmtana::pulse_param::peak, pmtana::pulse_param::ped_mean, pmtana::pulse_param::ped_sigma, Reset(), pmtana::pulse_param::reset_param(), pmtana::pulse_param::t_end, pmtana::pulse_param::t_max, pmtana::pulse_param::t_start, and fhicl::detail::atom::value().

61  {
62 
63  bool fire = false;
64 
65  bool in_tail = false;
66 
67  double pulse_start_threshold=0;
68  double pulse_tail_threshold =0;
69 
70  double pulse_start_baseline =0;
71 
72  //double threshold = ( _adc_thres > (_nsigma * _ped_rms) ? _adc_thres : (_nsigma * _ped_rms) );
73 
74  //threshold += _ped_mean;
75 
76  Reset();
77 
78  for(size_t i=0; i<wf.size(); ++i) {
79 
80  auto const& value = wf[i];
81 
82  float start_threshold = mean_v.at(i);
83 
84  if(sigma_v.at(i) * _nsigma < _adc_thres) start_threshold += _adc_thres;
85  else start_threshold += sigma_v.at(i) * _nsigma;
86 
87  // End pulse if significantly high peak found (new pulse)
88  if( (!fire || in_tail) && (double)value > start_threshold ) {
89 
90 
91  // If there's a pulse, end it
92  if(in_tail) {
93  _pulse.t_end = i - 1;
94 
95  _pulse_v.push_back(_pulse);
96 
98 
99  if(_verbose)
100  std::cout << "\033[93mPulse End\033[00m: "
101  << "baseline: " << mean_v[i] << " ... " << " ... adc: " << value << " T=" << i << std::endl;
102  }
103 
104  //
105  // Found a new pulse ... try to get a few samples prior to this
106  //
107 
108  pulse_start_threshold = start_threshold;
109  pulse_start_baseline = mean_v.at(i);
110 
111  pulse_tail_threshold = pulse_start_baseline;
112  if(sigma_v.at(i) * _end_nsigma < _end_adc_thres) pulse_tail_threshold += _end_adc_thres;
113  else pulse_tail_threshold += sigma_v.at(i) * _end_nsigma;
114 
115  int last_pulse_end_index = 0;
116  if(_pulse_v.size()) last_pulse_end_index = _pulse_v.back().t_end;
117  int buffer_num_index = (int)i - last_pulse_end_index;
118  if(buffer_num_index > (int)_num_presample) buffer_num_index = _num_presample;
119 
120  if(buffer_num_index<0) {
121  std::cerr << "\033[95m[ERROR]\033[00m Logic error! Negative buffer_num_index..." << std::endl;
122  throw std::exception();
123  }
124 
125  _pulse.t_start = i - buffer_num_index;
126  _pulse.ped_mean = pulse_start_baseline;
127  _pulse.ped_sigma = sigma_v.at(i);
128 
129  for(size_t pre_index=_pulse.t_start; pre_index<i; ++pre_index) {
130 
131  auto const& pre_adc = wf[pre_index];
132  if(pre_adc > pulse_start_baseline) continue;
133 
134  _pulse.area += pre_adc - pulse_start_baseline;
135 
136  }
137 
138  if(_verbose)
139  std::cout << "\033[93mPulse Start\033[00m: "
140  << "baseline: " << mean_v[i]
141  << " ... threshold: " << start_threshold
142  << " ... adc: " << value
143  << " T=" << i << std::endl;
144 
145  fire = true;
146  in_tail = false;
147  }
148 
149  if( fire && ((double)value) < pulse_start_threshold ) {
150  fire = false;
151  in_tail = true;
152  }
153 
154  if( (fire || in_tail) && ((double)value) < pulse_tail_threshold ){
155 
156  // Found the end of a pulse
157  _pulse.t_end = i - 1;
158 
159  _pulse_v.push_back(_pulse);
160 
162 
163  if(_verbose)
164  std::cout << "\033[93mPulse End\033[00m: "
165  << "baseline: " << mean_v[i] << " ... " << " ... adc: " << value << " T=" << i << std::endl;
166 
167  fire = false;
168  in_tail = false;
169 
170  }
171 
172  if(fire || in_tail){
173 
174  // Add this adc count to the integral
175  double adc_above_baseline = ((double)value - (double)pulse_start_baseline);
176 
177  //_pulse.area += ((double)value - (double)mean_v.at(i));
178  _pulse.area += adc_above_baseline;
179 
180  if(_pulse.peak < adc_above_baseline) {
181 
182  // Found a new maximum
183  _pulse.peak = adc_above_baseline;
184 
185  _pulse.t_max = i;
186 
187  }
188 
189  }
190 
191  }
192 
193  if(fire || in_tail){
194 
195  // Take care of a pulse that did not finish within the readout window.
196 
197  fire = false;
198  in_tail = false;
199 
200  _pulse.t_end = wf.size() - 1;
201 
202  _pulse_v.push_back(_pulse);
203 
205 
206  }
207 
208  return true;
209 
210  }
float _nsigma
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
std::string value(boost::any const &)
void Reset()
Implementation of AlgoSlidingWindow::reset() method.
float _adc_thres
A variable holder for a user-defined absolute ADC threshold value.
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
void pmtana::AlgoSlidingWindow::Reset ( )
virtual

Implementation of AlgoSlidingWindow::reset() method.

Reimplemented from pmtana::PMTPulseRecoBase.

Definition at line 50 of file AlgoSlidingWindow.cxx.

References pmtana::PMTPulseRecoBase::Reset().

Referenced by AlgoSlidingWindow(), and RecoPulse().

52  {
54  }
virtual void Reset()
A method to be called event-wise to reset parameters.
const bool pmtana::PMTPulseRecoBase::Status ( ) const
inherited

Status getter.

Definition at line 26 of file PMTPulseRecoBase.cxx.

References pmtana::PMTPulseRecoBase::_status.

28  { return _status; }
bool _status
Status after pulse reconstruction.

Member Data Documentation

float pmtana::AlgoSlidingWindow::_adc_thres
protected

A variable holder for a user-defined absolute ADC threshold value.

Definition at line 54 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().

float pmtana::AlgoSlidingWindow::_end_adc_thres
protected

Definition at line 54 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().

float pmtana::AlgoSlidingWindow::_end_nsigma
protected

Definition at line 57 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().

float pmtana::AlgoSlidingWindow::_nsigma
protected

A variable holder for a multiplicative factor for the pedestal standard deviation to define the threshold.

Definition at line 57 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().

size_t pmtana::AlgoSlidingWindow::_num_presample
protected

Definition at line 59 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().

pulse_param pmtana::PMTPulseRecoBase::_pulse
protectedinherited

A subject pulse_param object to be filled with the last reconstructed pulse parameters.

Definition at line 126 of file PMTPulseRecoBase.h.

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

bool pmtana::AlgoSlidingWindow::_verbose
protected

Definition at line 58 of file AlgoSlidingWindow.h.

Referenced by AlgoSlidingWindow(), and RecoPulse().


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