LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
AlgoThreshold.cxx
Go to the documentation of this file.
1 //
3 // AlgoThreshold source
4 //
6 
8 
9 #include "AlgoThreshold.h"
10 
11 namespace pmtana {
12 
13  //***************************************************************************
14  AlgoThreshold::AlgoThreshold(const std::string name) : PMTPulseRecoBase(name)
15  //***************************************************************************
16  {
17  //_adc_thres = 3;
18  //_nsigma = 5;
19  Reset();
20  }
21 
22  //************************************************************
24  std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
25  //AlgoThreshold::AlgoThreshold(const ::fcllite::PSet &pset,
26  const std::string name)
27  : PMTPulseRecoBase(name)
28  //*******************************************************
29  {
30 
31  _start_adc_thres = pset.get<double>("StartADCThreshold");
32  _end_adc_thres = pset.get<double>("EndADCThreshold");
33 
34  //_nsigma = pset.get<double>("NSigmaThreshold");
35 
36  _nsigma_start = pset.get<double>("NSigmaThresholdStart");
37  _nsigma_end = pset.get<double>("NSigmaThresholdEnd");
38 
39  _risetime_calc_ptr = std::move(risetimecalculator);
40 
41  Reset();
42  }
43 
44  //***************************************************************
46  //***************************************************************
47  {
49  }
50 
51  //***************************************************************
53  const PedestalMean_t& mean_v,
54  const PedestalSigma_t& sigma_v)
55  //***************************************************************
56  {
57  bool fire = false;
58 
59  double counter = 0;
60 
61  double ped_mean = mean_v.front();
62  double ped_rms = sigma_v.front();
63 
64  //double threshold = ( _adc_thres > (_nsigma * ped_rms) ? _adc_thres : (_nsigma * ped_rms) );
65  auto start_threshold =
66  (_start_adc_thres > (_nsigma_start * ped_rms) ? _start_adc_thres : (_nsigma_start * ped_rms));
67  auto end_threshold =
68  (_end_adc_thres > (_nsigma_end * ped_rms) ? _end_adc_thres : (_nsigma_end * ped_rms));
69 
70  // threshold += ped_mean
71 
72  start_threshold += ped_mean;
73  end_threshold += ped_mean;
74 
75  Reset();
76 
77  for (auto const& value : wf) {
78 
79  if (!fire && ((double)value) >= start_threshold) {
80 
81  // Found a new pulse
82 
83  fire = true;
84 
85  _pulse.ped_mean = ped_mean;
86  _pulse.ped_sigma = ped_rms;
87 
88  //vic: i move t_start back one, this helps with porch
89 
90  _pulse.t_start = counter - 1 > 0 ? counter - 1 : counter;
91  //std::cout << "counter: " << counter << " tstart : " << _pulse.t_start << "\n";
92  }
93 
94  if (fire && ((double)value) < end_threshold) {
95 
96  // Found the end of a pulse
97 
98  fire = false;
99 
100  //vic: i move t_start forward one, this helps with tail
101  _pulse.t_end = counter < wf.size() ? counter : counter - 1;
102 
103  if (_risetime_calc_ptr)
104  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
105  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
106  {mean_v.begin() + _pulse.t_start, mean_v.begin() + _pulse.t_end},
107  true);
108 
109  _pulse_v.push_back(_pulse);
110 
112  }
113 
114  //std::cout << "\tFire=" << fire << std::endl;
115 
116  if (fire) {
117 
118  // Add this adc count to the integral
119 
120  _pulse.area += ((double)value - (double)ped_mean);
121 
122  if (_pulse.peak < ((double)value - (double)ped_mean)) {
123 
124  // Found a new maximum
125 
126  _pulse.peak = ((double)value - (double)ped_mean);
127 
128  _pulse.t_max = counter;
129  }
130  }
131 
132  counter++;
133  }
134 
135  if (fire) {
136 
137  // Take care of a pulse that did not finish within the readout window.
138 
139  fire = false;
140 
141  _pulse.t_end = counter - 1;
142 
143  if (_risetime_calc_ptr)
144  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
145  {wf.begin() + _pulse.t_start, wf.begin() + _pulse.t_end},
146  {mean_v.begin() + _pulse.t_start, mean_v.begin() + _pulse.t_end},
147  true);
148 
149  _pulse_v.push_back(_pulse);
150 
152  }
153 
154  return true;
155  }
156 
157 }
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
AlgoThreshold(const std::string name="AlgoThreshold")
Default constructor.
void Reset()
Implementation of AlgoThreshold::reset() method.
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
std::vector< short > Waveform_t
bool RecoPulse(const pmtana::Waveform_t &wf, const pmtana::PedestalMean_t &mean_v, const pmtana::PedestalSigma_t &sigma_v)
Implementation of AlgoThreshold::reco() method.
double value
Definition: spectrum.C:18
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
double _nsigma_start
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
Definition: AlgoThreshold.h:64
Class definition file of AlgoThreshold.
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 _start_adc_thres
A variable holder for a user-defined absolute ADC threshold value.
Definition: AlgoThreshold.h:59