LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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  std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
14  const std::string name)
15  : PMTPulseRecoBase(name)
16  {
17 
18  _adc_thres = pset.get<float>("ADCThreshold");
19  _min_width = pset.get<float>("MinWidth");
20  _2nd_thres = pset.get<float>("SecondThreshold");
21  _pedestal = pset.get<float>("Pedestal");
22 
23  _risetime_calc_ptr = std::move(risetimecalculator);
24 
25  // _nsigma = 5;
26 
27  Reset();
28  }
29 
30  //---------------------------------------------------------------------------
32  {
34  }
35 
36  //---------------------------------------------------------------------------
38  const pmtana::PedestalMean_t& ped_mean,
39  const pmtana::PedestalSigma_t& ped_rms)
40  {
41 
42  bool fire = 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 =
49  ped_mean
50  .front(); //Switch pedestal definition to incoroprate pedestal finder - K.S. 04/18/2019
51 
52  double threshold = _adc_thres;
53  threshold += pedestal;
54  double pre_threshold = _2nd_thres;
55  pre_threshold += pedestal;
56 
57  Reset();
58 
59  for (short const& value : wf) {
60 
61  if (!fire && (double(value) >= pre_threshold)) {
62 
63  // Found a new pulse
64  fire = true;
65  record_hit = false;
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)) {
76  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
77  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
78  {ped_mean.begin() + _pulse.t_start, ped_mean.begin() + _pulse.t_end},
79  true);
80 
81  _pulse_v.push_back(_pulse);
82  record_hit = false;
83  }
85  }
86 
87  if (fire) {
88 
89  // We want to record the hit only if _adc_thres is reached
90  if (!record_hit && (double(value) >= threshold)) record_hit = true;
91 
92  // Add this ADC count to the integral
93  _pulse.area += (double(value) - double(pedestal));
94 
95  if (_pulse.peak < (double(value) - double(pedestal))) {
96 
97  // Found a new maximum
98  _pulse.peak = (double(value) - double(pedestal));
100  }
101  }
102 
103  counter++;
104  }
105 
106  if (fire) {
107 
108  // Take care of a pulse that did not finish within the readout window
109  fire = false;
110  _pulse.t_end = counter - 1;
111  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width)) {
112  if (_risetime_calc_ptr)
113  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
114  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
115  {ped_mean.begin() + _pulse.t_start, ped_mean.begin() + _pulse.t_end},
116  true);
117 
118  _pulse_v.push_back(_pulse);
119  record_hit = false;
120  }
122  }
123 
124  return true;
125  }
126 
127 }
double _adc_thres
Definition: AlgoSiPM.h:47
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
double _2nd_thres
Definition: AlgoSiPM.h:53
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
Definition: counter.h:295
T get(std::string const &key) const
Definition: ParameterSet.h:314
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Definition: AlgoSiPM.cxx:37
AlgoSiPM(const fhicl::ParameterSet &pset, std::unique_ptr< pmtana::RiseTimeCalculatorBase > risetimecalculator=nullptr, const std::string name="AlgoSiPM")
Definition: AlgoSiPM.cxx:12
std::vector< short > Waveform_t
double value
Definition: spectrum.C:18
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:31
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:56