00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef G4PATHFINDER_HH
00045 #define G4PATHFINDER_HH 1
00046
00047 #include <vector>
00048 #include "G4Types.hh"
00049
00050 #include "G4FieldTrack.hh"
00051
00052 class G4TransportationManager;
00053 class G4Navigator;
00054
00055 #include "G4TouchableHandle.hh"
00056 #include "G4FieldTrack.hh"
00057 #include "G4MultiNavigator.hh"
00058
00059 class G4PropagatorInField;
00060
00061 class G4PathFinder
00062 {
00063
00064 public:
00065
00066 static G4PathFinder* GetInstance();
00067
00068
00069
00070 G4double ComputeStep( const G4FieldTrack &pFieldTrack,
00071 G4double pCurrentProposedStepLength,
00072 G4int navigatorId,
00073 G4int stepNo,
00074 G4double &pNewSafety,
00075 ELimited &limitedStep,
00076 G4FieldTrack &EndState,
00077 G4VPhysicalVolume* currentVolume );
00078
00079
00080
00081
00082
00083
00084 void Locate( const G4ThreeVector& position,
00085 const G4ThreeVector& direction,
00086 G4bool relativeSearch=true);
00087
00088
00089
00090
00091 void ReLocate( const G4ThreeVector& position );
00092
00093
00094
00095
00096 void PrepareNewTrack( const G4ThreeVector& position,
00097 const G4ThreeVector& direction,
00098 G4VPhysicalVolume* massStartVol=0);
00099
00100
00101
00102 G4TouchableHandle CreateTouchableHandle( G4int navId ) const;
00103 inline G4VPhysicalVolume* GetLocatedVolume( G4int navId ) const;
00104
00105
00106
00107 inline void SetChargeMomentumMass( G4double charge,
00108 G4double momentum,
00109 G4double pMass );
00110
00111 inline G4bool IsParticleLooping() const;
00112
00113 inline G4double GetCurrentSafety() const;
00114
00115 inline G4double GetMinimumStep() const;
00116
00117
00118 inline unsigned int GetNumberGeometriesLimitingStep() const;
00119
00120 G4double ComputeSafety( const G4ThreeVector& globalPoint);
00121
00122
00123
00124 G4double ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint );
00125
00126
00127
00128
00129 void EnableParallelNavigation( G4bool enableChoice=true );
00130
00131
00132
00133
00134
00135
00136 inline G4int SetVerboseLevel(G4int lev=-1);
00137
00138 public:
00139
00140 inline G4int GetMaxLoopCount() const;
00141 inline void SetMaxLoopCount( G4int new_max );
00142
00143
00144
00145 public:
00146
00147 inline void MovePoint();
00148
00149
00150
00151
00152
00153 G4double LastPreSafety( G4int navId, G4ThreeVector& globalCenterPoint, G4double& minSafety );
00154
00155
00156
00157
00158
00159 void PushPostSafetyToPreSafety();
00160
00161
00162 G4String& LimitedString( ELimited lim );
00163
00164
00165 protected:
00166
00167 G4double DoNextLinearStep( const G4FieldTrack &FieldTrack,
00168 G4double proposedStepLength);
00169
00170 G4double DoNextCurvedStep( const G4FieldTrack &FieldTrack,
00171 G4double proposedStepLength,
00172 G4VPhysicalVolume* pCurrentPhysVolume);
00173
00174 void WhichLimited();
00175 void PrintLimited();
00176
00177
00178
00179
00180
00181
00182
00183 inline G4bool UseSafetyForOptimization( G4bool );
00184
00185
00186
00187 void ReportMove( const G4ThreeVector& OldV, const G4ThreeVector& NewV, const G4String& Quantity ) const;
00188
00189
00190 protected:
00191
00192 G4PathFinder();
00193 ~G4PathFinder();
00194
00195 inline G4Navigator* GetNavigator(G4int n) const;
00196
00197 private:
00198
00199
00200
00201
00202
00203 G4MultiNavigator *fpMultiNavigator;
00204
00205
00206
00207 G4int fNoActiveNavigators;
00208 G4bool fNewTrack;
00209
00210 static const G4int fMaxNav = 8;
00211
00212
00213
00214 G4Navigator* fpNavigator[fMaxNav];
00215
00216
00217
00218 ELimited fLimitedStep[fMaxNav];
00219 G4bool fLimitTruth[fMaxNav];
00220 G4double fCurrentStepSize[fMaxNav];
00221 G4int fNoGeometriesLimiting;
00222
00223 G4ThreeVector fPreSafetyLocation;
00224 G4double fPreSafetyMinValue;
00225 G4double fPreSafetyValues[ fMaxNav ];
00226
00227
00228 G4ThreeVector fPreStepLocation;
00229 G4double fMinSafety_PreStepPt;
00230 G4double fCurrentPreStepSafety[ fMaxNav ];
00231
00232
00233
00234 G4bool fPreStepCenterRenewed;
00235
00236 G4double fMinStep;
00237 G4double fTrueMinStep;
00238
00239
00240
00241 G4VPhysicalVolume* fLocatedVolume[fMaxNav];
00242 G4ThreeVector fLastLocatedPosition;
00243
00244
00245 G4FieldTrack fEndState;
00246 G4bool fFieldExertedForce;
00247
00248 G4bool fRelocatedPoint;
00249
00250
00251
00252
00253
00254 G4ThreeVector fSafetyLocation;
00255 G4double fMinSafety_atSafLocation;
00256 G4double fNewSafetyComputed[ fMaxNav ];
00257
00258
00259 G4int fLastStepNo, fCurrentStepNo;
00260
00261 G4int fVerboseLevel;
00262
00263 G4TransportationManager* fpTransportManager;
00264 G4PropagatorInField* fpFieldPropagator;
00265
00266 G4double kCarTolerance;
00267
00268 static G4PathFinder* fpPathFinder;
00269 };
00270
00271
00272
00273
00274
00275 inline G4VPhysicalVolume* G4PathFinder::GetLocatedVolume( G4int navId ) const
00276 {
00277 G4VPhysicalVolume* vol=0;
00278 if( (navId < fMaxNav) && (navId >=0) ) { vol= fLocatedVolume[navId]; }
00279 return vol;
00280 }
00281
00282 inline G4int G4PathFinder::SetVerboseLevel(G4int newLevel)
00283 {
00284 G4int old= fVerboseLevel; fVerboseLevel= newLevel; return old;
00285 }
00286
00287 inline G4double G4PathFinder::GetMinimumStep() const
00288 {
00289 return fMinStep;
00290 }
00291
00292 inline unsigned int G4PathFinder::GetNumberGeometriesLimitingStep() const
00293 {
00294 unsigned int noGeometries=fNoGeometriesLimiting;
00295 return noGeometries;
00296 }
00297
00298 inline G4double G4PathFinder::GetCurrentSafety() const
00299 {
00300 return fMinSafety_PreStepPt;
00301 }
00302
00303 inline void G4PathFinder::MovePoint()
00304 {
00305 fRelocatedPoint= true;
00306 }
00307
00308 inline G4Navigator* G4PathFinder::GetNavigator(G4int n) const
00309 {
00310 if( (n>fNoActiveNavigators)||(n<0)) { n=0; }
00311 return fpNavigator[n];
00312 }
00313
00314 inline G4double G4PathFinder::ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint )
00315 {
00316 globalCenterPoint= fSafetyLocation;
00317
00318 return fNewSafetyComputed[ navId ];
00319 }
00320
00321 inline G4double G4PathFinder::LastPreSafety( G4int navId,
00322 G4ThreeVector& globalCenterPoint,
00323 G4double& minSafety )
00324 {
00325 globalCenterPoint= fPreSafetyLocation;
00326 minSafety= fPreSafetyMinValue;
00327
00328 return fPreSafetyValues[ navId ];
00329 }
00330 #endif