12 #include <unordered_map> 30 _F = pset.
get<
float>(
"Fraction");
31 _D = pset.
get<
int> (
"Delay");
58 std::vector<double> cfd; cfd.reserve(wf.size());
62 for (
unsigned int k = 0;
k < wf.size(); ++
k) {
64 auto delayed = -1.0 *
_F * ( (
float) wf.at(
k) - mean_v.at(
k) );
68 cfd.push_back( delayed );
72 cfd.push_back(delayed + ( (
float) wf.at(
k -
_D) - mean_v.at(
k) ) );
83 auto in_peak = [&wf,&sigma_v,&mean_v](
int i,
float thresh) ->
bool 84 {
return wf.at(i) > sigma_v.at(i) * thresh + mean_v.at(i); };
87 for(
const auto&
cross : crossings) {
97 if ( i < 0 ) { i = 0;
break; }
119 if ( i > (
int)(wf.size()) - 1 ) { i = (
int)(wf.size()) - 1;
break; }
182 std::unordered_map<unsigned,pulse_param> delta;
185 for(
const auto&
p : pulses_copy ) {
187 if ( delta.count(
p.t_start) ) {
188 if ( (
p.t_end -
p.t_start) > (delta[
p.t_start].t_end - delta[
p.t_start].t_start) )
189 delta[
p.t_start] =
p;
194 delta[
p.t_start] =
p;
198 for(
const auto &
p : delta)
211 for(
const auto&
p : pulses_copy ) {
213 if ( delta.count(
p.t_end) ) {
214 if ( (
p.t_end -
p.t_start) > (delta[
p.t_end].t_end - delta[
p.t_end].t_start) )
224 for(
const auto &
p : delta)
236 std::map<unsigned,double> crossing;
239 for (
unsigned i = 0; i < trace.size() - 1; ++i) {
252 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
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)...