Belle II Software  release-08-00-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 582 of file ECLWaveformFit.cc.

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