LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PMTPulseRecoBase.cxx
Go to the documentation of this file.
1 //
3 // PMTPulseRecoBase source
4 //
6 
7 #ifndef PMTPULSERECOBASE_CC
8 #define PMTPULSERECOBASE_CC
9 
10 #include "PMTPulseRecoBase.h"
11 
12 namespace pmtana{
13 
14  //*************************************************************************
15  PMTPulseRecoBase::PMTPulseRecoBase(const std::string name) : _name (name)
16  , _status (true)
17  //*************************************************************************
18  { Reset(); }
19 
20  //***********************************************
21  const std::string& PMTPulseRecoBase::Name() const
22  //***********************************************
23  { return _name; }
24 
25  //*****************************************
26  const bool PMTPulseRecoBase::Status() const
27  //*****************************************
28  { return _status; }
29 
30  //***************************************************************
32  //***************************************************************
33  {}
34 
35  //******************************************************************
37  const PedestalMean_t& mean_v,
38  const PedestalSigma_t& sigma_v )
39  //******************************************************************
40  {
41  _status = this->RecoPulse(wf,mean_v,sigma_v);
42  return _status;
43  }
44 
45  //*****************************************************************************
46  bool CheckIndex(const std::vector<short> &wf, const size_t &begin, size_t &end)
47  //*****************************************************************************
48  {
49  if(begin >= wf.size() || end >= wf.size() || begin > end){
50 
51  std::cerr <<"Invalid arguments: waveform length = " << wf.size() << " begin = " << begin << " end = " << end << std::endl;
52 
53  return false;
54  }
55 
56  if(!end) end = wf.size() - 1;
57 
58  return true;
59  }
60 
61  //***************************************************************
63  //***************************************************************
64  {
66 
67  _pulse_v.clear();
68 
69  _pulse_v.reserve(3);
70  }
71 
72  //***************************************************************
73  const pulse_param& PMTPulseRecoBase::GetPulse(size_t index) const
74  //***************************************************************
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  }
90 
91  //***************************************************************
93  //***************************************************************
94  {
95  return _pulse_v;
96  }
97 
98  //***************************************************************
99  bool PMTPulseRecoBase::Integral(const std::vector<short> &wf,
100  double &result,
101  size_t begin,
102  size_t end) const
103  //***************************************************************
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  }
120 
121  //***************************************************************
122  bool PMTPulseRecoBase::Derivative(const std::vector<short> &wf,
123  std::vector<int32_t> &diff,
124  size_t begin,
125  size_t end) const
126  //***************************************************************
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  }
144 
145  //***************************************************************
146  size_t PMTPulseRecoBase::Max(const std::vector<short> &wf,
147  double &result,
148  size_t begin,
149  size_t end) const
150  //***************************************************************
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  }
168 
169  //***************************************************************
170  size_t PMTPulseRecoBase::Min(const std::vector<short> &wf,
171  double &result,
172  size_t begin,
173  size_t end) const
174  //***************************************************************
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  }
192 }
193 #endif
194 
bool _status
Status after pulse reconstruction.
bool Integral(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
std::string _name
Unique name.
size_t Min(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
const std::string & Name() const
Name getter.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
virtual ~PMTPulseRecoBase()
Default destructor.
intermediate_table::const_iterator const_iterator
size_t Max(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
bool CheckIndex(const std::vector< short > &wf, const size_t &begin, size_t &end)
const pulse_param_array & GetPulses() const
A getter for the whole array of pulse_param struct object.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< short > Waveform_t
virtual bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)=0
const bool Status() const
Status getter.
bool Reconstruct(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::vector< pmtana::pulse_param > pulse_param_array
Class definition file of PMTPulseRecoBase.
std::vector< double > PedestalMean_t
const pulse_param & GetPulse(size_t index=0) const
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
bool Derivative(const std::vector< short > &wf, std::vector< int32_t > &diff, size_t begin=0, size_t end=0) const
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33