Geant4 Cross Reference |
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 // >> 27 // $Id: G4PropagatorInField.hh 90009 2015-05-08 07:42:39Z gcosmo $ >> 28 // >> 29 // 26 // Class G4PropagatorInField 30 // Class G4PropagatorInField 27 // 31 // 28 // class description: 32 // class description: 29 // 33 // 30 // This class performs the navigation/propagat 34 // This class performs the navigation/propagation of a particle/track 31 // in a magnetic field. The field is in genera 35 // in a magnetic field. The field is in general non-uniform. 32 // For the calculation of the path, it relies 36 // For the calculation of the path, it relies on the class G4ChordFinder. >> 37 // >> 38 // Key Method: ComputeStep(..) 33 39 34 // History: 40 // History: 35 // ------- 41 // ------- 36 // 25.10.96 John Apostolakis, design and impl 42 // 25.10.96 John Apostolakis, design and implementation 37 // 25.03.97 John Apostolakis, adaptation for 43 // 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup 38 // 8.11.02 John Apostolakis, changes to enab 44 // 8.11.02 John Apostolakis, changes to enable use of safety in intersecting 39 // ------------------------------------------- 45 // --------------------------------------------------------------------------- >> 46 40 #ifndef G4PropagatorInField_hh 47 #ifndef G4PropagatorInField_hh 41 #define G4PropagatorInField_hh 1 48 #define G4PropagatorInField_hh 1 42 49 43 #include "G4Types.hh" 50 #include "G4Types.hh" 44 51 45 #include <vector> 52 #include <vector> 46 53 47 #include "G4FieldTrack.hh" 54 #include "G4FieldTrack.hh" 48 #include "G4FieldManager.hh" 55 #include "G4FieldManager.hh" 49 #include "G4VIntersectionLocator.hh" 56 #include "G4VIntersectionLocator.hh" 50 57 51 class G4ChordFinder; 58 class G4ChordFinder; 52 59 53 class G4Navigator; 60 class G4Navigator; 54 class G4VPhysicalVolume; 61 class G4VPhysicalVolume; 55 class G4VCurvedTrajectoryFilter; 62 class G4VCurvedTrajectoryFilter; 56 63 57 class G4PropagatorInField 64 class G4PropagatorInField 58 { 65 { 59 66 60 public: // with description 67 public: // with description 61 68 62 G4PropagatorInField( G4Navigator* theNaviga << 69 G4PropagatorInField( G4Navigator *theNavigator, 63 G4FieldManager* detect << 70 G4FieldManager *detectorFieldMgr, 64 G4VIntersectionLocator << 71 G4VIntersectionLocator *vLocator=0 ); 65 ~G4PropagatorInField(); 72 ~G4PropagatorInField(); 66 73 67 G4double ComputeStep( G4FieldTrack& pFieldT << 74 G4double ComputeStep( G4FieldTrack &pFieldTrack, 68 G4double pCurrentProp << 75 G4double pCurrentProposedStepLength, 69 G4double& pNewSafety, << 76 G4double &pNewSafety, 70 G4VPhysicalVolume* pP << 77 G4VPhysicalVolume *pPhysVol=0 ); 71 G4bool canRelaxDeltaC << 72 // Compute the next geometric Step 78 // Compute the next geometric Step 73 79 74 inline G4ThreeVector EndPosition() const; << 80 inline G4ThreeVector EndPosition() const; 75 inline G4ThreeVector EndMomentumDir() const << 81 inline G4ThreeVector EndMomentumDir() const; 76 inline G4bool IsParticleLooping() co << 82 inline G4bool IsParticleLooping() const; 77 // Return the state after the Step 83 // Return the state after the Step 78 84 79 inline G4double GetEpsilonStep() const; << 85 inline G4double GetEpsilonStep() const; 80 // Relative accuracy for current Step (Ca 86 // Relative accuracy for current Step (Calc.) 81 inline void SetEpsilonStep(G4double new << 87 inline void SetEpsilonStep(G4double newEps); 82 // The ratio DeltaOneStep()/h_current_ste 88 // The ratio DeltaOneStep()/h_current_step 83 89 84 G4FieldManager* FindAndSetFieldManager(G4VP << 90 G4FieldManager* FindAndSetFieldManager(G4VPhysicalVolume* pCurrentPhysVol); 85 // Set (and return) the correct field man 91 // Set (and return) the correct field manager (global or local), 86 // if it exists. << 92 // if it exists. 87 // Should be called before ComputeStep is 93 // Should be called before ComputeStep is called; 88 // Currently, ComputeStep will call it, i << 94 // - currently, ComputeStep will call it, if it has not been called. 89 95 90 inline G4ChordFinder* GetChordFinder(); 96 inline G4ChordFinder* GetChordFinder(); 91 97 92 G4int SetVerboseLevel( G4int verbose << 98 G4int SetVerboseLevel( G4int verbose ); 93 inline G4int GetVerboseLevel() const; << 99 inline G4int GetVerboseLevel() const; 94 inline G4int Verbose() const; << 100 inline G4int Verbose() const; 95 inline void CheckMode(G4bool mode); << 96 101 97 inline void SetVerboseTrace( G4bool enabl << 102 inline void SetVerboseTrace( G4bool enable ) { fVerbTracePiF = enable; } 98 inline G4bool GetVerboseTrace(); << 103 inline G4bool GetVerboseTrace() { return fVerbTracePiF; } 99 // Tracing key parts of Compute Step 104 // Tracing key parts of Compute Step 100 105 101 inline G4int GetMaxLoopCount() const; << 106 inline G4int GetMaxLoopCount() const; 102 inline void SetMaxLoopCount( G4int new_max << 107 inline void SetMaxLoopCount( G4int new_max ); 103 // A maximum for the number of substeps t << 108 // A maximum for the number of steps that a (looping) particle can take. 104 // Above this number it is signaled as << 109 105 << 110 void printStatus( const G4FieldTrack& startFT, 106 void printStatus( const G4FieldTrack& << 111 const G4FieldTrack& currentFT, 107 const G4FieldTrack& << 112 G4double requestStep, 108 G4double << 113 G4double safety, 109 G4double << 114 G4int step, 110 G4int << 115 G4VPhysicalVolume* startVolume); 111 G4VPhysicalVolume* << 112 // Print Method - useful mostly for debug 116 // Print Method - useful mostly for debugging. 113 117 114 inline G4FieldTrack GetEndState() const; 118 inline G4FieldTrack GetEndState() const; 115 119 116 inline G4double GetMinimumEpsilonStep() con << 120 inline G4double GetMinimumEpsilonStep() const; // Min for relative accuracy 117 inline void SetMinimumEpsilonStep( G4do << 121 inline void SetMinimumEpsilonStep( G4double newEpsMin ); // of any step 118 inline G4double GetMaximumEpsilonStep() con << 122 inline G4double GetMaximumEpsilonStep() const; 119 inline void SetMaximumEpsilonStep( G4do << 123 inline void SetMaximumEpsilonStep( G4double newEpsMax ); 120 // The 4 above methods are now obsolescen 124 // The 4 above methods are now obsolescent but *for now* will work 121 // They are being replaced by same-name m 125 // They are being replaced by same-name methods in G4FieldManager, 122 // allowing the specialisation in differe 126 // allowing the specialisation in different volumes. 123 // Their new behaviour is to change the v 127 // Their new behaviour is to change the values for the global field 124 // manager 128 // manager 125 129 126 void SetLargestAcceptableStep( G4double << 130 inline void SetLargestAcceptableStep( G4double newBigDist ); 127 G4double GetLargestAcceptableStep(); << 131 inline G4double GetLargestAcceptableStep(); 128 void ResetLargestAcceptableStep(); << 129 // Obtain / change the size of the larges << 130 // Reset method uses the world volume's << 131 << 132 G4double GetMaxStepSizeMultiplier(); << 133 void SetMaxStepSizeMultiplier(G4double << 134 // Control extra Multiplier parameter for << 135 G4double GetMinBigDistance(); << 136 void SetMinBigDistance(G4double val); << 137 // Control minimum 'directional' distance << 138 132 139 void SetTrajectoryFilter(G4VCurvedTrajector 133 void SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter); 140 // Set the filter that examines & stores 134 // Set the filter that examines & stores 'intermediate' 141 // curved trajectory points. Currently o << 135 // curved trajectory points. Currently only position is stored. 142 136 143 std::vector<G4ThreeVector>* GimmeTrajectory 137 std::vector<G4ThreeVector>* GimmeTrajectoryVectorAndForgetIt() const; 144 // Access the points which have passed by 138 // Access the points which have passed by the filter. 145 // Responsibility for deleting the points 139 // Responsibility for deleting the points lies with the client. 146 // This method MUST BE called exactly ONC 140 // This method MUST BE called exactly ONCE per step. 147 141 148 void ClearPropagatorState(); 142 void ClearPropagatorState(); 149 // Clear all the State of this class and 143 // Clear all the State of this class and its current associates 150 // --> the current field manager & chord << 144 // --> the current field manager & chord finder will also be called 151 145 152 inline void SetDetectorFieldManager( G4Fiel 146 inline void SetDetectorFieldManager( G4FieldManager* newGlobalFieldManager ); 153 // Update this (dangerous) state -- for t 147 // Update this (dangerous) state -- for the time being 154 148 155 inline void SetUseSafetyForOptimization( 149 inline void SetUseSafetyForOptimization( G4bool ); 156 inline G4bool GetUseSafetyForOptimization() 150 inline G4bool GetUseSafetyForOptimization(); 157 // Toggle & view parameter for using safe 151 // Toggle & view parameter for using safety to discard 158 // unneccesary calls to navigator (thus ' << 152 // unneccesary calls to navigator (thus 'optimising' performance) 159 inline G4bool IntersectChord( const G4Three << 153 inline G4bool IntersectChord( const G4ThreeVector& StartPointA, 160 const G4Three << 154 const G4ThreeVector& EndPointB, 161 G4doubl << 155 G4double &NewSafety, 162 G4doubl << 156 G4double &LinearStepLength, 163 G4Three << 157 G4ThreeVector &IntersectionPoint); 164 // Intersect the chord from StartPointA t 158 // Intersect the chord from StartPointA to EndPointB 165 // and return whether an intersection occ 159 // and return whether an intersection occurred 166 // NOTE: Safety is changed! << 160 // NOTE : SAFETY IS CHANGED 167 161 168 inline G4bool IsFirstStepInVolume(); << 162 inline G4bool IsFirstStepInVolume() { return fFirstStepInVolume; } 169 inline G4bool IsLastStepInVolume(); << 163 inline G4bool IsLastStepInVolume() { return fLastStepInVolume; } 170 inline void PrepareNewTrack(); << 164 void PrepareNewTrack() { fNewTrack = true; fFirstStepInVolume=false; fLastStepInVolume=false; } 171 165 172 inline G4VIntersectionLocator* GetIntersect 166 inline G4VIntersectionLocator* GetIntersectionLocator(); 173 inline void SetIntersectionLocator(G4VInter << 167 inline void SetIntersectionLocator(G4VIntersectionLocator *pLocator ); 174 // Change or get the object which calcula 168 // Change or get the object which calculates the exact 175 // intersection point with the next bound << 169 // intersection point with the next boundary 176 << 170 177 inline G4int GetIterationsToIncreaseChordDi << 178 inline void SetIterationsToIncreaseChordDi << 179 // Control the parameter which enables th << 180 // which ensures that chord segments ar << 181 // their sagitta is small than delta-ch << 182 // The Set method increases the value of << 183 // doubling it once the number of itera << 184 // value of 'IncreaseChordDistanceThres << 185 // again every time the iteration count << 186 // value. << 187 // Note: delta-chord is reset to its orig << 188 // each call to ComputeStep. << 189 << 190 public: // without description 171 public: // without description 191 172 192 inline G4double GetDeltaIntersection() cons << 173 inline G4double GetDeltaIntersection() const; 193 inline G4double GetDeltaOneStep() const; << 174 inline G4double GetDeltaOneStep() const; 194 175 195 inline G4FieldManager* GetCurrentFieldManag << 176 inline G4FieldManager* GetCurrentFieldManager(); 196 inline G4EquationOfMotion* GetCurrentEquati << 177 inline G4EquationOfMotion* GetCurrentEquationOfMotion(); 197 // Auxiliary methods - their results can 178 // Auxiliary methods - their results can/will change during propagation 198 179 199 inline void SetNavigatorForPropagating(G4Na << 180 inline void SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator ); 200 inline G4Navigator* GetNavigatorForPropagat << 181 inline G4Navigator* GetNavigatorForPropagating(); 201 182 202 inline void SetThresholdNoZeroStep( G4int n 183 inline void SetThresholdNoZeroStep( G4int noAct, 203 G4int n 184 G4int noHarsh, 204 G4int n 185 G4int noAbandon ); 205 inline G4int GetThresholdNoZeroSteps( G4int 186 inline G4int GetThresholdNoZeroSteps( G4int i ); 206 187 207 inline G4double GetZeroStepThreshold(); << 188 inline G4double GetZeroStepThreshold(); 208 inline void SetZeroStepThreshold( G4dou << 189 inline void SetZeroStepThreshold( G4double newLength ); 209 190 210 void RefreshIntersectionLocator(); 191 void RefreshIntersectionLocator(); 211 // Update the Locator with parameters fro 192 // Update the Locator with parameters from this class 212 // and from current field manager << 193 // and from current field manager 213 194 214 protected: // without description 195 protected: // without description 215 196 216 void PrintStepLengthDiagnostic( G4double 197 void PrintStepLengthDiagnostic( G4double currentProposedStepLength, 217 G4double 198 G4double decreaseFactor, 218 G4double 199 G4double stepTrial, 219 const G4FieldTrac 200 const G4FieldTrack& aFieldTrack); 220 201 221 void ReportLoopingParticle( G4int count, G << 202 void ReportLoopingParticle( G4int count, double StepTaken, G4VPhysicalVolume* pPhysVol); 222 G4double stepRe << 203 void ReportStuckParticle( G4int noZeroSteps, G4double proposedStep, G4double lastTriedStep, 223 const G4ThreeVe << 204 G4VPhysicalVolume* physVol ); 224 G4VPhysicalVolu << 225 void ReportStuckParticle(G4int noZeroSteps, << 226 G4double lastTried << 227 << 228 private: 205 private: 229 << 230 // ---------------------------------------- 206 // ---------------------------------------------------------------------- 231 // DATA Members 207 // DATA Members 232 // ---------------------------------------- 208 // ---------------------------------------------------------------------- 233 209 234 // ======================================= 210 // ================================================================== 235 // INVARIANTS - Must not change during tra 211 // INVARIANTS - Must not change during tracking 236 212 237 // ** PARAMETERS ----------- 213 // ** PARAMETERS ----------- 238 G4int fMax_loop_count = 1000; << 214 G4int fMax_loop_count; 239 // Limit for the number of sub-steps take << 215 // Limit for the number of sub-steps taken in one call to ComputeStep 240 G4int fIncreaseChordDistanceThreshold = 100 << 216 G4bool fUseSafetyForOptimisation; 241 G4bool fUseSafetyForOptimisation = true; << 217 242 // (false) is less sensitive to incorrect << 218 // Thresholds for identifying "abnormal" cases - which cause looping 243 << 219 G4int fActionThreshold_NoZeroSteps; // Threshold # - above it act 244 // Thresholds for identifying "abnormal" c << 220 G4int fSevereActionThreshold_NoZeroSteps; // Threshold # to act harshly 245 // << 221 G4int fAbandonThreshold_NoZeroSteps; // Threshold # to abandon 246 G4int fActionThreshold_NoZeroSteps = 2; << 222 G4double fZeroStepThreshold; 247 G4int fSevereActionThreshold_NoZeroSteps = << 223 // Threshold *length* for counting of tiny or 'zero' steps 248 G4int fAbandonThreshold_NoZeroSteps = 50; << 224 249 G4double fZeroStepThreshold = 0.0; << 250 // Threshold *length* for counting of tin << 251 << 252 // Parameters related to handling of very l << 253 // occur typically in large volumes with << 254 G4double fLargestAcceptableStep; 225 G4double fLargestAcceptableStep; 255 // Maximum size of a step - for optimizat << 226 // Maximum size of a step - for optimization (and to avoid problems) 256 G4double fMaxStepSizeMultiplier = 3; << 257 // Multiplier for directional exit distan << 258 G4double fMinBigDistance= 100. ; // * CLHEP << 259 // Minimum distance added to directional << 260 // ** End of PARAMETERS ----- 227 // ** End of PARAMETERS ----- 261 228 262 G4double kCarTolerance; 229 G4double kCarTolerance; 263 // Geometrical tolerance defining surfa 230 // Geometrical tolerance defining surface thickness 264 231 265 G4bool fAllocatedLocator; << 232 G4bool fAllocatedLocator; // Book-keeping 266 233 267 // --------------------------------------- 234 // -------------------------------------------------------- 268 // ** Dependent Objects - to which work is 235 // ** Dependent Objects - to which work is delegated 269 236 270 G4FieldManager* fDetectorFieldMgr; << 237 G4FieldManager *fDetectorFieldMgr; 271 // The Field Manager of the whole Dete 238 // The Field Manager of the whole Detector. (default) 272 239 273 G4VIntersectionLocator* fIntersectionLocato << 240 G4VIntersectionLocator *fIntersectionLocator; 274 // Refines candidate intersection 241 // Refines candidate intersection 275 242 276 G4VCurvedTrajectoryFilter* fpTrajectoryFilt << 243 G4VCurvedTrajectoryFilter* fpTrajectoryFilter; 277 // The filter encapsulates the algorithm 244 // The filter encapsulates the algorithm which selects which 278 // intermediate points should be stored i 245 // intermediate points should be stored in a trajectory. 279 // When it is NULL, no intermediate point 246 // When it is NULL, no intermediate points will be stored. 280 // Else PIF::ComputeStep must submit (all 247 // Else PIF::ComputeStep must submit (all) intermediate 281 // points it calculates, to this filter. 248 // points it calculates, to this filter. (jacek 04/11/2002) 282 249 283 G4Navigator* fNavigator; << 250 G4Navigator *fNavigator; 284 // Set externally - only by tracking / ru 251 // Set externally - only by tracking / run manager 285 // 252 // 286 // ** End of Dependent Objects ----------- 253 // ** End of Dependent Objects ---------------------------- 287 254 288 // End of INVARIANTS 255 // End of INVARIANTS 289 // ======================================= 256 // ================================================================== 290 257 291 // STATE information 258 // STATE information 292 // ----------------- 259 // ----------------- 293 G4FieldManager* fCurrentFieldMgr; << 260 G4FieldManager *fCurrentFieldMgr; 294 // The Field Manager of the current volu << 261 // The Field Manager of the current volume (may be the global) 295 G4bool fSetFieldMgr = false; // Has it bee << 262 G4bool fSetFieldMgr; // Has it been set for the current step 296 263 297 // Parameters of current step 264 // Parameters of current step 298 G4double fEpsilonStep; // Relati << 265 G4double fEpsilonStep; // Relative accuracy of current Step 299 G4FieldTrack End_PointAndTangent; // End po << 266 G4FieldTrack End_PointAndTangent; // End point storage 300 G4bool fParticleIsLooping = false; << 267 G4bool fParticleIsLooping; 301 G4int fNoZeroStep = 0; // Count << 268 G4int fNoZeroStep; // Count of zero Steps 302 269 303 // State used for Optimisation 270 // State used for Optimisation 304 G4double fFull_CurveLen_of_LastAttempt = -1 << 271 G4double fFull_CurveLen_of_LastAttempt; 305 G4double fLast_ProposedStepLength = -1; << 272 G4double fLast_ProposedStepLength; 306 // Previous step information -- for use i << 273 // Previous step information -- for use in adjust step size 307 G4ThreeVector fPreviousSftOrigin; << 274 G4ThreeVector fPreviousSftOrigin; 308 G4double fPreviousSafety = 0.0; << 275 G4double fPreviousSafety; 309 // Last safety origin & value: for optimi << 276 // Last safety origin & value: for optimisation 310 << 277 311 G4int fVerboseLevel = 0; << 278 G4int fVerboseLevel; 312 G4bool fVerbTracePiF = false; << 279 G4bool fVerbTracePiF; 313 G4bool fCheck = false; << 280 // For debugging purposes 314 // For debugging purposes << 281 315 << 282 G4bool fFirstStepInVolume; 316 G4bool fFirstStepInVolume = true; << 283 G4bool fLastStepInVolume; 317 G4bool fLastStepInVolume = true; << 284 G4bool fNewTrack; 318 G4bool fNewTrack = true; << 319 }; 285 }; 320 286 321 // Inline methods << 287 // Inline methods. 322 // << 288 // ******************************* >> 289 323 #include "G4PropagatorInField.icc" 290 #include "G4PropagatorInField.icc" 324 291 325 #endif 292 #endif 326 293