Belle II Software  release-05-02-19
SpecialFunctions.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/numerics/SpecialFunctions.h>
11 
12 #include <boost/math/tools/precision.hpp>
13 #include <boost/math/special_functions/sinc.hpp>
14 
15 #include <cmath>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 double TrackFindingCDC::sinc(double x)
21 {
22  return boost::math::sinc_pi(x);
23 }
24 
25 double TrackFindingCDC::asinc(double x)
26 {
27  // Implementation inspired by BOOST's sinc
28  BOOST_MATH_STD_USING;
29 
30  using namespace boost::math;
31  double const taylor_n_bound = tools::forth_root_epsilon<double>();
32 
33  if (abs(x) >= taylor_n_bound) {
34  return asin(x) / x;
35  } else {
36  // approximation by taylor series in x at 0 up to order 0
37  double result = 1.0;
38 
39  double const taylor_0_bound = tools::epsilon<double>();
40  if (abs(x) >= taylor_0_bound) {
41  double x2 = x * x;
42  // approximation by taylor series in x at 0 up to order 2
43  result += x2 / 6.0;
44 
45  double const taylor_2_bound = tools::root_epsilon<double>();
46  if (abs(x) >= taylor_2_bound) {
47  // approximation by taylor series in x at 0 up to order 4
48  result += x2 * x2 * (3.0 / 40.0);
49  }
50  }
51  return result;
52  }
53 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19