Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FieldSetup.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// G4FieldSetup
27//
28// Class description:
29//
30// The class for constructing magnetic, electromagnetic and gravity
31// fields which strength is defined via G4Field.
32//
33// The equation of motion of a particle in a field and the
34// integration method are set according to the selection in
35// G4FieldParameters, as well as other accuracy parameters.
36// The default values in G4FieldParameters correspond to defaults
37// set in Geant4.
38
39// Author: Ivana Hrivnacova (IJClab, Orsay), 2024.
40// --------------------------------------------------------------------
41#ifndef G4FIELDSETUP_HH
42#define G4FIELDSETUP_HH
43
44#include "G4FieldParameters.hh"
45#include "globals.hh"
46
47class G4Field;
50
51class G4ChordFinder;
53class G4FieldManager;
55class G4LogicalVolume;
57
58/**
59 * @brief G4FieldSetup is a class for constructing magnetic, electromagnetic
60 * and gravity fields which strength is defined via G4Field.
61 * The equation of motion of a particle in a field and the integration method
62 * are set according to the selection in G4FieldParameters, as well as other
63 * accuracy parameters.
64 */
65
67{
68 public:
69
70 /**
71 * Standard constructor for G4FieldSetup.
72 * @param[in] parameters The field parameters.
73 * @param[in] field Pointer to the field object.
74 * @param[in] lv Optional logical volume where field applies; if
75 * null, global field applies.
76 */
77 G4FieldSetup(const G4FieldParameters& parameters,
78 G4Field* field,
79 G4LogicalVolume* lv = nullptr);
80
81 /**
82 * Default Destructor.
83 */
85
86 /**
87 * Default constructor, copy constructor and assignment operator not allowed.
88 */
89 G4FieldSetup() = delete;
90 G4FieldSetup(const G4FieldSetup& right) = delete;
91 G4FieldSetup& operator=(const G4FieldSetup& right) = delete;
92
93 /**
94 * Clears previously created setup.
95 */
96 void Clear();
97
98 /**
99 * Updates the field setup with new field parameters.
100 */
101 void Update();
102
103 /**
104 * Prints information.
105 * @param[in] verboseLevel Verbosity level; if greater than 1, parameters
106 * are also printed out to standard output.
107 * @param[in] about Optional string.
108 */
109 void PrintInfo(G4int verboseLevel, const G4String& about = "created");
110
111 /**
112 * Setter for the field object.
113 */
114 inline void SetG4Field(G4Field* field) { fG4Field = field; }
115
116 /**
117 * Accessors.
118 */
119 inline G4Field* GetG4Field() const { return fG4Field; }
120 inline G4LogicalVolume* GetLogicalVolume() const { return fLogicalVolume; }
121 inline G4EquationOfMotion* GetEquation() const { return fEquation; }
122 inline G4MagIntegratorStepper* GetStepper() const { return fStepper; }
123
124 private:
125
126 /**
127 * Creates cached magnetic field if const distance is set greater than zero.
128 * @param[in] parameters The field parameters.
129 * @param[in] field Pointer to the field in input.
130 * @returns The pointer to the cached field or the input field otherwise.
131 */
132 G4Field* CreateCachedField( const G4FieldParameters& parameters,
133 G4Field* field);
134
135 /**
136 * Creates and sets the equation of motion of a particle in a field.
137 * @param[in] equation The equation type.
138 * @returns The pointer to the created equation of motion.
139 */
140 G4EquationOfMotion* CreateEquation(G4EquationType equation);
141
142 /**
143 * Creates and sets the field integration stepper.
144 * @param[in] equation Pointer to the equation of motion.
145 * @param[in] stepper The stepper type.
146 * @returns The pointer to the created integration stepper.
147 */
148 G4MagIntegratorStepper* CreateStepper(G4EquationOfMotion* equation,
149 G4StepperType stepper);
150
151 /**
152 * Creates and sets the FSAL field integration driver.
153 * @param[in] equation Pointer to the equation of motion.
154 * @param[in] stepper The stepper type.
155 * @param[in] minStep The minimum allowed step.
156 * @returns The pointer to the created FSAL integration driver.
157 */
159 CreateFSALStepperAndDriver(G4EquationOfMotion* equation,
160 G4StepperType stepper, G4double minStep);
161
162 // Methods to update field setup step by step
163
164 /**
165 * Creates cached field (if ConstDistance is set).
166 */
167 void CreateCachedField();
168
169 /**
170 * Creates the stepper.
171 */
172 void CreateStepper();
173
174 /**
175 * Creates the chord finder.
176 */
177 void CreateChordFinder();
178
179 /**
180 * Updates the field manager.
181 */
182 void UpdateFieldManager();
183
184 private: // data members
185
186 /** Messenger for this class. */
187 G4FieldSetupMessenger* fMessenger = nullptr;
188
189 /** Field parameters. */
190 const G4FieldParameters& fParameters;
191
192 /** The field manager. */
193 G4FieldManager* fFieldManager = nullptr;
194
195 /** The field class object. */
196 G4Field* fG4Field = nullptr;
197
198 /** The associated volume (if local field). */
199 G4LogicalVolume* fLogicalVolume = nullptr;
200
201 /** The equation of motion. */
202 G4EquationOfMotion* fEquation = nullptr;
203
204 /** The magnetic integrator stepper. */
205 G4MagIntegratorStepper* fStepper = nullptr;
206
207 /** The magnetic integrator driver. */
208 G4VIntegrationDriver* fDriver = nullptr;
209
210 /** Chord finder. */
211 G4ChordFinder* fChordFinder = nullptr;
212};
213
214#endif
G4EquationType
G4EquationType defines the types of equations of motion of a particle in a field in Geant4.
G4StepperType
G4StepperType defines the available integrator of particle's equation of motion in Geant4.
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4ChordFinder is a class that provides Runge-Kutta integration of motion ODE and also has a method th...
G4EquationOfMotion is the abstract base class for the right hand size of the equation of motion of a ...
G4FieldManager is a manager (store) for a pointer to the Field subclass that describes the field of a...
G4FieldParameters defines the type of equation of motion of a particle in a field and the integration...
G4FieldSetupMessenger is a messenger class that defines commands for G4FieldSetup.
G4FieldSetup(const G4FieldParameters &parameters, G4Field *field, G4LogicalVolume *lv=nullptr)
G4FieldSetup(const G4FieldSetup &right)=delete
G4FieldSetup()=delete
G4EquationOfMotion * GetEquation() const
G4FieldSetup & operator=(const G4FieldSetup &right)=delete
void PrintInfo(G4int verboseLevel, const G4String &about="created")
G4LogicalVolume * GetLogicalVolume() const
G4MagIntegratorStepper * GetStepper() const
G4Field * GetG4Field() const
void SetG4Field(G4Field *field)
G4Field is the abstract class for any kind of field. It allows any kind of field (vector,...
Definition G4Field.hh:67
G4LogicalVolume represents a leaf node or unpositioned subtree in the geometry hierarchy....
G4MagIntegratorStepper is an abstract base class for integrator of particle's equation of motion,...