Belle II Software  release-08-01-10
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. More...
 

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. More...
 
double m_r1
 See above/.
 

Static Public Attributes

constexpr static int c_nt = 12
 Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps. More...
 
constexpr static int c_ndt = 5
 Number of substeps.
 
constexpr static int c_ntail = 20
 Number of tail steps.
 
constexpr static double c_dt = 0.5
 Time step.
 
constexpr static double c_idt = 1 / c_dt
 Inverted time step.
 
constexpr static double c_dtn = c_dt / c_ndt
 Time substep.
 
constexpr static 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.

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 579 of file ECLWaveformFit.cc.

581 {
582  /* If before pulse start time (negative times), return 0. */
583  int k = 0;
584  while (t0 < 0) {
585  function[k] = 0;
586  derivatives[k] = 0;
587  t0 += c_dt;
588  ++k;
589  if (k >= c_NFitPoints)
590  return;
591  }
592 
593  /* Function and derivative values. */
594  double function0[c_NFitPoints], function1[c_NFitPoints];
595  double derivative0[c_NFitPoints], derivative1[c_NFitPoints];
596 
597  /* Interpolate first c_nt points (short time steps). */
598  double x = t0 * c_idtn;
599  double ix = floor(x);
600  double w = x - ix;
601  int j = ix;
602  double w2 = w * w;
603  double hw2 = 0.5 * w2;
604  double tw3 = ((1. / 6) * w) * w2;
605 
606  /* Number of interpolation points. */
607  int iMax = k + c_nt;
608  if (iMax > c_NFitPoints)
609  iMax = c_NFitPoints;
610 
611  /* Fill interpolation points. */
612  for (int i = k; i < iMax; ++i) {
613  function0[i] = m_FunctionInterpolation[j];
614  function1[i] = m_FunctionInterpolation[j + 1];
615  derivative0[i] = m_DerivativeInterpolation[j];
616  derivative1[i] = m_DerivativeInterpolation[j + 1];
617  j = j + c_ndt;
618  }
619 
620  /* Interpolation. */
621  #pragma omp simd
622  for (int i = k; i < iMax; ++i) {
623  double a[4];
624  double dfdt = (function1[i] - function0[i]) * c_idtn;
625  double fp = derivative1[i] + derivative0[i];
626  a[0] = function0[i];
627  a[1] = derivative0[i];
628  a[2] = -((fp + derivative0[i]) - 3 * dfdt);
629  a[3] = fp - 2 * dfdt;
630  double b2 = 2 * a[2];
631  double b3 = 6 * a[3];
632  function[i] = a[0] + c_dtn * (a[1] * w + b2 * hw2 + b3 * tw3);
633  derivatives[i] = a[1] + b2 * w + b3 * hw2;
634  }
635  t0 = t0 + c_dt * c_nt;
636  if (iMax == c_NFitPoints)
637  return;
638  k = iMax;
639 
640  /* Interpolate next c_ntail points (long time steps). */
641  x = t0 * c_idt;
642  ix = floor(x);
643  w = x - ix;
644  w2 = w * w;
645  hw2 = 0.5 * w2;
646  tw3 = ((1. / 6) * w) * w2;
647 
648  /* Number of interpolation points. */
649  iMax = k + c_ntail - 1;
650  if (iMax > c_NFitPoints)
651  iMax = c_NFitPoints;
652 
653  /* Interpolation. */
654  #pragma omp simd
655  for (int i = k; i < iMax; ++i) {
656  j = c_nt * c_ndt + i - k;
657  /*
658  * The interpolation step is the same as the distance between
659  * the fit points. It is possible to load the values in the interpolation
660  * loop while keeping its vectorization.
661  */
662  double f0 = m_FunctionInterpolation[j];
663  double f1 = m_FunctionInterpolation[j + 1];
664  double fp0 = m_DerivativeInterpolation[j];
665  double fp1 = m_DerivativeInterpolation[j + 1];
666  double a[4];
667  double dfdt = (f1 - f0) * c_idt;
668  double fp = fp1 + fp0;
669  a[0] = f0;
670  a[1] = fp0;
671  a[2] = -((fp + fp0) - 3 * dfdt);
672  a[3] = fp - 2 * dfdt;
673  double b2 = 2 * a[2];
674  double b3 = 6 * a[3];
675  function[i] = a[0] + c_dt * (a[1] * w + b2 * hw2 + b3 * tw3);
676  derivatives[i] = a[1] + b2 * w + b3 * hw2;
677  }
678  if (iMax == c_NFitPoints)
679  return;
680  k = iMax;
681 
682  /* Exponential tail. */
683  while (k < c_NFitPoints) {
684  function[k] = function[k - 1] * m_r0;
685  derivatives[k] = derivatives[k - 1] * m_r1;
686  ++k;
687  }
688 }
double m_r0
Assuming exponential drop of the signal function far away from 0, extrapolate it to +inf.
double m_FunctionInterpolation[c_nt *c_ndt+c_ntail]
Function values.
constexpr static double c_idt
Inverted time step.
constexpr static int c_ntail
Number of tail steps.
constexpr static double c_dtn
Time substep.
constexpr static double c_idtn
Inverted time substep.
double m_DerivativeInterpolation[c_nt *c_ndt+c_ntail]
Derivative values.
constexpr static int c_nt
Signal function is sampled in c_nt time steps with c_ndt substeps and c_ntail steps.
constexpr static double c_dt
Time step.
constexpr static int c_ndt
Number of substeps.

Member Data Documentation

◆ c_nt

constexpr static 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.

◆ 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.


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