AlgoSiPM.cxx
Go to the documentation of this file.
1 //=======================
2 // AlgoSiPM.cxx
3 //=======================
4 
5 #include "AlgoSiPM.h"
6 
8 
9 namespace pmtana {
10 
11  //---------------------------------------------------------------------------
13  : PMTPulseRecoBase(name)
14  {
15 
16  _adc_thres = pset.get< float >("ADCThreshold" );
17  _min_width = pset.get< float >("MinWidth" );
18  _2nd_thres = pset.get< float >("SecondThreshold");
19  _pedestal = pset.get< float >("Pedestal" );
20 
21 // _nsigma = 5;
22 
23  Reset();
24 
25  }
26 
27  //---------------------------------------------------------------------------
29  {
30 
32 
33  }
34 
35  //---------------------------------------------------------------------------
37  const pmtana::PedestalMean_t& ped_mean,
38  const pmtana::PedestalSigma_t& ped_rms )
39  {
40 
41  bool fire = false;
42  bool first_found = false;
43  bool record_hit = false;
44  int counter = 0;
45  // double threshold = (_2nd_thres > (_nsigma*_ped_rms) ? _2nd_thres
46  // : (_nsigma*_ped_rms));
47  //double pedestal = _pedestal;
48  double pedestal = ped_mean.front(); //Switch pedestal definition to incoroprate pedestal finder - K.S. 04/18/2019
49 
50  double threshold = _adc_thres;
51  threshold += pedestal;
52  double pre_threshold = _2nd_thres;
53  pre_threshold += pedestal;
54 
55  Reset();
56 
57  for (short const &value : wf) {
58 
59  if (!fire && (double(value) >= pre_threshold)) {
60 
61  // Found a new pulse
62  fire = true;
63  first_found = false;
64  record_hit = false;
66 
67  }
68 
69  if (fire && (double(value) < pre_threshold)) {
70 
71  // Found the end of a pulse
72  fire = false;
73  _pulse.t_end = counter - 1;
74  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
75  {
76  _pulse_v.push_back(_pulse);
77  record_hit = false;
78  }
80 
81  }
82 
83  if (fire) {
84 
85  // We want to record the hit only if _adc_thres is reached
86  if (!record_hit && (double(value) >= threshold)) record_hit = true;
87 
88  // Add this ADC count to the integral
89  _pulse.area += (double(value) - double(pedestal));
90 
91  if (!first_found &&
92  (_pulse.peak < (double(value) - double(pedestal)))) {
93 
94  // Found a new maximum
95  _pulse.peak = (double(value) - double(pedestal));
96  _pulse.t_max = counter;
97 
98  }
99  else if (!first_found)
100  // Found the first peak
101  first_found = true;
102 
103  }
104 
105  counter++;
106 
107  }
108 
109  if (fire) {
110 
111  // Take care of a pulse that did not finish within the readout window
112  fire = false;
113  _pulse.t_end = counter - 1;
114  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
115  {
116  _pulse_v.push_back(_pulse);
117  record_hit = false;
118  }
120 
121  }
122 
123  return true;
124 
125  }
126 
127 }
static QCString name
Definition: declinfo.cpp:673
double _adc_thres
Definition: AlgoSiPM.h:45
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
double _2nd_thres
Definition: AlgoSiPM.h:51
std::string string
Definition: nybbler.cc:12
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:271
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Definition: AlgoSiPM.cxx:36
std::vector< short > Waveform_t
AlgoSiPM(const fhicl::ParameterSet &pset, const std::string name="AlgoSiPM")
Definition: AlgoSiPM.cxx:12
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:28
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:54