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