Geant4 Cross Reference |
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 27 /// \file G4FieldParameters.cc 28 /// \brief Implementation of the G4FieldParameters class 29 /// 30 /// This code was initially developed in Geant4 VMC package 31 /// (https://github.com/vmc-project) 32 /// and adapted to Geant4. 33 /// 34 /// \author I. Hrivnacova; IJCLab, Orsay 35 36 #include "G4FieldParameters.hh" 37 #include "G4FieldParametersMessenger.hh" 38 39 #include "G4Exception.hh" 40 #include "G4SystemOfUnits.hh" 41 42 // 43 // static methods 44 // 45 46 //_____________________________________________________________________________ 47 G4String G4FieldParameters::FieldTypeName(G4FieldType field) 48 { 49 // Return the field type as a string 50 51 switch (field) { 52 case kMagnetic: 53 return G4String("Magnetic"); 54 case kElectroMagnetic: 55 return G4String("ElectroMagnetic"); 56 case kGravity: 57 return G4String("Gravity"); 58 } 59 60 G4Exception( 61 "G4FieldParameters::FieldTypeName:", "GeomFieldParameters0001", 62 FatalErrorInArgument, "Unknown field value."); 63 return G4String(); 64 } 65 66 //_____________________________________________________________________________ 67 G4String G4FieldParameters::EquationTypeName(G4EquationType equation) 68 { 69 // Return the equation type as a string 70 71 switch (equation) { 72 case kEqMagnetic: 73 return G4String("EqMagnetic"); 74 case kEqMagneticWithSpin: 75 return G4String("EqMagneticWithSpin"); 76 case kEqElectroMagnetic: 77 return G4String("EqElectroMagnetic"); 78 case kEqEMfieldWithSpin: 79 return G4String("EqEMfieldWithSpin"); 80 case kEqEMfieldWithEDM: 81 return G4String("EqEMfieldWithEDM"); 82 case kUserEquation: 83 return G4String("UserDefinedEq"); 84 } 85 86 G4Exception( 87 "G4FieldParameters::EquationTypeName:", "GeomFieldParameters0001", 88 FatalErrorInArgument, "Unknown equation value."); 89 return G4String(); 90 } 91 92 //_____________________________________________________________________________ 93 G4String G4FieldParameters::StepperTypeName(G4StepperType stepper) 94 { 95 // Return the stepper type as a string 96 97 switch (stepper) { 98 case kBogackiShampine23: 99 return G4String("BogackiShampine23"); 100 case kBogackiShampine45: 101 return G4String("BogackiShampine45"); 102 case kCashKarpRKF45: 103 return G4String("CashKarpRKF45"); 104 case kClassicalRK4: 105 return G4String("ClassicalRK4"); 106 case kDormandPrince745: 107 return G4String("DormandPrince745"); 108 case kDormandPrinceRK56: 109 return G4String("DormandPrinceRK56"); 110 case kDormandPrinceRK78: 111 return G4String("DormandPrinceRK78"); 112 case kExplicitEuler: 113 return G4String("ExplicitEuler"); 114 case kImplicitEuler: 115 return G4String("ImplicitEuler"); 116 case kSimpleHeum: 117 return G4String("SimpleHeum"); 118 case kSimpleRunge: 119 return G4String("SimpleRunge"); 120 case kConstRK4: 121 return G4String("ConstRK4"); 122 case kExactHelixStepper: 123 return G4String("ExactHelixStepper"); 124 case kHelixExplicitEuler: 125 return G4String("HelixExplicitEuler"); 126 case kHelixHeum: 127 return G4String("HelixHeum"); 128 case kHelixImplicitEuler: 129 return G4String("HelixImplicitEuler"); 130 case kHelixMixedStepper: 131 return G4String("HelixMixedStepper"); 132 case kHelixSimpleRunge: 133 return G4String("HelixSimpleRunge"); 134 case kNystromRK4: 135 return G4String("NystromRK4"); 136 case kRKG3Stepper: 137 return G4String("RKG3_Stepper"); 138 case kTsitourasRK45: 139 return G4String("TsitourasRK45"); 140 case kUserStepper: 141 return G4String("UserDefinedStepper"); 142 case kRK547FEq1: 143 return G4String("RK547FEq1"); 144 case kRK547FEq2: 145 return G4String("RK547FEq2"); 146 case kRK547FEq3: 147 return G4String("RK547FEq3"); 148 } 149 150 G4Exception( 151 "G4FieldParameters::StepperTypeName:", "GeomFieldParameters0001", 152 FatalErrorInArgument, "Unknown stepper value."); 153 return G4String(); 154 } 155 156 //_____________________________________________________________________________ 157 G4FieldType G4FieldParameters::GetFieldType(const G4String& name) 158 { 159 // Return the field type for given field type name 160 161 if (name == FieldTypeName(kMagnetic)) return kMagnetic; 162 if (name == FieldTypeName(kElectroMagnetic)) return kElectroMagnetic; 163 if (name == FieldTypeName(kGravity)) return kGravity; 164 165 G4Exception( 166 "G4FieldParameters::GetFieldType:", "GeomFieldParameters0001", 167 FatalErrorInArgument, "Unknown field name."); 168 return kMagnetic; 169 } 170 171 //_____________________________________________________________________________ 172 G4EquationType G4FieldParameters::GetEquationType(const G4String& name) 173 { 174 // Return the equation type for given equation type name 175 176 if (name == EquationTypeName(kEqMagnetic)) return kEqMagnetic; 177 if (name == EquationTypeName(kEqMagneticWithSpin)) return kEqMagneticWithSpin; 178 if (name == EquationTypeName(kEqElectroMagnetic)) return kEqElectroMagnetic; 179 if (name == EquationTypeName(kEqEMfieldWithSpin)) return kEqEMfieldWithSpin; 180 if (name == EquationTypeName(kEqEMfieldWithEDM)) return kEqEMfieldWithEDM; 181 if (name == EquationTypeName(kUserEquation)) return kUserEquation; 182 183 G4Exception( 184 "G4FieldParameters::GetEquationType:", "GeomFieldParameters0001", 185 FatalErrorInArgument, "Unknown equation name."); 186 return kEqMagnetic; 187 } 188 189 //_____________________________________________________________________________ 190 G4StepperType G4FieldParameters::GetStepperType(const G4String& name) 191 { 192 // Return the stepper type for given stepper type name 193 if (name == StepperTypeName(kBogackiShampine23)) return kBogackiShampine23; 194 if (name == StepperTypeName(kBogackiShampine45)) return kBogackiShampine45; 195 if (name == StepperTypeName(kCashKarpRKF45)) return kCashKarpRKF45; 196 if (name == StepperTypeName(kClassicalRK4)) return kClassicalRK4; 197 if (name == StepperTypeName(kDormandPrince745)) return kDormandPrince745; 198 if (name == StepperTypeName(kDormandPrinceRK56)) return kDormandPrinceRK56; 199 if (name == StepperTypeName(kDormandPrinceRK78)) return kDormandPrinceRK78; 200 if (name == StepperTypeName(kExplicitEuler)) return kExplicitEuler; 201 if (name == StepperTypeName(kImplicitEuler)) return kImplicitEuler; 202 if (name == StepperTypeName(kSimpleHeum)) return kSimpleHeum; 203 if (name == StepperTypeName(kSimpleRunge)) return kSimpleRunge; 204 if (name == StepperTypeName(kConstRK4)) return kConstRK4; 205 if (name == StepperTypeName(kExactHelixStepper)) return kExactHelixStepper; 206 if (name == StepperTypeName(kHelixExplicitEuler)) return kHelixExplicitEuler; 207 if (name == StepperTypeName(kHelixHeum)) return kHelixHeum; 208 if (name == StepperTypeName(kHelixImplicitEuler)) return kHelixImplicitEuler; 209 if (name == StepperTypeName(kHelixMixedStepper)) return kHelixMixedStepper; 210 if (name == StepperTypeName(kHelixSimpleRunge)) return kHelixSimpleRunge; 211 if (name == StepperTypeName(kNystromRK4)) return kNystromRK4; 212 if (name == StepperTypeName(kRKG3Stepper)) return kRKG3Stepper; 213 if (name == StepperTypeName(kRK547FEq1)) return kRK547FEq1; 214 if (name == StepperTypeName(kRK547FEq2)) return kRK547FEq2; 215 if (name == StepperTypeName(kRK547FEq3)) return kRK547FEq3; 216 if (name == StepperTypeName(kTsitourasRK45)) return kTsitourasRK45; 217 if (name == StepperTypeName(kUserStepper)) return kUserStepper; 218 219 G4Exception( 220 "G4FieldParameters::GetStepperType:", "GeomFieldParameters0001", 221 FatalErrorInArgument, "Unknown stepper name."); 222 return kClassicalRK4; 223 } 224 225 // 226 // ctors, dtor 227 // 228 229 //_____________________________________________________________________________ 230 G4FieldParameters::G4FieldParameters(const G4String& volumeName) 231 : fVolumeName(volumeName) 232 { 233 // Standard constructor 234 235 fMessenger = new G4FieldParametersMessenger(this); 236 } 237 238 //_____________________________________________________________________________ 239 G4FieldParameters::~G4FieldParameters() 240 { 241 // Destructor 242 243 delete fMessenger; 244 } 245 246 // 247 // public methods 248 // 249 250 //_____________________________________________________________________________ 251 void G4FieldParameters::PrintParameters() const 252 { 253 // Prints all customizable accuracy parameters 254 255 G4cout << "Magnetic field parameters: " << G4endl; 256 if (fVolumeName.size()) { 257 G4cout << " volume name = " << fVolumeName << G4endl; 258 } 259 G4cout << " field type = " << FieldTypeName(fField) << G4endl 260 << " equation type = " << EquationTypeName(fEquation) << G4endl 261 << " stepper type = " << StepperTypeName(fStepper) << G4endl 262 << " minStep = " << fMinimumStep << " mm" << G4endl 263 << " constDistance = " << fConstDistance << " mm" << G4endl 264 << " deltaChord = " << fDeltaChord << " mm" << G4endl 265 << " deltaOneStep = " << fDeltaOneStep << " mm" << G4endl 266 << " deltaIntersection = " << fDeltaIntersection << " mm" << G4endl 267 << " epsMin = " << fMinimumEpsilonStep << G4endl 268 << " epsMax= " << fMaximumEpsilonStep << G4endl; 269 } 270 271 //_____________________________________________________________________________ 272 void G4FieldParameters::SetUserEquationOfMotion(G4EquationOfMotion* equation) 273 { 274 // Set user defined equation of motion 275 276 fUserEquation = equation; 277 fEquation = kUserEquation; 278 } 279 280 //_____________________________________________________________________________ 281 void G4FieldParameters::SetUserStepper(G4MagIntegratorStepper* stepper) 282 { 283 // Set user defined integrator of particle's equation of motion 284 285 fUserStepper = stepper; 286 fStepper = kUserStepper; 287 } 288