92 #ifdef G4DEBUG_NAVIGATION
95 G4cout <<
" G4MultiNavigator::ComputeStep : entered " <<
G4endl;
96 G4cout <<
" Input position= " << pGlobalPoint
97 <<
" direction= " << pDirection <<
G4endl;
98 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
102 std::vector<G4Navigator*>::iterator pNavigatorIter;
113 step= (*pNavigatorIter)->ComputeStep( initialPosition,
117 if( safety < minSafety ){ minSafety = safety; }
118 if(
step < minStep ) { minStep=
step; }
124 #ifdef G4DEBUG_NAVIGATION
127 G4cout <<
"G4MultiNavigator::ComputeStep : Navigator ["
128 <<
num <<
"] -- step size " <<
step
129 <<
" safety= " << safety <<
G4endl;
149 #ifdef G4DEBUG_NAVIGATION
155 G4cout <<
"G4MultiNavigator::ComputeStep : "
156 <<
" initialPosition = " << initialPosition
157 <<
" and endPosition = " << endPosition <<
G4endl;
158 G4cout.precision( oldPrec );
162 pNewSafety = minSafety;
166 #ifdef G4DEBUG_NAVIGATION
169 G4cout <<
" G4MultiNavigator::ComputeStep : exits returning "
188 message <<
"Bad Navigator Id!" <<
G4endl
189 <<
" Navigator Id = " << navigatorId
191 G4Exception(
"G4MultiNavigator::ObtainFinalStep()",
"GeomNav0002",
201 #ifdef G4DEBUG_NAVIGATION
204 G4cout <<
" G4MultiNavigator::ComputeStep returns "
206 <<
" for Navigator " << navigatorId
207 <<
" Limited step = " << limitedStep
208 <<
" Safety(mm) = " << pNewSafety /
mm <<
G4endl;
220 #ifdef G4DEBUG_NAVIGATION
223 G4cout <<
" Entered G4MultiNavigator::PrepareNewTrack() " <<
G4endl;
244 #ifdef G4DEBUG_NAVIGATION
247 G4cout <<
" Entered G4MultiNavigator::PrepareNavigators() " <<
G4endl;
253 std::vector<G4Navigator*>::iterator pNavigatorIter;
259 message <<
"Too many active Navigators / worlds !" <<
G4endl
260 <<
" Active Navigators (worlds): "
262 <<
" which is more than the number allowed: "
264 G4Exception(
"G4MultiNavigator::PrepareNavigators()",
"GeomNav0002",
289 #ifdef G4DEBUG_NAVIGATION
292 G4cout <<
" G4MultiNavigator::PrepareNavigators() changed world volume "
293 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
306 const G4bool pRelativeSearch,
307 const G4bool ignoreDirection )
312 G4bool relative = pRelativeSearch;
313 std::vector<G4Navigator*>::iterator pNavIter
316 if( pDirection ) { direction = *pDirection; }
318 #ifdef G4DEBUG_NAVIGATION
321 G4cout <<
" Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
323 G4cout <<
" Locating at position: " << position
324 <<
", with direction: " << direction << G4endl
325 <<
" Relative: " << relative
326 <<
", ignore direction: " << ignoreDirection <<
G4endl;
336 (*pNavIter)->SetGeometricallyLimitedStep();
340 = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
341 relative, ignoreDirection );
352 #ifdef G4DEBUG_NAVIGATION
355 G4cout <<
" Located in world: " << num <<
", at: " << position <<
G4endl
357 <<
", found in volume: " << pLocated <<
G4endl;
366 G4cout <<
"Null' Id: Not-Set ";
376 return volMassLocated;
386 std::vector<G4Navigator*>::iterator pNavIter
389 #ifdef G4DEBUG_NAVIGATION
392 G4cout <<
" Entered G4MultiNavigator::ReLocate() " <<
G4endl
393 <<
" Re-locating at position: " << position <<
G4endl;
401 (*pNavIter)->LocateGlobalPointWithinVolume( position );
424 std::vector<G4Navigator*>::iterator pNavigatorIter;
429 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
430 if( safety < minSafety ) { minSafety = safety; }
436 #ifdef G4DEBUG_NAVIGATION
439 G4cout <<
" G4MultiNavigator::ComputeSafety - returns: "
440 << minSafety <<
", at location: " << position <<
G4endl;
451 G4Exception(
"G4MultiNavigator::CreateTouchableHistoryHandle()",
453 "Getting a touchable from G4MultiNavigator is not defined.");
459 if( locatedVolume ==
nullptr )
476 const G4int IdTransport= 0;
480 #ifdef G4DEBUG_NAVIGATION
483 G4cout <<
" Entered G4MultiNavigator::WhichLimited() " <<
G4endl;
491 if( transportLimited )
516 if( (last > -1) && (noLimited == 1 ) )
534 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
535 StrUndefined(
"Undefined"),
536 StrSharedTransport(
"SharedTransport"),
537 StrSharedOther(
"SharedOther");
538 G4cout <<
"### G4MultiNavigator::PrintLimited() reports: " <<
G4endl;
542 #ifdef G4DEBUG_NAVIGATION
545 G4cout << std::setw(5) <<
" NavId" <<
" "
546 << std::setw(12) <<
" step-size " <<
" "
547 << std::setw(12) <<
" raw-size " <<
" "
548 << std::setw(12) <<
" pre-safety " <<
" "
549 << std::setw(15) <<
" Limited / flag" <<
" "
550 << std::setw(15) <<
" World " <<
" "
566 << std::setw(12) << stepLen <<
" "
567 << std::setw(12) << rawStep <<
" "
573 case kDoNot : limitedStr = StrDoNot;
break;
574 case kUnique : limitedStr = StrUnique;
break;
577 default : limitedStr = StrUndefined;
break;
579 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
580 G4cout.precision(oldPrec);
592 G4cout <<
" " << WorldName ;
604 G4Exception(
"G4MultiNavigator::ResetState()",
"GeomNav0001",
606 "Cannot reset state for navigators of G4MultiNavigator.");
623 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
637 "Mass world pointer has been changed." );
653 if( pMassNavigator !=
nullptr )
660 G4Exception(
"G4MultiNavigator::ResetHierarchyAndLocate()",
662 "Cannot reset hierarchy before navigators are initialised.");
665 std::vector<G4Navigator*>::iterator pNavIter=
670 G4bool relativeSearch, ignoreDirection;
674 relativeSearch=
false,
675 ignoreDirection=
false);
687 G4bool isObtained =
false;
689 G4int firstNavigatorId = -1;
690 G4bool oneObtained =
false;
697 *argpObtained = isObtained;
703 std::vector<G4Navigator*>::iterator pNavIter=
712 (*pNavIter)->GetGlobalExitNormal( argPoint, &oneObtained );
716 if( !isObtained && (newNormal.
mag2() != 0.0) )
718 normalGlobalCrd = newNormal;
719 isObtained = oneObtained;
720 firstNavigatorId =
num;
725 G4double dotNewPrevious = newNormal.
dot( normalGlobalCrd );
727 if( productMagSq > 0.0 )
729 G4double productMag = std::sqrt( productMagSq );
730 dotNewPrevious /= productMag;
733 *argpObtained =
false;
738 message <<
"Clash of Normal from different Navigators!"
740 <<
" Previous Navigator Id = "
741 << firstNavigatorId <<
G4endl
742 <<
" Current Navigator Id = "
744 message <<
" Dot product of 2 normals = "
745 << dotNewPrevious <<
G4endl;
746 message <<
" Normal (previous) = "
747 << normalGlobalCrd <<
G4endl;
748 message <<
" Normal (current) = " << newNormal <<
G4endl;
749 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
768 <<
" candidate Navigators limiting the step!" <<
G4endl;
769 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
776 *argpObtained = isObtained;
777 return normalGlobalCrd;
787 G4bool isObtained =
false;
795 *argpObtained = isObtained;
798 G4int noWarningsStart = 10, noModuloWarnings = 100;
800 if( (numberWarnings < noWarningsStart )
801 || (numberWarnings%noModuloWarnings == 0) )
804 message <<
"Cannot obtain normal in local coordinates of two or more "
805 <<
"coordinate systems." <<
G4endl;
806 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
815 message <<
"Cannot obtain normal in local coordinates of two or more "
816 <<
"coordinate systems." <<
G4endl;
817 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
822 *argpObtained = isObtained;
823 return normalGlobalCrd;