Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4FieldManager << 23 // >> 24 // $Id: G4FieldManager.hh,v 1.13 2003/11/08 03:55:16 japost Exp $ >> 25 // GEANT4 tag $Name: geant4-06-00-patch-01 $ >> 26 // >> 27 // >> 28 // class G4FieldManager 27 // 29 // 28 // Class description: 30 // Class description: 29 // 31 // 30 // A class to manage (Store) a pointer to the 32 // A class to manage (Store) a pointer to the Field subclass that 31 // describes the field of a detector (magnetic 33 // describes the field of a detector (magnetic, electric or other). 32 // Also stores a reference to the chord finder 34 // Also stores a reference to the chord finder. 33 // 35 // 34 // The G4FieldManager class exists to allow th 36 // The G4FieldManager class exists to allow the user program to specify 35 // the electric, magnetic and/or other field(s 37 // the electric, magnetic and/or other field(s) of the detector. 36 // << 38 // (OR, in the future, of a part of it - planned to be a logical volume). 37 // A field manager can be set to a logical vol << 38 // in order to vary its field from that of the << 39 // a zero or constant field can override a glo << 40 // less exact version can override the externa << 41 // or higher precision for tracking can be spe << 42 // stepper can be chosen for different volumes << 43 // << 44 // It also stores a pointer to the ChordFinder 39 // It also stores a pointer to the ChordFinder object that can do the 45 // propagation in this field. All geometrical 40 // propagation in this field. All geometrical track "advancement" 46 // in the field is handled by this ChordFinder 41 // in the field is handled by this ChordFinder object. 47 // 42 // 48 // G4FieldManager allows the other classes/obj 43 // G4FieldManager allows the other classes/object (of the MagneticField 49 // & other class categories) to find out wheth 44 // & other class categories) to find out whether a detector field object 50 // exists and what that object is. 45 // exists and what that object is. 51 // 46 // 52 // The Chord Finder must be created either by 47 // The Chord Finder must be created either by calling CreateChordFinder 53 // for a Magnetic Field or by the user creatin 48 // for a Magnetic Field or by the user creating a a Chord Finder object 54 // "manually" and setting this pointer. 49 // "manually" and setting this pointer. 55 // 50 // 56 // A default FieldManager is created by the si 51 // A default FieldManager is created by the singleton class 57 // G4NavigatorForTracking and exists before ma 52 // G4NavigatorForTracking and exists before main is called. 58 // However a new one can be created and given 53 // However a new one can be created and given to G4NavigatorForTracking. 59 // 54 // 60 // Our current design envisions that one Field 55 // Our current design envisions that one Field manager is 61 // valid for each region detector. 56 // valid for each region detector. 62 // << 63 // It is expected that a particular geometrica << 64 // By default a Field Manager is created for t << 65 // will be utilised for all volumes unless it << 66 // field manager. << 67 // Note also that a region with both electric << 68 // have these treated as one field. << 69 // Similarly it could be extended to treat oth << 70 // components of a single field type. << 71 57 72 // Author: John Apostolakis, 10.03.97 - design << 58 // History: >> 59 // - 10.03.97 John Apostolakis, design and implementation. 73 // ------------------------------------------- 60 // ------------------------------------------------------------------- >> 61 74 #ifndef G4FIELDMANAGER_HH 62 #ifndef G4FIELDMANAGER_HH 75 #define G4FIELDMANAGER_HH 1 63 #define G4FIELDMANAGER_HH 1 76 64 77 #include "globals.hh" 65 #include "globals.hh" 78 66 79 class G4Field; 67 class G4Field; 80 class G4MagneticField; 68 class G4MagneticField; 81 class G4ChordFinder; 69 class G4ChordFinder; 82 class G4Track; // Forward reference for param 70 class G4Track; // Forward reference for parameter configuration 83 71 84 class G4FieldManager 72 class G4FieldManager 85 { 73 { 86 public: // with description 74 public: // with description 87 G4FieldManager(G4Field* detectorField = nu << 75 G4FieldManager(G4Field *detectorField=0, 88 G4ChordFinder* pChordFinder << 76 G4ChordFinder *pChordFinder=0, 89 G4bool b = true ); // field << 77 G4bool b=true ); // fieldChangesEnergy is taken from field 90 // General constructor for any field. << 78 // General constructor for any field. 91 // -> Must be set with field and chordfi << 79 // -> Must be set with field and chordfinder for use. 92 G4FieldManager(G4MagneticField* detectorMa << 80 G4FieldManager(G4MagneticField *detectorMagneticField); 93 // Creates ChordFinder << 81 // Creates ChordFinder 94 // -> Assumes pure magnetic field (so en << 82 // - assumes pure magnetic field (so Energy constant) 95 << 83 virtual ~G4FieldManager(); 96 virtual ~G4FieldManager(); << 84 97 << 85 G4bool SetDetectorField(G4Field *detectorField); 98 G4FieldManager(const G4FieldManager&) = de << 86 inline const G4Field* GetDetectorField() const; 99 G4FieldManager& operator=(const G4FieldMan << 87 inline G4bool DoesFieldExist() const; 100 << 88 // Set, get and check the field object 101 G4bool SetDetectorField(G4Field* detectorF << 89 102 // Pushes the field to the equation. << 90 void CreateChordFinder(G4MagneticField *detectorMagField); 103 // Failure to push the field (due to abs << 91 inline void SetChordFinder(G4ChordFinder *aChordFinder); 104 // stepper or equation) is << 92 inline G4ChordFinder* GetChordFinder(); 105 // - '0' = quiet : Do not comp << 93 inline const G4ChordFinder* GetChordFinder() const; 106 // (It will s << 94 // Create, set or get the associated Chord Finder 107 // - '1' = warn : a warning i << 95 108 // - '2'/else = FATAL : a fatal err << 96 virtual void ConfigureForTrack( const G4Track * ); 109 // Returns success (true) or failure (fa << 97 // Setup the choice of the configurable parameters 110 << 98 // relying on the current track's energy, particle identity, .. 111 inline void ProposeDetectorField(G4Field* << 99 // Note: In addition to the values of member variables, 112 // Pushes the field to this class only - << 100 // a user can use this to change the ChordFinder, the field, ... 113 // Should be used to initialise this fi << 114 // the chord finder and its dependent cl << 115 // User is then responsible to ensure th << 116 // i) an equation, stepper, driver a << 117 // ii) this field is used by the equa << 118 << 119 inline void ChangeDetectorField(G4Field* << 120 // Pushes the field to the equation ( & << 121 // Can be used only once the equation, s << 122 // have all been created. Else it is an << 123 << 124 inline const G4Field* GetDetectorField() << 125 inline G4bool DoesFieldExist() co << 126 // Set, get and check the field object << 127 << 128 void CreateChordFinder(G4MagneticField* de << 129 inline void SetChordFinder(G4ChordFinder* << 130 inline G4ChordFinder* GetChordFinder(); << 131 inline const G4ChordFinder* GetChordFinder << 132 // Create, set or get the associated Cho << 133 << 134 virtual void ConfigureForTrack( const G4 << 135 // Setup the choice of the configurable << 136 // relying on the current track's energy << 137 // Note: in addition to the values of me << 138 // a user can use this to change t << 139 << 140 // static functions to handle global field << 141 static void SetGlobalFieldManager(G4FieldM << 142 static G4FieldManager* GetGlobalFieldManag << 143 101 144 public: // with description 102 public: // with description 145 103 146 inline G4double GetDeltaIntersection() con << 104 inline G4double GetDeltaIntersection() const; // virtual ? 147 // Accuracy for boundary intersection. << 105 // Accuracy for boundary intersection. 148 106 149 inline G4double GetDeltaOneStep() const; << 107 inline G4double GetDeltaOneStep() const; // virtual ? 150 // Accuracy for one tracking/physics ste << 108 // Accuracy for one tracking/physics step. 151 109 152 inline void SetAccuraciesWithDeltaOneStep( << 110 inline void SetAccuraciesWithDeltaOneStep(G4double valDeltaOneStep); 153 // Sets both accuracies, maintaining a f << 111 // Sets both accuracies, maintaining a fixed ratio for accuracties 154 // of volume Intersection and Integratio << 112 // of volume Intersection and Integration (in One Step) 155 113 156 inline void SetDeltaOneStep(G4double v << 114 inline void SetDeltaOneStep(G4double valueD1step); 157 // Set accuracy for integration of one s 115 // Set accuracy for integration of one step. (only) 158 inline void SetDeltaIntersection(G4dou << 116 inline void SetDeltaIntersection(G4double valueDintersection); 159 // Set accuracy of intersection of a vo 117 // Set accuracy of intersection of a volume. (only) 160 118 161 inline G4double GetMinimumEpsilonStep() c << 119 inline G4double GetMinimumEpsilonStep() const; 162 G4bool SetMinimumEpsilonStep( G4 << 120 inline void SetMinimumEpsilonStep( G4double newEpsMin ); 163 // Minimum for Relative accuracy of a St << 121 // Minimum for Relative accuracy of a Step 164 << 122 165 inline G4double GetMaximumEpsilonStep() c << 123 inline G4double GetMaximumEpsilonStep() const; 166 G4bool SetMaximumEpsilonStep( G4 << 124 inline void SetMaximumEpsilonStep( G4double newEpsMax ); 167 // Maximum for Relative accuracy of a St << 125 // Maximum for Relative accuracy of a Step 168 126 169 inline G4bool DoesFieldChangeEnergy() co << 127 inline G4bool DoesFieldChangeEnergy() const; 170 inline void SetFieldChangesEnergy(G4bo << 128 inline void SetFieldChangesEnergy(G4bool value); 171 // For electric field this should be tru << 129 // For electric field this should be true 172 // For magnetic field this should be fal << 130 // For magnetic field this should be false 173 << 174 virtual G4FieldManager* Clone() const; << 175 // Needed for multi-threading, create a << 176 << 177 public: << 178 static G4double GetMaxAcceptedEpsilon(); << 179 static G4bool SetMaxAcceptedEpsilon(G4do << 180 // Set value -- within limits. << 181 // If it fails, with softFail=true it giv << 182 << 183 protected: << 184 static G4double fMaxAcceptedEpsilon; << 185 static constexpr G4double fMinAcceptedEpsi << 186 // Epsilon_min/max values must be smalle << 187 << 188 static constexpr G4double fMaxWarningEpsil << 189 static constexpr G4double fMaxFinalEpsilon << 190 << 191 static G4bool fVerboseConstruc << 192 // Control verbosity of constructors << 193 131 194 private: 132 private: 195 133 196 void InitialiseFieldChangesEnergy(); << 134 G4FieldManager(const G4FieldManager&); 197 // Check whether field/equation change t << 135 G4FieldManager& operator=(const G4FieldManager&); 198 // and sets the data member accordingly << 136 // Private copy constructor and assignment operator. 199 // Note: does not handle special cases - << 137 200 // separately (e.g. magnetic monopole i << 201 << 202 protected: << 203 void ReportBadEpsilonValue(G4ExceptionDes << 204 G4String& name << 205 << 206 private: 138 private: 207 G4Field* fDetectorField = nullptr; << 139 208 G4ChordFinder* fChordFinder = nullptr; << 140 G4Field* fDetectorField; 209 // Dependent objects -- with state that << 141 G4ChordFinder* fChordFinder; 210 << 142 211 G4bool fAllocatedChordFinder = false; // D << 143 G4bool fAllocatedChordFinder; // Did we used "new" to 212 // c << 144 // create fChordFinder ? 213 // INVARIANTS of tracking --------------- << 145 G4bool fFieldChangesEnergy; 214 // << 146 215 // 1. 'CONSTANTS' - default values for ac << 147 // Values for the required accuracies 216 // << 148 // 217 const G4double fEpsilonMinDefault= 5.0e-5; << 149 G4double fDelta_One_Step_Value; // for one tracking/physics step 218 const G4double fEpsilonMaxDefault= 1.0e-3; << 150 G4double fDelta_Intersection_Val; // for boundary intersection 219 << 151 220 static G4double fDefault_Delta_One_Step_Va << 152 G4double fDefault_Delta_One_Step_Value; // = 0.25 * mm; 221 static G4double fDefault_Delta_Intersectio << 153 G4double fDefault_Delta_Intersection_Val; // = 0.1 * mm; 222 // Default values for accuracy parameter << 154 223 << 155 // Values for the small possible relative accuracy of a step 224 // 2. CHARACTERISTIC of field << 156 // (corresponding to the greatest possible integration accuracy) 225 // << 157 226 G4bool fFieldChangesEnergy = false; << 158 G4double fEpsilonMinDefault; // Can be 1.0e-5 to 1.0e-10 ... 227 << 159 G4double fEpsilonMaxDefault; // Can be 1.0e-3 to 1.0e-8 ... 228 // 3. PARAMETERS that determine the accur << 160 G4double fEpsilonMin; 229 // << 161 G4double fEpsilonMax; 230 G4double fDelta_One_Step_Value; // f << 231 G4double fDelta_Intersection_Val; // f << 232 // Values for the required accuracies << 233 << 234 G4double fEpsilonMin; << 235 G4double fEpsilonMax; << 236 // Values for the small possible relativ << 237 // (corresponding to the greatest possib << 238 << 239 static G4ThreadLocal G4FieldManager* fGlob << 240 // Global field manager set by G4Transpo << 241 // to allow accessing the global field w << 242 // on navigation << 243 }; 162 }; 244 163 >> 164 // Our current design envisions that one Field manager is valid for a region of the detector. >> 165 // (eg a detector with electric E and magnetic B field will now treat >> 166 // them as one field - and could treat any other field of importance >> 167 // as additional components of a single field.) >> 168 // Does it make sense to have several instead ? >> 169 // Is the lack of elegance of the design (of G4Field) made up >> 170 // for by the simplification it allows ? >> 171 245 // Implementation of inline functions 172 // Implementation of inline functions 246 173 247 #include "G4FieldManager.icc" 174 #include "G4FieldManager.icc" 248 175 249 #endif << 176 #endif /* G4FIELDMANAGER_HH */ 250 177