21 std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
23 const std::string name)
74 double pulse_tail_threshold = 0;
76 double pulse_end_threshold = 0;
78 double pulse_start_baseline = 0;
80 int post_integration = 0;
82 assert(wf.size() == mean_v.size() && wf.size() == sigma_v.size());
90 for (
size_t i = 0; i < wf.size(); ++i) {
94 value = ((double)(wf[i])) - mean_v[i];
96 value = mean_v[i] - ((double)(wf[i]));
98 float start_threshold = 0.;
99 float tail_threshold = 0.;
103 start_threshold = sigma_v[i] *
_nsigma;
111 if ((!fire || in_tail || in_post) && ((double)value > start_threshold)) {
131 std::cout <<
"\033[93mPulse End\033[00m: " 132 <<
"baseline: " << mean_v[i] <<
" ... " 133 <<
" ... adc above: " << value <<
" T=" << i << std::endl;
140 pulse_tail_threshold = tail_threshold;
141 pulse_start_baseline = mean_v[i];
143 pulse_end_threshold = 0.;
149 int buffer_num_index = 0;
151 buffer_num_index = (
int)i -
_pulse_v.back().t_end - 1;
157 if (buffer_num_index < 0) {
158 std::cerr <<
"\033[95m[ERROR]\033[00m Logic error! Negative buffer_num_index..." 166 _pulse.
t_end =
static_cast<int>(i) - buffer_num_index;
183 std::cout <<
"\033[93mPulse End\033[00m: new pulse starts during in_post: " 184 <<
"baseline: " << mean_v[i] <<
" ... " 185 <<
" ... adc above: " << value <<
" T=" << i << std::endl;
192 for (
size_t pre_index =
_pulse.
t_start; pre_index < i; ++pre_index) {
194 double pre_adc = wf[pre_index];
196 pre_adc -= pulse_start_baseline;
198 pre_adc = pulse_start_baseline - pre_adc;
204 std::cout <<
"\033[93mPulse Start\033[00m: " 205 <<
"baseline: " << mean_v[i] <<
" ... threshold: " << start_threshold
206 <<
" ... adc above baseline: " << value <<
" ... pre-adc sum: " <<
_pulse.
area 207 <<
" T=" << i << std::endl;
214 if (fire && value < pulse_tail_threshold) {
220 if ((fire || in_tail || in_post) &&
_verbose) {
221 std::cout << (fire ?
"\033[93mPulsing\033[00m: " :
"\033[93mIn-tail\033[00m: ")
222 <<
"baseline: " << mean_v[i] <<
" std: " << sigma_v[i]
223 <<
" ... adc above baseline " << value <<
" T=" << i << std::endl;
226 if ((fire || in_tail) && value < pulse_end_threshold) {
228 fire = in_tail =
false;
232 if (in_post && post_integration < 1) {
248 std::cout <<
"\033[93mPulse End\033[00m: " 249 <<
"baseline: " << mean_v[i] <<
" ... adc: " << value <<
" T=" << i
250 <<
" ... area sum " <<
_pulse.
area << std::endl;
259 if (fire || in_tail || in_post) {
272 if (in_post) --post_integration;
276 if (fire || in_tail || in_post) {
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
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.
T get(std::string const &key) const
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)...
cet::coded_exception< error, detail::translate > exception