00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id: G4FieldManager.hh 69786 2013-05-15 09:38:51Z gcosmo $ 00028 // 00029 // 00030 // class G4FieldManager 00031 // 00032 // Class description: 00033 // 00034 // A class to manage (Store) a pointer to the Field subclass that 00035 // describes the field of a detector (magnetic, electric or other). 00036 // Also stores a reference to the chord finder. 00037 // 00038 // The G4FieldManager class exists to allow the user program to specify 00039 // the electric, magnetic and/or other field(s) of the detector. 00040 // 00041 // A field manager can be set to a logical volume (or to more than one), 00042 // in order to vary its field from that of the world. In this manner 00043 // a zero or constant field can override a global field, a more or 00044 // less exact version can override the external approximation, lower 00045 // or higher precision for tracking can be specified, a different 00046 // stepper can be chosen for different volumes, ... 00047 // 00048 // It also stores a pointer to the ChordFinder object that can do the 00049 // propagation in this field. All geometrical track "advancement" 00050 // in the field is handled by this ChordFinder object. 00051 // 00052 // G4FieldManager allows the other classes/object (of the MagneticField 00053 // & other class categories) to find out whether a detector field object 00054 // exists and what that object is. 00055 // 00056 // The Chord Finder must be created either by calling CreateChordFinder 00057 // for a Magnetic Field or by the user creating a a Chord Finder object 00058 // "manually" and setting this pointer. 00059 // 00060 // A default FieldManager is created by the singleton class 00061 // G4NavigatorForTracking and exists before main is called. 00062 // However a new one can be created and given to G4NavigatorForTracking. 00063 // 00064 // Our current design envisions that one Field manager is 00065 // valid for each region detector. 00066 00067 // History: 00068 // - 05.11.03 John Apostolakis, Added Min/MaximumEpsilonStep 00069 // - 20.06.03 John Apostolakis, Abstract & ability to ConfigureForTrack 00070 // - 10.03.97 John Apostolakis, design and implementation. 00071 // ------------------------------------------------------------------- 00072 00073 #ifndef G4FIELDMANAGER_HH 00074 #define G4FIELDMANAGER_HH 1 00075 00076 #include "globals.hh" 00077 00078 class G4Field; 00079 class G4MagneticField; 00080 class G4ChordFinder; 00081 class G4Track; // Forward reference for parameter configuration 00082 00083 class G4FieldManager 00084 { 00085 public: // with description 00086 G4FieldManager(G4Field *detectorField=0, 00087 G4ChordFinder *pChordFinder=0, 00088 G4bool b=true ); // fieldChangesEnergy is taken from field 00089 // General constructor for any field. 00090 // -> Must be set with field and chordfinder for use. 00091 G4FieldManager(G4MagneticField *detectorMagneticField); 00092 // Creates ChordFinder 00093 // - assumes pure magnetic field (so Energy constant) 00094 virtual ~G4FieldManager(); 00095 00096 G4bool SetDetectorField(G4Field *detectorField); 00097 inline const G4Field* GetDetectorField() const; 00098 inline G4bool DoesFieldExist() const; 00099 // Set, get and check the field object 00100 00101 void CreateChordFinder(G4MagneticField *detectorMagField); 00102 inline void SetChordFinder(G4ChordFinder *aChordFinder); 00103 inline G4ChordFinder* GetChordFinder(); 00104 inline const G4ChordFinder* GetChordFinder() const; 00105 // Create, set or get the associated Chord Finder 00106 00107 virtual void ConfigureForTrack( const G4Track * ); 00108 // Setup the choice of the configurable parameters 00109 // relying on the current track's energy, particle identity, .. 00110 // Note: In addition to the values of member variables, 00111 // a user can use this to change the ChordFinder, the field, ... 00112 00113 public: // with description 00114 00115 inline G4double GetDeltaIntersection() const; // virtual ? 00116 // Accuracy for boundary intersection. 00117 00118 inline G4double GetDeltaOneStep() const; // virtual ? 00119 // Accuracy for one tracking/physics step. 00120 00121 inline void SetAccuraciesWithDeltaOneStep(G4double valDeltaOneStep); 00122 // Sets both accuracies, maintaining a fixed ratio for accuracties 00123 // of volume Intersection and Integration (in One Step) 00124 00125 inline void SetDeltaOneStep(G4double valueD1step); 00126 // Set accuracy for integration of one step. (only) 00127 inline void SetDeltaIntersection(G4double valueDintersection); 00128 // Set accuracy of intersection of a volume. (only) 00129 00130 inline G4double GetMinimumEpsilonStep() const; 00131 inline void SetMinimumEpsilonStep( G4double newEpsMin ); 00132 // Minimum for Relative accuracy of a Step 00133 00134 inline G4double GetMaximumEpsilonStep() const; 00135 inline void SetMaximumEpsilonStep( G4double newEpsMax ); 00136 // Maximum for Relative accuracy of a Step 00137 00138 inline G4bool DoesFieldChangeEnergy() const; 00139 inline void SetFieldChangesEnergy(G4bool value); 00140 // For electric field this should be true 00141 // For magnetic field this should be false 00142 00143 private: 00144 00145 G4FieldManager(const G4FieldManager&); 00146 G4FieldManager& operator=(const G4FieldManager&); 00147 // Private copy constructor and assignment operator. 00148 00149 private: 00150 // Dependent objects -- with state that depends on tracking 00151 G4Field* fDetectorField; 00152 G4ChordFinder* fChordFinder; 00153 00154 G4bool fAllocatedChordFinder; // Did we used "new" to 00155 // create fChordFinder ? 00156 // INVARIANTS of tracking --------------------------------------- 00157 // 00158 // 1. CONSTANTS 00159 const G4double fEpsilonMinDefault; // Can be 1.0e-5 to 1.0e-10 ... 00160 const G4double fEpsilonMaxDefault; // Can be 1.0e-3 to 1.0e-8 ... 00161 00162 // 2. CHARACTERISTIC of field 00163 G4bool fFieldChangesEnergy; 00164 00165 // 3. PARAMETERS 00166 // 00167 // Values for the required accuracies 00168 G4double fDelta_One_Step_Value; // for one tracking/physics step 00169 G4double fDelta_Intersection_Val; // for boundary intersection 00170 00171 G4double fDefault_Delta_One_Step_Value; // = 0.25 * mm; 00172 G4double fDefault_Delta_Intersection_Val; // = 0.1 * mm; 00173 00174 // Values for the small possible relative accuracy of a step 00175 // (corresponding to the greatest possible integration accuracy) 00176 G4double fEpsilonMin; 00177 G4double fEpsilonMax; 00178 00179 }; 00180 00181 // Our current design and implementation expect that a particular 00182 // geometrical region has a Field manager. 00183 // By default a Field Manager is created for the world volume, and 00184 // will be utilised for all volumes unless it is overridden by a 'local' 00185 // field manager. 00186 00187 // Note also that a region with both electric E and magnetic B field will 00188 // have these treated as one field. 00189 // Similarly it could be extended to treat other fields as additional components 00190 // of a single field type. 00191 00192 00193 // Implementation of inline functions 00194 00195 #include "G4FieldManager.icc" 00196 00197 #endif /* G4FIELDMANAGER_HH */