39 : fNavigator(navigator), fNavHistory(navHistory)
64 G4double distEndpointSq = (pGlobalpoint-stepEndPoint).mag2();
65 G4bool stayedOnEndpoint = distEndpointSq <
sqr(fkCarTolerance);
70 if( motherPhysical != physicalVolume )
72 std::ostringstream msg;
73 msg <<
" Current (navigation) phys-volume: " << motherPhysical
75 <<
" Request made for phys-volume: " << physicalVolume
77 G4Exception(
"G4SafetyCalculator::SafetyInCurrentVolume",
"GeomNav0001",
79 "This method must be called only in the Current volume.");
82 if( !(endpointOnSurface && stayedOnEndpoint) )
101 *motherPhysical, pMaxLength);
105 safety=fnormalNav.
ComputeSafety(localPoint,fNavHistory,pMaxLength);
111 safety=fparamNav.
ComputeSafety(localPoint,fNavHistory,pMaxLength);
115 safety=fregularNav.
ComputeSafety(localPoint,fNavHistory,pMaxLength);
120 fNavHistory, pMaxLength);
123 safety = fpExternalNav->
ComputeSafety(localPoint, fNavHistory,
130 fPreviousSftOrigin = pGlobalpoint;
131 fPreviousSafety = safety;
196 return fpExternalNav;
204 fpExternalNav = eNav;
217 G4bool enteredDaughterVol,
220 constexpr G4double reportThreshold= 3.0e-14;
222 constexpr G4double errorThreshold= 1.0e-08;
224 constexpr G4double epsilonLen= 1.0e-20;
227 const G4double oldSafetyPlus = std::fabs(oldSafety)+epsilonLen;
228 if( std::fabs( newValue - oldSafety) > reportThreshold * oldSafetyPlus )
231 std::ostringstream msg;
232 G4double diff= (newValue-oldSafety);
233 G4double relativeDiff= diff / oldSafetyPlus;
235 msg <<
" New (G4SafetyCalculator) value *disagrees* by relative diff " << relativeDiff
236 <<
" in physical volume '" << motherPhysical->
GetName() <<
"' "
237 <<
"copy-no = " << motherPhysical->
GetCopyNo();
238 if( enteredDaughterVol ) { msg <<
" ( Just Entered new daughter volume. ) "; }
239 if( exitedMotherVol ) { msg <<
" ( Just Exited previous volume. ) "; }
241 msg <<
" Safeties: old= " << std::setprecision(12) << oldSafety
242 <<
" trial " << newValue
243 <<
" new-old= " << std::setprecision(7) << diff <<
G4endl;
245 if( std::fabs(diff) < errorThreshold * ( std::fabs(oldSafety)+1.0e-20 ) )
247 msg <<
" (tiny difference) ";
252 msg <<
" (real difference) ";
256 msg <<
" NOTE: keepState = " << keepState <<
G4endl;
257 msg <<
" Location - Global coordinates: " << globalPoint
258 <<
" volume= '" << motherPhysical->
GetName() <<
"'"
260 msg <<
" Argument maxLength= " << maxLength <<
G4endl;
262 std::size_t depth= fNavHistory.
GetDepth();
263 msg <<
" Navigation History: depth = " << depth <<
G4endl;
266 msg <<
" d= " << i <<
" " << std::setw(32)
273#ifdef G4DEBUG_NAVIGATION
276 msg <<
" Redoing estimator: value = " << std::setprecision(16) << redo
277 <<
" diff/last= " << std::setprecision(7) << redo - newValue
278 <<
" diff/old= " << redo - oldSafety <<
G4endl;
281 G4Exception(
"G4SafetyCalculator::CompareSafetyValues()",
"GeomNav1007",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4SmartVoxelHeader * GetVoxelHeader() const
G4int GetReplicaNo(G4int n) const
G4VPhysicalVolume * GetVolume(G4int n) const
std::size_t GetDepth() const
G4VPhysicalVolume * GetTopVolume() const
G4bool EnteredDaughterVolume() const
G4bool ExitedMotherVolume() const
G4ThreeVector GetLastStepEndPoint() const
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX) final
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) override
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) final
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX) const
void SetExternalNavigation(G4VExternalNavigation *externalNav)
G4VExternalNavigation * GetExternalNavigation() const
G4SafetyCalculator(const G4Navigator &navigator, const G4NavigationHistory &navHistory)
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLv) const
void QuickLocateWithinVolume(const G4ThreeVector &pointLocal, G4VPhysicalVolume *motherPhysical)
void CompareSafetyValues(G4double oldSafety, G4double newValue, G4VPhysicalVolume *motherPhysical, const G4ThreeVector &globalPoint, G4bool keepState, G4double maxLength, G4bool enteredVolume, G4bool exitedVolume)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
G4double SafetyInCurrentVolume(const G4ThreeVector &globalpoint, G4VPhysicalVolume *physicalVolume, const G4double pProposedMaxLength=DBL_MAX, G4bool verbose=false)
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
virtual void RelocateWithinVolume(G4VPhysicalVolume *motherPhysical, const G4ThreeVector &localPoint)
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)=0
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4VPhysicalVolume ¤tPhysical, G4double maxLength=DBL_MAX)