51 for(
auto num=0; num< fMaxNav; ++num )
53 fpNavigator[num] =
nullptr;
63 if( massNav !=
nullptr )
66 if( pWorld !=
nullptr )
69 fLastMassWorld = pWorld;
86 G4double minSafety= kInfinity, minStep= kInfinity;
91#ifdef G4DEBUG_NAVIGATION
94 G4cout <<
" G4MultiNavigator::ComputeStep : entered " <<
G4endl;
95 G4cout <<
" Input position= " << pGlobalPoint
96 <<
" direction= " << pDirection <<
G4endl;
97 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
101 std::vector<G4Navigator*>::iterator pNavigatorIter;
103 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
108 for(
auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
112 step= (*pNavigatorIter)->ComputeStep( initialPosition,
116 if( safety < minSafety ){ minSafety = safety; }
117 if( step < minStep ) { minStep= step; }
123#ifdef G4DEBUG_NAVIGATION
126 G4cout <<
"G4MultiNavigator::ComputeStep : Navigator ["
127 << num <<
"] -- step size " << step
128 <<
" safety= " << safety <<
G4endl;
148#ifdef G4DEBUG_NAVIGATION
154 G4cout <<
"G4MultiNavigator::ComputeStep : "
155 <<
" initialPosition = " << initialPosition
156 <<
" and endPosition = " << endPosition <<
G4endl;
157 G4cout.precision( oldPrec );
161 pNewSafety = minSafety;
165#ifdef G4DEBUG_NAVIGATION
168 G4cout <<
" G4MultiNavigator::ComputeStep : exits returning "
184 if( navigatorId > fNoActiveNavigators )
186 std::ostringstream message;
187 message <<
"Bad Navigator Id!" <<
G4endl
188 <<
" Navigator Id = " << navigatorId
189 <<
" No Active = " << fNoActiveNavigators <<
".";
190 G4Exception(
"G4MultiNavigator::ObtainFinalStep()",
"GeomNav0002",
200#ifdef G4DEBUG_NAVIGATION
203 G4cout <<
" G4MultiNavigator::ComputeStep returns "
205 <<
" for Navigator " << navigatorId
206 <<
" Limited step = " << limitedStep
207 <<
" Safety(mm) = " << pNewSafety / mm <<
G4endl;
219#ifdef G4DEBUG_NAVIGATION
222 G4cout <<
" Entered G4MultiNavigator::PrepareNewTrack() " <<
G4endl;
243#ifdef G4DEBUG_NAVIGATION
246 G4cout <<
" Entered G4MultiNavigator::PrepareNavigators() " <<
G4endl;
252 std::vector<G4Navigator*>::const_iterator pNavigatorIter;
253 fNoActiveNavigators = (
G4int)pTransportManager-> GetNoActiveNavigators();
255 if( fNoActiveNavigators > fMaxNav )
257 std::ostringstream message;
258 message <<
"Too many active Navigators / worlds !" <<
G4endl
259 <<
" Active Navigators (worlds): "
260 << fNoActiveNavigators <<
G4endl
261 <<
" which is more than the number allowed: "
263 G4Exception(
"G4MultiNavigator::PrepareNavigators()",
"GeomNav0002",
268 for(
auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
270 fpNavigator[num] = *pNavigatorIter;
283 if( (massWorld != fLastMassWorld) && (massWorld!=
nullptr) )
288#ifdef G4DEBUG_NAVIGATION
291 G4cout <<
" G4MultiNavigator::PrepareNavigators() changed world volume "
292 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
296 fLastMassWorld = massWorld;
305 const G4bool pRelativeSearch,
306 const G4bool ignoreDirection )
311 G4bool relative = pRelativeSearch;
314 if( pDirection !=
nullptr ) { direction = *pDirection; }
316#ifdef G4DEBUG_NAVIGATION
319 G4cout <<
" Entered G4MultiNavigator::LocateGlobalPointAndSetup() "
322 <<
", with direction: " << direction <<
G4endl
323 <<
" Relative: " << relative
324 <<
", ignore direction: " << ignoreDirection <<
G4endl;
325 G4cout <<
" Number of active navigators: " << fNoActiveNavigators
330 for (
auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
334 (*pNavIter)->SetGeometricallyLimitedStep();
338 = (*pNavIter)->LocateGlobalPointAndSetup(
position, &direction,
339 relative, ignoreDirection );
350#ifdef G4DEBUG_NAVIGATION
355 <<
", found in volume: " << pLocated <<
G4endl;
364 G4cout <<
"Null' Id: Not-Set ";
374 return volMassLocated;
386#ifdef G4DEBUG_NAVIGATION
389 G4cout <<
" Entered G4MultiNavigator::ReLocate() " <<
G4endl
394 for (
auto num=0; num< fNoActiveNavigators ; ++pNavIter,++num )
398 (*pNavIter)->LocateGlobalPointWithinVolume(
position );
419 G4double minSafety = kInfinity, safety = kInfinity;
421 std::vector<G4Navigator*>::iterator pNavigatorIter;
422 pNavigatorIter= pTransportManager-> GetActiveNavigatorsIterator();
424 for(
auto num=0; num< fNoActiveNavigators; ++pNavigatorIter,++num )
426 safety = (*pNavigatorIter)->ComputeSafety(
position, maxDistance, state);
427 if( safety < minSafety ) { minSafety = safety; }
433#ifdef G4DEBUG_NAVIGATION
436 G4cout <<
" G4MultiNavigator::ComputeSafety - returns: "
447 G4Exception(
"G4MultiNavigator::CreateTouchableHistoryHandle()",
449 "Getting a touchable from G4MultiNavigator is not defined.");
455 if( locatedVolume ==
nullptr )
472 const G4int IdTransport= 0;
476#ifdef G4DEBUG_NAVIGATION
479 G4cout <<
" Entered G4MultiNavigator::WhichLimited() " <<
G4endl;
487 if( transportLimited )
492 for (
auto num = 0; num < fNoActiveNavigators; ++num )
498 limitedStep = ( step ==
fMinStep ) && ( step != kInfinity);
512 if( (last > -1) && (noLimited == 1 ) )
530 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
531 StrUndefined(
"Undefined"),
532 StrSharedTransport(
"SharedTransport"),
533 StrSharedOther(
"SharedOther");
534 G4cout <<
"### G4MultiNavigator::PrintLimited() reports: " <<
G4endl;
538#ifdef G4DEBUG_NAVIGATION
541 G4cout << std::setw(5) <<
" NavId" <<
" "
542 << std::setw(12) <<
" step-size " <<
" "
543 << std::setw(12) <<
" raw-size " <<
" "
544 << std::setw(12) <<
" pre-safety " <<
" "
545 << std::setw(15) <<
" Limited / flag" <<
" "
546 << std::setw(15) <<
" World " <<
" "
551 for (
auto num = 0; num < fNoActiveNavigators; ++num )
561 G4cout << std::setw(5) << num <<
" "
562 << std::setw(12) << stepLen <<
" "
563 << std::setw(12) << rawStep <<
" "
565 << std::setw(5) << (
fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
569 case kDoNot : limitedStr = StrDoNot;
break;
570 case kUnique : limitedStr = StrUnique;
break;
573 default : limitedStr = StrUndefined;
break;
575 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
576 G4cout.precision(oldPrec);
583 if( pWorld !=
nullptr )
588 G4cout <<
" " << WorldName ;
600 G4Exception(
"G4MultiNavigator::ResetState()",
"GeomNav0001",
602 "Cannot reset state for navigators of G4MultiNavigator.");
619 "Cannot setup hierarchy for navigators of G4MultiNavigator.");
629 if( navTrackWorld != fLastMassWorld )
633 "Mass world pointer has been changed." );
649 if( pMassNavigator !=
nullptr )
656 G4Exception(
"G4MultiNavigator::ResetHierarchyAndLocate()",
658 "Cannot reset hierarchy before navigators are initialised.");
663 for (
auto num = 0; num < fNoActiveNavigators ; ++pNavIter,++num )
665 G4bool relativeSearch, ignoreDirection;
669 relativeSearch=
false,
670 ignoreDirection=
false);
682 G4bool isObtained =
false;
684 G4int firstNavigatorId = -1;
685 G4bool oneObtained =
false;
692 *argpObtained = isObtained;
700 for (
auto num = 0; num < fNoActiveNavigators ; ++pNavIter, ++num )
706 (*pNavIter)->GetGlobalExitNormal( argPoint, &oneObtained );
710 if( !isObtained && (newNormal.
mag2() != 0.0) )
712 normalGlobalCrd = newNormal;
713 isObtained = oneObtained;
714 firstNavigatorId = num;
719 G4double dotNewPrevious = newNormal.
dot( normalGlobalCrd );
721 if( productMagSq > 0.0 )
723 G4double productMag = std::sqrt( productMagSq );
724 dotNewPrevious /= productMag;
725 if( dotNewPrevious < (1 - perThousand) )
727 *argpObtained =
false;
731 std::ostringstream message;
732 message <<
"Clash of Normal from different Navigators!"
734 <<
" Previous Navigator Id = "
735 << firstNavigatorId <<
G4endl
736 <<
" Current Navigator Id = "
738 message <<
" Dot product of 2 normals = "
739 << dotNewPrevious <<
G4endl;
740 message <<
" Normal (previous) = "
741 << normalGlobalCrd <<
G4endl;
742 message <<
" Normal (current) = " << newNormal <<
G4endl;
743 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
760 std::ostringstream message;
762 <<
" candidate Navigators limiting the step!" <<
G4endl;
763 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
770 *argpObtained = isObtained;
771 return normalGlobalCrd;
781 G4bool isObtained =
false;
789 *argpObtained = isObtained;
792 G4int noWarningsStart = 10, noModuloWarnings = 100;
794 if( (numberWarnings < noWarningsStart )
795 || (numberWarnings%noModuloWarnings == 0) )
797 std::ostringstream message;
798 message <<
"Cannot obtain normal in local coordinates of two or more "
799 <<
"coordinate systems." <<
G4endl;
800 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
808 std::ostringstream message;
809 message <<
"Cannot obtain normal in local coordinates of two or more "
810 <<
"coordinate systems." <<
G4endl;
811 G4Exception(
"G4MultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
816 *argpObtained = isObtained;
817 return normalGlobalCrd;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
#define fMinSafety_atSafLocation
#define fLastLocatedPosition
#define fMinSafety_PreStepPt
G4GLOB_DLL std::ostream G4cout
double dot(const Hep3Vector &) const
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=nullptr, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true) override
~G4MultiNavigator() override
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
void ResetState() override
void SetupHierarchy() override
void LocateGlobalPointWithinVolume(const G4ThreeVector &position) override
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false) override
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety) override
G4ThreeVector GetLocalExitNormal(G4bool *obtained) override
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector direction)
G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &E_Pt, G4bool *obtained) override
G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &E_Pt, G4bool *obtained) override
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h) override
G4TouchableHandle CreateTouchableHistoryHandle() const override
G4TouchableHistory * CreateTouchableHistory() const
G4bool fWasLimitedByGeometry
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &point, G4bool *valid)
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
void SetWorldVolume(G4VPhysicalVolume *pWorld)
virtual G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4VPhysicalVolume * GetWorldVolume() const
virtual const G4NavigationHistory * GetHistory() const
virtual void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=nullptr)
std::vector< G4Navigator * >::iterator GetActiveNavigatorsIterator()
static G4TransportationManager * GetTransportationManager()
G4Navigator * GetNavigatorForTracking() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const