Warning, /geant4/examples/extended/field/field01/README.md is written in an unsupported language. File is not indexed.
0001 \page Examplefield01 Example field01
0002
0003 Example that enables investigation of the accuracy and performance of the
0004 tracking in a magnetic field.
0005
0006 The key Geant4 capabilities demonstrated in this example are:
0007 - creating a uniform magnetic field interactively using the field
0008 messenger,
0009 - choosing the type of Runge Kutta stepper used for integration of the
0010 motion of charged particles in the magnetic field,
0011 - controlling the thresholds that determine which looping particles are
0012 killed by G4Transportation.
0013
0014 Some of these capabilities are available via interactive commands,
0015 implemented in F01FieldMessenger.
0016
0017 The magnetic field is defined in the F01DetectorConstruction::ConstructSDandField()
0018 method in the F01DetectorConstruction class using the G4FieldBuilder class.
0019
0020 The interactive commands, under the /field directory, are created with
0021 the instantiation of G4FieldBuilder in the F03DetectorConstruction constructor,
0022
0023 ## Choosing the type of stepper
0024
0025 The basic capabilities of choosing the stepper type are demonstrated in the
0026 field.in macro file:
0027
0028 ```
0029 /field/stepperType TsitourasRK45 ## Choose a stepper type ( Tsitouras )
0030 /field/stepperType RK547FEq1 ## Choose an FSAL stepper ( FEqRK1 )
0031 /field/setMinimumStep 0.1 mm ## Smaller steps always succeed
0032 /field/update ## Initialise using parameters above
0033 ## if they were changed after initialization
0034 ```
0035
0036 In addition it is possible to choose to use a new type of stepper, known
0037 as 'First Same as Last' or FSAL, which in each step obtains the field value
0038 at the step endpoint and evaluates the 'right hand size' of the equation
0039 for the next integration step. This reduces the number of calls to the field
0040 evaluation, which can be one the most computationally expensive methods,
0041 while providing similar accuracy.
0042
0043 There are several potential choices of the stepper type. Here are some suggestions:
0044 ```
0045 ===========================================================================
0046 Number Name of Stepper Comments
0047 ===========================================================================
0048 Recommended - default since Geant4 10.4:
0049
0050 DormandPrince745 : Uses a pair 4th & 5th order formulae (like other 4/5
0051 well-known and very efficient embedded method
0052 methods); their difference is the error estimate.
0053 Highly recommended in literature, including
0054 Hairer & Wanner, & Numerical Recipes
0055 Used in several established RK code (e.g. DOPRI5)
0056 ===========================================================================
0057 Good choices for reasonably smooth fields:
0058
0059 BogackiShampine45 : more efficient embedded 4/5 pair
0060 Used in many applications, including
0061 RKSUITE suite.
0062
0063 TsitourasRK45. : potentially the most efficient embedded 4/5
0064 pair - found in expanded search of parameter space.
0065
0066 DormandPrinceRK56. : higher order embedded method from authors of DoPri5.
0067 Uses a pair 5th & 6th order formulae.
0068
0069 DormandPrinceRK78. : higher order embedded method from authors of DoPri5.
0070 Uses a pair 7th & 8th order formulae.
0071
0072 NystromRK4 : a specialised Nystrom method for magnetic fields.
0073 Reuses the field value at the mid-point of the step,
0074 and also provides an analytical estimation of the
0075 integration error based on numerical evaluation of
0076 fourth order variation in the equation for
0077 magnetic field.
0078 ===========================================================================
0079 The new 'First Same as Last' (FSAL) steppers can be chosen in addition:
0080 RKFEq1 : FSAL stepper with improved equilibrium properties.
0081 When kinks or other anomalies are encountered,
0082 and at the start of integration when the best
0083 step size is not known, this type of stepper
0084 converges faster and more smoothly to good
0085 step sizes.
0086 ===========================================================================
0087 The old default and old first alternative -
0088
0089 ClassicalRK4 : original Runge-Kutta method, very robust but slower )
0090 ( obtains error estimate by doing 2 half steps )
0091 Good baseline for comparison - long experience of use.
0092 May be good alternative for less smooth fields.
0093
0094 CashKarpRKF45 : The oldest 'embedded' RK method in Geant4 -
0095 also fairly robust.
0096 Faster than ClassicalRK4 for smoother fields,
0097 as it does not need two half steps to estimate error.
0098 Available since Geant4 1.0
0099
0100 ===========================================================================
0101 Other potential choices for non-smooth fields (with kinks, abrupt changes):
0102
0103 SimpleHeum : low order, with error obtained from half-steps
0104 BogackiShampine23 : lower order embedded method (new in 10.3-beta)
0105 ===========================================================================
0106 ```
0107
0108 ## Controlling the killing of looping particles
0109
0110 Occasionally tracks 'looping' in a strong magnetic field, making little
0111 progress even over hundreds of integration steps. This is due to a
0112 combination of a strong magnetic field and a thin material (gas or vacuum)
0113 in which the size of a physics step is substantially larger than the radius
0114 of curvature of the track.
0115
0116 Since the amount of CPU time which can be consumed by one or few such tracks
0117 is very large, it is important to limit the number of integration steps
0118 spent on these tracks. The module for propagation in field in Geant4
0119 flags tracks which take more than a certain number (default 1,000) integration
0120 steps without reaching the requested end of the step size, which was
0121 determined by the physics and geometry.
0122
0123 The Geant4 G4Transportation and G4CoupledTransportation processes are tasked
0124 to select which of the looping tracks are killed and which survive. To
0125 balance the potential significant cost of integrating looping particles,
0126 three thresholds exist
0127
0128 - **The 'Warning' Energy**: a track with energy below this value that is found to
0129 loop is killed silently (no warning.)
0130 Above the 'Warning Energy', if a track is selected for killing a warning is
0131 generated.
0132
0133 - **The 'Important' Energy**: the threshold energy above which a track will survive
0134 for multiple steps if found looping.
0135
0136 - Number of 'tracking' steps. They will be only be killed only if they still
0137 loop after than.
0138 **The number of 'trials'**: the number of steps that 'important' tracks survive.
0139
0140 Note that currently only stable particles are killed. ( Refinements to enable
0141 toggling whether unstable particles can be killed are in development. )
0142
0143 This example demonstrate choosing different values for these parametes
0144 in the main() method of field01.cc using one of two techniques.
0145
0146 ### i) Using G4PhysicsListHelper
0147
0148 The first method is new in Geant4 release 10.5, and uses the G4PhysicsListHelper
0149 which has methods to choose a pre-selected set of parameter values. The choices
0150 are between a set each of low and high thresholds. Either one can be enabled
0151 by calling correspondingly
0152 ```cpp
0153 G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
0154 ```
0155 or
0156 ```cpp
0157 G4PhysicsListHelper::GetPhysicsListHelper()->UseHighLooperThresholds();
0158 ```
0159
0160 These methods must be called before the physics is constructed - i.e. typically
0161 before RunManager's Initialise() method is called.
0162 This works only if either
0163 - a modular physics lists is used, or if
0164 - the G4ModularPhysicsList and its AddTransporation method are used to create and register a common transportation process for all particles (one for each thread).
0165
0166 ### ii) Fine grained control (available in Geant4 versions since 7.0)
0167
0168 Fine grained control of the Transportation's parameters for looping particles
0169 is also possible.
0170
0171 This is demonstrated in the F01RunAction::ChangeLooperParameters() method,
0172 which is called by the BeginOfRunAction. There the appropriate
0173 Transportation object for the electron is obtained, and its parameters
0174 (if valid) are used to overwrite the thresholds in the G4Transportation class.
0175
0176 For example, to ensure that only looping particles with energy 10 keV are
0177 killed silently we change the value of the 'Warning' Energy:
0178 ```cpp
0179 runAction->SetWarningEnergy( 10.0 * CLHEP::keV );
0180 ```
0181 [ This is passed along to the registered G4Transportation or
0182 G4CoupledTransportation object by the F01RunAction's ChangeLooperParameters.]
0183
0184 As a result the killing of any (stable) looping track with energy over 10 keV
0185 will generate a warning.
0186
0187 A second configurable energy threshold enables tracks above it to survive a
0188 chosen number of 'tracking' steps. They will be only be killed only if they
0189 still loop after than number of tracking steps. F01RunAction's methods are
0190 used to configure these parameters:
0191 ```cpp
0192 runAction->SetImportantEnergy( 0.1 * CLHEP::MeV );
0193 runAction->SetNumberOfTrials( 30 );
0194 ```
0195 which the run action passes to the G4Transportation or
0196 G4CoupledTransportation object registered for the electron.
0197
0198 Note that for all pre-configured and modular physics lists share a single
0199 Transportation process for all types of particles. So the parameters for
0200 killing loopers will be shared by all particle types in this case.
0201
0202 ## Background Information
0203
0204 ### GEOMETRY DEFINITION
0205
0206 The "Absorber" is a solid made of a given material.
0207
0208 Three parameters define the absorber :
0209 - the material of the absorber,
0210 - the thickness of an absorber,
0211 - the transverse size of the absorber (the input face is a square).
0212
0213 The volume "World" contains the "Absorber".
0214 In this test the parameters of the "World" can be changed , too.
0215
0216 In addition a transverse uniform magnetic field can be applied.
0217
0218 The default geometry is constructed in F01DetectorConstruction class,
0219 but all the parameters can be changed via
0220 the commands defined in the F01DetectorMessenger class.
0221
0222 ### AN EVENT : THE PRIMARY GENERATOR
0223
0224 The primary kinematic consists of a single particle (electron, Ekin = 0.5 GeV)
0225 which hits the
0226 absorber perpendicular to the input face. The type of the particle
0227 and its energy are set in the F01PrimaryGeneratorAction class, and can
0228 be changed via the G4 build-in commands of G4ParticleGun class (see
0229 the macros provided with this example).
0230
0231 It is also possible to change the position of the primary particle vertex
0232 or activate its randomization via the commands defined in the
0233 F01PrimaryGeneratorMessenger class.
0234
0235 A RUN is a set of events.
0236
0237 ### DETECTOR RESPONSE
0238
0239 The spatial distribution of charged particles transported in magnetic
0240 field is envistigated.
0241 A HIT is a record, event per event , of all the
0242 informations needed to simulate and analyse the detector response.
0243
0244 In this example a F01CalorHit is defined as a set of 2 informations:
0245 - the total energy deposit in the absorber,
0246 - the total tracklength of all charged particles in the absorber,
0247
0248 Therefore the absorber is declared
0249 'sensitive detector' (SD), see F01CalorimeterSD, which means they can contribute to the hit.
0250
0251 ### PHYSICS LIST
0252
0253 The particle's type and the physic processes which will be available
0254 in this example are set in the FTFP_BERT physics list. This physics list
0255 requires data files for electromagnetic and hadronic processes.
0256 See more on installation of the datasets in Geant4 Installation Guide,
0257
0258 ### HOW TO START ?
0259
0260 - Execute field01 in 'batch' mode from macro file e.g.
0261 ```
0262 % ./field01 field01.in
0263 ```
0264
0265 - Execute field01 in 'interactive' mode with visualization e.g.
0266 ```
0267 % ./field01
0268 ....
0269 Idle> /run/beamOn 1
0270 ....
0271 ```