13 #include <unordered_map> 26 const std::string name)
31 _F = pset.
get<
float>(
"Fraction");
32 _D = pset.
get<
int> (
"Delay");
64 std::vector<double> cfd; cfd.reserve(wf.size());
68 for (
unsigned int k = 0; k < wf.size(); ++k) {
70 auto delayed = -1.0 *
_F * ( (float) wf.at(k) - mean_v.at(k) );
74 cfd.push_back( delayed );
78 cfd.push_back(delayed + ( (
float) wf.at(k -
_D) - mean_v.at(k) ) );
89 auto in_peak = [&wf,&sigma_v,&mean_v](
int i,
float thresh) ->
bool 90 {
return wf.at(i) > sigma_v.at(i) * thresh + mean_v.at(i); };
93 for(
const auto&
cross : crossings) {
103 if ( i < 0 ) { i = 0;
break; }
125 if ( i > (
int)(wf.size()) - 1 ) { i = (int)(wf.size()) - 1;
break; }
188 std::unordered_map<unsigned,pulse_param> delta;
191 for(
const auto& p : pulses_copy ) {
193 if ( delta.count(p.t_start) ) {
194 if ( (p.t_end - p.t_start) > (delta[p.t_start].t_end - delta[p.t_start].t_start) )
195 delta[p.t_start] = p;
200 delta[p.t_start] = p;
204 for(
const auto & p : delta)
217 for(
const auto& p : pulses_copy ) {
219 if ( delta.count(p.t_end) ) {
220 if ( (p.t_end - p.t_start) > (delta[p.t_end].t_end - delta[p.t_end].t_start) )
230 for(
const auto & p : delta)
242 std::map<unsigned,double> crossing;
245 for (
unsigned i = 0; i < trace.size() - 1; ++i) {
258 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.
virtual ~AlgoCFD()
Default destructor.
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< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
std::vector< short > Waveform_t
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)...