#include <G4SafetyHelper.hh>
Public Member Functions | |
G4SafetyHelper () | |
~G4SafetyHelper () | |
G4double | CheckNextStep (const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety) |
G4double | ComputeSafety (const G4ThreeVector &pGlobalPoint, G4double maxRadius=DBL_MAX) |
void | Locate (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction) |
void | ReLocateWithinVolume (const G4ThreeVector &pGlobalPoint) |
void | EnableParallelNavigation (G4bool parallel) |
void | InitialiseNavigator () |
G4int | SetVerboseLevel (G4int lev) |
G4VPhysicalVolume * | GetWorldVolume () |
void | SetCurrentSafety (G4double val, const G4ThreeVector &pos) |
void | InitialiseHelper () |
Definition at line 53 of file G4SafetyHelper.hh.
G4SafetyHelper::G4SafetyHelper | ( | ) |
Definition at line 42 of file G4SafetyHelper.cc.
00043 : fUseParallelGeometries(false), // By default, one geometry only 00044 fFirstCall(true), 00045 fVerbose(0), 00046 fLastSafetyPosition(0.0,0.0,0.0), 00047 fLastSafety(0.0), 00048 fRecomputeFactor(0.0) 00049 { 00050 fpPathFinder= 0; // Cannot initialise this yet - a loop results 00051 00052 // Initialization of the Navigator pointer is postponed, and must 00053 // be undertaken by another class calling InitialiseHelper() 00054 // 00055 fpMassNavigator= 0; 00056 fMassNavigatorId= -1; 00057 }
G4SafetyHelper::~G4SafetyHelper | ( | ) |
G4double G4SafetyHelper::CheckNextStep | ( | const G4ThreeVector & | position, | |
const G4ThreeVector & | direction, | |||
const G4double | currentMaxStep, | |||
G4double & | newSafety | |||
) |
Definition at line 94 of file G4SafetyHelper.cc.
References G4Navigator::CheckNextStep().
Referenced by G4VMscModel::ComputeGeomLimit().
00098 { 00099 // Distance in the Mass geometry 00100 // 00101 G4double linstep = fpMassNavigator->CheckNextStep( position, 00102 direction, 00103 currentMaxStep, 00104 newSafety); 00105 fLastSafetyPosition = position; 00106 fLastSafety = newSafety; 00107 00108 // TO-DO: Can replace this with a call to PathFinder 00109 // giving id of Mass Geometry --> this avoid doing the work twice 00110 00111 return linstep; 00112 }
G4double G4SafetyHelper::ComputeSafety | ( | const G4ThreeVector & | pGlobalPoint, | |
G4double | maxRadius = DBL_MAX | |||
) |
Definition at line 114 of file G4SafetyHelper.cc.
References G4PathFinder::ComputeSafety(), and G4Navigator::ComputeSafety().
Referenced by G4VEnergyLossProcess::AlongStepDoIt(), and G4VMscModel::ComputeSafety().
00115 { 00116 G4double newSafety; 00117 00118 // Only recompute (calling Navigator/PathFinder) if 'position' 00119 // is *not* the safety location and has moved 'significantly' 00120 // 00121 G4double moveLengthSq = (position-fLastSafetyPosition).mag2(); 00122 G4double safeDistance = fRecomputeFactor*fLastSafety; 00123 if( (moveLengthSq > 0.0 ) 00124 && (moveLengthSq >= safeDistance*safeDistance)) 00125 { 00126 fLastSafetyPosition = position; 00127 00128 if( !fUseParallelGeometries ) 00129 { 00130 // Safety for mass geometry 00131 fLastSafety = fpMassNavigator->ComputeSafety(position, maxLength, true); 00132 } 00133 else 00134 { 00135 // Safety for all geometries 00136 fLastSafety = fpPathFinder->ComputeSafety(position); 00137 } 00138 newSafety = fLastSafety; 00139 } 00140 else 00141 { 00142 // return last value if position is not significantly changed 00143 // 00144 G4double moveLength = 0; 00145 if( moveLengthSq > 0.0 ) 00146 { 00147 moveLength= std::sqrt(moveLengthSq); 00148 } 00149 newSafety = fLastSafety-moveLength; 00150 } 00151 return newSafety; 00152 }
void G4SafetyHelper::EnableParallelNavigation | ( | G4bool | parallel | ) | [inline] |
Definition at line 130 of file G4SafetyHelper.hh.
Referenced by G4PathFinder::EnableParallelNavigation().
G4VPhysicalVolume * G4SafetyHelper::GetWorldVolume | ( | ) | [inline] |
Definition at line 136 of file G4SafetyHelper.hh.
References G4Navigator::GetWorldVolume().
Referenced by G4VMscModel::ComputeGeomLimit().
00137 { 00138 return fpMassNavigator->GetWorldVolume(); 00139 }
void G4SafetyHelper::InitialiseHelper | ( | ) |
Definition at line 81 of file G4SafetyHelper.cc.
References InitialiseNavigator().
Referenced by G4VEnergyLossProcess::BuildPhysicsTable(), G4VMscModel::GetParticleChangeForMSC(), G4PathFinder::PrepareNewTrack(), and G4VMultipleScattering::PreparePhysicsTable().
00082 { 00083 fLastSafetyPosition = G4ThreeVector(0.0,0.0,0.0); 00084 fLastSafety = 0.0; 00085 if (fFirstCall) { InitialiseNavigator(); } 00086 fFirstCall = false; 00087 }
void G4SafetyHelper::InitialiseNavigator | ( | ) |
Definition at line 59 of file G4SafetyHelper.cc.
References G4TransportationManager::ActivateNavigator(), FatalException, G4Exception(), G4PathFinder::GetInstance(), G4TransportationManager::GetNavigatorForTracking(), G4TransportationManager::GetTransportationManager(), and G4Navigator::GetWorldVolume().
Referenced by InitialiseHelper().
00060 { 00061 fpPathFinder= G4PathFinder::GetInstance(); 00062 00063 G4TransportationManager* pTransportMgr= 00064 G4TransportationManager::GetTransportationManager(); 00065 00066 fpMassNavigator = pTransportMgr->GetNavigatorForTracking(); 00067 00068 // Check 00069 // 00070 G4VPhysicalVolume* worldPV = fpMassNavigator->GetWorldVolume(); 00071 if( worldPV == 0 ) 00072 { 00073 G4Exception("G4SafetyHelper::InitialiseNavigator", 00074 "InvalidNavigatorWorld", FatalException, 00075 "Found that existing tracking Navigator has NULL world"); 00076 } 00077 00078 fMassNavigatorId = pTransportMgr->ActivateNavigator( fpMassNavigator ); 00079 }
void G4SafetyHelper::Locate | ( | const G4ThreeVector & | pGlobalPoint, | |
const G4ThreeVector & | direction | |||
) |
Definition at line 184 of file G4SafetyHelper.cc.
References G4PathFinder::Locate(), and G4Navigator::LocateGlobalPointAndSetup().
00186 { 00187 if( !fUseParallelGeometries) 00188 { 00189 fpMassNavigator->LocateGlobalPointAndSetup(newPosition, &newDirection, 00190 true, false); 00191 } 00192 else 00193 { 00194 fpPathFinder->Locate( newPosition, newDirection ); 00195 } 00196 }
void G4SafetyHelper::ReLocateWithinVolume | ( | const G4ThreeVector & | pGlobalPoint | ) |
Definition at line 154 of file G4SafetyHelper.cc.
References G4endl, G4Exception(), JustWarning, G4Navigator::LocateGlobalPointWithinVolume(), G4PathFinder::ReLocate(), and sqr().
Referenced by G4VMultipleScattering::PostStepDoIt().
00155 { 00156 #ifdef G4VERBOSE 00157 if( fVerbose > 0 ) { 00158 // There is an opportunity - and need - to check whether the proposed move is safe 00159 G4ThreeVector moveVec= newPosition - fLastSafetyPosition; 00160 if( moveVec.mag2() > sqr(fLastSafety) ) 00161 { 00162 // A problem exists - we are proposing to move outside 'Safety Sphere' 00163 G4ExceptionDescription ed; 00164 ed << " Safety Sphere: Radius = " << fLastSafety; 00165 ed << " Center = " << fLastSafetyPosition << G4endl; 00166 ed << " New Location : Move = " << moveVec.mag2(); 00167 ed << " Position = " << newPosition << G4endl; 00168 G4Exception("G4SafetyHelper::ReLocateWithinVolume", "GeomNav999", JustWarning, 00169 "Unsafe Move> Asked to relocate beyond 'Safety sphere'."); 00170 } 00171 } 00172 #endif 00173 00174 if( !fUseParallelGeometries ) 00175 { 00176 fpMassNavigator->LocateGlobalPointWithinVolume( newPosition ); 00177 } 00178 else 00179 { 00180 fpPathFinder->ReLocate( newPosition ); 00181 } 00182 }
void G4SafetyHelper::SetCurrentSafety | ( | G4double | val, | |
const G4ThreeVector & | pos | |||
) | [inline] |
Definition at line 142 of file G4SafetyHelper.hh.
Referenced by G4Transportation::AlongStepGetPhysicalInteractionLength(), G4ITTransportation::AlongStepGetPhysicalInteractionLength(), and G4CoupledTransportation::AlongStepGetPhysicalInteractionLength().
Definition at line 96 of file G4SafetyHelper.hh.
00096 { G4int oldlv= fVerbose; fVerbose= lev; return oldlv; }