10 #include "fhiclcpp/ParameterSet.h"
12 #include <unordered_map>
24 std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
26 const std::string
name)
31 _F = pset.get<
float>(
"Fraction");
32 _D = pset.get<
int> (
"Delay");
61 std::vector<double> cfd; cfd.reserve(wf.size());
65 for (
unsigned int k = 0;
k < wf.size(); ++
k) {
67 auto delayed = -1.0 *
_F * ( (float) wf.at(
k) - mean_v.at(
k) );
71 cfd.push_back( delayed );
75 cfd.push_back(delayed + ( (
float) wf.at(
k -
_D) - mean_v.at(
k) ) );
86 auto in_peak = [&wf,&sigma_v,&mean_v](
int i,
float thresh) ->
bool
87 {
return wf.at(i) > sigma_v.at(i) * thresh + mean_v.at(i); };
90 for(
const auto&
cross : crossings) {
100 if ( i < 0 ) { i = 0;
break; }
122 if ( i > (
int)(wf.size()) - 1 ) { i = (int)(wf.size()) - 1;
break; }
191 std::unordered_map<unsigned,pulse_param> delta;
194 for(
const auto&
p : pulses_copy ) {
196 if ( delta.count(
p.t_start) ) {
197 if ( (
p.t_end -
p.t_start) > (delta[
p.t_start].t_end - delta[
p.t_start].t_start) )
198 delta[
p.t_start] =
p;
203 delta[
p.t_start] =
p;
207 for(
const auto &
p : delta)
220 for(
const auto&
p : pulses_copy ) {
222 if ( delta.count(
p.t_end) ) {
223 if ( (
p.t_end -
p.t_start) > (delta[
p.t_end].t_end - delta[
p.t_end].t_start) )
233 for(
const auto &
p : delta)
245 std::map<unsigned,double> crossing;
248 for (
unsigned i = 0; i < trace.size() - 1; ++i) {
261 crossing[i] = (double) i - trace.at(i) * ( 1.0 / ( trace.at(i+1) - trace.at(i) ) );
const std::map< unsigned, double > LinearZeroPointX(const std::vector< double > &trace)
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
void Reset()
Implementation of AlgoCFD::reset() method.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
M::value_type trace(const M &m)
AlgoCFD(const std::string name="CFD")
Default constructor.
Class definition file of AlgoCFD.
std::vector< short > Waveform_t
auto begin(FixedBins< T, C > const &) noexcept
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Implementation of AlgoCFD::reco() method.
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
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)...