8 #include <ecl/digitization/shaperdsp.h>
13 using namespace Belle2::ECL;
15 const 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;
30 void ShaperDSP_t::sv123shift_t::init(
double _t,
const ShaperDSP_t& _p)
33 sincos(t * _p.
_dw0, &s0, &c0);
34 sincos(t * _p.
_dw1, &s1, &c1);
35 e0 = exp(-t * _p.
_dks0);
36 e1 = exp(-t * _p.
_dks1);
37 es = exp(-t * _p.
_ds);
38 ed = exp(-t * _p.
_dd);
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;
79 void ShaperDSP_t::shaperdspshift_t::init(
double _t,
const ShaperDSP_t& _p)
81 sv123shift_t::init(_t, _p);
82 et0 = exp(-t * _p.
_dt0);
83 et1 = exp(-t * _p.
_dt1);
90 sv123shift_t::operator +=(r0);
114 dd_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);
124 void ShaperDSP_t::Sv123_init(
double t01,
double tb1,
double t02,
double tb2,
double td1,
double ts1)
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;
235 double f0p = (_dw0 * c.e0) * (_cs0 * c.c0 - _cc0 * c.s0) - (_dks0 * f0);
236 double f1p = (_dw1 * c.e1) * (_cs1 * c.c1 - _cc1 * c.s1) - (_dks1 * f1);
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;
252 ft0m = Sv123(t0 + _tm);
254 return _w0 * ft0 + _w1 * (ft0p + ft0m);
262 dd_t ft0p = ddSv123(t0 + _tp), ft0 = dd_t(0, 0), ft0m = dd_t(0, 0);
266 ft0m = ddSv123(t0 + _tm);
268 return _w0 * ft0 + _w1 * (ft0p + ft0m);
276 double f = Sv123_filtered(t00);
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);
292 dd_t f = ddSv123_filtered(t00);
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;
308 void ShaperDSP_t::init(
const double* s,
double unitscale)
316 Sv123_init(t01, tb1, t02, tb2, td1, ts1);
333 _tp.init(_filterdt, *
this);
334 _tm.init(-_filterdt, *
this);
337 void ShaperDSP_t::init(
const double* s)
342 void ShaperDSP_t::init(
const std::vector<double>& s,
double unitscale)
345 init(s.data(), unitscale);
347 init(_defs, unitscale);
350 double ShaperDSP_t::operator()(
double t)
const
353 return ShaperDSP(t0);
356 double ShaperDSP_t::operator()(
double* x,
double*)
358 return (*
this)(x[0]);
361 void ShaperDSP_t::settimestride(
double dt)
363 _tstride.init(dt, *
this);
366 void ShaperDSP_t::setseedoffset(
double dt)
368 _toffset.init(dt, *
this);
371 void ShaperDSP_t::settimeseed(
double t0)
373 _tzero.init(t0 - _toff, *
this);
376 void ShaperDSP_t::nextseed()
381 void ShaperDSP_t::fillarray(
int n,
double* s)
const
385 for (
int i = 0; i < n; i++, t0 += _tstride) {
386 s[i] = ShaperDSP(t0);
390 void ShaperDSP_t::fillarray(
int n, dd_t* s)
const
394 for (
int i = 0; i < n; i++, t0 += _tstride) {
395 s[i] = ddShaperDSP(t0);
399 void ShaperDSP_t::fillarray(
double t,
int n,
double* s)
const
403 for (
int i = 0; i < n; i++, t0 += _tstride) {
404 s[i] = ShaperDSP(t0);
408 void ShaperDSP_t::fillarray(
double t,
int n, dd_t* s)
const
412 for (
int i = 0; i < n; i++, t0 += _tstride) {
413 s[i] = ddShaperDSP(t0);
417 void ShaperDSP_t::fillvector(std::vector<double>& s)
const
419 fillarray(s.size(), s.data());
422 void ShaperDSP_t::fillvector(std::vector<dd_t>& s)
const
424 fillarray(s.size(), s.data());
427 void ShaperDSP_t::fillvector(
double t, std::vector<double>& s)
const
429 fillarray(t, s.size(), s.data());
432 void ShaperDSP_t::fillvector(
double t, std::vector<dd_t>& s)
const
434 fillarray(t, s.size(), s.data());
Class include function that calculate electronic response from energy deposit
double _dw0
circular frequency of the first Bessel stage
double _dks1
decrement of the second Bessel stage
double _dt0
coefficient for first exponent factor
double _dw1
circular frequency of the second Bessel stage
double _ds
inverse scintillation decay time
double _dd
inverse time of the differential stage
double _dks0
decrement of the first Bessel stage
double _dt1
coefficient for second exponent factor
B2Vector3< DataType > operator*(DataType a, const B2Vector3< DataType > &p)
non-memberfunction Scaling of 3-vectors with a real number
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
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
double et1
shift parameter 1
double et0
shift parameter 0
struct to encapsulate the electronic response from energy deposit
bool validshift(const sv123shift_t &x) const
check for a valid shift