ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MagIntegratorStepper.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MagIntegratorStepper.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 // G4MagIntegratorStepper
27 //
28 // Class description:
29 //
30 // Abstract base class for integrator of particle's equation of motion,
31 // used in tracking in space dependent magnetic field
32 //
33 // A Stepper must integrate over NumberOfVariables elements,
34 // and also copy (from input to output) any of NoStateVariables
35 // not included in the NumberOfVariables.
36 //
37 // So it is expected that NoStateVariables >= NumberOfVariables
38 
39 // Author: J.Apostolakis, CERN - 15.01.1997
40 // --------------------------------------------------------------------
41 #ifndef G4MAGINTEGRATORSTEPPER_HH
42 #define G4MAGINTEGRATORSTEPPER_HH
43 
44 #include "G4Types.hh"
45 #include "G4EquationOfMotion.hh"
46 
48 {
49  public: // with description
50 
52  G4int numIntegrationVariables,
53  G4int numStateVariables = 12,
54  G4bool isFSAL = false );
55 
56  virtual ~G4MagIntegratorStepper() = default;
57  // Constructor and destructor. No actions.
58 
61 
62  virtual void Stepper( const G4double y[],
63  const G4double dydx[],
64  G4double h,
65  G4double yout[],
66  G4double yerr[] ) = 0;
67  // The stepper for the Runge Kutta integration.
68  // The stepsize is fixed, with the Step size given by h.
69  // Integrates ODE starting values y[0 to 6].
70  // Outputs yout[] and its estimated error yerr[].
71 
72  virtual G4double DistChord() const = 0;
73  // Estimate the maximum distance of a chord from the true path
74  // over the segment last integrated.
75 
76  inline void NormaliseTangentVector( G4double vec[6] );
77  // Simple utility function to (re)normalise 'unit velocity' vector.
78 
79  inline void NormalisePolarizationVector( G4double vec[12] );
80  // Simple utility function to (re)normalise 'unit spin' vector.
81 
82  inline void RightHandSide( const G4double y[], G4double dydx[] ) const;
83  // Utility method to supply the standard Evaluation of the
84  // Right Hand side of the associated equation.
85 
86  inline void RightHandSide( const G4double y[],
87  G4double dydx[],
88  G4double field[] ) const;
89  // Calculate dydx and field at point y.
90 
91  inline G4int GetNumberOfVariables() const;
92  // Get the number of variables that the stepper will integrate over.
93 
94  inline G4int GetNumberOfStateVariables() const;
95  // Get the number of variables of state variables (>= above, integration)
96 
97  virtual G4int IntegratorOrder() const = 0;
98  // Returns the order of the integrator
99  // i.e. its error behaviour is of the order O(h^order).
100 
101  inline G4int IntegrationOrder();
102  // Replacement method - using new data member
103 
105  inline const G4EquationOfMotion* GetEquationOfMotion() const;
106  // As some steppers (eg RKG3) require other methods of Eq_Rhs
107  // this function allows for access to them.
108 
109  inline void SetEquationOfMotion(G4EquationOfMotion* newEquation);
110 
111  inline unsigned long GetfNoRHSCalls();
112  inline void ResetfNORHSCalls();
113  // Count number of calls to RHS method(s)
114 
115  inline G4bool IsFSAL() const;
116 
117  protected:
118 
119  inline void SetIntegrationOrder(G4int order);
120  inline void SetFSAL(G4bool flag = true);
121 
122  private:
123 
125  const G4int fNoIntegrationVariables = 0; // Variables in integration
126  const G4int fNoStateVariables = 0; // Number required for FieldTrack
127 
128  mutable unsigned long fNoRHSCalls = 0UL;
129  // Counter for calls to RHS method
130 
131  // Parameters of a RK method -- must be shared by all steppers of a type
132  // -- Invariants for a class
133 
134  G4int fIntegrationOrder = -1; // must be set by stepper !!!
135  // All ClassicalRK4 steppers are 4th order
136  G4bool fIsFSAL = false;
137  // Depends on RK method & implementation
138 };
139 
140 #include "G4MagIntegratorStepper.icc"
141 
142 #endif /* G4MAGIntegratorSTEPPER */