73 double pulse_tail_threshold = 0;
75 double pulse_end_threshold = 0;
77 double pulse_start_baseline = 0;
79 int post_integration = 0;
81 assert(wf.size() == mean_v.size() && wf.size() == sigma_v.size());
89 for (
size_t i = 0; i < wf.size(); ++i) {
93 value = ((double)(wf[i])) - mean_v[i];
95 value = mean_v[i] - ((double)(wf[i]));
97 float start_threshold = 0.;
98 float tail_threshold = 0.;
102 start_threshold = sigma_v[i] *
_nsigma;
110 if ((!fire || in_tail || in_post) && ((double)value > start_threshold)) {
122 std::cout <<
"\033[93mPulse End\033[00m: " 123 <<
"baseline: " << mean_v[i] <<
" ... " 124 <<
" ... adc above: " << value <<
" T=" << i <<
std::endl;
131 pulse_tail_threshold = tail_threshold;
132 pulse_start_baseline = mean_v[i];
134 pulse_end_threshold = 0.;
140 int buffer_num_index = 0;
142 buffer_num_index = (
int)i -
_pulse_v.back().t_end - 1;
148 if (buffer_num_index < 0) {
149 std::cerr <<
"\033[95m[ERROR]\033[00m Logic error! Negative buffer_num_index..." 157 _pulse.
t_end =
static_cast<int>(i) - buffer_num_index;
166 std::cout <<
"\033[93mPulse End\033[00m: new pulse starts during in_post: " 167 <<
"baseline: " << mean_v[i] <<
" ... " 168 <<
" ... adc above: " << value <<
" T=" << i <<
std::endl;
175 for (
size_t pre_index =
_pulse.
t_start; pre_index < i; ++pre_index) {
177 double pre_adc = wf[pre_index];
179 pre_adc -= pulse_start_baseline;
181 pre_adc = pulse_start_baseline - pre_adc;
187 std::cout <<
"\033[93mPulse Start\033[00m: " 188 <<
"baseline: " << mean_v[i] <<
" ... threshold: " << start_threshold
189 <<
" ... adc above baseline: " << value <<
" ... pre-adc sum: " <<
_pulse.
area 197 if (fire && value < pulse_tail_threshold) {
203 if ((fire || in_tail || in_post) &&
_verbose) {
204 std::cout << (fire ?
"\033[93mPulsing\033[00m: " :
"\033[93mIn-tail\033[00m: ")
205 <<
"baseline: " << mean_v[i] <<
" std: " << sigma_v[i]
206 <<
" ... adc above baseline " << value <<
" T=" << i <<
std::endl;
209 if ((fire || in_tail) && value < pulse_end_threshold) {
211 fire = in_tail =
false;
215 if (in_post && post_integration < 1) {
223 std::cout <<
"\033[93mPulse End\033[00m: " 224 <<
"baseline: " << mean_v[i] <<
" ... adc: " << value <<
" T=" << i
234 if (fire || in_tail || in_post) {
247 if (in_post) --post_integration;
251 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
bool _positive
A boolean to set waveform positive/negative polarity.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
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
QTextStream & endl(QTextStream &s)