Belle II Software development
Spline.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
9/* Own header. */
10#include <framework/utilities/Spline.h>
11
12/* Framework headers. */
13#include <framework/logging/Logger.h>
14
15using namespace Belle2;
16
17void Spline::muidSpline(int n, double dx, double Y[], double B[], double C[], double D[])
18{
19 if (n < 2)
20 B2FATAL("The spline interpolation can't be applied (histograms with less than 3 bins).");
21 D[0] = dx;
22 C[1] = (Y[1] - Y[0]) / dx;
23 for (int i = 1; i < n - 1; i++) {
24 D[i] = dx;
25 B[i] = dx * 4.0;
26 C[i + 1] = (Y[i + 1] - Y[i]) / dx;
27 C[i] = C[i + 1] - C[i];
28 }
29 B[0] = -dx;
30 B[n - 1] = -dx;
31 C[0] = (C[2] - C[1]) / 6.0;
32 C[n - 1] = -(C[n - 2] - C[n - 3]) / 6.0;
33 for (int i = 1; i < n; i++) {
34 double temp = dx / B[i - 1];
35 B[i] -= temp * dx;
36 C[i] -= temp * C[i - 1];
37 }
38 C[n - 1] /= B[n - 1];
39 for (int i = n - 2; i >= 0; i--) {
40 C[i] = (C[i] - D[i] * C[i + 1]) / B[i];
41 }
42 B[n - 1] = (Y[n - 1] - Y[n - 2]) / dx + (C[n - 2] + C[n - 1] * 2.0) * dx;
43 for (int i = 0; i < n - 1; i++) {
44 B[i] = (Y[i + 1] - Y[i]) / dx - (C[i + 1] + C[i] * 2.0) * dx;
45 D[i] = (C[i + 1] - C[i]) / dx;
46 C[i] = C[i] * 3.0;
47 }
48 C[n - 1] = C[n - 1] * 3.0;
49 D[n - 1] = D[n - 2];
50}
Abstract base class for different kinds of events.