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 field/field04/include/F04GlobalField.hh 28 /// \brief Definition of the F04GlobalField class 29 // 30 31 #ifndef F04GlobalField_h 32 #define F04GlobalField_h 1 33 34 #include "F04DetectorConstruction.hh" 35 #include "F04ElementField.hh" 36 #include "F04FieldMessenger.hh" 37 38 #include "G4ChordFinder.hh" 39 #include "G4ElectroMagneticField.hh" 40 #include "G4EqEMFieldWithSpin.hh" 41 #include "G4EqMagElectricField.hh" 42 #include "G4FieldManager.hh" 43 #include "G4MagIntegratorStepper.hh" 44 #include "G4Mag_EqRhs.hh" 45 #include "G4Mag_SpinEqRhs.hh" 46 #include "G4MagneticField.hh" 47 #include "G4PropagatorInField.hh" 48 49 #include <vector> 50 51 // F04GlobalField - handles the global ElectroMagnetic field 52 // 53 // There is a single G04GlobalField object. 54 // 55 // The field from each individual beamline element is given by a 56 // ElementField object. Any number of overlapping ElementField 57 // objects can be added to the global field. Any element that 58 // represents an element with an EM field must add the appropriate 59 // ElementField to the global GlobalField object. 60 61 using FieldList = std::vector<F04ElementField*>; 62 63 class F04GlobalField : public G4ElectroMagneticField 64 { 65 // class F04GlobalField : public G4MagneticField { 66 67 private: 68 F04GlobalField(F04DetectorConstruction* const); 69 F04GlobalField(const F04GlobalField&); 70 71 F04GlobalField& operator=(const F04GlobalField&); 72 73 void SetupArray(); 74 75 public: 76 ~F04GlobalField() override; 77 78 /// GetObject() returns the single F04GlobalField object. 79 /// It is constructed, if necessary. 80 static F04GlobalField* GetObject(F04DetectorConstruction* const); 81 static F04GlobalField* GetObject(); 82 83 /// GetFieldValue() returns the field value at a given point[]. 84 /// field is really field[6]: Bx,By,Bz,Ex,Ey,Ez. 85 /// point[] is in global coordinates: x,y,z,t. 86 void GetFieldValue(const G4double* point, G4double* field) const override; 87 88 /// DoesFieldChangeEnergy() returns true. 89 G4bool DoesFieldChangeEnergy() const override { return true; } 90 91 /// AddElementField() adds the ElementField object for a single 92 /// element to the global field. 93 void AddElementField(F04ElementField* f) 94 { 95 if (fFields) fFields->push_back(f); 96 } 97 98 /// Clear() removes all ElementField-s from the global object, 99 /// and destroys them. Used before the geometry is completely 100 /// re-created. 101 void Clear(); 102 103 /// constructs all field tracking objects 104 void ConstructField(); 105 106 /// Set the Stepper types 107 void SetStepperType(G4int i) { fStepperType = i; } 108 109 /// Set the Stepper 110 void SetStepper(); 111 112 /// Set the minimum step length 113 void SetMinStep(G4double stp) { fMinStep = stp; } 114 115 /// Set the delta chord length 116 void SetDeltaChord(G4double dcr) { fDeltaChord = dcr; } 117 118 /// Set the delta one step length 119 void SetDeltaOneStep(G4double stp) { fDeltaOneStep = stp; } 120 121 /// Set the delta intersection length 122 void SetDeltaIntersection(G4double its) { fDeltaIntersection = its; } 123 124 /// Set the minimum eps length 125 void SetEpsMin(G4double eps) { fEpsMin = eps; } 126 127 /// Set the maximum eps length 128 void SetEpsMax(G4double eps) { fEpsMax = eps; } 129 130 /// Return the list of Element Fields 131 FieldList* GetFields() { return fFields; } 132 133 protected: 134 /// Get the global field manager 135 G4FieldManager* GetGlobalFieldManager(); 136 137 private: 138 static G4ThreadLocal F04GlobalField* fObject; 139 140 G4int fNfp = 0; 141 G4bool fFirst = true; 142 143 FieldList* fFields = nullptr; 144 145 const F04ElementField** fFp = nullptr; 146 147 private: 148 // A. INVARIANTS: 149 // -------------- 150 // INVARIANT: an integer to indicate the type of RK integration method ('stepper') used 151 G4int fStepperType = 4; // ClassicalRK4 is default stepper; 152 153 // INVARIANTS: Accuracy parameters of field propagation (and the integration it uses.) 154 // 1. These values are lengths - initialised in src 155 G4double fMinStep = 0.01 * CLHEP::mm; 156 G4double fDeltaChord = 3.0 * CLHEP::mm; 157 G4double fDeltaOneStep = 0.01 * CLHEP::mm; 158 G4double fDeltaIntersection = 0.1 * CLHEP::mm; 159 // 2. Dimensionless numbers - can initialise here 160 G4double fEpsMin = 2.5e-7; // Relative accuracy of integration (minimum) 161 G4double fEpsMax = 0.001; // Relative accuracy of integration (maximum) 162 163 // B. STATE: objects which carry out the propagation and are modified during tracking 164 // -------- 165 // G4Mag_EqRhs* fEquation; 166 // G4Mag_SpinEqRhs* fEquation; 167 168 // G4EqMagElectricField* fEquation; 169 G4EqEMFieldWithSpin* fEquation = nullptr; 170 171 G4FieldManager* fFieldManager = nullptr; 172 G4PropagatorInField* fFieldPropagator = nullptr; 173 G4MagIntegratorStepper* fStepper = nullptr; 174 G4ChordFinder* fChordFinder = nullptr; 175 176 // INVARIANTS during tracking: Auxiliary class & information - used for setup 177 F04FieldMessenger* fFieldMessenger; 178 F04DetectorConstruction* fDetectorConstruction = nullptr; 179 }; 180 181 #endif 182