File indexing completed on 2025-01-18 09:58:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 #ifndef G4PATHFINDER_HH
0043 #define G4PATHFINDER_HH 1
0044
0045 #include <vector>
0046 #include "G4Types.hh"
0047
0048 #include "G4FieldTrack.hh"
0049
0050 class G4TransportationManager;
0051 class G4Navigator;
0052
0053 #include "G4MultiNavigator.hh"
0054 #include "G4TouchableHandle.hh"
0055
0056 class G4PropagatorInField;
0057
0058 class G4PathFinder
0059 {
0060
0061 public:
0062
0063 static G4PathFinder* GetInstance();
0064
0065
0066 static G4PathFinder* GetInstanceIfExist();
0067
0068
0069 G4double ComputeStep( const G4FieldTrack& pFieldTrack,
0070 G4double pCurrentProposedStepLength,
0071 G4int navigatorId,
0072 G4int stepNo,
0073 G4double& pNewSafety,
0074 ELimited& limitedStep,
0075 G4FieldTrack& EndState,
0076 G4VPhysicalVolume* currentVolume );
0077
0078
0079
0080
0081
0082 void Locate( const G4ThreeVector& position,
0083 const G4ThreeVector& direction,
0084 G4bool relativeSearch = true);
0085
0086
0087
0088 void ReLocate( const G4ThreeVector& position );
0089
0090
0091
0092 void PrepareNewTrack( const G4ThreeVector& position,
0093 const G4ThreeVector& direction,
0094 G4VPhysicalVolume* massStartVol = nullptr);
0095
0096
0097 void EndTrack();
0098
0099
0100
0101
0102 G4TouchableHandle CreateTouchableHandle( G4int navId ) const;
0103 inline G4VPhysicalVolume* GetLocatedVolume( G4int navId ) const;
0104
0105
0106
0107 inline G4bool IsParticleLooping() const;
0108
0109 inline G4double GetCurrentSafety() const;
0110
0111 inline G4double GetMinimumStep() const;
0112
0113
0114 inline unsigned int GetNumberGeometriesLimitingStep() const;
0115
0116 G4double ComputeSafety( const G4ThreeVector& globalPoint);
0117
0118
0119
0120 G4double ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint );
0121
0122
0123
0124
0125 void EnableParallelNavigation( G4bool enableChoice = true );
0126
0127
0128
0129
0130
0131 inline G4int SetVerboseLevel(G4int lev = -1);
0132
0133 public:
0134
0135 inline G4int GetMaxLoopCount() const;
0136 inline void SetMaxLoopCount( G4int new_max );
0137
0138
0139 public:
0140
0141 inline void MovePoint();
0142
0143
0144
0145
0146
0147 G4double LastPreSafety( G4int navId, G4ThreeVector& globalCenterPoint,
0148 G4double& minSafety );
0149
0150
0151
0152
0153
0154 void PushPostSafetyToPreSafety();
0155
0156
0157
0158 G4String& LimitedString( ELimited lim );
0159
0160
0161 ~G4PathFinder();
0162
0163
0164 protected:
0165
0166 G4double DoNextLinearStep( const G4FieldTrack& FieldTrack,
0167 G4double proposedStepLength);
0168
0169 G4double DoNextCurvedStep( const G4FieldTrack& FieldTrack,
0170 G4double proposedStepLength,
0171 G4VPhysicalVolume* pCurrentPhysVolume);
0172
0173 void WhichLimited();
0174 void PrintLimited();
0175
0176
0177 inline G4bool UseSafetyForOptimization( G4bool );
0178
0179
0180 void ReportMove( const G4ThreeVector& OldV,
0181 const G4ThreeVector& NewV,
0182 const G4String& Quantity ) const;
0183
0184
0185 protected:
0186
0187 G4PathFinder();
0188
0189 inline G4Navigator* GetNavigator(G4int n) const;
0190
0191 private:
0192
0193
0194
0195
0196
0197 G4MultiNavigator* fpMultiNavigator;
0198
0199
0200 G4int fNoActiveNavigators = 0;
0201 G4bool fNewTrack = false;
0202
0203 static const G4int fMaxNav = 16;
0204
0205
0206
0207 G4Navigator* fpNavigator[fMaxNav];
0208
0209
0210
0211 ELimited fLimitedStep[fMaxNav];
0212 G4bool fLimitTruth[fMaxNav];
0213 G4double fCurrentStepSize[fMaxNav];
0214 G4int fNoGeometriesLimiting = 0;
0215
0216 G4ThreeVector fPreSafetyLocation;
0217
0218 G4double fPreSafetyMinValue = -1.0;
0219
0220 G4double fPreSafetyValues[ fMaxNav ];
0221
0222
0223
0224
0225 G4ThreeVector fPreStepLocation;
0226
0227 G4double fMinSafety_PreStepPt = -1.0;
0228
0229 G4double fCurrentPreStepSafety[ fMaxNav ];
0230
0231
0232
0233
0234 G4bool fPreStepCenterRenewed = false;
0235
0236
0237 G4double fMinStep = -1.0;
0238 G4double fTrueMinStep = -1.0;
0239
0240
0241
0242 G4VPhysicalVolume* fLocatedVolume[fMaxNav];
0243 G4ThreeVector fLastLocatedPosition;
0244
0245
0246
0247
0248 G4FieldTrack fEndState;
0249 G4bool fFieldExertedForce = false;
0250
0251 G4bool fRelocatedPoint = false;
0252
0253
0254
0255
0256
0257
0258 G4ThreeVector fSafetyLocation;
0259
0260 G4double fMinSafety_atSafLocation = -1.0;
0261
0262 G4double fNewSafetyComputed[ fMaxNav ];
0263
0264
0265
0266
0267 G4int fLastStepNo = -1, fCurrentStepNo = -1;
0268
0269 G4int fVerboseLevel = 0;
0270
0271 G4TransportationManager* fpTransportManager;
0272 G4PropagatorInField* fpFieldPropagator;
0273
0274 G4double kCarTolerance;
0275
0276 static G4ThreadLocal G4PathFinder* fpPathFinder;
0277 };
0278
0279
0280
0281
0282
0283 inline G4VPhysicalVolume* G4PathFinder::GetLocatedVolume( G4int navId ) const
0284 {
0285 G4VPhysicalVolume* vol = nullptr;
0286 if( (navId < fMaxNav) && (navId >= 0) ) { vol= fLocatedVolume[navId]; }
0287 return vol;
0288 }
0289
0290 inline G4int G4PathFinder::SetVerboseLevel(G4int newLevel)
0291 {
0292 G4int old = fVerboseLevel;
0293 fVerboseLevel = newLevel;
0294 return old;
0295 }
0296
0297 inline G4double G4PathFinder::GetMinimumStep() const
0298 {
0299 return fMinStep;
0300 }
0301
0302 inline unsigned int G4PathFinder::GetNumberGeometriesLimitingStep() const
0303 {
0304 unsigned int noGeometries = fNoGeometriesLimiting;
0305 return noGeometries;
0306 }
0307
0308 inline G4double G4PathFinder::GetCurrentSafety() const
0309 {
0310 return fMinSafety_PreStepPt;
0311 }
0312
0313 inline void G4PathFinder::MovePoint()
0314 {
0315 fRelocatedPoint = true;
0316 }
0317
0318 inline G4Navigator* G4PathFinder::GetNavigator(G4int n) const
0319 {
0320 if( (n>fNoActiveNavigators) || (n<0) ) { n=0; }
0321 return fpNavigator[n];
0322 }
0323
0324 inline G4double
0325 G4PathFinder::ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint )
0326 {
0327 globalCenterPoint = fSafetyLocation;
0328 return fNewSafetyComputed[ navId ];
0329 }
0330
0331 inline G4double
0332 G4PathFinder::LastPreSafety( G4int navId, G4ThreeVector& globalCenterPoint,
0333 G4double& minSafety )
0334 {
0335 globalCenterPoint = fPreSafetyLocation;
0336 minSafety = fPreSafetyMinValue;
0337 return fPreSafetyValues[ navId ];
0338 }
0339
0340 #endif