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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /geometry/magneticfield/include/G4FieldManager.hh (Version 11.3.0) and /geometry/magneticfield/include/G4FieldManager.hh (Version 10.1.p1)


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