Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BFieldIntegrationDriver.hh
Go to the documentation of this file.
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// G4BFieldIntegrationDriver
27//
28// Class description:
29//
30// Specialised integration driver for pure magnetic field.
31
32// Author: Dmitry Sorokin (CERN, Google Summer of Code 2017), 12.09.2018
33// Supervision: John Apostolakis (CERN)
34// --------------------------------------------------------------------
35#ifndef G4BFIELD_INTEGRATION_DRIVER_HH
36#define G4BFIELD_INTEGRATION_DRIVER_HH
37
39#include "G4Mag_EqRhs.hh"
40
41#include <memory>
42
43/**
44 * @brief G4BFieldIntegrationDriver is specialised integration driver
45 * for pure magnetic field.
46 */
47
49{
50 public:
51
52 /**
53 * Constructor for the integrator driver.
54 * @param[in] smallStepDriver Pointer to driver for small steps.
55 * @param[in] largeStepDriver Pointer to driver for large steps.
56 */
58 std::unique_ptr<G4VIntegrationDriver> smallStepDriver,
59 std::unique_ptr<G4VIntegrationDriver> largeStepDriver);
60
61 /**
62 * Default Destructor.
63 */
64 ~G4BFieldIntegrationDriver() override = default;
65
66 /**
67 * Copy constructor and assignment operator not allowed.
68 */
71
72 /**
73 * Computes the step to take, based on chord limits.
74 * @param[in,out] track The current track in field.
75 * @param[in] hstep Proposed step length.
76 * @param[in] eps Requested accuracy, y_err/hstep.
77 * @param[in] chordDistance Maximum sagitta distance.
78 * @returns The length of step taken.
79 */
81 G4double hstep,
82 G4double eps,
83 G4double chordDistance) override;
84
85 /**
86 * Integrates ODE from current s (s=s0) to s=s0+h with accuracy eps.
87 * @param[in,out] track The current track in field.
88 * @param[in] hstep Proposed step length.
89 * @param[in] eps Requested accuracy, y_err/hstep.
90 * @param[in] hinitial Initial minimum integration step.
91 * @returns true if integration succeeds.
92 */
94 G4double hstep,
95 G4double eps,
96 G4double hinitial = 0) override;
97
98 /**
99 * Checks whether the driver implements re-integration.
100 * @returns true if driver *Recalculates* when AccurateAdvance() is called.
101 */
102 inline G4bool DoesReIntegrate() const override;
103
104 /**
105 * Setter and getter for the equation of motion.
106 */
107 void SetEquationOfMotion(G4EquationOfMotion* equation) override;
109
110 /**
111 * Returns a pointer to the integrator stepper.
112 */
114
115 /**
116 * Computes a step size for the next step, taking the last step's
117 * normalised error 'errMaxNorm'.
118 * @param[in] errMaxNorm The normalised error on last step.
119 * @param[in] hstepCurrent The current proposed step.
120 * @returns The step size for the next step.
121 */
123 G4double hstepCurrent) override;
124
125 /**
126 * Setter and getter for verbosity.
127 */
128 inline void SetVerboseLevel(G4int level) override;
129 inline G4int GetVerboseLevel() const override;
130
131 /**
132 * Dispatch interface method for computing step.
133 */
134 inline void OnComputeStep(const G4FieldTrack* track) override;
135
136 /**
137 * Dispatch interface method for initialisation/reset of driver.
138 */
139 inline void OnStartTracking() override;
140
141 /**
142 * Writes out to stream the parameters/state of the driver.
143 */
144 inline void StreamInfo( std::ostream& os ) const override;
145
146 /**
147 * Prints out statistics of the integrator driver.
148 */
149 void PrintStatistics() const;
150
151 /** [[deprecated("will be removed")]] */
152 inline void GetDerivatives(const G4FieldTrack& track,
153 G4double dydx[]) const override;
154
155 /** [[deprecated("will be removed")]] */
156 inline void GetDerivatives(const G4FieldTrack& track,
157 G4double dydx[],
158 G4double field[]) const override;
159
160 /** [[deprecated("use GetEquationOfMotion() instead of GetStepper()->GetEquationOfMotion()")]] */
161 inline const G4MagIntegratorStepper* GetStepper() const override;
162
163 private:
164
165 /**
166 * Given the field track, computes the radius of the curvature in field.
167 */
168 G4double CurvatureRadius(const G4FieldTrack& track) const;
169
170 /**
171 * Returns the value of the field in the 'Field' array, give the track.
172 * @param[in] track The current field track.
173 * @param[in,out] Field The array with field values.
174 */
175 void GetFieldValue(const G4FieldTrack& track,
176 G4double Field[] ) const;
177
178 private:
179
180 std::unique_ptr<G4VIntegrationDriver> fSmallStepDriver;
181 std::unique_ptr<G4VIntegrationDriver> fLargeStepDriver;
182 G4VIntegrationDriver* fCurrDriver = nullptr;
183 G4Mag_EqRhs* fEquation = nullptr;
184
185 G4int fSmallDriverSteps = 0;
186 G4int fLargeDriverSteps = 0;
187};
188
189#include "G4BFieldIntegrationDriver.icc"
190
191#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4double ComputeNewStepSize(G4double errMaxNorm, G4double hstepCurrent) override
~G4BFieldIntegrationDriver() override=default
G4int GetVerboseLevel() const override
G4BFieldIntegrationDriver(std::unique_ptr< G4VIntegrationDriver > smallStepDriver, std::unique_ptr< G4VIntegrationDriver > largeStepDriver)
void GetDerivatives(const G4FieldTrack &track, G4double dydx[], G4double field[]) const override
void GetDerivatives(const G4FieldTrack &track, G4double dydx[]) const override
const G4MagIntegratorStepper * GetStepper() const override
const G4BFieldIntegrationDriver & operator=(const G4BFieldIntegrationDriver &)=delete
void OnComputeStep(const G4FieldTrack *track) override
G4bool DoesReIntegrate() const override
G4bool AccurateAdvance(G4FieldTrack &track, G4double hstep, G4double eps, G4double hinitial=0) override
G4EquationOfMotion * GetEquationOfMotion() override
void SetEquationOfMotion(G4EquationOfMotion *equation) override
void StreamInfo(std::ostream &os) const override
void SetVerboseLevel(G4int level) override
G4double AdvanceChordLimited(G4FieldTrack &track, G4double hstep, G4double eps, G4double chordDistance) override
G4BFieldIntegrationDriver(const G4BFieldIntegrationDriver &)=delete
void OnStartTracking() override
G4MagIntegratorStepper * GetStepper() override
G4EquationOfMotion is the abstract base class for the right hand size of the equation of motion of a ...
G4FieldTrack defines a data structure bringing together a magnetic track's state (position,...
G4MagIntegratorStepper is an abstract base class for integrator of particle's equation of motion,...
G4Mag_EqRhs is the "standard" equation of motion of a particle in a pure magnetic field.