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

#include "AlgoThreshold.h"

Inheritance diagram for pmtana::AlgoThreshold:
pmtana::PMTPulseRecoBase

Public Member Functions

 AlgoThreshold (const std::string name="AlgoThreshold")
 Default constructor. More...
 
 AlgoThreshold (const fhicl::ParameterSet &pset, const std::string name="AlgoThreshold")
 Alternative constructor. More...
 
virtual ~AlgoThreshold ()
 Default destructor. More...
 
void Reset ()
 Implementation of AlgoThreshold::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 &wf, const pmtana::PedestalMean_t &mean_v, const pmtana::PedestalSigma_t &sigma_v)
 Implementation of AlgoThreshold::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

double _start_adc_thres
 A variable holder for a user-defined absolute ADC threshold value. More...
 
double _end_adc_thres
 
double _nsigma_start
 A variable holder for a multiplicative factor for the pedestal standard deviation to define the threshold. More...
 
double _nsigma_end
 
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 AlgoThreshold 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 33 of file AlgoThreshold.h.

Constructor & Destructor Documentation

pmtana::AlgoThreshold::AlgoThreshold ( const std::string  name = "AlgoThreshold")

Default constructor.

Definition at line 15 of file AlgoThreshold.cxx.

References Reset().

15  : PMTPulseRecoBase(name)
16  //***************************************************************************
17  {
18  //_adc_thres = 3;
19  //_nsigma = 5;
20  Reset();
21  }
void Reset()
Implementation of AlgoThreshold::reset() method.
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
pmtana::AlgoThreshold::AlgoThreshold ( const fhicl::ParameterSet pset,
const std::string  name = "AlgoThreshold" 
)

Alternative constructor.

Definition at line 24 of file AlgoThreshold.cxx.

References _end_adc_thres, _nsigma_end, _nsigma_start, _start_adc_thres, fhicl::ParameterSet::get(), and Reset().

27  : PMTPulseRecoBase(name)
28  //*******************************************************
29  {
30 
31  _start_adc_thres = pset.get<double>("StartADCThreshold");
32  _end_adc_thres = pset.get<double>("EndADCThreshold");
33 
34  //_nsigma = pset.get<double>("NSigmaThreshold");
35 
36  _nsigma_start = pset.get<double>("NSigmaThresholdStart");
37  _nsigma_end = pset.get<double>("NSigmaThresholdEnd");
38 
39  Reset();
40 
41  }
void Reset()
Implementation of AlgoThreshold::reset() method.
T get(std::string const &key) const
Definition: ParameterSet.h:231
double _nsigma_start
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
Definition: AlgoThreshold.h:64
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
double _start_adc_thres
A variable holder for a user-defined absolute ADC threshold value.
Definition: AlgoThreshold.h:59
pmtana::AlgoThreshold::~AlgoThreshold ( )
virtual

Default destructor.

Definition at line 44 of file AlgoThreshold.cxx.

46  {}

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::AlgoThreshold::RecoPulse ( const pmtana::Waveform_t wf,
const pmtana::PedestalMean_t mean_v,
const pmtana::PedestalSigma_t sigma_v 
)
protectedvirtual

Implementation of AlgoThreshold::reco() method.

Implements pmtana::PMTPulseRecoBase.

Definition at line 56 of file AlgoThreshold.cxx.

References _end_adc_thres, _nsigma_end, _nsigma_start, pmtana::PMTPulseRecoBase::_pulse, pmtana::PMTPulseRecoBase::_pulse_v, _start_adc_thres, 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().

60  {
61  bool fire = false;
62 
63  double counter=0;
64 
65  double ped_mean = mean_v.front();
66  double ped_rms = sigma_v.front();
67 
68  //double threshold = ( _adc_thres > (_nsigma * ped_rms) ? _adc_thres : (_nsigma * ped_rms) );
69  auto start_threshold = ( _start_adc_thres > (_nsigma_start * ped_rms) ? _start_adc_thres : (_nsigma_start * ped_rms) );
70  auto end_threshold = ( _end_adc_thres > (_nsigma_end * ped_rms) ? _end_adc_thres : (_nsigma_end * ped_rms) );
71 
72  // threshold += ped_mean
73 
74  start_threshold += ped_mean;
75  end_threshold += ped_mean;
76 
77  Reset();
78 
79  for(auto const &value : wf){
80 
81  if( !fire && ((double)value) >= start_threshold ){
82 
83  // Found a new pulse
84 
85  fire = true;
86 
87  _pulse.ped_mean = ped_mean;
88  _pulse.ped_sigma = ped_rms;
89 
90  //vic: i move t_start back one, this helps with porch
91 
92  _pulse.t_start = counter - 1 > 0 ? counter - 1 : counter;
93  //std::cout << "counter: " << counter << " tstart : " << _pulse.t_start << "\n";
94 
95  }
96 
97  if( fire && ((double)value) < end_threshold ){
98 
99  // Found the end of a pulse
100 
101  fire = false;
102 
103  //vic: i move t_start forward one, this helps with tail
104  _pulse.t_end = counter < wf.size() ? counter : counter - 1;
105 
106  _pulse_v.push_back(_pulse);
107 
109 
110  }
111 
112 
113  //std::cout << "\tFire=" << fire << std::endl;
114 
115  if(fire){
116 
117  // Add this adc count to the integral
118 
119  _pulse.area += ((double)value - (double)ped_mean);
120 
121  if(_pulse.peak < ((double)value - (double)ped_mean)) {
122 
123  // Found a new maximum
124 
125  _pulse.peak = ((double)value - (double)ped_mean);
126 
127  _pulse.t_max = counter;
128 
129  }
130 
131  }
132 
133  counter++;
134  }
135 
136  if(fire){
137 
138  // Take care of a pulse that did not finish within the readout window.
139 
140  fire = false;
141 
142  _pulse.t_end = counter - 1;
143 
144  _pulse_v.push_back(_pulse);
145 
147 
148  }
149 
150  return true;
151 
152  }
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
void Reset()
Implementation of AlgoThreshold::reset() method.
std::string value(boost::any const &)
double _nsigma_start
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
Definition: AlgoThreshold.h:64
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
double _start_adc_thres
A variable holder for a user-defined absolute ADC threshold value.
Definition: AlgoThreshold.h:59
void pmtana::AlgoThreshold::Reset ( )
virtual

Implementation of AlgoThreshold::reset() method.

Reimplemented from pmtana::PMTPulseRecoBase.

Definition at line 49 of file AlgoThreshold.cxx.

References pmtana::PMTPulseRecoBase::Reset().

Referenced by AlgoThreshold(), and RecoPulse().

51  {
53  }
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

double pmtana::AlgoThreshold::_end_adc_thres
protected

Definition at line 60 of file AlgoThreshold.h.

Referenced by AlgoThreshold(), and RecoPulse().

double pmtana::AlgoThreshold::_nsigma_end
protected

Definition at line 65 of file AlgoThreshold.h.

Referenced by AlgoThreshold(), and RecoPulse().

double pmtana::AlgoThreshold::_nsigma_start
protected

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

Definition at line 64 of file AlgoThreshold.h.

Referenced by AlgoThreshold(), 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(), pmtana::AlgoSlidingWindow::RecoPulse(), pmtana::AlgoCFD::RecoPulse(), RecoPulse(), pmtana::AlgoFixedWindow::Reset(), and pmtana::PMTPulseRecoBase::Reset().

double pmtana::AlgoThreshold::_start_adc_thres
protected

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

Definition at line 59 of file AlgoThreshold.h.

Referenced by AlgoThreshold(), and RecoPulse().


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