45 #define State(X) fpTrackState->X
46 #define fLimitedStep State(fLimitedStep)
47 #define fLimitTruth State(fLimitTruth)
48 #define fCurrentStepSize State(fCurrentStepSize)
49 #define fNewSafety State(fNewSafety)
50 #define fNoLimitingStep State(fNoLimitingStep)
51 #define fIdNavLimiting State(fIdNavLimiting)
52 #define fMinStep State(fMinStep)
53 #define fMinSafety State(fMinSafety)
54 #define fTrueMinStep State(fTrueMinStep)
55 #define fLocatedVolume State(fLocatedVolume)
56 #define fLastLocatedPosition State(fLastLocatedPosition)
57 #define fSafetyLocation State(fSafetyLocation)
58 #define fMinSafety_atSafLocation State(fMinSafety_atSafLocation)
59 #define fPreStepLocation State(fPreStepLocation)
60 #define fMinSafety_PreStepPt State(fMinSafety_PreStepPt)
61 #define fWasLimitedByGeometry State(fWasLimitedByGeometry)
68 : G4ITNavigator(), fLastMassWorld(0)
85 SetWorldVolume( pWorld );
106 #ifdef G4DEBUG_NAVIGATION
109 G4cout <<
" G4ITMultiNavigator::ComputeStep : entered " <<
G4endl;
110 G4cout <<
" Input position= " << pGlobalPoint
111 <<
" direction= " << pDirection <<
G4endl;
112 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
116 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
127 step= (*pNavigatorIter)->ComputeStep( initialPosition,
131 if( safety < minSafety ){ minSafety = safety; }
132 if(
step < minStep ) { minStep=
step; }
138 #ifdef G4DEBUG_NAVIGATION
141 G4cout <<
"G4ITMultiNavigator::ComputeStep : Navigator ["
142 <<
num <<
"] -- step size " <<
step
143 <<
" safety= " << safety <<
G4endl;
163 #ifdef G4DEBUG_NAVIGATION
169 G4cout <<
"G4ITMultiNavigator::ComputeStep : "
170 <<
" initialPosition = " << initialPosition
171 <<
" and endPosition = " << endPosition <<
G4endl;
172 G4cout.precision( oldPrec );
176 pNewSafety = minSafety;
180 #ifdef G4DEBUG_NAVIGATION
183 G4cout <<
" G4ITMultiNavigator::ComputeStep : exits returning "
202 message <<
"Bad Navigator Id!" <<
G4endl
203 <<
" Navigator Id = " << navigatorId
205 G4Exception(
"G4ITMultiNavigator::ObtainFinalStep()",
"GeomNav0002",
215 #ifdef G4DEBUG_NAVIGATION
218 G4cout <<
" G4ITMultiNavigator::ComputeStep returns "
220 <<
" for Navigator " << navigatorId
221 <<
" Limited step = " << limitedStep
222 <<
" Safety(mm) = " << pNewSafety /
mm <<
G4endl;
234 #ifdef G4DEBUG_NAVIGATION
237 G4cout <<
" Entered G4ITMultiNavigator::PrepareNewTrack() " <<
G4endl;
258 #ifdef G4DEBUG_NAVIGATION
261 G4cout <<
" Entered G4ITMultiNavigator::PrepareNavigators() " <<
G4endl;
267 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
273 message <<
"Too many active Navigators / worlds !" <<
G4endl
274 <<
" Active Navigators (worlds): "
276 <<
" which is more than the number allowed: "
278 G4Exception(
"G4ITMultiNavigator::PrepareNavigators()",
"GeomNav0002",
303 #ifdef G4DEBUG_NAVIGATION
306 G4cout <<
" G4ITMultiNavigator::PrepareNavigators() changed world volume "
307 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
320 const G4bool pRelativeSearch,
321 const G4bool ignoreDirection )
326 G4bool relative = pRelativeSearch;
327 std::vector<G4ITNavigator*>::iterator pNavIter
330 if( pDirection ) { direction = *pDirection; }
332 #ifdef G4DEBUG_NAVIGATION
335 G4cout <<
" Entered G4ITMultiNavigator::LocateGlobalPointAndSetup() "
337 G4cout <<
" Locating at position: " << position
338 <<
", with direction: " << direction << G4endl
339 <<
" Relative: " << relative
340 <<
", ignore direction: " << ignoreDirection <<
G4endl;
350 (*pNavIter)->SetGeometricallyLimitedStep();
354 = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
355 relative, ignoreDirection );
366 #ifdef G4DEBUG_NAVIGATION
369 G4cout <<
" Located in world: " << num <<
", at: " << position <<
G4endl
371 <<
", found in volume: " << pLocated <<
G4endl;
380 G4cout <<
"Null' Id: Not-Set ";
390 return volMassLocated;
400 std::vector<G4ITNavigator*>::iterator pNavIter
403 #ifdef G4DEBUG_NAVIGATION
406 G4cout <<
" Entered G4ITMultiNavigator::ReLocate() " <<
G4endl
407 <<
" Re-locating at position: " << position <<
G4endl;
415 (*pNavIter)->LocateGlobalPointWithinVolume( position );
438 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
443 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
444 if( safety < minSafety ) { minSafety = safety; }
450 #ifdef G4DEBUG_NAVIGATION
453 G4cout <<
" G4ITMultiNavigator::ComputeSafety - returns: "
454 << minSafety <<
", at location: " << position <<
G4endl;
465 G4Exception(
"G4ITMultiNavigator::CreateTouchableHistoryHandle()",
467 "Getting a touchable from G4ITMultiNavigator is not defined.");
470 touchHist=
fpNavigator[0] -> CreateTouchableHistory();
473 if( locatedVolume == 0 )
490 const G4int IdTransport= 0;
494 #ifdef G4DEBUG_NAVIGATION
497 G4cout <<
" Entered G4ITMultiNavigator::WhichLimited() " <<
G4endl;
505 if( transportLimited )
530 if( (last > -1) && (noLimited == 1 ) )
547 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
548 StrUndefined(
"Undefined"),
549 StrSharedTransport(
"SharedTransport"),
550 StrSharedOther(
"SharedOther");
551 G4cout <<
"### G4ITMultiNavigator::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 " <<
" "
579 << std::setw(12) << stepLen <<
" "
580 << std::setw(12) << rawStep <<
" "
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(
"G4ITMultiNavigator::ResetState()",
"GeomNav0001",
619 "Cannot reset state for navigators of G4ITMultiNavigator.");
621 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
633 G4Exception(
"G4ITMultiNavigator::SetupHierarchy()",
635 "Cannot setup hierarchy for navigators of G4ITMultiNavigator.");
647 G4Exception(
"G4ITMultiNavigator::CheckMassWorld()",
649 "Mass world pointer has been changed." );
667 massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
672 G4Exception(
"G4ITMultiNavigator::ResetHierarchyAndLocate()",
674 "Cannot reset hierarchy before navigators are initialised.");
677 std::vector<G4ITNavigator*>::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<G4ITNavigator*>::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(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
771 <<
" candidate Navigators limiting the step!" <<
G4endl;
772 G4Exception(
"G4ITMultiNavigator::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(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
816 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
817 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
822 *argpObtained= isObtained;
823 return normalGlobalCrd;