Belle II Software development
SpecialFunctions.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 <tracking/trackFindingCDC/numerics/SpecialFunctions.h>
9
10#include <boost/math/tools/precision.hpp>
11#include <boost/math/special_functions/sinc.hpp>
12
13#include <cmath>
14
15using namespace Belle2;
16using namespace TrackFindingCDC;
17
18double TrackFindingCDC::sinc(double x)
19{
20 return boost::math::sinc_pi(x);
21}
22
23double TrackFindingCDC::asinc(double x)
24{
25 // Implementation inspired by BOOST's sinc
26 BOOST_MATH_STD_USING;
27
28 using namespace boost::math;
29 double const taylor_n_bound = tools::forth_root_epsilon<double>();
30
31 if (abs(x) >= taylor_n_bound) {
32 return asin(x) / x;
33 } else {
34 // approximation by taylor series in x at 0 up to order 0
35 double result = 1.0;
36
37 double const taylor_0_bound = tools::epsilon<double>();
38 if (abs(x) >= taylor_0_bound) {
39 double x2 = x * x;
40 // approximation by taylor series in x at 0 up to order 2
41 result += x2 / 6.0;
42
43 double const taylor_2_bound = tools::root_epsilon<double>();
44 if (abs(x) >= taylor_2_bound) {
45 // approximation by taylor series in x at 0 up to order 4
46 result += x2 * x2 * (3.0 / 40.0);
47 }
48 }
49 return result;
50 }
51}
Abstract base class for different kinds of events.