46 #define State(X) fpTrackState->X
47 #define fLimitedStep State(fLimitedStep)
48 #define fLimitTruth State(fLimitTruth)
49 #define fCurrentStepSize State(fCurrentStepSize)
50 #define fNewSafety State(fNewSafety)
51 #define fNoLimitingStep State(fNoLimitingStep)
52 #define fIdNavLimiting State(fIdNavLimiting)
53 #define fMinStep State(fMinStep)
54 #define fMinSafety State(fMinSafety)
55 #define fTrueMinStep State(fTrueMinStep)
56 #define fLocatedVolume State(fLocatedVolume)
57 #define fLastLocatedPosition State(fLastLocatedPosition)
58 #define fSafetyLocation State(fSafetyLocation)
59 #define fMinSafety_atSafLocation State(fMinSafety_atSafLocation)
60 #define fPreStepLocation State(fPreStepLocation)
61 #define fMinSafety_PreStepPt State(fMinSafety_PreStepPt)
62 #define fWasLimitedByGeometry State(fWasLimitedByGeometry)
69 : G4ITNavigator(), fLastMassWorld(0)
73 for(
G4int num=0; num< fMaxNav; ++num )
86 SetWorldVolume( pWorld );
107 #ifdef G4DEBUG_NAVIGATION
110 G4cout <<
" G4ITMultiNavigator::ComputeStep : entered " <<
G4endl;
111 G4cout <<
" Input position= " << pGlobalPoint
112 <<
" direction= " << pDirection <<
G4endl;
113 G4cout <<
" Requested step= " << proposedStepLength <<
G4endl;
117 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
128 step= (*pNavigatorIter)->ComputeStep( initialPosition,
132 if( safety < minSafety ){ minSafety = safety; }
133 if( step < minStep ) { minStep= step; }
139 #ifdef G4DEBUG_NAVIGATION
142 G4cout <<
"G4ITMultiNavigator::ComputeStep : Navigator ["
143 << num <<
"] -- step size " << step
144 <<
" safety= " << safety <<
G4endl;
164 #ifdef G4DEBUG_NAVIGATION
170 G4cout <<
"G4ITMultiNavigator::ComputeStep : "
171 <<
" initialPosition = " << initialPosition
172 <<
" and endPosition = " << endPosition <<
G4endl;
173 G4cout.precision( oldPrec );
177 pNewSafety = minSafety;
181 #ifdef G4DEBUG_NAVIGATION
184 G4cout <<
" G4ITMultiNavigator::ComputeStep : exits returning "
203 message <<
"Bad Navigator Id!" <<
G4endl
204 <<
" Navigator Id = " << navigatorId
206 G4Exception(
"G4ITMultiNavigator::ObtainFinalStep()",
"GeomNav0002",
216 #ifdef G4DEBUG_NAVIGATION
219 G4cout <<
" G4ITMultiNavigator::ComputeStep returns "
221 <<
" for Navigator " << navigatorId
222 <<
" Limited step = " << limitedStep
223 <<
" Safety(mm) = " << pNewSafety /
mm <<
G4endl;
235 #ifdef G4DEBUG_NAVIGATION
238 G4cout <<
" Entered G4ITMultiNavigator::PrepareNewTrack() " <<
G4endl;
259 #ifdef G4DEBUG_NAVIGATION
262 G4cout <<
" Entered G4ITMultiNavigator::PrepareNavigators() " <<
G4endl;
268 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
274 message <<
"Too many active Navigators / worlds !" <<
G4endl
275 <<
" Active Navigators (worlds): "
277 <<
" which is more than the number allowed: "
279 G4Exception(
"G4ITMultiNavigator::PrepareNavigators()",
"GeomNav0002",
304 #ifdef G4DEBUG_NAVIGATION
307 G4cout <<
" G4ITMultiNavigator::PrepareNavigators() changed world volume "
308 <<
" for mass geometry to " << massWorld->
GetName() <<
G4endl;
321 const G4bool pRelativeSearch,
322 const G4bool ignoreDirection )
327 G4bool relative = pRelativeSearch;
328 std::vector<G4ITNavigator*>::iterator pNavIter
331 if( pDirection ) { direction = *pDirection; }
333 #ifdef G4DEBUG_NAVIGATION
336 G4cout <<
" Entered G4ITMultiNavigator::LocateGlobalPointAndSetup() "
338 G4cout <<
" Locating at position: " << position
339 <<
", with direction: " << direction << G4endl
340 <<
" Relative: " << relative
341 <<
", ignore direction: " << ignoreDirection <<
G4endl;
351 (*pNavIter)->SetGeometricallyLimitedStep();
355 = (*pNavIter)->LocateGlobalPointAndSetup( position, &direction,
356 relative, ignoreDirection );
367 #ifdef G4DEBUG_NAVIGATION
370 G4cout <<
" Located in world: " << num <<
", at: " << position <<
G4endl
372 <<
", found in volume: " << pLocated <<
G4endl;
381 G4cout <<
"Null' Id: Not-Set ";
391 return volMassLocated;
401 std::vector<G4ITNavigator*>::iterator pNavIter
404 #ifdef G4DEBUG_NAVIGATION
407 G4cout <<
" Entered G4ITMultiNavigator::ReLocate() " <<
G4endl
408 <<
" Re-locating at position: " << position <<
G4endl;
416 (*pNavIter)->LocateGlobalPointWithinVolume( position );
439 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
444 safety = (*pNavigatorIter)->ComputeSafety( position, maxDistance, state);
445 if( safety < minSafety ) { minSafety = safety; }
451 #ifdef G4DEBUG_NAVIGATION
454 G4cout <<
" G4ITMultiNavigator::ComputeSafety - returns: "
455 << minSafety <<
", at location: " << position <<
G4endl;
466 G4Exception(
"G4ITMultiNavigator::CreateTouchableHistoryHandle()",
468 "Getting a touchable from G4ITMultiNavigator is not defined.");
471 touchHist=
fpNavigator[0] -> CreateTouchableHistory();
474 if( locatedVolume == 0 )
491 const G4int IdTransport= 0;
495 #ifdef G4DEBUG_NAVIGATION
498 G4cout <<
" Entered G4ITMultiNavigator::WhichLimited() " <<
G4endl;
506 if( transportLimited )
531 if( (last > -1) && (noLimited == 1 ) )
548 static const G4String StrDoNot(
"DoNot"), StrUnique(
"Unique"),
549 StrUndefined(
"Undefined"),
550 StrSharedTransport(
"SharedTransport"),
551 StrSharedOther(
"SharedOther");
552 G4cout <<
"### G4ITMultiNavigator::PrintLimited() reports: " <<
G4endl;
556 #ifdef G4DEBUG_NAVIGATION
559 G4cout << std::setw(5) <<
" NavId" <<
" "
560 << std::setw(12) <<
" step-size " <<
" "
561 << std::setw(12) <<
" raw-size " <<
" "
562 << std::setw(12) <<
" pre-safety " <<
" "
563 << std::setw(15) <<
" Limited / flag" <<
" "
564 << std::setw(15) <<
" World " <<
" "
579 G4cout << std::setw(5) << num <<
" "
580 << std::setw(12) << stepLen <<
" "
581 << std::setw(12) << rawStep <<
" "
583 << std::setw(5) << (
fLimitTruth[num] ?
"YES" :
" NO") <<
" ";
587 case kDoNot : limitedStr= StrDoNot;
break;
588 case kUnique : limitedStr = StrUnique;
break;
591 default : limitedStr = StrUndefined;
break;
593 G4cout <<
" " << std::setw(15) << limitedStr <<
" ";
594 G4cout.precision(oldPrec);
606 G4cout <<
" " << WorldName ;
618 G4Exception(
"G4ITMultiNavigator::ResetState()",
"GeomNav0001",
620 "Cannot reset state for navigators of G4ITMultiNavigator.");
622 std::vector<G4ITNavigator*>::iterator pNavigatorIter;
634 G4Exception(
"G4ITMultiNavigator::SetupHierarchy()",
636 "Cannot setup hierarchy for navigators of G4ITMultiNavigator.");
648 G4Exception(
"G4ITMultiNavigator::CheckMassWorld()",
650 "Mass world pointer has been changed." );
668 massVolume= pMassNavigator->ResetHierarchyAndLocate( point, direction,
673 G4Exception(
"G4ITMultiNavigator::ResetHierarchyAndLocate()",
675 "Cannot reset hierarchy before navigators are initialised.");
678 std::vector<G4ITNavigator*>::iterator pNavIter=
683 G4bool relativeSearch, ignoreDirection;
687 relativeSearch=
false,
688 ignoreDirection=
false);
702 G4int firstNavigatorId= -1;
703 G4bool oneObtained=
false;
709 *argpObtained= isObtained;
715 std::vector<G4ITNavigator*>::iterator pNavIter=
727 if( !isObtained && (newNormal.
mag2() != 0.0) )
729 normalGlobalCrd= newNormal;
730 isObtained = oneObtained;
731 firstNavigatorId= num;
734 G4double dotNewPrevious= newNormal.
dot( normalGlobalCrd );
736 if( productMagSq > 0.0 )
738 G4double productMag= std::sqrt( productMagSq );
739 dotNewPrevious /= productMag;
742 *argpObtained=
false;
747 message <<
"Clash of Normal from different Navigators!" <<
G4endl
748 <<
" Previous Navigator Id = " << firstNavigatorId <<
G4endl
749 <<
" Current Navigator Id = " << num <<
G4endl;
750 message <<
" Dot product of 2 normals = " << dotNewPrevious <<
G4endl;
751 message <<
" Normal (previous) = " << normalGlobalCrd <<
G4endl;
752 message <<
" Normal (current) = " << newNormal <<
G4endl;
753 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
772 <<
" candidate Navigators limiting the step!" <<
G4endl;
773 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
780 *argpObtained= isObtained;
781 return normalGlobalCrd;
798 *argpObtained= isObtained;
801 G4int noWarningsStart= 10, noModuloWarnings=100;
803 if( (numberWarnings < noWarningsStart ) || (numberWarnings%noModuloWarnings==0) )
806 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
807 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
817 message <<
"Cannot obtain normal in local coordinates of two or more coordinate systems." <<
G4endl;
818 G4Exception(
"G4ITMultiNavigator::GetGlobalExitNormal()",
"GeomNav0002",
823 *argpObtained= isObtained;
824 return normalGlobalCrd;
G4double ObtainFinalStep(G4int navigatorId, G4double &pNewSafety, G4double &minStepLast, ELimited &limitedStep)
std::vector< G4ITNavigator * >::iterator GetActiveNavigatorsIterator()
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
void PrepareNewTrack(const G4ThreeVector position, const G4ThreeVector direction)
static G4ITTransportationManager * GetTransportationManager()
static const G4double kInfinity
virtual G4ThreeVector GetGlobalExitNormal(const G4ThreeVector &CurrentE_Point, G4bool *obtained)
static constexpr double mm
virtual G4ThreeVector GetLocalExitNormal(G4bool *obtained)
void message(RunManager *runmanager)
#define fMinSafety_atSafLocation
double dot(const Hep3Vector &) const
void UpdateYourself(G4VPhysicalVolume *pPhysVol, const G4NavigationHistory *history=0)
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4int fNoActiveNavigators
const G4NavigationHistory * GetHistory() const
G4VPhysicalVolume * ResetHierarchyAndLocate(const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
#define fMinSafety_PreStepPt
virtual G4int GetCopyNo() const =0
G4ITNavigator * GetNavigatorForTracking() const
#define fLastLocatedPosition
G4TouchableHistoryHandle CreateTouchableHistoryHandle() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
G4VPhysicalVolume * fLastMassWorld
G4GLOB_DLL std::ostream G4cout
#define fWasLimitedByGeometry
void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4ITTransportationManager * pTransportManager
static constexpr double perThousand
const G4String & GetName() const
G4ITNavigator * fpNavigator[fMaxNav]