Belle II Software release-09-00-01
SignalInterpolation2 Struct Reference

Interpolation of signal shape using function values and the first derivative. More...

#include <ECLWaveformFit.h>

Public Member Functions

 SignalInterpolation2 ()
 Default constructor.
 
 SignalInterpolation2 (const std::vector< double > &)
 Constructor with parameters with the parameter layout as in ECLDigitWaveformParameters.
 
void getShape (double t0, double *function, double *derivatives) const
 Returns signal shape and derivatives in 31 equidistant time points starting from t0.
 

Public Attributes

double m_FunctionInterpolation [c_nt *c_ndt+c_ntail]
 Function values.
 
double m_DerivativeInterpolation [c_nt *c_ndt+c_ntail]
 Derivative values.
 
double m_r0
 Assuming exponential drop of the signal function far away from 0, extrapolate it to +inf.
 
double m_r1
 See above/.
 

Static Public Attributes

static constexpr int c_nt = 12
 Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps.
 
static constexpr int c_ndt = 5
 Number of substeps.
 
static constexpr int c_ntail = 20
 Number of tail steps.
 
static constexpr double c_dt = 0.5
 Time step.
 
static constexpr double c_idt = 1 / c_dt
 Inverted time step.
 
static constexpr double c_dtn = c_dt / c_ndt
 Time substep.
 
static constexpr double c_idtn = c_ndt / c_dt
 Inverted time substep.
 

Detailed Description

Interpolation of signal shape using function values and the first derivative.

Definition at line 57 of file ECLWaveformFit.h.

Constructor & Destructor Documentation

◆ SignalInterpolation2() [1/2]

Default constructor.

Definition at line 105 of file ECLWaveformFit.h.

105{};

◆ SignalInterpolation2() [2/2]

SignalInterpolation2 ( const std::vector< double > &  s)
explicit

Constructor with parameters with the parameter layout as in ECLDigitWaveformParameters.

Definition at line 632 of file ECLWaveformFit.cc.

633{
634 double T0 = -0.2;
635 std::vector<double> p(s.begin() + 1, s.end());
636 p[1] = std::max(0.0029, p[1]);
637 p[4] = std::max(0.0029, p[4]);
638
639 ShaperDSP_t dsp(p, s[0]);
640 dsp.settimestride(c_dtn);
641 dsp.settimeseed(T0);
642 dd_t t[(c_nt + c_ntail)*c_ndt];
643 dsp.fillarray(sizeof(t) / sizeof(t[0]), t);
644
645 for (int i = 0; i < c_nt * c_ndt; i++) {
646 m_FunctionInterpolation[i] = t[i].first;
647 m_DerivativeInterpolation[i] = t[i].second;
648 }
649 for (int i = 0; i < c_ntail; i++) {
650 int j = c_nt * c_ndt + i;
651 int k = c_nt * c_ndt + i * c_ndt;
652 m_FunctionInterpolation[j] = t[k].first;
653 m_DerivativeInterpolation[j] = t[k].second;
654 }
655 int i1 = c_nt * c_ndt + c_ntail - 2;
656 int i2 = c_nt * c_ndt + c_ntail - 1;
659}
Class include function that calculate electronic response from energy deposit
Definition: shaperdsp.h:26
double m_r0
Assuming exponential drop of the signal function far away from 0, extrapolate it to +inf.
static constexpr int c_ntail
Number of tail steps.
double m_FunctionInterpolation[c_nt *c_ndt+c_ntail]
Function values.
static constexpr int c_nt
Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps.
double m_DerivativeInterpolation[c_nt *c_ndt+c_ntail]
Derivative values.
static constexpr int c_ndt
Number of substeps.
static constexpr double c_dtn
Time substep.

Member Function Documentation

◆ getShape()

void getShape ( double  t0,
double *  function,
double *  derivatives 
) const

Returns signal shape and derivatives in 31 equidistant time points starting from t0.

Parameters
[in]t0Time.
[out]functionFunction values.
[out]derivativesDerivatives.

Definition at line 661 of file ECLWaveformFit.cc.

663{
664 /* If before pulse start time (negative times), return 0. */
665 int k = 0;
666 while (t0 < 0) {
667 function[k] = 0;
668 derivatives[k] = 0;
669 t0 += c_dt;
670 ++k;
671 if (k >= c_NFitPoints)
672 return;
673 }
674
675 /* Function and derivative values. */
676 double function0[c_NFitPoints], function1[c_NFitPoints];
677 double derivative0[c_NFitPoints], derivative1[c_NFitPoints];
678
679 /* Interpolate first c_nt points (short time steps). */
680 double x = t0 * c_idtn;
681 double ix = floor(x);
682 double w = x - ix;
683 int j = ix;
684 double w2 = w * w;
685 double hw2 = 0.5 * w2;
686 double tw3 = ((1. / 6) * w) * w2;
687
688 /* Number of interpolation points. */
689 int iMax = k + c_nt;
690 if (iMax > c_NFitPoints)
691 iMax = c_NFitPoints;
692
693 /* Fill interpolation points. */
694 for (int i = k; i < iMax; ++i) {
695 function0[i] = m_FunctionInterpolation[j];
696 function1[i] = m_FunctionInterpolation[j + 1];
697 derivative0[i] = m_DerivativeInterpolation[j];
698 derivative1[i] = m_DerivativeInterpolation[j + 1];
699 j = j + c_ndt;
700 }
701
702 /* Interpolation. */
703 #pragma omp simd
704 for (int i = k; i < iMax; ++i) {
705 double a[4];
706 double dfdt = (function1[i] - function0[i]) * c_idtn;
707 double fp = derivative1[i] + derivative0[i];
708 a[0] = function0[i];
709 a[1] = derivative0[i];
710 a[2] = -((fp + derivative0[i]) - 3 * dfdt);
711 a[3] = fp - 2 * dfdt;
712 double b2 = 2 * a[2];
713 double b3 = 6 * a[3];
714 function[i] = a[0] + c_dtn * (a[1] * w + b2 * hw2 + b3 * tw3);
715 derivatives[i] = a[1] + b2 * w + b3 * hw2;
716 }
717 t0 = t0 + c_dt * c_nt;
718 if (iMax == c_NFitPoints)
719 return;
720 k = iMax;
721
722 /* Interpolate next c_ntail points (long time steps). */
723 x = t0 * c_idt;
724 ix = floor(x);
725 w = x - ix;
726 w2 = w * w;
727 hw2 = 0.5 * w2;
728 tw3 = ((1. / 6) * w) * w2;
729
730 /* Number of interpolation points. */
731 iMax = k + c_ntail - 1;
732 if (iMax > c_NFitPoints)
733 iMax = c_NFitPoints;
734
735 /* Interpolation. */
736 #pragma omp simd
737 for (int i = k; i < iMax; ++i) {
738 j = c_nt * c_ndt + i - k;
739 /*
740 * The interpolation step is the same as the distance between
741 * the fit points. It is possible to load the values in the interpolation
742 * loop while keeping its vectorization.
743 */
744 double f0 = m_FunctionInterpolation[j];
745 double f1 = m_FunctionInterpolation[j + 1];
746 double fp0 = m_DerivativeInterpolation[j];
747 double fp1 = m_DerivativeInterpolation[j + 1];
748 double a[4];
749 double dfdt = (f1 - f0) * c_idt;
750 double fp = fp1 + fp0;
751 a[0] = f0;
752 a[1] = fp0;
753 a[2] = -((fp + fp0) - 3 * dfdt);
754 a[3] = fp - 2 * dfdt;
755 double b2 = 2 * a[2];
756 double b3 = 6 * a[3];
757 function[i] = a[0] + c_dt * (a[1] * w + b2 * hw2 + b3 * tw3);
758 derivatives[i] = a[1] + b2 * w + b3 * hw2;
759 }
760 if (iMax == c_NFitPoints)
761 return;
762 k = iMax;
763
764 /* Exponential tail. */
765 while (k < c_NFitPoints) {
766 function[k] = function[k - 1] * m_r0;
767 derivatives[k] = derivatives[k - 1] * m_r1;
768 ++k;
769 }
770}
static constexpr double c_idt
Inverted time step.
static constexpr double c_idtn
Inverted time substep.
static constexpr double c_dt
Time step.

Member Data Documentation

◆ c_dt

constexpr double c_dt = 0.5
staticconstexpr

Time step.

Definition at line 72 of file ECLWaveformFit.h.

◆ c_dtn

constexpr double c_dtn = c_dt / c_ndt
staticconstexpr

Time substep.

Definition at line 78 of file ECLWaveformFit.h.

◆ c_idt

constexpr double c_idt = 1 / c_dt
staticconstexpr

Inverted time step.

Definition at line 75 of file ECLWaveformFit.h.

◆ c_idtn

constexpr double c_idtn = c_ndt / c_dt
staticconstexpr

Inverted time substep.

Definition at line 81 of file ECLWaveformFit.h.

◆ c_ndt

constexpr int c_ndt = 5
staticconstexpr

Number of substeps.

Definition at line 66 of file ECLWaveformFit.h.

◆ c_nt

constexpr int c_nt = 12
staticconstexpr

Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps.

c_dt is the time step.

Definition at line 63 of file ECLWaveformFit.h.

◆ c_ntail

constexpr int c_ntail = 20
staticconstexpr

Number of tail steps.

Definition at line 69 of file ECLWaveformFit.h.

◆ m_DerivativeInterpolation

double m_DerivativeInterpolation[c_nt *c_ndt+c_ntail]

Derivative values.

Definition at line 87 of file ECLWaveformFit.h.

◆ m_FunctionInterpolation

double m_FunctionInterpolation[c_nt *c_ndt+c_ntail]

Function values.

Definition at line 84 of file ECLWaveformFit.h.

◆ m_r0

double m_r0

Assuming exponential drop of the signal function far away from 0, extrapolate it to +inf.

f(i_last + i) = f(i_last)*m_r0^i f'(i_last + i) = f'(i_last)*m_r1^i where i_last is the last point within sampled values in m_FunctionInterpolation (m_DerivativeInterpolation).

Definition at line 97 of file ECLWaveformFit.h.

◆ m_r1

double m_r1

See above/.

Definition at line 100 of file ECLWaveformFit.h.


The documentation for this struct was generated from the following files: