Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RealQuadraticEquation.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RealQuadraticEquation.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 // RealQuadraticEquation.h, Acts project
12 
13 #pragma once
14 #include <cmath>
15 #include <utility>
16 
17 namespace Acts {
18 namespace detail {
19 
46 
48  double first = 0;
49  double second = 0;
50  int solutions = 0;
51 
57  RealQuadraticEquation(double alpha, double beta, double gamma) {
58  double discriminant = beta * beta - 4 * alpha * gamma;
59  if (discriminant >= 0) {
60  solutions = (discriminant == 0) ? 1 : 2;
61  double q = -0.5 * (beta + (beta > 0 ? std::sqrt(discriminant)
62  : -std::sqrt(discriminant)));
63  first = q / alpha;
64  second = gamma / q;
65  }
66  }
67 };
68 
69 } // namespace detail
70 } // namespace Acts