All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlgoThreshold.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // AlgoThreshold source
4 //
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include "fhiclcpp/ParameterSet.h"
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  //************************************************************
23  AlgoThreshold::AlgoThreshold(const fhicl::ParameterSet &pset,
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 
45  //***************************************************************
47  //***************************************************************
48  {
50  }
51 
52  //***************************************************************
54  const PedestalMean_t& mean_v,
55  const PedestalSigma_t& sigma_v)
56  //***************************************************************
57  {
58  bool fire = false;
59 
60  double counter=0;
61 
62  double ped_mean = mean_v.front();
63  double ped_rms = sigma_v.front();
64 
65  //double threshold = ( _adc_thres > (_nsigma * ped_rms) ? _adc_thres : (_nsigma * ped_rms) );
66  auto start_threshold = ( _start_adc_thres > (_nsigma_start * ped_rms) ? _start_adc_thres : (_nsigma_start * ped_rms) );
67  auto end_threshold = ( _end_adc_thres > (_nsigma_end * ped_rms) ? _end_adc_thres : (_nsigma_end * ped_rms) );
68 
69  // threshold += ped_mean
70 
71  start_threshold += ped_mean;
72  end_threshold += ped_mean;
73 
74  Reset();
75 
76  for(auto const &value : wf){
77 
78  if( !fire && ((double)value) >= start_threshold ){
79 
80  // Found a new pulse
81 
82  fire = true;
83 
84  _pulse.ped_mean = ped_mean;
85  _pulse.ped_sigma = ped_rms;
86 
87  //vic: i move t_start back one, this helps with porch
88 
89  _pulse.t_start = counter - 1 > 0 ? counter - 1 : counter;
90  //std::cout << "counter: " << counter << " tstart : " << _pulse.t_start << "\n";
91 
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 
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 
115 
116  //std::cout << "\tFire=" << fire << std::endl;
117 
118  if(fire){
119 
120  // Add this adc count to the integral
121 
122  _pulse.area += ((double)value - (double)ped_mean);
123 
124  if(_pulse.peak < ((double)value - (double)ped_mean)) {
125 
126  // Found a new maximum
127 
128  _pulse.peak = ((double)value - (double)ped_mean);
129 
130  _pulse.t_max = counter;
131 
132  }
133 
134  }
135 
136  counter++;
137  }
138 
139  if(fire){
140 
141  // Take care of a pulse that did not finish within the readout window.
142 
143  fire = false;
144 
145  _pulse.t_end = counter - 1;
146 
148  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
149  {wf.begin()+_pulse.t_start, wf.begin()+_pulse.t_end},
150  {mean_v.begin()+_pulse.t_start, mean_v.begin()+_pulse.t_end},
151  true);
152 
153  _pulse_v.push_back(_pulse);
154 
156 
157  }
158 
159  return true;
160 
161  }
162 
163 }
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:285
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::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:65
Class definition file of AlgoThreshold.
then echo fcl name
temporary value
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:60