53 fNoActiveNavigators= 0;
64 for(
G4int num=0; num< fMaxNav; ++num )
82 fLastMassWorld = pWorld;
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;
117 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
122 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
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 "
198 if( navigatorId > fNoActiveNavigators )
200 std::ostringstream message;
201 message <<
"Bad Navigator Id!" <<
G4endl
202 <<
" Navigator Id = " << navigatorId
203 <<
" No Active = " << fNoActiveNavigators <<
".";
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;
267 fNoActiveNavigators= pTransportManager-> GetNoActiveNavigators();
269 if( fNoActiveNavigators > fMaxNav )
271 std::ostringstream message;
272 message <<
"Too many active Navigators / worlds !" <<
G4endl
273 <<
" Active Navigators (worlds): "
274 << fNoActiveNavigators <<
G4endl
275 <<
" which is more than the number allowed: "
277 G4Exception(
"G4MultiNavigator::PrepareNavigators()",
"GeomNav0002",
281 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
282 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
284 fpNavigator[num] = *pNavigatorIter;
297 if( (massWorld != fLastMassWorld) && (massWorld!=0) )
302 #ifdef G4DEBUG_NAVIGATION
305 G4cout <<
" G4MultiNavigator::PrepareNavigators() changed world volume "
306 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
310 fLastMassWorld = massWorld;
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;
340 G4cout <<
" Number of active navigators: " << fNoActiveNavigators
345 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
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;
410 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
414 (*pNavIter)->LocateGlobalPointWithinVolume( position );
437 std::vector<G4Navigator*>::iterator pNavigatorIter;
438 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
440 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
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 )
509 for (
G4int num= 0; num < fNoActiveNavigators; num++ )
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 " <<
" "
568 for (
G4int num= 0; num < fNoActiveNavigators; num++ )
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;
622 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
623 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
635 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
645 if( navTrackWorld != fLastMassWorld )
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=
680 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
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=
717 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
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;
745 std::ostringstream message;
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",
769 std::ostringstream message;
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) )
804 std::ostringstream message;
805 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
806 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
815 std::ostringstream message;
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;
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
static constexpr double mm
static const G4double kInfinity
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
double dot(const Hep3Vector &) const
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
G4Navigator * GetNavigatorForTracking() const
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
#define fMinSafety_atSafLocation
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
#define fLastLocatedPosition
G4bool fWasLimitedByGeometry
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4TransportationManager * GetTransportationManager()
G4TouchableHistory * CreateTouchableHistory() const
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
virtual G4int GetCopyNo() const =0
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
#define fMinSafety_PreStepPt
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
static constexpr double perThousand
const G4NavigationHistory * GetHistory() const
G4VPhysicalVolume * GetWorldVolume() const