Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FieldParameters.cc
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// Implementation of the G4FieldParameters class
27//
28// Author: Ivana Hrivnacova (IJCLab, Orsay), 2024.
29// --------------------------------------------------------------------
30
31#include "G4FieldParameters.hh"
33
34#include "G4Exception.hh"
35#include "G4SystemOfUnits.hh"
36
37//
38// static methods
39//
40
41//_____________________________________________________________________________
43{
44 // Return the field type as a string
45
46 switch (field)
47 {
48 case kMagnetic:
49 return {"Magnetic"};
51 return {"ElectroMagnetic"};
52 case kGravity:
53 return {"Gravity"};
54 case kUserFieldType:
55 return {"UserDefinedField"};
56 }
57
59 "G4FieldParameters::FieldTypeName:", "GeomFieldParameters0001",
60 FatalErrorInArgument, "Unknown field value.");
61 return {};
62}
63
64//_____________________________________________________________________________
66{
67 // Return the equation type as a string
68
69 switch (equation)
70 {
71 case kEqMagnetic:
72 return {"EqMagnetic"};
74 return {"EqMagneticWithSpin"};
76 return {"EqElectroMagnetic"};
78 return {"EqEMfieldWithSpin"};
80 return {"EqEMfieldWithEDM"};
81 case kEqGravity:
82 return {"EqGravity"};
83 case kEqMonopole:
84 return {"EqMonopole"};
85 case kEqReplate:
86 return {"EqReplate"};
87 case kUserEquation:
88 return {"UserDefinedEq"};
89 }
90
92 "G4FieldParameters::EquationTypeName:", "GeomFieldParameters0001",
93 FatalErrorInArgument, "Unknown equation value.");
94 return {};
95}
96
97//_____________________________________________________________________________
99{
100 // Return the stepper type as a string
101
102 switch (stepper)
103 {
105 return {"BogackiShampine23"};
107 return {"BogackiShampine45"};
108 case kCashKarpRKF45:
109 return {"CashKarpRKF45"};
110 case kClassicalRK4:
111 return {"ClassicalRK4"};
112 case kDoLoMcPriRK34:
113 return {"DoLoMcPriRK34"};
115 return {"DormandPrince745"};
117 return {"DormandPrinceRK56"};
119 return {"DormandPrinceRK78"};
120 case kExplicitEuler:
121 return {"ExplicitEuler"};
122 case kImplicitEuler:
123 return {"ImplicitEuler"};
124 case kSimpleHeum:
125 return {"SimpleHeum"};
126 case kSimpleRunge:
127 return {"SimpleRunge"};
128 case kConstRK4:
129 return {"ConstRK4"};
131 return {"ExactHelixStepper"};
133 return {"HelixExplicitEuler"};
134 case kHelixHeum:
135 return {"HelixHeum"};
137 return {"HelixImplicitEuler"};
139 return {"HelixMixedStepper"};
141 return {"HelixSimpleRunge"};
142 case kNystromRK4:
143 return {"NystromRK4"};
144 case kRKG3Stepper:
145 return {"RKG3_Stepper"};
146 case kTsitourasRK45:
147 return {"TsitourasRK45"};
148 case kUserStepper:
149 return {"UserDefinedStepper"};
150 case kRK547FEq1:
151 return {"RK547FEq1"};
152 case kRK547FEq2:
153 return {"RK547FEq2"};
154 case kRK547FEq3:
155 return {"RK547FEq3"};
156 case kTCashKarpRKF45:
157 return {"TCashKarpRKF45"};
159 return {"TDormandPrince45"};
161 return {"TMagErrorStepper"};
162 case kQSStepper:
163 return {"QSStepper"};
164 }
165
167 "G4FieldParameters::StepperTypeName:", "GeomFieldParameters0001",
168 FatalErrorInArgument, "Unknown stepper value.");
169 return {};
170}
171
172//_____________________________________________________________________________
174{
175 // Return the field type for given field type name
176
177 if (name == FieldTypeName(kMagnetic)) { return kMagnetic; }
178 if (name == FieldTypeName(kElectroMagnetic)) { return kElectroMagnetic; }
179 if (name == FieldTypeName(kGravity)) { return kGravity; }
180 if (name == FieldTypeName(kUserFieldType)) { return kUserFieldType; }
181
183 "G4FieldParameters::GetFieldType:", "GeomFieldParameters0001",
184 FatalErrorInArgument, "Unknown field name.");
185 return kMagnetic;
186}
187
188//_____________________________________________________________________________
190{
191 // Return the equation type for given equation type name
192
193 if (name == EquationTypeName(kEqMagnetic)) { return kEqMagnetic; }
198 if (name == EquationTypeName(kEqGravity)) { return kEqGravity; }
199 if (name == EquationTypeName(kEqMonopole)) { return kEqMonopole; }
200 if (name == EquationTypeName(kEqReplate)) { return kEqReplate; }
201 if (name == EquationTypeName(kUserEquation)) { return kUserEquation; }
202
204 "G4FieldParameters::GetEquationType:", "GeomFieldParameters0001",
205 FatalErrorInArgument, "Unknown equation name.");
206 return kEqMagnetic;
207}
208
209//_____________________________________________________________________________
211{
212 // Return the stepper type for given stepper type name
215 if (name == StepperTypeName(kCashKarpRKF45)) { return kCashKarpRKF45; }
216 if (name == StepperTypeName(kClassicalRK4)) { return kClassicalRK4; }
217 if (name == StepperTypeName(kDoLoMcPriRK34)) { return kDoLoMcPriRK34; }
218 if (name == StepperTypeName(kDormandPrince745)) { return kDormandPrince745; }
221 if (name == StepperTypeName(kExplicitEuler)) { return kExplicitEuler; }
222 if (name == StepperTypeName(kImplicitEuler)) { return kImplicitEuler; }
223 if (name == StepperTypeName(kSimpleHeum)) { return kSimpleHeum; }
224 if (name == StepperTypeName(kSimpleRunge)) { return kSimpleRunge; }
225 if (name == StepperTypeName(kConstRK4)) { return kConstRK4; }
228 if (name == StepperTypeName(kHelixHeum)) { return kHelixHeum; }
231 if (name == StepperTypeName(kHelixSimpleRunge)) { return kHelixSimpleRunge; }
232 if (name == StepperTypeName(kNystromRK4)) { return kNystromRK4; }
233 if (name == StepperTypeName(kQSStepper)) { return kQSStepper; }
234 if (name == StepperTypeName(kRKG3Stepper)) { return kRKG3Stepper; }
235 if (name == StepperTypeName(kRK547FEq1)) { return kRK547FEq1; }
236 if (name == StepperTypeName(kRK547FEq2)) { return kRK547FEq2; }
237 if (name == StepperTypeName(kRK547FEq3)) { return kRK547FEq3; }
238 if (name == StepperTypeName(kTsitourasRK45)) { return kTsitourasRK45; }
239 if (name == StepperTypeName(kTCashKarpRKF45)) { return kTCashKarpRKF45; }
240 if (name == StepperTypeName(kTDormandPrince45)) { return kTDormandPrince45; }
241 if (name == StepperTypeName(kTMagErrorStepper)) { return kTMagErrorStepper; }
242 if (name == StepperTypeName(kUserStepper)) { return kUserStepper; }
243
245 "G4FieldParameters::GetStepperType:", "GeomFieldParameters0001",
246 FatalErrorInArgument, "Unknown stepper name.");
247 return kClassicalRK4;
248}
249
250//
251// ctors, dtor
252//
253
254//_____________________________________________________________________________
256 : fVolumeName(volumeName)
257{
258 // Standard constructor
259
260 fMessenger = new G4FieldParametersMessenger(this);
261}
262
263//_____________________________________________________________________________
265{
266 // Destructor
267
268 delete fMessenger;
269}
270
271//
272// public methods
273//
274
275//_____________________________________________________________________________
277{
278 // Prints all customizable accuracy parameters
279
280 G4cout << "Magnetic field parameters: " << G4endl;
281 if (!fVolumeName.empty())
282 {
283 G4cout << " volume name = " << fVolumeName << G4endl;
284 }
285 G4cout << " field type = " << FieldTypeName(fField) << G4endl
286 << " equation type = " << EquationTypeName(fEquation) << G4endl
287 << " stepper type = " << StepperTypeName(fStepper) << G4endl
288 << " minStep = " << fMinimumStep << " mm" << G4endl
289 << " constDistance = " << fConstDistance << " mm" << G4endl
290 << " deltaChord = " << fDeltaChord << " mm" << G4endl
291 << " deltaOneStep = " << fDeltaOneStep << " mm" << G4endl
292 << " deltaIntersection = " << fDeltaIntersection << " mm" << G4endl
293 << " epsMin = " << fMinimumEpsilonStep << G4endl
294 << " epsMax= " << fMaximumEpsilonStep << G4endl;
295}
296
297//_____________________________________________________________________________
299{
300 // Set user defined equation of motion
301
302 fUserEquation = equation;
303 fEquation = kUserEquation;
304}
305
306//_____________________________________________________________________________
308{
309 // Set user defined integrator of particle's equation of motion
310
311 fUserStepper = stepper;
312 fStepper = kUserStepper;
313}
@ FatalErrorInArgument
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4EquationType
G4EquationType defines the types of equations of motion of a particle in a field in Geant4.
@ kEqMagneticWithSpin
@ kUserEquation
User defined equation of motion.
@ kEqEMfieldWithSpin
@ kEqMagnetic
@ kEqGravity
@ kEqReplate
@ kEqMonopole
@ kEqElectroMagnetic
@ kEqEMfieldWithEDM
G4FieldType
G4FieldType defines the available fields in Geant4.
@ kElectroMagnetic
electromagnetic field
@ kUserFieldType
User defined field type.
@ kGravity
gravity field
@ kMagnetic
magnetic field
G4StepperType
G4StepperType defines the available integrator of particle's equation of motion in Geant4.
@ kRKG3Stepper
G4RKG3_Stepper.
@ kRK547FEq2
G4RK547FEq2.
@ kHelixSimpleRunge
G4HelixSimpleRunge.
@ kNystromRK4
G4NystromRK4.
@ kDormandPrince745
G4DormandPrince745.
@ kCashKarpRKF45
G4CashKarpRKF45.
@ kDormandPrinceRK78
G4DormandPrinceRK78.
@ kQSStepper
G4QSStepper.
@ kSimpleRunge
G4SimpleRunge.
@ kHelixImplicitEuler
G4HelixImplicitEuler.
@ kConstRK4
G4ConstRK4.
@ kUserStepper
User defined stepper.
@ kDoLoMcPriRK34
G4DoLoMcPriRK34.
@ kSimpleHeum
G4SimpleHeum.
@ kHelixHeum
G4HelixHeum.
@ kHelixExplicitEuler
G4HelixExplicitEuler.
@ kDormandPrinceRK56
G4DormandPrinceRK56.
@ kTDormandPrince45
G4TDormandPrince45.
@ kTsitourasRK45
G4TsitourasRK45.
@ kImplicitEuler
G4ImplicitEuler.
@ kExactHelixStepper
G4ExactHelixStepper.
@ kHelixMixedStepper
G4HelixMixedStepper.
@ kBogackiShampine45
G4BogackiShampine45.
@ kExplicitEuler
G4ExplicitEuler.
@ kTCashKarpRKF45
G4TCashKarpRKF45.
@ kRK547FEq1
G4RK547FEq1.
@ kRK547FEq3
G4RK547FEq3.
@ kBogackiShampine23
G4BogackiShampine23.
@ kClassicalRK4
G4ClassicalRK4.
@ kTMagErrorStepper
G4TMagErrorStepper.
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4EquationOfMotion is the abstract base class for the right hand size of the equation of motion of a ...
G4FieldParametersMessenger is a messenger class that defines commands for field configuration....
const G4EquationType & GetEquationType() const
void SetUserStepper(G4MagIntegratorStepper *stepper)
void SetUserEquationOfMotion(G4EquationOfMotion *equation)
const G4StepperType & GetStepperType() const
static G4String EquationTypeName(G4EquationType equation)
void PrintParameters() const
G4FieldParameters(const G4String &volumeName="")
const G4FieldType & GetFieldType() const
static G4String StepperTypeName(G4StepperType stepper)
static G4String FieldTypeName(G4FieldType field)
G4MagIntegratorStepper is an abstract base class for integrator of particle's equation of motion,...