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;
82 et0 = exp(-t * _p.
_dt0);
83 et1 = exp(-t * _p.
_dt1);
114dd_t
operator +(
const dd_t& c0,
const dd_t& c1)
116 return dd_t(c0.first + c1.first, c0.second + c1.second);
121 return dd_t(a * c.first, a * c.second);
126 double dks0, dks1, dksm,
127 dw0, dw1, dwp, dwm, das1, dac1, das0, dac0, dzna, dksm2, ds, dd,
128 dcs0, dsn0, dzn0, td, ts, dr,
129 dcs0s, dsn0s, dcs0d, dsn0d, dcs1s, dsn1s, dcs1d, dsn1d;
131 dr = (ts1 - td1) / td1;
132 if (std::abs(dr) >= 0.0000001) {
144 dr = ((t01 - t02) * (t01 - t02) + (tb1 - tb2) * (tb1 - tb2)) / (t01 * t01 + tb1 * tb1);
147 if (dr < 0.0000000001) {
149 dks0 = dks1 * 1.00001;
151 dks0 = dks1 * 0.99999;
167 dzna = (dksm2 + dwm * dwm) * (dksm2 + dwp * dwp);
169 das0 = dw1 * (dksm2 + dwp * dwm);
170 dac0 = -2 * dksm * dw0 * dw1;
171 das1 = dw0 * (dksm2 - dwp * dwm);
176 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
178 dsn0s = (dsn0 * das0 - dcs0 * dac0) / dzn0;
179 dcs0s = (dcs0 * das0 + dsn0 * dac0) / dzn0;
183 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
185 dsn1s = (dsn0 * das1 - dcs0 * dac1) / dzn0;
186 dcs1s = (dcs0 * das1 + dsn0 * dac1) / dzn0;
190 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
192 dsn0d = (dsn0 * das0 - dcs0 * dac0) / dzn0;
193 dcs0d = (dcs0 * das0 + dsn0 * dac0) / dzn0;
197 dzn0 = dcs0 * dcs0 + dsn0 * dsn0;
199 dsn1d = (dsn0 * das1 - dcs0 * dac1) / dzn0;
200 dcs1d = (dcs0 * das1 + dsn0 * dac1) / dzn0;
209 double sc = 1 / (dzna * (ts - td));
210 _cs0 = sc * (dsn0s - dsn0d);
211 _cc0 = sc * (dcs0s - dcs0d);
212 _cs1 = sc * (dsn1s - dsn1d);
213 _cc1 = sc * (dcs1s - dcs1d);
214 _ces = sc * (dcs0s + dcs1s);
215 _ced = sc * (dcs0d + dcs1d);
220 double f0 = (
_cs0 * c.s0 +
_cc0 * c.c0) * c.e0;
221 double f1 = (
_cs1 * c.s1 +
_cc1 * c.c1) * c.e1;
222 double fs =
_ces * c.es;
223 double fd =
_ced * c.ed;
225 return (f0 + f1) + (fd - fs);
230 double f0 = (
_cs0 * c.s0 +
_cc0 * c.c0) * c.e0;
231 double f1 = (
_cs1 * c.s1 +
_cc1 * c.c1) * c.e1;
232 double fs =
_ces * c.es;
233 double fd =
_ced * c.ed;
237 double fsp =
_ds * fs;
238 double fdp =
_dd * fd;
240 double f = (f0 + f1) + (fd - fs);
241 double fp = (f0p + f1p) - (fdp - fsp);
248 double ft0p =
Sv123(t0 +
_tp), ft0 = 0, ft0m = 0;
254 return _w0 * ft0 +
_w1 * (ft0p + ft0m);
262 dd_t ft0p =
ddSv123(t0 +
_tp), ft0 = dd_t(0, 0), ft0m = dd_t(0, 0);
268 return _w0 * ft0 +
_w1 * (ft0p + ft0m);
278 double z = t0.
t *
_dt1;
280 double odd = 1 + z2 * (1 / 6. + z2 * (1 / 120.));
281 double evn = 1 + z2 * (1 / 2. + z2 * (1 / 24.));
282 double texp = evn + z * odd;
283 double df =
_ccc * t0.
et0 * (1 - t0.
et1 * texp);
294 double z = t0.
t *
_dt1;
296 double odd = 1 + z2 * (1 / 6. + z2 * (1 / 120.));
297 double evn = 1 + z2 * (1 / 2. + z2 * (1 / 24.));
298 double texp = evn + z * odd;
299 double u = t0.
et0 * (1 - t0.
et1 * texp);
302 double up = -
_dt0 * u + ((
_dt1 * t0.
et0) * (t0.
et1 * z2)) * ((z2 * z) * (1 / 120.));
303 f.second -=
_ccc * up;
345 init(s.data(), unitscale);
358 return (*
this)(x[0]);
385 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
394 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
403 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
412 for (
int i = 0; i < n; i++, t0 +=
_tstride) {
Class include function that calculate electronic response from energy deposit
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
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
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
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