8#include <ecl/digitization/shaperdsp.h>
13using namespace Belle2::ECL;
15const double ShaperDSP_t::_defs[] = {0.5, 0.6483, 0.4017, 0.3741, 0.8494, 0.00144547, 4.7071, 0.8156, 0.5556, 0.2752};
19 o << s.t <<
" " << s.c0 <<
" " << s.c0 <<
" " << s.c1 <<
" " << s.s1 <<
" " << s.e0 <<
" " << s.e1 <<
" " << s.es <<
" " << s.ed;
26 o << s0 <<
" " << s.et0 <<
" " << s.et1;
45 double c0r = r.c0 *
c0 - r.s0 *
s0;
46 double s0r = r.c0 *
s0 + r.s0 *
c0;
50 double c1r = r.c1 *
c1 - r.s1 *
s1;
51 double s1r = r.c1 *
s1 + r.s1 *
c1;
67 a.c0 = r.c0 *
c0 - r.s0 *
s0;
68 a.s0 = r.c0 *
s0 + r.s0 *
c0;
69 a.c1 = r.c1 *
c1 - r.s1 *
s1;
70 a.s1 = r.c1 *
s1 + r.s1 *
c1;
115dd_t
operator +(
const dd_t& c0,
const dd_t& c1)
117 return dd_t(c0.first + c1.first, c0.second + c1.second);
122 return dd_t(a * c.first, a * c.second);
127 double dks0, dks1, dksm,
128 dw0, dw1, dwp, dwm, das1, dac1, das0, dac0, dzna, dksm2, ds, dd,
129 dcs0, dsn0, dzn0, td, ts, dr,
130 dcs0s, dsn0s, dcs0d, dsn0d, dcs1s, dsn1s, dcs1d, dsn1d;
132 dr = (ts1 - td1) / td1;
133 if (std::abs(dr) >= 0.0000001) {
145 dr = ((t01 - t02) * (t01 - t02) + (tb1 - tb2) * (tb1 - tb2)) / (t01 * t01 + tb1 * tb1);
148 if (dr < 0.0000000001) {
150 dks0 = dks1 * 1.00001;
152 dks0 = dks1 * 0.99999;
168 dzna = (dksm2 + dwm * dwm) * (dksm2 + dwp * dwp);
170 das0 = dw1 * (dksm2 + dwp * dwm);
171 dac0 = -2 * dksm * dw0 * dw1;
172 das1 = dw0 * (dksm2 - dwp * dwm);
177 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
179 dsn0s = (dsn0 * das0 - dcs0 * dac0) / dzn0;
180 dcs0s = (dcs0 * das0 + dsn0 * dac0) / dzn0;
184 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
186 dsn1s = (dsn0 * das1 - dcs0 * dac1) / dzn0;
187 dcs1s = (dcs0 * das1 + dsn0 * dac1) / dzn0;
191 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
193 dsn0d = (dsn0 * das0 - dcs0 * dac0) / dzn0;
194 dcs0d = (dcs0 * das0 + dsn0 * dac0) / dzn0;
198 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
200 dsn1d = (dsn0 * das1 - dcs0 * dac1) / dzn0;
201 dcs1d = (dcs0 * das1 + dsn0 * dac1) / dzn0;
210 double sc = 1 / (dzna * (ts - td));
211 _cs0 = sc * (dsn0s - dsn0d);
212 _cc0 = sc * (dcs0s - dcs0d);
213 _cs1 = sc * (dsn1s - dsn1d);
214 _cc1 = sc * (dcs1s - dcs1d);
215 _ces = sc * (dcs0s + dcs1s);
216 _ced = sc * (dcs0d + dcs1d);
221 double f0 = (
_cs0 * c.s0 +
_cc0 * c.c0) * c.e0;
222 double f1 = (
_cs1 * c.s1 +
_cc1 * c.c1) * c.e1;
223 double fs =
_ces * c.es;
224 double fd =
_ced * c.ed;
226 return (f0 + f1) + (fd - fs);
231 double f0 = (
_cs0 * c.s0 +
_cc0 * c.c0) * c.e0;
232 double f1 = (
_cs1 * c.s1 +
_cc1 * c.c1) * c.e1;
233 double fs =
_ces * c.es;
234 double fd =
_ced * c.ed;
238 double fsp =
_ds * fs;
239 double fdp =
_dd * fd;
241 double f = (f0 + f1) + (fd - fs);
242 double fp = (f0p + f1p) - (fdp - fsp);
249 double ft0p =
Sv123(t0 +
_tp), ft0 = 0, ft0m = 0;
255 return _w0 * ft0 +
_w1 * (ft0p + ft0m);
263 dd_t ft0p =
ddSv123(t0 +
_tp), ft0 = dd_t(0, 0), ft0m = dd_t(0, 0);
269 return _w0 * ft0 +
_w1 * (ft0p + ft0m);
279 double z = t0.
t *
_dt1;
281 double odd = 1 + z2 * (1 / 6. + z2 * (1 / 120.));
282 double evn = 1 + z2 * (1 / 2. + z2 * (1 / 24.));
283 double texp = evn + z * odd;
284 double df =
_ccc * t0.
et0 * (1 - t0.
et1 * texp);
295 double z = t0.
t *
_dt1;
297 double odd = 1 + z2 * (1 / 6. + z2 * (1 / 120.));
298 double evn = 1 + z2 * (1 / 2. + z2 * (1 / 24.));
299 double texp = evn + z * odd;
300 double u = t0.
et0 * (1 - t0.
et1 * texp);
303 double up = -
_dt0 * u + ((
_dt1 * t0.
et0) * (t0.
et1 * z2)) * ((z2 * z) * (1 / 120.));
304 f.second -=
_ccc * up;
346 init(s.data(), unitscale);
359 return (*
this)(x[0]);
386 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
395 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
404 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
413 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
double _dw0
circular frequency of the first Bessel stage
void fillvector(std::vector< double > &) const
fill vector with response function values and its derivative
dd_t ddSv123(const sv123shift_t &) const
calculate derivative of the Sv123 function
double _cs1
linear coefficient before sin of the second Bessel stage
void init(const double *, double)
calculate some values for Sv123 function
double _dks1
decrement of the second Bessel stage
double _cc0
linear coefficient before cos of the first Bessel stage
double _dt0
coefficient for first exponent factor
void settimeseed(double)
set initial time
double Sv123_filtered(const sv123shift_t &) const
Numerical calculation of the time convolution.
double _cc1
linear coefficient before cos of the second Bessel stage
dd_t ddSv123_filtered(const sv123shift_t &) const
This is derivative of the confolution.
shaperdspshift_t _tzero
initial time
shaperdspshift_t _tstride
time step of the grid for response function calculation
double _cs0
linear coefficient before sin of the first Bessel stage
double _w1
weight coefficient at sv123(t+_filterdt) +sv123(t-_filterdt) = a/2
double _dw1
circular frequency of the second Bessel stage
ShaperDSP_t()
class constructor
double _ced
linear coefficient before second part of tail section
void settimestride(double)
set grid step for function calculation
double Sv123(const sv123shift_t &) const
calculate Sv123 function
dd_t ddShaperDSP(const shaperdspshift_t &) const
calculate derivative of the response function
double _ds
inverse scintillation decay time
void nextseed()
substruct toffset to tzero
double _dd
inverse time of the differential stage
double ShaperDSP(const shaperdspshift_t &) const
calculate response function
double _dks0
decrement of the first Bessel stage
double _w0
weight coefficient at sv123(t) = (1-a)
void setseedoffset(double)
set timeoffset
static constexpr double _filterdt
time shift that include in response function for numerical calculation time convolutions.
void fillarray(int, double *) const
fill array for amplitude and time calculation
static const double _defs[]
parameters of the response function that use as default
shaperdspshift_t _toffset
time offset
double operator()(double) const
wrapper of the function
double _ccc
exponent factor for tail part of the signal
double _ces
linear coefficient before first part of tail section
double _dt1
coefficient for second exponent factor
sv123shift_t _tp
_filterdt
void Sv123_init(double t01, double tb1, double t02, double tb2, double td1, double ts1)
calculate some values for Sv123 function
B2Vector3< DataType > operator*(DataType a, const B2Vector3< DataType > &p)
non-memberfunction Scaling of 3-vectors with a real number
B2Vector3< DataType > operator+(const TVector3 &a, const B2Vector3< DataType > &b)
non-memberfunction for adding a TVector3 to a B2Vector3
struct for a shift of the shaper dsp
shaperdspshift_t operator+(const shaperdspshift_t &) const
addition operator
shaperdspshift_t & operator+=(const shaperdspshift_t &)
increment operator
shaperdspshift_t()
default constructor
double et1
shift parameter 1
void init(double, const ShaperDSP_t &)
initialise
double et0
shift parameter 0
struct to encapsulate the electronic response from energy deposit
double e0
exponent factor for first Bessel stage
double es
first exponent factor for tail part of the signal.
double c0
cos of the first Bessel stage
double s1
sin of the second Bessel stage
double ed
second exponent factor for tail part of the signal.
sv123shift_t operator+(const sv123shift_t &) const
addition operator
bool validshift(const sv123shift_t &x) const
check for a valid shift
double c1
cos of the second Bessel stage
sv123shift_t()
default constructor
double s0
sin of the first Bessel stage
double e1
exponent factor for second Bessel stage
void init(double, const ShaperDSP_t &)
initialise
sv123shift_t & operator+=(const sv123shift_t &)
increment operator