105 #ifdef G4DEBUG_NAVIGATION
108 G4cout <<
" G4MultiNavigator::ComputeStep : entered " <<
G4endl;
109 G4cout <<
" Input position= " << pGlobalPoint
110 <<
" direction= " << pDirection <<
G4endl;
111 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
115 std::vector<G4Navigator*>::iterator pNavigatorIter;
126 step= (*pNavigatorIter)->ComputeStep( initialPosition,
130 if( safety < minSafety ){ minSafety = safety; }
131 if( step < minStep ) { minStep= step; }
137 #ifdef G4DEBUG_NAVIGATION
140 G4cout <<
"G4MultiNavigator::ComputeStep : Navigator ["
141 << num <<
"] -- step size " << step
142 <<
" safety= " << safety <<
G4endl;
162 #ifdef G4DEBUG_NAVIGATION
168 G4cout <<
"G4MultiNavigator::ComputeStep : "
169 <<
" initialPosition = " << initialPosition
170 <<
" and endPosition = " << endPosition <<
G4endl;
171 G4cout.precision( oldPrec );
175 pNewSafety = minSafety;
179 #ifdef G4DEBUG_NAVIGATION
182 G4cout <<
" G4MultiNavigator::ComputeStep : exits returning "
201 message <<
"Bad Navigator Id!" <<
G4endl
202 <<
" Navigator Id = " << navigatorId
204 G4Exception(
"G4MultiNavigator::ObtainFinalStep()",
"GeomNav0002",
214 #ifdef G4DEBUG_NAVIGATION
217 G4cout <<
" G4MultiNavigator::ComputeStep returns "
219 <<
" for Navigator " << navigatorId
220 <<
" Limited step = " << limitedStep
221 <<
" Safety(mm) = " << pNewSafety /
mm <<
G4endl;
233 #ifdef G4DEBUG_NAVIGATION
236 G4cout <<
" Entered G4MultiNavigator::PrepareNewTrack() " <<
G4endl;
257 #ifdef G4DEBUG_NAVIGATION
260 G4cout <<
" Entered G4MultiNavigator::PrepareNavigators() " <<
G4endl;
266 std::vector<G4Navigator*>::iterator pNavigatorIter;
272 message <<
"Too many active Navigators / worlds !" <<
G4endl
273 <<
" Active Navigators (worlds): "
275 <<
" which is more than the number allowed: "
277 G4Exception(
"G4MultiNavigator::PrepareNavigators()",
"GeomNav0002",
302 #ifdef G4DEBUG_NAVIGATION
305 G4cout <<
" G4MultiNavigator::PrepareNavigators() changed world volume "
306 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
319 const G4bool pRelativeSearch,
320 const G4bool ignoreDirection )
325 G4bool relative = pRelativeSearch;
326 std::vector<G4Navigator*>::iterator pNavIter
329 if( pDirection ) { direction = *pDirection; }
331 #ifdef G4DEBUG_NAVIGATION
334 G4cout <<
" Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
336 G4cout <<
" Locating at position: " << position
337 <<
", with direction: " << direction << G4endl
338 <<
" Relative: " << relative
339 <<
", ignore direction: " << ignoreDirection <<
G4endl;
349 (*pNavIter)->SetGeometricallyLimitedStep();
353 = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
354 relative, ignoreDirection );
365 #ifdef G4DEBUG_NAVIGATION
368 G4cout <<
" Located in world: " << num <<
", at: " << position <<
G4endl
370 <<
", found in volume: " << pLocated <<
G4endl;
379 G4cout <<
"Null' Id: Not-Set ";
389 return volMassLocated;
399 std::vector<G4Navigator*>::iterator pNavIter
402 #ifdef G4DEBUG_NAVIGATION
405 G4cout <<
" Entered G4MultiNavigator::ReLocate() " <<
G4endl
406 <<
" Re-locating at position: " << position <<
G4endl;
414 (*pNavIter)->LocateGlobalPointWithinVolume( position );
437 std::vector<G4Navigator*>::iterator pNavigatorIter;
442 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
443 if( safety < minSafety ) { minSafety = safety; }
449 #ifdef G4DEBUG_NAVIGATION
452 G4cout <<
" G4MultiNavigator::ComputeSafety - returns: "
453 << minSafety <<
", at location: " << position <<
G4endl;
464 G4Exception(
"G4MultiNavigator::CreateTouchableHistoryHandle()",
466 "Getting a touchable from G4MultiNavigator is not defined.");
472 if( locatedVolume == 0 )
489 const G4int IdTransport= 0;
493 #ifdef G4DEBUG_NAVIGATION
496 G4cout <<
" Entered G4MultiNavigator::WhichLimited() " <<
G4endl;
504 if( transportLimited )
529 if( (last > -1) && (noLimited == 1 ) )
547 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
548 StrUndefined(
"Undefined"),
549 StrSharedTransport(
"SharedTransport"),
550 StrSharedOther(
"SharedOther");
551 G4cout <<
"### G4MultiNavigator::PrintLimited() reports: " <<
G4endl;
555 #ifdef G4DEBUG_NAVIGATION
558 G4cout << std::setw(5) <<
" NavId" <<
" "
559 << std::setw(12) <<
" step-size " <<
" "
560 << std::setw(12) <<
" raw-size " <<
" "
561 << std::setw(12) <<
" pre-safety " <<
" "
562 << std::setw(15) <<
" Limited / flag" <<
" "
563 << std::setw(15) <<
" World " <<
" "
578 G4cout << std::setw(5) << num <<
" "
579 << std::setw(12) << stepLen <<
" "
580 << std::setw(12) << rawStep <<
" "
582 << std::setw(5) << (
fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
586 case kDoNot : limitedStr= StrDoNot;
break;
587 case kUnique : limitedStr = StrUnique;
break;
590 default : limitedStr = StrUndefined;
break;
592 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
593 G4cout.precision(oldPrec);
605 G4cout <<
" " << WorldName ;
617 G4Exception(
"G4MultiNavigator::ResetState()",
"GeomNav0001",
619 "Cannot reset state for navigators of G4MultiNavigator.");
621 std::vector<G4Navigator*>::iterator pNavigatorIter;
635 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
649 "Mass world pointer has been changed." );
672 G4Exception(
"G4MultiNavigator::ResetHierarchyAndLocate()",
674 "Cannot reset hierarchy before navigators are initialised.");
677 std::vector<G4Navigator*>::iterator pNavIter=
682 G4bool relativeSearch, ignoreDirection;
686 relativeSearch=
false,
687 ignoreDirection=
false);
701 G4int firstNavigatorId= -1;
702 G4bool oneObtained=
false;
708 *argpObtained= isObtained;
714 std::vector<G4Navigator*>::iterator pNavIter=
726 if( !isObtained && (newNormal.
mag2() != 0.0) )
728 normalGlobalCrd= newNormal;
729 isObtained = oneObtained;
730 firstNavigatorId= num;
733 G4double dotNewPrevious= newNormal.
dot( normalGlobalCrd );
735 if( productMagSq > 0.0 )
737 G4double productMag= std::sqrt( productMagSq );
738 dotNewPrevious /= productMag;
741 *argpObtained=
false;
746 message <<
"Clash of Normal from different Navigators!" <<
G4endl
747 <<
" Previous Navigator Id = " << firstNavigatorId <<
G4endl
748 <<
" Current Navigator Id = " << num <<
G4endl;
749 message <<
" Dot product of 2 normals = " << dotNewPrevious <<
G4endl;
750 message <<
" Normal (previous) = " << normalGlobalCrd <<
G4endl;
751 message <<
" Normal (current) = " << newNormal <<
G4endl;
752 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
771 <<
" candidate Navigators limiting the step!" <<
G4endl;
772 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
779 *argpObtained= isObtained;
780 return normalGlobalCrd;
797 *argpObtained= isObtained;
800 G4int noWarningsStart= 10, noModuloWarnings=100;
802 if( (numberWarnings < noWarningsStart ) || (numberWarnings%noModuloWarnings==0) )
805 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
806 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
816 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
817 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
822 *argpObtained= isObtained;
823 return normalGlobalCrd;
G4ThreeVector fPreStepLocation
G4double fMinSafety_atSafLocation
G4ThreeVector fLastLocatedPosition
G4double fNewSafety[fMaxNav]
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
static const G4double kInfinity
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
static constexpr double mm
G4TouchableHistory * CreateTouchableHistory() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
ELimited fLimitedStep[fMaxNav]
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
void message(RunManager *runmanager)
double dot(const Hep3Vector &) const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
G4Navigator * GetNavigatorForTracking() const
G4TransportationManager * pTransportManager
G4bool fLimitTruth[fMaxNav]
static const G4int fMaxNav
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4VPhysicalVolume * fLastMassWorld
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
const G4NavigationHistory * GetHistory() const
G4bool fWasLimitedByGeometry
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4Navigator * fpNavigator[fMaxNav]
G4double fCurrentStepSize[fMaxNav]
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
virtual G4int GetCopyNo() const =0
G4int fNoActiveNavigators
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
static G4TransportationManager * GetTransportationManager()
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double fMinSafety_PreStepPt
G4GLOB_DLL std::ostream G4cout
G4ThreeVector fSafetyLocation
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4VPhysicalVolume * GetWorldVolume() const
G4VPhysicalVolume * fLocatedVolume[fMaxNav]
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
static constexpr double perThousand
const G4String & GetName() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)