Belle II Software development
algorithms.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <ecl/digitization/algorithms.h>
9#include <cmath>
10using namespace std;
11using namespace Belle2::ECL;
12
13double Belle2::ECL::ShaperDSP(double Ti)
14{
15 return ShaperDSP(Ti, (const double*)0);
16}
17
18double Belle2::ECL::ShaperDSP(double Ti, const float* sf)
19{
20 if (sf) {
21 double sd[10];
22 for (int i = 0; i < 10; i++) sd[i] = sf[i]; // conversion to double
23 return ShaperDSP(Ti, sd);
24 }
25 return ShaperDSP(Ti, (const double*)0);
26}
27
28double Belle2::ECL::ShaperDSP(double Ti, const double* s)
29{
30 const double scale = 27.7221;
31 static const double defs[10] = {0.5, 0.6483, 0.4017, 0.3741, 0.8494, 0.00144547, 4.7071, 0.8156, 0.5556, 0.2752};
32 if (!s) s = defs;
33 double t = Ti * (127. / 144.) - s[0];
34 const double dt = 0.2;
35 // Sv123 is defined everywhere so no restriction on t
36 double fm = Sv123(t - dt, s[2], s[3], s[7], s[8], s[1], s[4]);
37 double f0 = Sv123(t, s[2], s[3], s[7], s[8], s[1], s[4]);
38 double fp = Sv123(t + dt, s[2], s[3], s[7], s[8], s[1], s[4]);
39 double w = s[9];
40 // Is this some kind of a low pass filter?
41 double svp = (1 - w) * f0 + (0.5 * w) * (fp + fm);
42
43 if (t > 0) {
44 double y = t / s[6], z = t / s[2];
45 svp -= s[5] * exp(-y) * (1 - exp(-z) * (1 + z * (1 + z * (1 / 2. + z * (1 / 6. + z * (1 / 24. + z * (1 / 120.)))))));
46 }
47 return svp * scale;
48}
49//
50double Belle2::ECL::ShaperDSPofflineFit(double Ti, const double* s, double scale)
51{
52 //
53 //Used to fit and draw offline fit results.
54 //
55 double t = Ti - s[0];
56 const double dt = 0.2;
57 // Sv123 is defined everywhere so no restriction on t
58 double fm = Sv123(t - dt, s[2], s[3], s[7], s[8], s[1], s[4]);
59 double f0 = Sv123(t, s[2], s[3], s[7], s[8], s[1], s[4]);
60 double fp = Sv123(t + dt, s[2], s[3], s[7], s[8], s[1], s[4]);
61 double w = s[9];
62 double svp = (1 - w) * f0 + (0.5 * w) * (fp + fm);
63
64 if (t > 0) {
65 double y = t / s[6], z = t / s[2];
66 svp -= s[5] * exp(-y) * (1 - exp(-z) * (1 + z * (1 + z * (1 / 2. + z * (1 / 6. + z * (1 / 24. + z * (1 / 120.)))))));
67 }
68 return svp * scale;
69}
STL namespace.