91 int nSamples = signal.size();
112 for (
auto it = signal.rbegin(); (nPed <
mPreSamples) && it != signal.rend(); ++it) {
128 float maxSample = 0.;
131 short ap = -1, app = -1;
132 double b0 = 0.,
b1 = 0., b2 = 0., y2 = 0.;
133 double sa0 = 0., sa1 = 0., sa2 = 0., sa3 = 0., sa4 = 0.;
135 int firstS = nSamples;
137 for (
int i = 1;
i <=
j;
i++) {
138 short a = signal[firstS -
i] - pedMean;
139 float xi =
i * mDecTime;
144 if (
a == maxSample) {
149 if (app > 0 && ap > 0) {
153 float atmp = 0.5 * (app +
a);
154 float xiprev = xi - mDecTime;
155 float st = (atmp - ap) * mexp[
i - 1];
158 b2 +=
st * xiprev * xiprev;
159 y2 += atmp * atmp - ap * ap;
166 if (maxSample > 900 && nMax >= 3) {
169 sa0 = ma0[
i] - ma0[
i - 2];
170 sa1 = ma1[
i] - ma1[
i - 2];
171 sa2 = ma2[
i] - ma2[
i - 2];
172 sa3 = ma3[
i] - ma3[
i - 2];
173 sa4 = ma4[
i] - ma4[
i - 2];
174 float st = ap * mexp[
i - 1];
175 float xiprev = xi - mDecTime;
178 b2 -=
st * xiprev * xiprev;
180 st = app * mexp[
i - 2];
184 b2 -=
st * xiprev * xiprev;
191 float st =
a * mexp[
i];
197 sa0 = ma0[
i] - ma0[
i - 1];
198 sa1 = ma1[
i] - ma1[
i - 1];
199 sa2 = ma2[
i] - ma2[
i - 1];
200 sa3 = ma3[
i] - ma3[
i - 1];
201 sa4 = ma4[
i] - ma4[
i - 1];
206 if (maxSample < mMinTimeCalc) {
221 double a,
b,
c, d, e;
223 a = ma1[
j] * b0 - ma0[
j] *
b1;
224 b = ma0[
j] * b2 + 2. * ma1[
j] *
b1 - 3. * ma2[
j] * b0;
225 c = 3. * (ma3[
j] * b0 - ma1[
j] * b2);
226 d = 3. * ma2[
j] * b2 - ma4[
j] * b0 - 2. * ma3[
j] *
b1;
227 e = ma4[
j] *
b1 - ma3[
j] * b2;
229 a = (ma1[
j] - sa1) * b0 - (ma0[
j] - sa0) *
b1;
230 b = (ma0[
j] - sa0) * b2 + 2. * (ma1[
j] - sa1) *
b1 - 3. * (ma2[
j] - sa2) * b0;
231 c = 3. * ((ma3[
j] - sa3) * b0 - (ma1[
j] - sa1) * b2);
232 d = 3. * (ma2[
j] - sa2) * b2 - (ma4[
j] - sa4) * b0 - 2. * (ma3[
j] - sa4) *
b1;
233 e = (ma4[
j] - sa4) *
b1 - (ma3[
j] - sa3) * b2;
239 if (ma0[
j] *
b1 - ma1[
j] * b0 != 0) {
240 z = (ma1[
j] *
b1 - ma2[
j] * b0) / (ma0[
j] *
b1 - ma1[
j] * b0) - 1.;
242 double q = 0., dq = 0., ddq = 0., lq = 0., dz = 0.1;
246 q =
a * z4 +
b * z3 +
c * z2 + d *
z + e;
247 dq = 4. *
a * z3 + 3. *
b * z2 + 2. *
c *
z + d;
248 ddq = 12. *
a * z2 + 6. *
b *
z + 2. *
c;
250 lq = q * ddq / (dq * dq);
254 double ttt = dq * (1. - 0.5 * lq);
261 while (TMath::Abs(q) > 0.0001 && (++it < 15)) {
266 q =
a * z4 +
b * z3 +
c * z2 + d *
z + e;
267 dq = 4. *
a * z3 + 3. *
b * z2 + 2. *
c *
z + d;
268 ddq = 12. *
a * z2 + 6. *
b *
z + 2. *
c;
270 lq = q * ddq / (dq * dq);
271 ttt = dq * (1. - 0.5 * lq);
285 double denom = ma4[
j] - 4. * ma3[
j] *
z + 6. * ma2[
j] *
z *
z - 4. * ma1[
j] *
z *
z *
z + ma0[
j] *
z *
z *
z *
z;
287 mAmp = 4. *
exp(-2 -
z) * (b2 - 2. *
b1 *
z + b0 *
z *
z) / denom;
292 if ((TMath::Abs(q) < mQAccuracy) && (
mAmp < 1.2 * maxSample)) {
294 mChi2 = (y2 - 0.25 *
exp(2. +
z) *
mAmp * (b2 - 2 *
b1 *
z + b0 * z2)) / nSamples;