All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlgoSiPM.cxx
Go to the documentation of this file.
1 //=======================
2 // AlgoSiPM.cxx
3 //=======================
4 
5 #include "AlgoSiPM.h"
6 
7 #include "fhiclcpp/ParameterSet.h"
8 
9 namespace pmtana {
10 
11  //---------------------------------------------------------------------------
12  AlgoSiPM::AlgoSiPM(const fhicl::ParameterSet &pset,
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 
31  //---------------------------------------------------------------------------
33  {
34 
36 
37  }
38 
39  //---------------------------------------------------------------------------
41  const pmtana::PedestalMean_t& ped_mean,
42  const pmtana::PedestalSigma_t& ped_rms )
43  {
44 
45  bool fire = false;
46  bool first_found = false;
47  bool record_hit = false;
48  int counter = 0;
49  // double threshold = (_2nd_thres > (_nsigma*_ped_rms) ? _2nd_thres
50  // : (_nsigma*_ped_rms));
51  //double pedestal = _pedestal;
52  double pedestal = ped_mean.front(); //Switch pedestal definition to incoroprate pedestal finder - K.S. 04/18/2019
53 
54  double threshold = _adc_thres;
55  threshold += pedestal;
56  double pre_threshold = _2nd_thres;
57  pre_threshold += pedestal;
58 
59  Reset();
60 
61  for (short const &value : wf) {
62 
63  if (!fire && (double(value) >= pre_threshold)) {
64 
65  // Found a new pulse
66  fire = true;
67  first_found = false;
68  record_hit = false;
70 
71  }
72 
73  if (fire && (double(value) < pre_threshold)) {
74 
75  // Found the end of a pulse
76  fire = false;
77  _pulse.t_end = counter - 1;
78  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
79  {
81  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
82  {wf.begin()+_pulse.t_start, wf.begin()+_pulse.t_end},
83  {ped_mean.begin()+_pulse.t_start, ped_mean.begin()+_pulse.t_end},
84  true);
85 
86  _pulse_v.push_back(_pulse);
87  record_hit = false;
88  }
90 
91  }
92 
93  if (fire) {
94 
95  // We want to record the hit only if _adc_thres is reached
96  if (!record_hit && (double(value) >= threshold)) record_hit = true;
97 
98  // Add this ADC count to the integral
99  _pulse.area += (double(value) - double(pedestal));
100 
101  if (!first_found &&
102  (_pulse.peak < (double(value) - double(pedestal)))) {
103 
104  // Found a new maximum
105  _pulse.peak = (double(value) - double(pedestal));
106  _pulse.t_max = counter;
107 
108  }
109  else if (!first_found)
110  // Found the first peak
111  first_found = true;
112 
113  }
114 
115  counter++;
116 
117  }
118 
119  if (fire) {
120 
121  // Take care of a pulse that did not finish within the readout window
122  fire = false;
123  _pulse.t_end = counter - 1;
124  if (record_hit && ((_pulse.t_end - _pulse.t_start) >= _min_width))
125  {
127  _pulse.t_rise = _risetime_calc_ptr->RiseTime(
128  {wf.begin()+_pulse.t_start, wf.begin()+_pulse.t_end},
129  {ped_mean.begin()+_pulse.t_start, ped_mean.begin()+_pulse.t_end},
130  true);
131 
132  _pulse_v.push_back(_pulse);
133  record_hit = false;
134  }
136 
137  }
138 
139  return true;
140 
141  }
142 
143 }
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:285
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Definition: AlgoSiPM.cxx:40
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
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
then echo fcl name
temporary value
void Reset()
A method to be called event-wise to reset parameters.
Definition: AlgoSiPM.cxx:32
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