LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
AlgoSiPM.cxx
Go to the documentation of this file.
1 //=======================
2 // AlgoSiPM.cxx
3 //=======================
4 
5 #include "AlgoSiPM.h"
6 
7 #ifndef ALGOSIPM_CXX
8 #define ALGOSIPM_CXX
9 
10 namespace pmtana {
11 
12  //---------------------------------------------------------------------------
13  AlgoSiPM::AlgoSiPM(const fhicl::ParameterSet &pset,const std::string name)
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  }
27 
28  //---------------------------------------------------------------------------
30  {}
31 
32  //---------------------------------------------------------------------------
34  {
35 
37 
38  }
39 
40  //---------------------------------------------------------------------------
42  const pmtana::PedestalMean_t& ped_mean,
43  const pmtana::PedestalSigma_t& ped_rms )
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  }
129 
130 }
131 
132 #endif
double _adc_thres
Definition: AlgoSiPM.h:48
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
double _2nd_thres
Definition: AlgoSiPM.h:54
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
T get(std::string const &key) const
Definition: ParameterSet.h:231
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Definition: AlgoSiPM.cxx:41
std::vector< short > Waveform_t
std::string value(boost::any const &)
AlgoSiPM(const fhicl::ParameterSet &pset, const std::string name="AlgoSiPM")
Definition: AlgoSiPM.cxx:13
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:33
std::vector< double > PedestalMean_t
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