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