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)
70 fNoActiveNavigators= 0;
72 for(
G4int num=0; num< fMaxNav; ++num )
85 SetWorldVolume( pWorld );
86 fLastMassWorld = pWorld;
101 G4double minSafety= kInfinity, minStep= kInfinity;
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;
118 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
123 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
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 "
199 if( navigatorId > fNoActiveNavigators )
201 std::ostringstream message;
202 message <<
"Bad Navigator Id!" <<
G4endl
203 <<
" Navigator Id = " << navigatorId
204 <<
" No Active = " << fNoActiveNavigators <<
".";
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;
268 fNoActiveNavigators= pTransportManager-> GetNoActiveNavigators();
270 if( fNoActiveNavigators > fMaxNav )
272 std::ostringstream message;
273 message <<
"Too many active Navigators / worlds !" <<
G4endl
274 <<
" Active Navigators (worlds): "
275 << fNoActiveNavigators <<
G4endl
276 <<
" which is more than the number allowed: "
278 G4Exception(
"G4ITMultiNavigator::PrepareNavigators()",
"GeomNav0002",
282 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
283 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
285 fpNavigator[num] = *pNavigatorIter;
298 if( (massWorld != fLastMassWorld) && (massWorld!=0) )
301 fpNavigator[0] -> SetWorldVolume( massWorld );
303#ifdef G4DEBUG_NAVIGATION
306 G4cout <<
" G4ITMultiNavigator::PrepareNavigators() changed world volume "
307 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
311 fLastMassWorld = massWorld;
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() "
338 <<
", with direction: " << direction <<
G4endl
339 <<
" Relative: " << relative
340 <<
", ignore direction: " << ignoreDirection <<
G4endl;
341 G4cout <<
" Number of active navigators: " << fNoActiveNavigators
346 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
350 (*pNavIter)->SetGeometricallyLimitedStep();
354 = (*pNavIter)->LocateGlobalPointAndSetup(
position, &direction,
355 relative, ignoreDirection );
366#ifdef G4DEBUG_NAVIGATION
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
411 for (
G4int num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
415 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
436 G4double minSafety = kInfinity, safety = kInfinity;
438 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
439 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
441 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
443 safety = (*pNavigatorIter)->ComputeSafety(
position, maxDistance, state);
444 if( safety < minSafety ) { minSafety = safety; }
450#ifdef G4DEBUG_NAVIGATION
453 G4cout <<
" G4ITMultiNavigator::ComputeSafety - returns: "
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 )
510 for (
G4int num= 0; num < fNoActiveNavigators; num++ )
516 limitedStep = ( step ==
fMinStep ) && ( step != kInfinity);
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 " <<
" "
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);
595 G4ITNavigator *pNav= fpNavigator[ num ];
605 G4cout <<
" " << WorldName ;
617 G4Exception(
"G4ITMultiNavigator::ResetState()",
"GeomNav0001",
619 "Cannot reset state for navigators of G4ITMultiNavigator.");
621 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
622 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
623 for(
G4int num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
633 G4Exception(
"G4ITMultiNavigator::SetupHierarchy()",
635 "Cannot setup hierarchy for navigators of G4ITMultiNavigator.");
645 if( navTrackWorld != fLastMassWorld )
647 G4Exception(
"G4ITMultiNavigator::CheckMassWorld()",
649 "Mass world pointer has been changed." );
663 G4ITNavigator* pMassNavigator= fpNavigator[0];
667 massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
672 G4Exception(
"G4ITMultiNavigator::ResetHierarchyAndLocate()",
674 "Cannot reset hierarchy before navigators are initialised.");
677 std::vector<G4ITNavigator*>::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;
707 normalGlobalCrd= fpNavigator[
fIdNavLimiting ]->GetGlobalExitNormal( argPoint, &isObtained);
708 *argpObtained= isObtained;
714 std::vector<G4ITNavigator*>::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;
739 if( dotNewPrevious < (1 - perThousand) )
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(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
769 std::ostringstream message;
771 <<
" candidate Navigators limiting the step!" <<
G4endl;
772 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
779 *argpObtained= isObtained;
780 return normalGlobalCrd;
796 normalGlobalCrd= fpNavigator[
fIdNavLimiting ]->GetLocalExitNormal( &isObtained);
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(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
815 std::ostringstream message;
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;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define fWasLimitedByGeometry
#define fMinSafety_atSafLocation
#define fLastLocatedPosition
#define fMinSafety_PreStepPt
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
std::vector< G4ITNavigator * >::iterator GetActiveNavigatorsIterator()
static G4ITTransportationManager * GetTransportationManager()
G4ITNavigator * GetNavigatorForTracking() const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
const G4NavigationHistory * GetHistory() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const