Belle II Software development
EclConfiguration::signalsample_t Struct Reference

a struct for a signal sample More...

#include <EclConfiguration.h>

Public Member Functions

void InitSample (const float *MP, double unitscale=-1)
 
void InitSample (const double *MPd, double unitscale=-1)
 
double Accumulate (const double a, const double t0, double *s) const
 

Public Attributes

double m_sumscale
 energy deposit in fitting window scale factor
 
double m_ft [m_nl *m_ns]
 Simulated signal shape.
 

Detailed Description

a struct for a signal sample

Definition at line 63 of file EclConfiguration.h.

Member Function Documentation

◆ Accumulate()

double Accumulate ( const double  a,
const double  t0,
double *  s 
) const
Parameters
[in]aSignal amplitude
[in]t0Signal offset
[out]sOutput array with added signal
Returns
Energy deposition in ADC units

Definition at line 79 of file EclConfiguration.cc.

80{
81 // input parameters
82 // a -- signal amplitude
83 // t -- signal offset
84 // output parameter
85 // s -- output array with added signal
86 const double itick = getRF() / s_clock; // reciprocal to avoid division in usec^-1 (has to be evaluated at compile time)
87 const double tlen = m_nl - 1.0 / m_ns; // length of the sampled signal in ADC clocks units
88 const double tmax = m_tmin + m_nsmp - 1; // upper range of the fit region
89
90 double t = t0 * itick; // rescale time in usec to ADC clocks
91 double x0 = t, x1 = t + tlen;
92
93 if (x0 > tmax) return 0; // signal starts after the upper range of output array -- do nothing
94 if (x0 < m_tmin) {
95 if (x1 < m_tmin) return 0; // signal ends before lower range of output array -- do nothing
96 x0 = m_tmin; // adjust signal with range of output array
97 }
98
99 int imax = m_nsmp; // length of sampled signal is long enough so
100 // the last touched element is the last element
101 // of the output array
102 if (x1 < tmax) { // if initial time is too early we need to adjust
103 // the last touched element of output array to avoid
104 // out-of-bound situation in m_ft
105 imax = x1 - m_tmin; // imax is always positive so floor can be
106 // replace by simple typecast
107 imax += 1; // like s.end()
108 }
109
110 double imind = ceil(x0 - m_tmin); // store result in double to avoid int->double conversion below
111 // the ceil function today at modern CPUs is surprisingly fast (before it was horribly slow)
112 int imin = imind; // starting point to fill output array
113 double w = ((m_tmin - t) + imind) * double(m_ns);
114 int jmin = w; // starting point in sampled signal array
115 w -= jmin;
116
117 // use linear interpolation between samples. Since signal samples
118 // are aligned with output samples only two weights are need to
119 // calculate to fill output array
120 const double w1 = a * w, w0 = a - w1;
121 double sum = 0;
122 for (int i = imin, j = jmin; i < imax; i++, j += m_ns) {
123 double amp = w0 * m_ft[j] + w1 * m_ft[j + 1];
124 s[i] += amp;
125 sum += amp;
126 }
127 return sum * m_sumscale;
128}
static constexpr double m_tmin
lower range of the signal fitting region in ADC clocks
static constexpr double s_clock
digitization clock in RF units
static constexpr int m_nl
length of samples signal in number of ADC clocks
static constexpr int m_ns
number of samples per ADC clock
static double getRF()
See m_rf.
static constexpr int m_nsmp
number of ADC measurements for signal fitting
double m_ft[m_nl *m_ns]
Simulated signal shape.
double m_sumscale
energy deposit in fitting window scale factor

◆ InitSample() [1/2]

void InitSample ( const double *  MPd,
double  unitscale = -1 
)
Parameters
MPdDouble array of waveform parameters
unitscaleNormalization of template waveform

Definition at line 53 of file EclConfiguration.cc.

54{
55 const int N = m_ns * m_nl;
56 vector<double> MP(MPd, MPd + 10);
57 ShaperDSP_t dsp(MP, u);
58 dsp.settimestride(m_step / m_ns);
59 dsp.fillarray(0.0, N, m_ft);
60
61 double sum = 0;
62 for (int i = 0; i < N; i++) sum += m_ft[i];
63 m_sumscale = m_ns / sum;
64}
static constexpr double m_step
time between points in internal units t_{asrto}*m_rf/2.
Class include function that calculate electronic response from energy deposit
Definition: shaperdsp.h:26

◆ InitSample() [2/2]

void InitSample ( const float *  MP,
double  unitscale = -1 
)
Parameters
MPFloat array of waveform parameters
unitscaleNormalization of template waveform

Definition at line 67 of file EclConfiguration.cc.

68{
69 double MPd[10];
70 for (int i = 0; i < 10; i++) MPd[i] = MP[i];
71 InitSample(MPd, u);
72}
void InitSample(const float *MP, double unitscale=-1)

Member Data Documentation

◆ m_ft

double m_ft[m_nl *m_ns]

Simulated signal shape.

Definition at line 82 of file EclConfiguration.h.

◆ m_sumscale

double m_sumscale

energy deposit in fitting window scale factor

Definition at line 81 of file EclConfiguration.h.


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