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