12 #include <unordered_map> 23 std::unique_ptr<pmtana::RiseTimeCalculatorBase> risetimecalculator,
25 const std::string name)
30 _F = pset.
get<
float>(
"Fraction");
31 _D = pset.
get<
int>(
"Delay");
59 std::vector<double> cfd;
60 cfd.reserve(wf.size());
64 for (
unsigned int k = 0; k < wf.size(); ++k) {
66 auto delayed = -1.0 *
_F * ((float)wf.at(k) - mean_v.at(k));
70 cfd.push_back(delayed);
74 cfd.push_back(delayed + ((
float)wf.at(k -
_D) - mean_v.at(k)));
84 auto in_peak = [&wf, &sigma_v, &mean_v](
int i,
float thresh) ->
bool {
85 return wf.at(i) > sigma_v.at(i) * thresh + mean_v.at(i);
89 for (
const auto&
cross : crossings) {
124 if (i > (
int)(wf.size()) - 1) {
125 i = (int)(wf.size()) - 1;
194 std::unordered_map<unsigned, pulse_param> delta;
197 for (
const auto& p : pulses_copy) {
199 if (delta.count(p.t_start)) {
200 if ((p.t_end - p.t_start) > (delta[p.t_start].t_end - delta[p.t_start].t_start))
201 delta[p.t_start] = p;
206 delta[p.t_start] = p;
210 for (
const auto& p : delta)
222 for (
const auto& p : pulses_copy) {
224 if (delta.count(p.t_end)) {
225 if ((p.t_end - p.t_start) > (delta[p.t_end].t_end - delta[p.t_end].t_start))
235 for (
const auto& p : delta)
247 std::map<unsigned, double> crossing;
250 for (
unsigned i = 0; i < trace.size() - 1; ++i) {
263 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.
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 RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
Implementation of AlgoCFD::reco() method.
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
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)...