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 /// \file G4FieldSetup.h 27 /// \brief Definition of the G4FieldSetup class 28 /// 29 /// This code was initially developed in Geant4 VMC package 30 /// (https://github.com/vmc-project) 31 /// and adapted to Geant4. 32 /// 33 /// \author I. Hrivnacova; IJCLab, Orsay 34 35 #ifndef G4FIELDSETUP_HH 36 #define G4FIELDSETUP_HH 37 38 #include "G4FieldParameters.hh" 39 #include "globals.hh" 40 41 class G4Field; 42 class G4FieldParameters; 43 class G4FieldSetupMessenger; 44 45 class G4ChordFinder; 46 class G4EquationOfMotion; 47 class G4FieldManager; 48 class G4MagIntegratorStepper; 49 class G4LogicalVolume; 50 class G4VIntegrationDriver; 51 52 class TVirtualMagField; 53 54 /// \ingroup geometry 55 /// \brief The class for constructing magnetic, electromagnetic and gravity 56 /// fields which strength is defined via G4Field. 57 /// 58 /// The equation of motion of a particle in a field and the 59 /// integration method is set according to the selection in 60 /// G4FieldParameters, as well as other accuracy parameters. 61 /// The default values in G4FieldParameters correspond to defaults 62 /// set in Geant4 (taken from Geant4 9.3 release.) 63 /// As Geant4 classes to not provide access methods for these defaults, 64 /// the defaults have to be checked with each new Geant4 release. 65 /// TO DO: unify defaults in G4 classes and G4 parameters 66 /// 67 /// \author I. Hrivnacova; IJClab, Orsay 68 69 class G4FieldSetup 70 { 71 public: 72 /// Standard constructor 73 G4FieldSetup(const G4FieldParameters& parameters, G4Field* field, 74 G4LogicalVolume* lv = nullptr); 75 /// Destructor 76 ~G4FieldSetup(); 77 78 // Methods 79 80 /// Clear previously created setup 81 void Clear(); 82 /// Update field setup with new field parameters 83 void Update(); 84 /// Print information 85 void PrintInfo(G4int verboseLevel, const G4String about = "created"); 86 87 // Set methods 88 89 /// Set G4 field 90 void SetG4Field(G4Field* field); 91 92 // Access to field setting 93 94 /// Return the instantiated field 95 G4Field* GetG4Field() const; 96 /// Return the logical vol;ume 97 G4LogicalVolume* GetLogicalVolume() const; 98 /// Return the equation of motion 99 G4EquationOfMotion* GetEquation() const; 100 /// Return the magnetic integrator stepper 101 G4MagIntegratorStepper* GetStepper() const; 102 /// Return the magnetic integrator driver 103 G4VIntegrationDriver* GetIntegrationDriver() const; 104 105 private: 106 /// Not implemented 107 G4FieldSetup() = delete; 108 /// Not implemented 109 G4FieldSetup(const G4FieldSetup& right) = delete; 110 /// Not implemented 111 G4FieldSetup& operator=(const G4FieldSetup& right) = delete; 112 113 // Methods 114 115 // Create cached magnetic field if const distance is set > 0. 116 // and field is of G4MagneticField. 117 // Return the input field otherwise. 118 G4Field* CreateCachedField( 119 const G4FieldParameters& parameters, G4Field* field); 120 121 /// Set the equation of motion of a particle in a field 122 G4EquationOfMotion* CreateEquation(G4EquationType equation); 123 124 /// Set the integrator of particle's equation of motion 125 G4MagIntegratorStepper* CreateStepper( 126 G4EquationOfMotion* equation, G4StepperType stepper); 127 128 /// Set the FSAL integrator of particle's equation of motion 129 G4VIntegrationDriver* CreateFSALStepperAndDriver( 130 G4EquationOfMotion* equation, G4StepperType stepper, G4double minStep); 131 132 // methods to update field setup step by step 133 /// Create cached field (if ConstDistance is set) 134 void CreateCachedField(); 135 /// Create cached field (if ConstDistance is set) 136 void CreateStepper(); 137 /// Create chord finder 138 void CreateChordFinder(); 139 /// Update field manager 140 void UpdateFieldManager(); 141 142 // Data members 143 144 /// Messenger for this class 145 G4FieldSetupMessenger* fMessenger = nullptr; 146 /// Parameters 147 const G4FieldParameters& fParameters; 148 /// Geant4 field manager 149 G4FieldManager* fFieldManager = nullptr; 150 /// Geant4 field 151 G4Field* fG4Field = nullptr; 152 /// The associated ROOT volume (if local field) 153 G4LogicalVolume* fLogicalVolume = nullptr; 154 /// The equation of motion 155 G4EquationOfMotion* fEquation = nullptr; 156 /// The magnetic integrator stepper 157 G4MagIntegratorStepper* fStepper = nullptr; 158 /// The magnetic integrator driver 159 G4VIntegrationDriver* fDriver = nullptr; 160 /// Chord finder 161 G4ChordFinder* fChordFinder = nullptr; 162 }; 163 164 // inline functions 165 166 inline void G4FieldSetup::SetG4Field(G4Field* field) 167 { 168 // Set G4 field 169 fG4Field = field; 170 } 171 172 inline G4Field* G4FieldSetup::GetG4Field() const 173 { 174 // Return the instantiated field 175 return fG4Field; 176 } 177 178 inline G4LogicalVolume* G4FieldSetup::GetLogicalVolume() const 179 { 180 // Return the logical vol;ume 181 return fLogicalVolume; 182 } 183 184 inline G4EquationOfMotion* G4FieldSetup::GetEquation() const 185 { 186 // Return the equation of motion 187 return fEquation; 188 } 189 190 inline G4MagIntegratorStepper* G4FieldSetup::GetStepper() const 191 { 192 // Return the magnetic integrator stepper 193 return fStepper; 194 } 195 196 #endif // G4FIELDSETUP_HH 197