ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4PolynomialSolver.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4PolynomialSolver.hh
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
//
28
// class G4PolynomialSolver
29
//
30
// Class description:
31
//
32
// G4PolynomialSolver allows the user to solve a polynomial equation
33
// with a great precision. This is used by Implicit Equation solver.
34
//
35
// The Bezier clipping method is used to solve the polynomial.
36
//
37
// How to use it:
38
// Create a class that is the function to be solved.
39
// This class could have internal parameters to allow to change
40
// the equation to be solved without recreating a new one.
41
//
42
// Define a Polynomial solver, example:
43
// G4PolynomialSolver<MyFunctionClass,G4double(MyFunctionClass::*)(G4double)>
44
// PolySolver (&MyFunction,
45
// &MyFunctionClass::Function,
46
// &MyFunctionClass::Derivative,
47
// precision);
48
//
49
// The precision is relative to the function to solve.
50
//
51
// In MyFunctionClass, provide the function to solve and its derivative:
52
// Example of function to provide :
53
//
54
// x,y,z,dx,dy,dz,Rmin,Rmax are internal variables of MyFunctionClass
55
//
56
// G4double MyFunctionClass::Function(G4double value)
57
// {
58
// G4double Lx,Ly,Lz;
59
// G4double result;
60
//
61
// Lx = x + value*dx;
62
// Ly = y + value*dy;
63
// Lz = z + value*dz;
64
//
65
// result = TorusEquation(Lx,Ly,Lz,Rmax,Rmin);
66
//
67
// return result ;
68
// }
69
//
70
// G4double MyFunctionClass::Derivative(G4double value)
71
// {
72
// G4double Lx,Ly,Lz;
73
// G4double result;
74
//
75
// Lx = x + value*dx;
76
// Ly = y + value*dy;
77
// Lz = z + value*dz;
78
//
79
// result = dx*TorusDerivativeX(Lx,Ly,Lz,Rmax,Rmin);
80
// result += dy*TorusDerivativeY(Lx,Ly,Lz,Rmax,Rmin);
81
// result += dz*TorusDerivativeZ(Lx,Ly,Lz,Rmax,Rmin);
82
//
83
// return result;
84
// }
85
//
86
// Then to have a root inside an interval [IntervalMin,IntervalMax] do the
87
// following:
88
//
89
// MyRoot = PolySolver.solve(IntervalMin,IntervalMax);
90
//
91
92
// History:
93
//
94
// - 19.12.00 E.Medernach, First implementation
95
//
96
97
#ifndef G4POL_SOLVER_HH
98
#define G4POL_SOLVER_HH
99
100
#include "
globals.hh
"
101
102
template
<
class
T,
class
F>
103
class
G4PolynomialSolver
104
{
105
public
:
// with description
106
107
G4PolynomialSolver
(
T
* typeF,
F
func
,
F
deriv
,
G4double
precision
);
108
~G4PolynomialSolver
();
109
110
111
G4double
solve
(
G4double
IntervalMin,
G4double
IntervalMax);
112
113
private
:
114
115
G4double
Newton
(
G4double
IntervalMin,
G4double
IntervalMax);
116
//General Newton method with Bezier Clipping
117
118
// Works for polynomial of order less or equal than 4.
119
// But could be changed to work for polynomial of any order providing
120
// that we find the bezier control points.
121
122
G4int
BezierClipping
(
G4double
*IntervalMin,
G4double
*IntervalMax);
123
// This is just one iteration of Bezier Clipping
124
125
126
T
*
FunctionClass
;
127
F
Function
;
128
F
Derivative
;
129
130
G4double
Precision
;
131
};
132
133
#include "G4PolynomialSolver.icc"
134
135
#endif
geant4
tree
geant4-10.6-release
source
global
HEPNumerics
include
G4PolynomialSolver.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:20
using
1.8.2 with
ECCE GitHub integration