LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
AlgoThreshold.cxx
Go to the documentation of this file.
1 //
3 // AlgoThreshold source
4 //
6 
7 #ifndef ALGOTHRESHOLD_CXX
8 #define ALGOTHRESHOLD_CXX
9 
10 #include "AlgoThreshold.h"
11 
12 namespace pmtana{
13 
14  //***************************************************************************
15  AlgoThreshold::AlgoThreshold(const std::string name) : PMTPulseRecoBase(name)
16  //***************************************************************************
17  {
18  //_adc_thres = 3;
19  //_nsigma = 5;
20  Reset();
21  }
22 
23  //************************************************************
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  Reset();
40 
41  }
42 
43  //***************************************************************
45  //***************************************************************
46  {}
47 
48  //***************************************************************
50  //***************************************************************
51  {
53  }
54 
55  //***************************************************************
57  const PedestalMean_t& mean_v,
58  const PedestalSigma_t& sigma_v)
59  //***************************************************************
60  {
61  bool fire = false;
62 
63  double counter=0;
64 
65  double ped_mean = mean_v.front();
66  double ped_rms = sigma_v.front();
67 
68  //double threshold = ( _adc_thres > (_nsigma * ped_rms) ? _adc_thres : (_nsigma * ped_rms) );
69  auto start_threshold = ( _start_adc_thres > (_nsigma_start * ped_rms) ? _start_adc_thres : (_nsigma_start * ped_rms) );
70  auto end_threshold = ( _end_adc_thres > (_nsigma_end * ped_rms) ? _end_adc_thres : (_nsigma_end * ped_rms) );
71 
72  // threshold += ped_mean
73 
74  start_threshold += ped_mean;
75  end_threshold += ped_mean;
76 
77  Reset();
78 
79  for(auto const &value : wf){
80 
81  if( !fire && ((double)value) >= start_threshold ){
82 
83  // Found a new pulse
84 
85  fire = true;
86 
87  _pulse.ped_mean = ped_mean;
88  _pulse.ped_sigma = ped_rms;
89 
90  //vic: i move t_start back one, this helps with porch
91 
92  _pulse.t_start = counter - 1 > 0 ? counter - 1 : counter;
93  //std::cout << "counter: " << counter << " tstart : " << _pulse.t_start << "\n";
94 
95  }
96 
97  if( fire && ((double)value) < end_threshold ){
98 
99  // Found the end of a pulse
100 
101  fire = false;
102 
103  //vic: i move t_start forward one, this helps with tail
104  _pulse.t_end = counter < wf.size() ? counter : counter - 1;
105 
106  _pulse_v.push_back(_pulse);
107 
109 
110  }
111 
112 
113  //std::cout << "\tFire=" << fire << std::endl;
114 
115  if(fire){
116 
117  // Add this adc count to the integral
118 
119  _pulse.area += ((double)value - (double)ped_mean);
120 
121  if(_pulse.peak < ((double)value - (double)ped_mean)) {
122 
123  // Found a new maximum
124 
125  _pulse.peak = ((double)value - (double)ped_mean);
126 
127  _pulse.t_max = counter;
128 
129  }
130 
131  }
132 
133  counter++;
134  }
135 
136  if(fire){
137 
138  // Take care of a pulse that did not finish within the readout window.
139 
140  fire = false;
141 
142  _pulse.t_end = counter - 1;
143 
144  _pulse_v.push_back(_pulse);
145 
147 
148  }
149 
150  return true;
151 
152  }
153 
154 }
155 
156 #endif
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
virtual ~AlgoThreshold()
Default destructor.
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:231
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.
std::string value(boost::any const &)
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