LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
pmtana::AlgoSiPM Class Reference

#include "AlgoSiPM.h"

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

Public Member Functions

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

Detailed Description

Definition at line 21 of file AlgoSiPM.h.

Constructor & Destructor Documentation

pmtana::AlgoSiPM::AlgoSiPM ( const fhicl::ParameterSet pset,
const std::string  name = "AlgoSiPM" 
)

Definition at line 13 of file AlgoSiPM.cxx.

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

14  : PMTPulseRecoBase(name)
15  {
16 
17  _adc_thres = pset.get< float >("ADCThreshold" );
18  _min_width = pset.get< float >("MinWidth" );
19  _2nd_thres = pset.get< float >("SecondThreshold");
20  _pedestal = pset.get< float >("Pedestal" );
21 
22 // _nsigma = 5;
23 
24  Reset();
25 
26  }
double _adc_thres
Definition: AlgoSiPM.h:48
double _2nd_thres
Definition: AlgoSiPM.h:54
T get(std::string const &key) const
Definition: ParameterSet.h:231
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:33
double _pedestal
Definition: AlgoSiPM.h:57
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
pmtana::AlgoSiPM::~AlgoSiPM ( )

Definition at line 29 of file AlgoSiPM.cxx.

30  {}

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::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 41 of file AlgoSiPM.cxx.

References _2nd_thres, _adc_thres, _min_width, _pedestal, pmtana::PMTPulseRecoBase::_pulse, pmtana::PMTPulseRecoBase::_pulse_v, pmtana::pulse_param::area, pmtana::pulse_param::peak, 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().

44  {
45 
46  bool fire = false;
47  bool first_found = false;
48  bool record_hit = false;
49  int counter = 0;
50  // double threshold = (_2nd_thres > (_nsigma*_ped_rms) ? _2nd_thres
51  // : (_nsigma*_ped_rms));
52  double pedestal = _pedestal;
53  double threshold = _adc_thres;
54  threshold += pedestal;
55  double pre_threshold = _2nd_thres;
56  pre_threshold += pedestal;
57 
58  Reset();
59 
60  for (short const &value : wf) {
61 
62  if (!fire && (double(value) >= pre_threshold)) {
63 
64  // Found a new pulse
65  fire = true;
66  first_found = false;
67  record_hit = false;
68  _pulse.t_start = counter;
69 
70  }
71 
72  if (fire && (double(value) < pre_threshold)) {
73 
74  // Found the end of a pulse
75  fire = false;
76  _pulse.t_end = counter - 1;
77  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
78  {
79  _pulse_v.push_back(_pulse);
80  record_hit = false;
81  }
83 
84  }
85 
86  if (fire) {
87 
88  // We want to record the hit only if _adc_thres is reached
89  if (!record_hit && (double(value) >= threshold)) record_hit = true;
90 
91  // Add this ADC count to the integral
92  _pulse.area += (double(value) - double(pedestal));
93 
94  if (!first_found &&
95  (_pulse.peak < (double(value) - double(pedestal)))) {
96 
97  // Found a new maximum
98  _pulse.peak = (double(value) - double(pedestal));
99  _pulse.t_max = counter;
100 
101  }
102  else if (!first_found)
103  // Found the first peak
104  first_found = true;
105 
106  }
107 
108  counter++;
109 
110  }
111 
112  if (fire) {
113 
114  // Take care of a pulse that did not finish within the readout window
115  fire = false;
116  _pulse.t_end = counter - 1;
117  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
118  {
119  _pulse_v.push_back(_pulse);
120  record_hit = false;
121  }
123 
124  }
125 
126  return true;
127 
128  }
double _adc_thres
Definition: AlgoSiPM.h:48
double _2nd_thres
Definition: AlgoSiPM.h:54
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()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:33
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
double _pedestal
Definition: AlgoSiPM.h:57
void pmtana::AlgoSiPM::Reset ( )
virtual

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

Reimplemented from pmtana::PMTPulseRecoBase.

Definition at line 33 of file AlgoSiPM.cxx.

References pmtana::PMTPulseRecoBase::Reset().

Referenced by AlgoSiPM(), and RecoPulse().

34  {
35 
37 
38  }
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::AlgoSiPM::_2nd_thres
protected

Definition at line 54 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

double pmtana::AlgoSiPM::_adc_thres
protected

Definition at line 48 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

int pmtana::AlgoSiPM::_min_width
protected

Definition at line 51 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

double pmtana::AlgoSiPM::_pedestal
protected

Definition at line 57 of file AlgoSiPM.h.

Referenced by AlgoSiPM(), and RecoPulse().

pulse_param pmtana::PMTPulseRecoBase::_pulse
protectedinherited

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