Belle II Software  release-05-02-19
Quadratic.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - 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 #pragma once
11 
12 #include <utility>
13 #include <cmath>
14 
15 namespace Belle2 {
21  namespace TrackFindingCDC {
22 
25  template<class ANumber>
26  inline auto square(ANumber t) -> decltype(t* t) {return t * t;}
27 
35  inline double hypot2(double x, double y) { return sqrt(x * x + y * y); }
36 
38  inline double hypot3(double x, double y, double z) { return sqrt(x * x + y * y + z * z); }
39 
48  inline std::pair<double, double> solveQuadraticABC(const double a, const double b, const double c)
49  {
50  /*if ( a == 0 ){
51  // this distinction must not be made since the else block gives the same result
52  // we may save some computation steps here but maybe that is not worth while
53  // since we most often ask for solutions with a != 0
54  // essentially this is the zero position of a line
55  smallSolution = - c / b
56  bigSolution = std::numeric_limits<double>::infinity() ;
57  return result;
58  }*/
59 
60  const double discriminant = b * b - 4 * a * c;
61  const double root = sqrt(discriminant);
62  const double bigSum = (b > 0) ? -b - root : -b + root;
63 
64  const double bigSolution = bigSum / 2 / a;
65  const double smallSolution = 2 * c / bigSum;
66 
67  return {bigSolution, smallSolution};
68  }
69  }
71 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19