7 #include "fhiclcpp/ParameterSet.h"
20 const fhicl::ParameterSet& pset,
21 std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
23 const std::string
name)
27 _positive = pset.get<
bool>(
"PositivePolarity",
true);
35 _nsigma = pset.get<
float>(
"NSigmaThreshold");
39 _end_nsigma = pset.get<
float>(
"EndNSigmaThreshold");
41 _verbose = pset.get<
bool>(
"Verbosity");
47 _min_width = pset.get<
size_t>(
"MinPulseWidth", 0);
76 double pulse_tail_threshold = 0;
78 double pulse_end_threshold = 0;
80 double pulse_start_baseline = 0;
82 int post_integration = 0;
84 assert(wf.size() == mean_v.size() && wf.size() == sigma_v.size());
92 for (
size_t i = 0; i < wf.size(); ++i) {
96 value = ((double)(wf[i])) - mean_v[i];
98 value = mean_v[i] - ((double)(wf[i]));
100 float start_threshold = 0.;
101 float tail_threshold = 0.;
105 start_threshold = sigma_v[i] *
_nsigma;
113 if ((!fire || in_tail || in_post) && ((double)value > start_threshold)) {
133 std::cout <<
"\033[93mPulse End\033[00m: "
134 <<
"baseline: " << mean_v[i] <<
" ... "
135 <<
" ... adc above: " << value <<
" T=" << i << std::endl;
142 pulse_tail_threshold = tail_threshold;
143 pulse_start_baseline = mean_v[i];
145 pulse_end_threshold = 0.;
151 int buffer_num_index = 0;
153 buffer_num_index = (
int)i -
_pulse_v.back().t_end - 1;
159 if (buffer_num_index < 0) {
160 std::cerr <<
"\033[95m[ERROR]\033[00m Logic error! Negative buffer_num_index..."
162 throw std::exception();
168 _pulse.
t_end =
static_cast<int>(i) - buffer_num_index;
185 std::cout <<
"\033[93mPulse End\033[00m: new pulse starts during in_post: "
186 <<
"baseline: " << mean_v[i] <<
" ... "
187 <<
" ... adc above: " << value <<
" T=" << i << std::endl;
194 for (
size_t pre_index =
_pulse.
t_start; pre_index < i; ++pre_index) {
196 double pre_adc = wf[pre_index];
198 pre_adc -= pulse_start_baseline;
200 pre_adc = pulse_start_baseline - pre_adc;
206 std::cout <<
"\033[93mPulse Start\033[00m: "
207 <<
"baseline: " << mean_v[i] <<
" ... threshold: " << start_threshold
208 <<
" ... adc above baseline: " << value <<
" ... pre-adc sum: " <<
_pulse.
area
209 <<
" T=" << i << std::endl;
216 if (fire && value < pulse_tail_threshold) {
222 if ((fire || in_tail || in_post) &&
_verbose) {
223 std::cout << (fire ?
"\033[93mPulsing\033[00m: " :
"\033[93mIn-tail\033[00m: ")
224 <<
"baseline: " << mean_v[i] <<
" std: " << sigma_v[i]
225 <<
" ... adc above baseline " << value <<
" T=" << i << std::endl;
228 if ((fire || in_tail) && value < pulse_end_threshold) {
230 fire = in_tail =
false;
234 if (in_post && post_integration < 1) {
250 std::cout <<
"\033[93mPulse End\033[00m: "
251 <<
"baseline: " << mean_v[i] <<
" ... adc: " << value <<
" T=" << i
252 <<
" ... area sum " <<
_pulse.
area << std::endl;
261 if (fire || in_tail || in_post) {
274 if (in_post) --post_integration;
278 if (fire || in_tail || in_post) {
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
BEGIN_PROLOG could also be cerr
float _nsigma
A variable holder for a multiplicative factor for the pedestal standard deviation to define the thres...
AlgoSlidingWindow(const std::string name="SlidingWindow")
Default constructor.
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Implementation of AlgoSlidingWindow::reco() method.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
std::vector< short > Waveform_t
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
bool _positive
A boolean to set waveform positive/negative polarity.
Class definition file of AlgoSlidingWindow.
void Reset()
Implementation of AlgoSlidingWindow::reset() method.
float _adc_thres
A variable holder for a user-defined absolute ADC threshold value.
std::vector< double > PedestalMean_t
size_t _min_width
A variable holder to ensure the minimum pulse width.
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
BEGIN_PROLOG could also be cout