Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Structures | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
G4ITNavigator Class Reference

#include <G4ITNavigator.hh>

Public Member Functions

 G4ITNavigator ()
 
virtual ~G4ITNavigator ()
 
G4ITNavigatorState_LockGetNavigatorState ()
 
void SetNavigatorState (G4ITNavigatorState_Lock *)
 
void NewNavigatorState ()
 
virtual G4double ComputeStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
G4double CheckNextStep (const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
 
virtual G4VPhysicalVolumeResetHierarchyAndLocate (const G4ThreeVector &point, const G4ThreeVector &direction, const G4TouchableHistory &h)
 
virtual G4VPhysicalVolumeLocateGlobalPointAndSetup (const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
 
virtual void LocateGlobalPointWithinVolume (const G4ThreeVector &position)
 
void LocateGlobalPointAndUpdateTouchableHandle (const G4ThreeVector &position, const G4ThreeVector &direction, G4TouchableHandle &oldTouchableToUpdate, const G4bool RelativeSearch=true)
 
void LocateGlobalPointAndUpdateTouchable (const G4ThreeVector &position, const G4ThreeVector &direction, G4VTouchable *touchableToUpdate, const G4bool RelativeSearch=true)
 
void LocateGlobalPointAndUpdateTouchable (const G4ThreeVector &position, G4VTouchable *touchableToUpdate, const G4bool RelativeSearch=true)
 
void SetGeometricallyLimitedStep ()
 
virtual G4double ComputeSafety (const G4ThreeVector &globalpoint, const G4double pProposedMaxLength=DBL_MAX, const G4bool keepState=false)
 
G4VPhysicalVolumeGetWorldVolume () const
 
void SetWorldVolume (G4VPhysicalVolume *pWorld)
 
G4GRSVolumeCreateGRSVolume () const
 
G4GRSSolidCreateGRSSolid () const
 
G4TouchableHistoryCreateTouchableHistory () const
 
G4TouchableHistoryCreateTouchableHistory (const G4NavigationHistory *) const
 
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle () const
 
virtual G4ThreeVector GetLocalExitNormal (G4bool *valid)
 
virtual G4ThreeVector GetLocalExitNormalAndCheck (const G4ThreeVector &point, G4bool *valid)
 
virtual G4ThreeVector GetGlobalExitNormal (const G4ThreeVector &point, G4bool *valid)
 
G4int GetVerboseLevel () const
 
void SetVerboseLevel (G4int level)
 
G4bool IsActive () const
 
void Activate (G4bool flag)
 
G4bool EnteredDaughterVolume () const
 
G4bool ExitedMotherVolume () const
 
void CheckMode (G4bool mode)
 
G4bool IsCheckModeActive () const
 
void SetPushVerbosity (G4bool mode)
 
void PrintState () const
 
const G4AffineTransformGetGlobalToLocalTransform () const
 
const G4AffineTransform GetLocalToGlobalTransform () const
 
G4AffineTransform GetMotherToDaughterTransform (G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
 
void ResetStackAndState ()
 
G4int SeverityOfZeroStepping (G4int *noZeroSteps) const
 
void SetSavedState ()
 
void RestoreSavedState ()
 
G4ThreeVector GetCurrentLocalCoordinate () const
 
G4ThreeVector NetTranslation () const
 
G4RotationMatrix NetRotation () const
 
void EnableBestSafety (G4bool value=false)
 

Protected Member Functions

G4ThreeVector ComputeLocalPoint (const G4ThreeVector &rGlobPoint) const
 
G4ThreeVector ComputeLocalAxis (const G4ThreeVector &pVec) const
 
virtual void ResetState ()
 
EVolume VolumeType (const G4VPhysicalVolume *pVol) const
 
EVolume CharacteriseDaughters (const G4LogicalVolume *pLog) const
 
G4int GetDaughtersRegularStructureId (const G4LogicalVolume *pLog) const
 
virtual void SetupHierarchy ()
 

Protected Attributes

G4double kCarTolerance
 
G4NavigationHistory fHistory
 
G4bool fEnteredDaughter
 
G4bool fExitedMother
 
G4bool fWasLimitedByGeometry
 
G4ThreeVector fStepEndPoint
 
G4ThreeVector fLastStepEndPointLocal
 
G4int fVerbose
 

Friends

std::ostream & operator<< (std::ostream &os, const G4ITNavigator &n)
 

Detailed Description

Definition at line 90 of file G4ITNavigator.hh.

Constructor & Destructor Documentation

G4ITNavigator::G4ITNavigator ( )

Definition at line 58 of file G4ITNavigator.cc.

References fLastStepEndPointLocal, fStepEndPoint, G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), kCarTolerance, ResetStackAndState(), and G4RegularNavigation::SetNormalNavigation().

59  : fWasLimitedByGeometry(false), fVerbose(0),
60  fTopPhysical(0), fCheck(false), fPushed(false), fWarnPush(true)
61 {
62  fActive= false;
63  fLastTriedStepComputation= false;
65 
66  fActionThreshold_NoZeroSteps = 10;
67  fAbandonThreshold_NoZeroSteps = 25;
68 
70  fregularNav.SetNormalNavigation( &fnormalNav );
71 
72  fStepEndPoint = G4ThreeVector( kInfinity, kInfinity, kInfinity );
73  fLastStepEndPointLocal = G4ThreeVector( kInfinity, kInfinity, kInfinity );
74 
75  fpSaveState = 0;
76 
77  // this->SetVerboseLevel(3);
78  // this->CheckMode(true);
79 }
CLHEP::Hep3Vector G4ThreeVector
G4double kCarTolerance
G4double GetSurfaceTolerance() const
G4ThreeVector fLastStepEndPointLocal
void SetNormalNavigation(G4NormalNavigation *fnormnav)
G4bool fWasLimitedByGeometry
void ResetStackAndState()
static G4GeometryTolerance * GetInstance()
G4ThreeVector fStepEndPoint
G4ITNavigator::~G4ITNavigator ( )
virtual

Definition at line 115 of file G4ITNavigator.cc.

116 {;}

Member Function Documentation

void G4ITNavigator::Activate ( G4bool  flag)
inline
EVolume G4ITNavigator::CharacteriseDaughters ( const G4LogicalVolume pLog) const
inlineprotected
void G4ITNavigator::CheckMode ( G4bool  mode)
inline
G4double G4ITNavigator::CheckNextStep ( const G4ThreeVector pGlobalPoint,
const G4ThreeVector pDirection,
const G4double  pCurrentProposedStepLength,
G4double pNewSafety 
)

Definition at line 1087 of file G4ITNavigator.cc.

References ComputeStep(), RestoreSavedState(), and SetSavedState().

1091 {
1092  G4double step;
1093 
1094  // Save the state, for this parasitic call
1095  //
1096  SetSavedState();
1097 
1098  step = ComputeStep ( pGlobalpoint,
1099  pDirection,
1100  pCurrentProposedStepLength,
1101  pNewSafety );
1102 
1103  // If a parasitic call, then attempt to restore the key parts of the state
1104  //
1105  RestoreSavedState();
1106 
1107  return step;
1108 }
void RestoreSavedState()
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double &pNewSafety)
void SetSavedState()
double G4double
Definition: G4Types.hh:76
G4ThreeVector G4ITNavigator::ComputeLocalAxis ( const G4ThreeVector pVec) const
inlineprotected

Referenced by ComputeStep().

G4ThreeVector G4ITNavigator::ComputeLocalPoint ( const G4ThreeVector rGlobPoint) const
inlineprotected
G4double G4ITNavigator::ComputeSafety ( const G4ThreeVector globalpoint,
const G4double  pProposedMaxLength = DBL_MAX,
const G4bool  keepState = false 
)
virtual

Definition at line 1441 of file G4ITNavigator.cc.

References CharacteriseDaughters(), ComputeLocalPoint(), G4ParameterisedNavigation::ComputeSafety(), G4NormalNavigation::ComputeSafety(), G4VoxelNavigation::ComputeSafety(), G4RegularNavigation::ComputeSafety(), G4ReplicaNavigation::ComputeSafety(), FatalException, fEnteredDaughter, fExitedMother, fHistory, fStepEndPoint, fVerbose, G4cout, G4endl, G4Exception(), GetDaughtersRegularStructureId(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetName(), G4NavigationHistory::GetTopVolume(), G4NavigationHistory::GetTopVolumeType(), G4LogicalVolume::GetVoxelHeader(), kCarTolerance, kNormal, kParameterised, kReplica, LocateGlobalPointWithinVolume(), PrintState(), RestoreSavedState(), and SetSavedState().

Referenced by G4ITTransportation::AlongStepGetPhysicalInteractionLength().

1444 {
1445  G4double newSafety = 0.0;
1446 
1447 #ifdef G4DEBUG_NAVIGATION
1448  G4int oldcoutPrec = G4cout.precision(8);
1449  if( fVerbose > 0 )
1450  {
1451  G4cout << "*** G4ITNavigator::ComputeSafety: ***" << G4endl
1452  << " Called at point: " << pGlobalpoint << G4endl;
1453 
1454  G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
1455  G4cout << " Volume = " << motherPhysical->GetName()
1456  << " - Maximum length = " << pMaxLength << G4endl;
1457  if( fVerbose >= 4 )
1458  {
1459  G4cout << " ----- Upon entering Compute Safety:" << G4endl;
1460  PrintState();
1461  }
1462  }
1463 #endif
1464 
1465  if (keepState) { SetSavedState(); }
1466  // fLastTriedStepComputation= true; -- this method is NOT computing the Step size
1467 
1468  G4double distEndpointSq = (pGlobalpoint-fStepEndPoint).mag2();
1469  G4bool stayedOnEndpoint = distEndpointSq < kCarTolerance*kCarTolerance;
1470  G4bool endpointOnSurface = fEnteredDaughter || fExitedMother;
1471 
1472  if( !(endpointOnSurface && stayedOnEndpoint) )
1473  {
1474  // Pseudo-relocate to this point (updates voxel information only)
1475  //
1476  LocateGlobalPointWithinVolume( pGlobalpoint );
1477  // --->> Danger: Side effects on sub-navigator voxel information <<---
1478  // Could be replaced again by 'granular' calls to sub-navigator
1479  // locates (similar side-effects, but faster.
1480  // Solutions:
1481  // 1) Re-locate (to where?)
1482  // 2) Insure that the methods using (G4ComputeStep?)
1483  // does a relocation (if information is disturbed only ?)
1484 
1485 #ifdef G4DEBUG_NAVIGATION
1486  if( fVerbose >= 2 )
1487  {
1488  G4cout << " G4ITNavigator::ComputeSafety() relocates-in-volume to point: "
1489  << pGlobalpoint << G4endl;
1490  }
1491 #endif
1492  G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
1493  G4LogicalVolume *motherLogical = motherPhysical->GetLogicalVolume();
1494  G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
1495  G4ThreeVector localPoint = ComputeLocalPoint(pGlobalpoint);
1496 
1498  {
1499  switch(CharacteriseDaughters(motherLogical))
1500  {
1501  case kNormal:
1502  if ( pVoxelHeader )
1503  {
1504  newSafety=fvoxelNav.ComputeSafety(localPoint,fHistory,pMaxLength);
1505  }
1506  else
1507  {
1508  newSafety=fnormalNav.ComputeSafety(localPoint,fHistory,pMaxLength);
1509  }
1510  break;
1511  case kParameterised:
1512  if( GetDaughtersRegularStructureId(motherLogical) != 1 )
1513  {
1514  newSafety = fparamNav.ComputeSafety(localPoint,fHistory,pMaxLength);
1515  }
1516  else // Regular structure
1517  {
1518  newSafety = fregularNav.ComputeSafety(localPoint,fHistory,pMaxLength);
1519  }
1520  break;
1521  case kReplica:
1522  G4Exception("G4ITNavigator::ComputeSafety()", "NotApplicable",
1523  FatalException, "Not applicable for replicated volumes.");
1524  break;
1525  }
1526  }
1527  else
1528  {
1529  newSafety = freplicaNav.ComputeSafety(pGlobalpoint, localPoint,
1530  fHistory, pMaxLength);
1531  }
1532  }
1533  else // if( endpointOnSurface && stayedOnEndpoint )
1534  {
1535 #ifdef G4DEBUG_NAVIGATION
1536  if( fVerbose >= 2 )
1537  {
1538  G4cout << " G4ITNavigator::ComputeSafety() finds that point - "
1539  << pGlobalpoint << " - is on surface " << G4endl;
1540  if( fEnteredDaughter ) { G4cout << " entered new daughter volume"; }
1541  if( fExitedMother ) { G4cout << " and exited previous volume."; }
1542  G4cout << G4endl;
1543  G4cout << " EndPoint was = " << fStepEndPoint << G4endl;
1544  }
1545 #endif
1546  newSafety = 0.0;
1547  }
1548 
1549  // Remember last safety origin & value
1550  //
1551  fPreviousSftOrigin = pGlobalpoint;
1552  fPreviousSafety = newSafety;
1553 
1554  if (keepState) { RestoreSavedState(); }
1555 
1556 #ifdef G4DEBUG_NAVIGATION
1557  if( fVerbose > 1 )
1558  {
1559  G4cout << " ---- Exiting ComputeSafety " << G4endl;
1560  if( fVerbose > 2 ) { PrintState(); }
1561  G4cout << " Returned value of Safety = " << newSafety << G4endl;
1562  }
1563  G4cout.precision(oldcoutPrec);
1564 #endif
1565 
1566  return newSafety;
1567 }
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
G4double kCarTolerance
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
void RestoreSavedState()
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
int G4int
Definition: G4Types.hh:78
G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
G4bool fExitedMother
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
bool G4bool
Definition: G4Types.hh:79
EVolume GetTopVolumeType() const
virtual G4double ComputeSafety(const G4ThreeVector &globalpoint, const G4NavigationHistory &history, const G4double pMaxLength=DBL_MAX)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4NavigationHistory fHistory
G4LogicalVolume * GetLogicalVolume() const
G4bool fEnteredDaughter
G4double ComputeSafety(const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
#define G4endl
Definition: G4ios.hh:61
void SetSavedState()
void PrintState() const
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4double ComputeSafety(const G4ThreeVector &globalPoint, const G4ThreeVector &localPoint, G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
double G4double
Definition: G4Types.hh:76
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
G4ThreeVector fStepEndPoint
G4double G4ITNavigator::ComputeStep ( const G4ThreeVector pGlobalPoint,
const G4ThreeVector pDirection,
const G4double  pCurrentProposedStepLength,
G4double pNewSafety 
)
virtual

Definition at line 725 of file G4ITNavigator.cc.

References CharacteriseDaughters(), G4VPhysicalVolume::CheckOverlaps(), ComputeLocalAxis(), ComputeLocalPoint(), G4RegularNavigation::ComputeStep(), G4ParameterisedNavigation::ComputeStep(), G4NormalNavigation::ComputeStep(), G4VoxelNavigation::ComputeStep(), G4ReplicaNavigation::ComputeStep(), EventMustBeAborted, FatalException, fEnteredDaughter, fExitedMother, fHistory, fLastStepEndPointLocal, fStepEndPoint, fVerbose, G4cout, G4endl, G4Exception(), G4ThreadLocal, GetDaughtersRegularStructureId(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::GetRegularStructureId(), G4VPhysicalVolume::GetRotation(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTopVolume(), G4NavigationHistory::GetTopVolumeType(), G4LogicalVolume::GetVoxelHeader(), JustWarning, kCarTolerance, kNormal, kParameterised, kReplica, LocateGlobalPointAndSetup(), LocateGlobalPointWithinVolume(), PrintState(), and G4VSolid::SurfaceNormal().

Referenced by G4ITTransportation::AlongStepGetPhysicalInteractionLength(), and CheckNextStep().

729 {
730  G4ThreeVector localDirection = ComputeLocalAxis(pDirection);
731  G4double Step = kInfinity;
732  G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
733  G4LogicalVolume *motherLogical = motherPhysical->GetLogicalVolume();
734 
735  static G4ThreadLocal G4int sNavCScalls=0;
736  sNavCScalls++;
737 
738  fLastTriedStepComputation= true;
739 
740 #ifdef G4VERBOSE
741  if( fVerbose > 0 )
742  {
743  G4cout << "*** G4ITNavigator::ComputeStep: ***" << G4endl;
744  G4cout << " Volume = " << motherPhysical->GetName()
745  << " - Proposed step length = " << pCurrentProposedStepLength
746  << G4endl;
747 #ifdef G4DEBUG_NAVIGATION
748  if( fVerbose >= 4 )
749  {
750  G4cout << " Called with the arguments: " << G4endl
751  << " Globalpoint = " << std::setw(25) << pGlobalpoint << G4endl
752  << " Direction = " << std::setw(25) << pDirection << G4endl;
753  G4cout << " ---- Upon entering :" << G4endl;
754  PrintState();
755  }
756 #endif
757  }
758 #endif
759 
760  G4ThreeVector newLocalPoint = ComputeLocalPoint(pGlobalpoint);
761  if( newLocalPoint != fLastLocatedPointLocal )
762  {
763  // Check whether the relocation is within safety
764  //
765  G4ThreeVector oldLocalPoint = fLastLocatedPointLocal;
766  G4double moveLenSq = (newLocalPoint-oldLocalPoint).mag2();
767 
768  if ( moveLenSq >= kCarTolerance*kCarTolerance )
769  {
770 #ifdef G4VERBOSE
771  ComputeStepLog(pGlobalpoint, moveLenSq);
772 #endif
773  // Relocate the point within the same volume
774  //
775  LocateGlobalPointWithinVolume( pGlobalpoint );
776  fLastTriedStepComputation= true; // Ensure that this is set again !!
777  }
778  }
780  {
781  switch( CharacteriseDaughters(motherLogical) )
782  {
783  case kNormal:
784  if ( motherLogical->GetVoxelHeader() )
785  {
786  Step = fvoxelNav.ComputeStep(fLastLocatedPointLocal,
787  localDirection,
788  pCurrentProposedStepLength,
789  pNewSafety,
790  fHistory,
791  fValidExitNormal,
792  fExitNormal,
793  fExiting,
794  fEntering,
795  &fBlockedPhysicalVolume,
796  fBlockedReplicaNo);
797 
798  }
799  else
800  {
801  if( motherPhysical->GetRegularStructureId() == 0 )
802  {
803  Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
804  localDirection,
805  pCurrentProposedStepLength,
806  pNewSafety,
807  fHistory,
808  fValidExitNormal,
809  fExitNormal,
810  fExiting,
811  fEntering,
812  &fBlockedPhysicalVolume,
813  fBlockedReplicaNo);
814  }
815  else // Regular (non-voxelised) structure
816  {
817  LocateGlobalPointAndSetup( pGlobalpoint, &pDirection, true, true );
818  fLastTriedStepComputation= true; // Ensure that this is set again !!
819  //
820  // if physical process limits the step, the voxel will not be the
821  // one given by ComputeStepSkippingEqualMaterials() and the local
822  // point will be wrongly calculated.
823 
824  // There is a problem: when msc limits the step and the point is
825  // assigned wrongly to phantom in previous step (while it is out
826  // of the container volume). Then LocateGlobalPointAndSetup() has
827  // reset the history topvolume to world.
828  //
830  {
831  G4Exception("G4ITNavigator::ComputeStep()",
832  "GeomNav1001", JustWarning,
833  "Point is relocated in voxels, while it should be outside!");
834  Step = fnormalNav.ComputeStep(fLastLocatedPointLocal,
835  localDirection,
836  pCurrentProposedStepLength,
837  pNewSafety,
838  fHistory,
839  fValidExitNormal,
840  fExitNormal,
841  fExiting,
842  fEntering,
843  &fBlockedPhysicalVolume,
844  fBlockedReplicaNo);
845  }
846  else
847  {
848  Step = fregularNav.
849  ComputeStepSkippingEqualMaterials(fLastLocatedPointLocal,
850  localDirection,
851  pCurrentProposedStepLength,
852  pNewSafety,
853  fHistory,
854  fValidExitNormal,
855  fExitNormal,
856  fExiting,
857  fEntering,
858  &fBlockedPhysicalVolume,
859  fBlockedReplicaNo,
860  motherPhysical);
861  }
862  }
863  }
864  break;
865  case kParameterised:
866  if( GetDaughtersRegularStructureId(motherLogical) != 1 )
867  {
868  Step = fparamNav.ComputeStep(fLastLocatedPointLocal,
869  localDirection,
870  pCurrentProposedStepLength,
871  pNewSafety,
872  fHistory,
873  fValidExitNormal,
874  fExitNormal,
875  fExiting,
876  fEntering,
877  &fBlockedPhysicalVolume,
878  fBlockedReplicaNo);
879  }
880  else // Regular structure
881  {
882  Step = fregularNav.ComputeStep(fLastLocatedPointLocal,
883  localDirection,
884  pCurrentProposedStepLength,
885  pNewSafety,
886  fHistory,
887  fValidExitNormal,
888  fExitNormal,
889  fExiting,
890  fEntering,
891  &fBlockedPhysicalVolume,
892  fBlockedReplicaNo);
893  }
894  break;
895  case kReplica:
896  G4Exception("G4ITNavigator::ComputeStep()", "GeomNav0001",
897  FatalException, "Not applicable for replicated volumes.");
898  break;
899  }
900  }
901  else
902  {
903  // In the case of a replica, it must handle the exiting
904  // edge/corner problem by itself
905  //
906  G4bool exitingReplica = fExitedMother;
907  G4bool calculatedExitNormal= false;
908 
909  Step = freplicaNav.ComputeStep(pGlobalpoint,
910  pDirection,
911  fLastLocatedPointLocal,
912  localDirection,
913  pCurrentProposedStepLength,
914  pNewSafety,
915  fHistory,
916  fValidExitNormal,
917  calculatedExitNormal,
918  fExitNormal,
919  exitingReplica,
920  fEntering,
921  &fBlockedPhysicalVolume,
922  fBlockedReplicaNo);
923  fExiting= exitingReplica; // still ok to set it ??
924  }
925 
926  // Remember last safety origin & value.
927  //
928  fPreviousSftOrigin = pGlobalpoint;
929  fPreviousSafety = pNewSafety;
930 
931  // Count zero steps - one can occur due to changing momentum at a boundary
932  // - one, two (or a few) can occur at common edges between
933  // volumes
934  // - more than two is likely a problem in the geometry
935  // description or the Navigation
936 
937  // Rule of thumb: likely at an Edge if two consecutive steps are zero,
938  // because at least two candidate volumes must have been
939  // checked
940  //
941  fLocatedOnEdge = fLastStepWasZero && (Step==0.0);
942  fLastStepWasZero = (Step==0.0);
943  if (fPushed) fPushed = fLastStepWasZero;
944 
945  // Handle large number of consecutive zero steps
946  //
947  if ( fLastStepWasZero )
948  {
949  fNumberZeroSteps++;
950 #ifdef G4DEBUG_NAVIGATION
951  if( fNumberZeroSteps > 1 )
952  {
953  G4cout << "G4ITNavigator::ComputeStep(): another zero step, # "
954  << fNumberZeroSteps
955  << " at " << pGlobalpoint
956  << " in volume " << motherPhysical->GetName()
957  << " nav-comp-step calls # " << sNavCScalls
958  << G4endl;
959  }
960 #endif
961  if( fNumberZeroSteps > fActionThreshold_NoZeroSteps-1 )
962  {
963  // Act to recover this stuck track. Pushing it along direction
964  //
965  Step += 100*kCarTolerance;
966 #ifdef G4VERBOSE
967  if ((!fPushed) && (fWarnPush))
968  {
969  std::ostringstream message;
970  message << "Track stuck or not moving." << G4endl
971  << " Track stuck, not moving for "
972  << fNumberZeroSteps << " steps" << G4endl
973  << " in volume -" << motherPhysical->GetName()
974  << "- at point " << pGlobalpoint << G4endl
975  << " direction: " << pDirection << "." << G4endl
976  << " Potential geometry or navigation problem !"
977  << G4endl
978  << " Trying pushing it of " << Step << " mm ...";
979  G4Exception("G4ITNavigator::ComputeStep()", "GeomNav1002",
980  JustWarning, message, "Potential overlap in geometry!");
981  }
982 #endif
983  fPushed = true;
984  }
985  if( fNumberZeroSteps > fAbandonThreshold_NoZeroSteps-1 )
986  {
987  // Must kill this stuck track
988  //
989  std::ostringstream message;
990  message << "Stuck Track: potential geometry or navigation problem."
991  << G4endl
992  << " Track stuck, not moving for "
993  << fNumberZeroSteps << " steps" << G4endl
994  << " in volume -" << motherPhysical->GetName()
995  << "- at point " << pGlobalpoint << G4endl
996  << " direction: " << pDirection << ".";
997  motherPhysical->CheckOverlaps(5000, false);
998  G4Exception("G4ITNavigator::ComputeStep()", "GeomNav0003",
999  EventMustBeAborted, message);
1000  }
1001  }
1002  else
1003  {
1004  if (!fPushed) fNumberZeroSteps = 0;
1005  }
1006 
1007  fEnteredDaughter = fEntering; // I expect to enter a volume in this Step
1008  fExitedMother = fExiting;
1009 
1010  fStepEndPoint = pGlobalpoint + Step * pDirection;
1011  fLastStepEndPointLocal = fLastLocatedPointLocal + Step * localDirection;
1012 
1013  if( fExiting )
1014  {
1015 #ifdef G4DEBUG_NAVIGATION
1016  if( fVerbose > 2 )
1017  {
1018  G4cout << " At G4Nav CompStep End - if(exiting) - fExiting= " << fExiting
1019  << " fValidExitNormal = " << fValidExitNormal << G4endl;
1020  G4cout << " fExitNormal= " << fExitNormal << G4endl;
1021  }
1022 #endif
1023 
1024  if(fValidExitNormal)
1025  {
1026  // Convention: fExitNormal is in the 'grand-mother' coordinate system
1027  //
1028  fGrandMotherExitNormal= fExitNormal;
1029  }
1030  else
1031  {
1032  // We must calculate the normal anyway (in order to have it if requested)
1033  //
1034  G4ThreeVector finalLocalPoint =
1035  fLastLocatedPointLocal + localDirection*Step;
1036 
1037  // Now fGrandMotherExitNormal is in the 'grand-mother' coordinate system
1038  //
1039  fGrandMotherExitNormal =
1040  motherLogical->GetSolid()->SurfaceNormal(finalLocalPoint);
1041 
1042  const G4RotationMatrix* mRot = motherPhysical->GetRotation();
1043  if( mRot )
1044  {
1045  fGrandMotherExitNormal *= (*mRot).inverse();
1046  }
1047  // Do not set fValidExitNormal -- this signifies that the solid is convex!
1048  }
1049  }
1050  fStepEndPoint= pGlobalpoint+Step*pDirection;
1051 
1052  if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
1053  {
1054  // This if Step is not really limited by the geometry.
1055  // The Navigator is obliged to return "infinity"
1056  //
1057  Step = kInfinity;
1058  }
1059 
1060 #ifdef G4VERBOSE
1061  if( fVerbose > 1 )
1062  {
1063  if( fVerbose >= 4 )
1064  {
1065  G4cout << " ----- Upon exiting :" << G4endl;
1066  PrintState();
1067  }
1068  G4cout <<" Returned step = " << Step << G4endl;
1069  if( Step == kInfinity )
1070  {
1071  G4cout << " Original proposed step = "
1072  << pCurrentProposedStepLength << G4endl;
1073  }
1074  G4cout << " Safety = " << pNewSafety << G4endl;
1075  }
1076 #endif
1077 
1078  return Step;
1079 }
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double kCarTolerance
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector &position)
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4bool &calculatedExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
G4ThreeVector fLastStepEndPointLocal
G4bool fExitedMother
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
bool G4bool
Definition: G4Types.hh:79
EVolume GetTopVolumeType() const
virtual G4int GetRegularStructureId() const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
G4ThreeVector ComputeLocalAxis(const G4ThreeVector &pVec) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4NavigationHistory fHistory
G4double ComputeStep(const G4ThreeVector &localPoint, const G4ThreeVector &localDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4LogicalVolume * GetLogicalVolume() const
const G4RotationMatrix * GetRotation() const
Definition: Step.hh:41
G4bool fEnteredDaughter
#define G4endl
Definition: G4ios.hh:61
void PrintState() const
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
double G4double
Definition: G4Types.hh:76
virtual G4double ComputeStep(const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
G4VSolid * GetSolid() const
G4ThreeVector fStepEndPoint
G4GRSSolid* G4ITNavigator::CreateGRSSolid ( ) const
inline
G4GRSVolume* G4ITNavigator::CreateGRSVolume ( ) const
inline
G4TouchableHistory* G4ITNavigator::CreateTouchableHistory ( ) const
inline
G4TouchableHistory* G4ITNavigator::CreateTouchableHistory ( const G4NavigationHistory ) const
inline
G4TouchableHistoryHandle G4ITNavigator::CreateTouchableHistoryHandle ( ) const
virtual

Definition at line 1573 of file G4ITNavigator.cc.

References CreateTouchableHistory().

1574 {
1576 }
G4ReferenceCountedHandle< G4TouchableHistory > G4TouchableHistoryHandle
G4TouchableHistory * CreateTouchableHistory() const
void G4ITNavigator::EnableBestSafety ( G4bool  value = false)
inline
G4bool G4ITNavigator::EnteredDaughterVolume ( ) const
inline
G4bool G4ITNavigator::ExitedMotherVolume ( ) const
inline
G4ThreeVector G4ITNavigator::GetCurrentLocalCoordinate ( ) const
inline
G4int G4ITNavigator::GetDaughtersRegularStructureId ( const G4LogicalVolume pLog) const
inlineprotected
G4ThreeVector G4ITNavigator::GetGlobalExitNormal ( const G4ThreeVector point,
G4bool valid 
)
virtual

Definition at line 1418 of file G4ITNavigator.cc.

References GetLocalExitNormalAndCheck(), GetLocalToGlobalTransform(), and G4AffineTransform::TransformAxis().

1420 {
1421  G4bool validNormal;
1422  G4ThreeVector localNormal, globalNormal;
1423 
1424  localNormal = GetLocalExitNormalAndCheck( IntersectPointGlobal, &validNormal);
1425  *pValidNormal = validNormal;
1426  G4AffineTransform localToGlobal = GetLocalToGlobalTransform();
1427  globalNormal = localToGlobal.TransformAxis( localNormal );
1428 
1429  return globalNormal;
1430 }
const G4AffineTransform GetLocalToGlobalTransform() const
bool G4bool
Definition: G4Types.hh:79
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
virtual G4ThreeVector GetLocalExitNormalAndCheck(const G4ThreeVector &point, G4bool *valid)
const G4AffineTransform& G4ITNavigator::GetGlobalToLocalTransform ( ) const
inline
G4ThreeVector G4ITNavigator::GetLocalExitNormal ( G4bool valid)
virtual

Definition at line 1200 of file G4ITNavigator.cc.

References CharacteriseDaughters(), G4VSolid::DistanceToIn(), G4VSolid::DistanceToOut(), EnteredDaughterVolume(), FatalException, fExitedMother, fHistory, fLastStepEndPointLocal, fVerbose, G4endl, G4Exception(), G4VSolid::GetEntityType(), G4VPhysicalVolume::GetLogicalVolume(), GetMotherToDaughterTransform(), G4VSolid::GetName(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetName(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTopVolume(), G4VSolid::Inside(), JustWarning, kCarTolerance, kInside, kOutside, kReplica, kSurface, G4VSolid::SurfaceNormal(), G4AffineTransform::TransformPoint(), and VolumeType().

Referenced by GetLocalExitNormalAndCheck().

1201 {
1202  G4ThreeVector ExitNormal(0.,0.,0.);
1203  G4VSolid *currentSolid=0;
1204  G4LogicalVolume *candidateLogical;
1205  if ( fLastTriedStepComputation )
1206  {
1207  // use fLastLocatedPointLocal
1208  // and next candidate volume
1209  G4ThreeVector nextSolidExitNormal(0.,0.,0.);
1210 
1211  if( fEntering && (fBlockedPhysicalVolume!=0) )
1212  {
1213  candidateLogical= fBlockedPhysicalVolume->GetLogicalVolume();
1214  if( candidateLogical )
1215  {
1216  // fLastStepEndPointLocal is in the coordinates of the mother
1217  // we need it in the daughter's coordinate system.
1218 
1219  if( CharacteriseDaughters(candidateLogical) != kReplica )
1220  {
1221  // First transform fLastLocatedPointLocal to the new daughter
1222  // coordinates
1223  G4AffineTransform MotherToDaughterTransform=
1224  GetMotherToDaughterTransform( fBlockedPhysicalVolume,
1225  fBlockedReplicaNo,
1226  VolumeType(fBlockedPhysicalVolume) );
1227  G4ThreeVector daughterPointOwnLocal=
1228  MotherToDaughterTransform.TransformPoint( fLastStepEndPointLocal );
1229 
1230  // OK if it is a parameterised volume
1231  //
1232  EInside inSideIt;
1233  G4bool onSurface;
1234  G4double safety= -1.0;
1235  currentSolid= candidateLogical->GetSolid();
1236  inSideIt = currentSolid->Inside(daughterPointOwnLocal);
1237  onSurface = (inSideIt == kSurface);
1238  if( ! onSurface )
1239  {
1240  if( inSideIt == kOutside )
1241  {
1242  safety = (currentSolid->DistanceToIn(daughterPointOwnLocal));
1243  onSurface = safety < 100.0 * kCarTolerance;
1244  }
1245  else if (inSideIt == kInside )
1246  {
1247  safety = (currentSolid->DistanceToOut(daughterPointOwnLocal));
1248  onSurface = safety < 100.0 * kCarTolerance;
1249  }
1250  }
1251 
1252  if( onSurface )
1253  {
1254  nextSolidExitNormal =
1255  currentSolid->SurfaceNormal(daughterPointOwnLocal);
1256 
1257  // Entering the solid ==> opposite
1258  //
1259  ExitNormal = -nextSolidExitNormal;
1260  }
1261  else
1262  {
1263 #ifdef G4VERBOSE
1264  if(( fVerbose == 1 ) && ( fCheck ))
1265  {
1266  std::ostringstream message;
1267  message << "Point not on surface ! " << G4endl
1268  << " Point = "
1269  << daughterPointOwnLocal << G4endl
1270  << " Physical volume = "
1271  << fBlockedPhysicalVolume->GetName() << G4endl
1272  << " Logical volume = "
1273  << candidateLogical->GetName() << G4endl
1274  << " Solid = " << currentSolid->GetName()
1275  << " Type = "
1276  << currentSolid->GetEntityType() << G4endl
1277  << *currentSolid << G4endl;
1278  if( inSideIt == kOutside )
1279  {
1280  message << "Point is Outside. " << G4endl
1281  << " Safety (from outside) = " << safety << G4endl;
1282  }
1283  else // if( inSideIt == kInside )
1284  {
1285  message << "Point is Inside. " << G4endl
1286  << " Safety (from inside) = " << safety << G4endl;
1287  }
1288  G4Exception("G4ITNavigator::GetLocalExitNormal()", "GeomNav1001",
1289  JustWarning, message);
1290  }
1291 #endif
1292  }
1293  *valid = onSurface; // was =true;
1294  }
1295  else
1296  {
1297  *valid = false; // TODO: Need Separate code for replica!!!!
1298 #ifdef G4DEBUG_NAVIGATION
1299  G4Exception("G4ITNavigator::GetLocalExitNormal()", "GeomNav0001",
1300  FatalException,
1301  "Local normal not (yet) available for replica volumes.");
1302 #endif
1303  }
1304  }
1305  }
1306  else if ( fExiting )
1307  {
1308  ExitNormal = fGrandMotherExitNormal;
1309  *valid = true;
1310  }
1311  else // ie ( fBlockedPhysicalVolume == 0 )
1312  {
1313  *valid = false;
1314  }
1315  }
1316  else
1317  {
1318  if ( EnteredDaughterVolume() )
1319  {
1320  ExitNormal= -(fHistory.GetTopVolume()->GetLogicalVolume()->
1321  GetSolid()->SurfaceNormal(fLastLocatedPointLocal));
1322  *valid = true;
1323  }
1324  else
1325  {
1326  if( fExitedMother )
1327  {
1328  ExitNormal = fGrandMotherExitNormal;
1329  *valid = true;
1330  }
1331  else // We are not at a boundary. ExitNormal remains (0,0,0)
1332  {
1333  *valid = false;
1334  }
1335  }
1336  }
1337  return ExitNormal;
1338 }
G4String GetName() const
G4VPhysicalVolume * GetTopVolume() const
G4String GetName() const
G4double kCarTolerance
virtual G4GeometryType GetEntityType() const =0
G4ThreeVector fLastStepEndPointLocal
EVolume VolumeType(const G4VPhysicalVolume *pVol) const
G4bool fExitedMother
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
bool G4bool
Definition: G4Types.hh:79
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const =0
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4NavigationHistory fHistory
G4LogicalVolume * GetLogicalVolume() const
EInside
Definition: geomdefs.hh:58
G4bool EnteredDaughterVolume() const
#define G4endl
Definition: G4ios.hh:61
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
double G4double
Definition: G4Types.hh:76
G4AffineTransform GetMotherToDaughterTransform(G4VPhysicalVolume *dVolume, G4int dReplicaNo, EVolume dVolumeType)
virtual G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const =0
G4VSolid * GetSolid() const
G4ThreeVector G4ITNavigator::GetLocalExitNormalAndCheck ( const G4ThreeVector point,
G4bool valid 
)
virtual

Definition at line 1393 of file G4ITNavigator.cc.

References GetGlobalToLocalTransform(), GetLocalExitNormal(), and G4AffineTransform::TransformPoint().

Referenced by GetGlobalExitNormal().

1395 {
1396  G4ThreeVector ExpectedBoundaryPointLocal;
1397 
1398  // Check Current point against expected 'local' value
1399  //
1400  if ( fLastTriedStepComputation )
1401  {
1402  const G4AffineTransform& GlobalToLocal= GetGlobalToLocalTransform();
1403  ExpectedBoundaryPointLocal =
1404  GlobalToLocal.TransformPoint( ExpectedBoundaryPointGlobal );
1405  }
1406 
1407  return GetLocalExitNormal( pValid);
1408 }
const G4AffineTransform & GetGlobalToLocalTransform() const
virtual G4ThreeVector GetLocalExitNormal(G4bool *valid)
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
const G4AffineTransform G4ITNavigator::GetLocalToGlobalTransform ( ) const
inline

Referenced by GetGlobalExitNormal().

G4AffineTransform G4ITNavigator::GetMotherToDaughterTransform ( G4VPhysicalVolume dVolume,
G4int  dReplicaNo,
EVolume  dVolumeType 
)

Definition at line 1347 of file G4ITNavigator.cc.

References G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), G4VPVParameterisation::ComputeTransformation(), FatalException, G4Exception(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4VPhysicalVolume::GetRegularStructureId(), G4VPhysicalVolume::GetRotation(), G4VPhysicalVolume::GetTranslation(), kNormal, kParameterised, kReplica, and G4LogicalVolume::SetSolid().

Referenced by GetLocalExitNormal().

1350 {
1351  switch (enteringVolumeType)
1352  {
1353  case kNormal: // Nothing is needed to prepare the transformation
1354  break; // It is stored already in the physical volume (placement)
1355  case kReplica: // Sets the transform in the Replica - tbc
1356  G4Exception("G4ITNavigator::GetMotherToDaughterTransform()",
1357  "GeomNav0001", FatalException,
1358  "Method NOT Implemented yet for replica volumes.");
1359  break;
1360  case kParameterised:
1361  if( pEnteringPhysVol->GetRegularStructureId() == 0 )
1362  {
1363  G4VPVParameterisation *pParam =
1364  pEnteringPhysVol->GetParameterisation();
1365  G4VSolid* pSolid =
1366  pParam->ComputeSolid(enteringReplicaNo, pEnteringPhysVol);
1367  pSolid->ComputeDimensions(pParam, enteringReplicaNo, pEnteringPhysVol);
1368 
1369  // Sets the transform in the Parameterisation
1370  //
1371  pParam->ComputeTransformation(enteringReplicaNo, pEnteringPhysVol);
1372 
1373  // Set the correct solid and material in Logical Volume
1374  //
1375  G4LogicalVolume* pLogical = pEnteringPhysVol->GetLogicalVolume();
1376  pLogical->SetSolid( pSolid );
1377  }
1378  break;
1379  }
1380  return G4AffineTransform(pEnteringPhysVol->GetRotation(),
1381  pEnteringPhysVol->GetTranslation()).Invert();
1382 }
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:137
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
void SetSolid(G4VSolid *pSolid)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
G4ITNavigatorState_Lock * G4ITNavigator::GetNavigatorState ( )

Definition at line 594 of file G4ITNavigator.cc.

References SetSavedState().

Referenced by G4ITStepProcessor::DoDefinePhysicalStepLength(), and G4ITStepProcessor::DoStepping().

595 {
596  SetSavedState();
597  return fpSaveState;
598 }
void SetSavedState()
G4int G4ITNavigator::GetVerboseLevel ( ) const
inline
G4VPhysicalVolume* G4ITNavigator::GetWorldVolume ( ) const
inline
G4bool G4ITNavigator::IsActive ( ) const
inline
G4bool G4ITNavigator::IsCheckModeActive ( ) const
inline
G4VPhysicalVolume * G4ITNavigator::LocateGlobalPointAndSetup ( const G4ThreeVector point,
const G4ThreeVector direction = 0,
const G4bool  pRelativeSearch = true,
const G4bool  ignoreDirection = true 
)
virtual

Definition at line 151 of file G4ITNavigator.cc.

References G4NavigationHistory::BackLevel(), G4ReplicaNavigation::BackLocate(), CharacteriseDaughters(), G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), G4VPVParameterisation::ComputeTransformation(), G4ReplicaNavigation::ComputeTransformation(), CLHEP::Hep3Vector::dot(), fEnteredDaughter, fExitedMother, fHistory, fVerbose, fWasLimitedByGeometry, G4cout, G4endl, G4VPhysicalVolume::GetCopyNo(), GetDaughtersRegularStructureId(), G4NavigationHistory::GetDepth(), G4VPhysicalVolume::GetLogicalVolume(), G4VSolid::GetName(), G4VPhysicalVolume::GetName(), G4VPhysicalVolume::GetParameterisation(), G4VPhysicalVolume::GetRegularStructureId(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTopReplicaNo(), G4NavigationHistory::GetTopTransform(), G4NavigationHistory::GetTopVolume(), G4NavigationHistory::GetTopVolumeType(), G4LogicalVolume::GetVoxelHeader(), G4VSolid::Inside(), kNormal, kOutside, kParameterised, kReplica, kSurface, G4RegularNavigation::LevelLocate(), G4NormalNavigation::LevelLocate(), G4ParameterisedNavigation::LevelLocate(), G4VoxelNavigation::LevelLocate(), G4ReplicaNavigation::LevelLocate(), G4NavigationHistory::NewLevel(), PrintState(), ResetStackAndState(), G4VPhysicalVolume::SetCopyNo(), G4LogicalVolume::SetSolid(), G4VSolid::SurfaceNormal(), G4AffineTransform::TransformAxis(), G4AffineTransform::TransformPoint(), G4LogicalVolume::UpdateMaterial(), and VolumeType().

Referenced by ComputeStep(), ResetHierarchyAndLocate(), and G4ITStepProcessor::SetInitialStep().

155 {
156  G4bool notKnownContained=true, noResult;
157  G4VPhysicalVolume *targetPhysical;
158  G4LogicalVolume *targetLogical;
159  G4VSolid *targetSolid=0;
160  G4ThreeVector localPoint, globalDirection;
161  EInside insideCode;
162 
163  G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
164  fLastTriedStepComputation= false;
165 
166  if( considerDirection && pGlobalDirection != 0 )
167  {
168  globalDirection=*pGlobalDirection;
169  }
170 
171 #ifdef G4VERBOSE
172  if( fVerbose > 2 )
173  {
174  G4int oldcoutPrec = G4cout.precision(8);
175  G4cout << "*** G4ITNavigator::LocateGlobalPointAndSetup: ***" << G4endl;
176  G4cout << " Called with arguments: " << G4endl
177  << " Globalpoint = " << globalPoint << G4endl
178  << " RelativeSearch = " << relativeSearch << G4endl;
179  if( fVerbose == 4 )
180  {
181  G4cout << " ----- Upon entering:" << G4endl;
182  PrintState();
183  }
184  G4cout.precision(oldcoutPrec);
185  }
186 #endif
187 
188  if ( !relativeSearch )
189  {
191  }
192  else
193  {
194  if ( fWasLimitedByGeometry )
195  {
196  fWasLimitedByGeometry = false;
197  fEnteredDaughter = fEntering; // Remember
198  fExitedMother = fExiting; // Remember
199  if ( fExiting )
200  {
201  if ( fHistory.GetDepth() )
202  {
203  fBlockedPhysicalVolume = fHistory.GetTopVolume();
204  fBlockedReplicaNo = fHistory.GetTopReplicaNo();
206  }
207  else
208  {
209  fLastLocatedPointLocal = localPoint;
210  fLocatedOutsideWorld = true;
211  return 0; // Have exited world volume
212  }
213  // A fix for the case where a volume is "entered" at an edge
214  // and a coincident surface exists outside it.
215  // - This stops it from exiting further volumes and cycling
216  // - However ReplicaNavigator treats this case itself
217  //
218  if ( fLocatedOnEdge && (VolumeType(fBlockedPhysicalVolume)!=kReplica ))
219  {
220  fExiting= false;
221  }
222  }
223  else
224  if ( fEntering )
225  {
226  switch (VolumeType(fBlockedPhysicalVolume))
227  {
228  case kNormal:
229  fHistory.NewLevel(fBlockedPhysicalVolume, kNormal,
230  fBlockedPhysicalVolume->GetCopyNo());
231  break;
232  case kReplica:
233  freplicaNav.ComputeTransformation(fBlockedReplicaNo,
234  fBlockedPhysicalVolume);
235  fHistory.NewLevel(fBlockedPhysicalVolume, kReplica,
236  fBlockedReplicaNo);
237  fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
238  break;
239  case kParameterised:
240  if( fBlockedPhysicalVolume->GetRegularStructureId() == 0 )
241  {
242  G4VSolid *pSolid;
243  G4VPVParameterisation *pParam;
244  G4TouchableHistory parentTouchable( fHistory );
245  pParam = fBlockedPhysicalVolume->GetParameterisation();
246  pSolid = pParam->ComputeSolid(fBlockedReplicaNo,
247  fBlockedPhysicalVolume);
248  pSolid->ComputeDimensions(pParam, fBlockedReplicaNo,
249  fBlockedPhysicalVolume);
250  pParam->ComputeTransformation(fBlockedReplicaNo,
251  fBlockedPhysicalVolume);
252  fHistory.NewLevel(fBlockedPhysicalVolume, kParameterised,
253  fBlockedReplicaNo);
254  fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
255  //
256  // Set the correct solid and material in Logical Volume
257  //
258  G4LogicalVolume *pLogical;
259  pLogical = fBlockedPhysicalVolume->GetLogicalVolume();
260  pLogical->SetSolid( pSolid );
261  pLogical->UpdateMaterial(pParam ->
262  ComputeMaterial(fBlockedReplicaNo,
263  fBlockedPhysicalVolume,
264  &parentTouchable));
265  }
266  break;
267  }
268  fEntering = false;
269  fBlockedPhysicalVolume = 0;
270  localPoint = fHistory.GetTopTransform().TransformPoint(globalPoint);
271  notKnownContained = false;
272  }
273  }
274  else
275  {
276  fBlockedPhysicalVolume = 0;
277  fEntering = false;
278  fEnteredDaughter = false; // Full Step was not taken, did not enter
279  fExiting = false;
280  fExitedMother = false; // Full Step was not taken, did not exit
281  }
282  }
283  //
284  // Search from top of history up through geometry until
285  // containing volume found:
286  // If on
287  // o OUTSIDE - Back up level, not/no longer exiting volumes
288  // o SURFACE and EXITING - Back up level, setting new blocking no.s
289  // else
290  // o containing volume found
291  //
292  while (notKnownContained)
293  {
295  {
296  targetSolid = fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid();
297  localPoint = fHistory.GetTopTransform().TransformPoint(globalPoint);
298  insideCode = targetSolid->Inside(localPoint);
299 #ifdef G4VERBOSE
300  if(( fVerbose == 1 ) && ( fCheck ))
301  {
302  G4String solidResponse = "-kInside-";
303  if (insideCode == kOutside)
304  solidResponse = "-kOutside-";
305  else if (insideCode == kSurface)
306  solidResponse = "-kSurface-";
307  G4cout << "*** G4ITNavigator::LocateGlobalPointAndSetup(): ***" << G4endl
308  << " Invoked Inside() for solid: " << targetSolid->GetName()
309  << ". Solid replied: " << solidResponse << G4endl
310  << " For local point p: " << localPoint << G4endl;
311  }
312 #endif
313  }
314  else
315  {
316  insideCode = freplicaNav.BackLocate(fHistory, globalPoint, localPoint,
317  fExiting, notKnownContained);
318  // !CARE! if notKnownContained returns false then the point is within
319  // the containing placement volume of the replica(s). If insidecode
320  // will result in the history being backed up one level, then the
321  // local point returned is the point in the system of this new level
322  }
323  if ( insideCode==kOutside )
324  {
325  if ( fHistory.GetDepth() )
326  {
327  fBlockedPhysicalVolume = fHistory.GetTopVolume();
328  fBlockedReplicaNo = fHistory.GetTopReplicaNo();
330  fExiting = false;
331  }
332  else
333  {
334  fLastLocatedPointLocal = localPoint;
335  fLocatedOutsideWorld = true;
336  return 0; // Have exited world volume
337  }
338  }
339  else
340  if ( insideCode==kSurface )
341  {
342  G4bool isExiting = fExiting;
343  if( (!fExiting)&&considerDirection )
344  {
345  // Figure out whether we are exiting this level's volume
346  // by using the direction
347  //
348  G4bool directionExiting = false;
349  G4ThreeVector localDirection =
350  fHistory.GetTopTransform().TransformAxis(globalDirection);
352  {
353  G4ThreeVector normal = targetSolid->SurfaceNormal(localPoint);
354  directionExiting = normal.dot(localDirection) > 0.0;
355  isExiting = isExiting || directionExiting;
356  }
357  }
358  if( isExiting )
359  {
360  if ( fHistory.GetDepth() )
361  {
362  fBlockedPhysicalVolume = fHistory.GetTopVolume();
363  fBlockedReplicaNo = fHistory.GetTopReplicaNo();
365  //
366  // Still on surface but exited volume not necessarily convex
367  //
368  fValidExitNormal = false;
369  }
370  else
371  {
372  fLastLocatedPointLocal = localPoint;
373  fLocatedOutsideWorld = true;
374  return 0; // Have exited world volume
375  }
376  }
377  else
378  {
379  notKnownContained=false;
380  }
381  }
382  else
383  {
384  notKnownContained=false;
385  }
386  } // END while (notKnownContained)
387  //
388  // Search downwards until deepest containing volume found,
389  // blocking fBlockedPhysicalVolume/BlockedReplicaNum
390  //
391  // 3 Cases:
392  //
393  // o Parameterised daughters
394  // =>Must be one G4PVParameterised daughter & voxels
395  // o Positioned daughters & voxels
396  // o Positioned daughters & no voxels
397 
398  noResult = true; // noResult should be renamed to
399  // something like enteredLevel, as that is its meaning.
400  do
401  {
402  // Determine `type' of current mother volume
403  //
404  targetPhysical = fHistory.GetTopVolume();
405  if (!targetPhysical) { break; }
406  targetLogical = targetPhysical->GetLogicalVolume();
407  switch( CharacteriseDaughters(targetLogical) )
408  {
409  case kNormal:
410  if ( targetLogical->GetVoxelHeader() ) // use optimised navigation
411  {
412  noResult = fvoxelNav.LevelLocate(fHistory,
413  fBlockedPhysicalVolume,
414  fBlockedReplicaNo,
415  globalPoint,
416  pGlobalDirection,
417  considerDirection,
418  localPoint);
419  }
420  else // do not use optimised navigation
421  {
422  noResult = fnormalNav.LevelLocate(fHistory,
423  fBlockedPhysicalVolume,
424  fBlockedReplicaNo,
425  globalPoint,
426  pGlobalDirection,
427  considerDirection,
428  localPoint);
429  }
430  break;
431  case kReplica:
432  noResult = freplicaNav.LevelLocate(fHistory,
433  fBlockedPhysicalVolume,
434  fBlockedReplicaNo,
435  globalPoint,
436  pGlobalDirection,
437  considerDirection,
438  localPoint);
439  break;
440  case kParameterised:
441  if( GetDaughtersRegularStructureId(targetLogical) != 1 )
442  {
443  noResult = fparamNav.LevelLocate(fHistory,
444  fBlockedPhysicalVolume,
445  fBlockedReplicaNo,
446  globalPoint,
447  pGlobalDirection,
448  considerDirection,
449  localPoint);
450  }
451  else // Regular structure
452  {
453  noResult = fregularNav.LevelLocate(fHistory,
454  fBlockedPhysicalVolume,
455  fBlockedReplicaNo,
456  globalPoint,
457  pGlobalDirection,
458  considerDirection,
459  localPoint);
460  }
461  break;
462  }
463 
464  // LevelLocate returns true if it finds a daughter volume
465  // in which globalPoint is inside (or on the surface).
466 
467  if ( noResult )
468  {
469  // Entering a daughter after ascending
470  //
471  // The blocked volume is no longer valid - it was for another level
472  //
473  fBlockedPhysicalVolume = 0;
474  fBlockedReplicaNo = -1;
475 
476  // fEntering should be false -- else blockedVolume is assumed good.
477  // fEnteredDaughter is used for ExitNormal
478  //
479  fEntering = false;
480  fEnteredDaughter = true;
481 #ifdef G4DEBUG_NAVIGATION
482  if( fVerbose > 2 )
483  {
484  G4VPhysicalVolume* enteredPhysical = fHistory.GetTopVolume();
485  G4cout << "*** G4ITNavigator::LocateGlobalPointAndSetup() ***" << G4endl;
486  G4cout << " Entering volume: " << enteredPhysical->GetName()
487  << G4endl;
488  }
489 #endif
490  }
491  } while (noResult);
492 
493  fLastLocatedPointLocal = localPoint;
494 
495 #ifdef G4VERBOSE
496  if( fVerbose == 4 )
497  {
498  G4int oldcoutPrec = G4cout.precision(8);
499  G4String curPhysVol_Name("None");
500  if (targetPhysical) { curPhysVol_Name = targetPhysical->GetName(); }
501  G4cout << " Return value = new volume = " << curPhysVol_Name << G4endl;
502  G4cout << " ----- Upon exiting:" << G4endl;
503  PrintState();
504 #ifdef G4DEBUG_NAVIGATION
505  G4cout << "Upon exiting LocateGlobalPointAndSetup():" << G4endl;
506  G4cout << " History = " << G4endl << fHistory << G4endl << G4endl;
507 #endif
508  G4cout.precision(oldcoutPrec);
509  }
510 #endif
511 
512  fLocatedOutsideWorld= false;
513 
514  return targetPhysical;
515 }
G4String GetName() const
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
virtual G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
void UpdateMaterial(G4Material *pMaterial)
double dot(const Hep3Vector &) const
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:137
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4int GetDepth() const
void SetSolid(G4VSolid *pSolid)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
void ComputeTransformation(const G4int replicaNo, G4VPhysicalVolume *pVol, G4ThreeVector &point) const
int G4int
Definition: G4Types.hh:78
G4int GetTopReplicaNo() const
EVolume VolumeType(const G4VPhysicalVolume *pVol) const
G4bool fExitedMother
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
virtual EInside Inside(const G4ThreeVector &p) const =0
bool G4bool
Definition: G4Types.hh:79
EVolume GetTopVolumeType() const
virtual G4int GetRegularStructureId() const =0
virtual G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const =0
virtual G4VPVParameterisation * GetParameterisation() const =0
virtual void SetCopyNo(G4int CopyNo)=0
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
void NewLevel(G4VPhysicalVolume *pNewMother, EVolume vType=kNormal, G4int nReplica=-1)
G4ThreeVector TransformPoint(const G4ThreeVector &vec) const
G4NavigationHistory fHistory
G4LogicalVolume * GetLogicalVolume() const
EInside
Definition: geomdefs.hh:58
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
G4ThreeVector TransformAxis(const G4ThreeVector &axis) const
virtual G4int GetCopyNo() const =0
G4bool fEnteredDaughter
#define G4endl
Definition: G4ios.hh:61
const G4AffineTransform & GetTopTransform() const
G4bool fWasLimitedByGeometry
void PrintState() const
void ResetStackAndState()
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4bool LevelLocate(G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
EInside BackLocate(G4NavigationHistory &history, const G4ThreeVector &globalPoint, G4ThreeVector &localPoint, const G4bool &exiting, G4bool &notKnownInside) const
G4VSolid * GetSolid() const
void G4ITNavigator::LocateGlobalPointAndUpdateTouchable ( const G4ThreeVector position,
const G4ThreeVector direction,
G4VTouchable touchableToUpdate,
const G4bool  RelativeSearch = true 
)
inline
void G4ITNavigator::LocateGlobalPointAndUpdateTouchable ( const G4ThreeVector position,
G4VTouchable touchableToUpdate,
const G4bool  RelativeSearch = true 
)
inline
void G4ITNavigator::LocateGlobalPointAndUpdateTouchableHandle ( const G4ThreeVector position,
const G4ThreeVector direction,
G4TouchableHandle oldTouchableToUpdate,
const G4bool  RelativeSearch = true 
)
inline
void G4ITNavigator::LocateGlobalPointWithinVolume ( const G4ThreeVector position)
virtual

Definition at line 531 of file G4ITNavigator.cc.

References CharacteriseDaughters(), ComputeLocalPoint(), FatalException, fEnteredDaughter, fExitedMother, fHistory, fVerbose, G4cout, G4endl, G4Exception(), GetDaughtersRegularStructureId(), G4VPhysicalVolume::GetLogicalVolume(), G4NavigationHistory::GetTopVolume(), G4NavigationHistory::GetTopVolumeType(), G4LogicalVolume::GetVoxelHeader(), kNormal, kParameterised, kReplica, G4ParameterisedNavigation::ParamVoxelLocate(), and G4VoxelNavigation::VoxelLocate().

Referenced by ComputeSafety(), ComputeStep(), and G4ITTransportation::PostStepDoIt().

532 {
533  fLastLocatedPointLocal = ComputeLocalPoint(pGlobalpoint);
534  fLastTriedStepComputation= false;
535 
536 #ifdef G4DEBUG_NAVIGATION
537  if( fVerbose > 2 )
538  {
539  G4cout << "Entering LocateGlobalWithinVolume(): History = " << G4endl;
540  G4cout << fHistory << G4endl;
541  }
542 #endif
543 
544  // For the case of Voxel (or Parameterised) volume the respective
545  // Navigator must be messaged to update its voxel information etc
546 
547  // Update the state of the Sub Navigators
548  // - in particular any voxel information they store/cache
549  //
550  G4VPhysicalVolume* motherPhysical = fHistory.GetTopVolume();
551  G4LogicalVolume* motherLogical = motherPhysical->GetLogicalVolume();
552  G4SmartVoxelHeader* pVoxelHeader = motherLogical->GetVoxelHeader();
553 
555  {
556  switch( CharacteriseDaughters(motherLogical) )
557  {
558  case kNormal:
559  if ( pVoxelHeader )
560  {
561  fvoxelNav.VoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
562  }
563  break;
564  case kParameterised:
565  if( GetDaughtersRegularStructureId(motherLogical) != 1 )
566  {
567  // Resets state & returns voxel node
568  //
569  fparamNav.ParamVoxelLocate( pVoxelHeader, fLastLocatedPointLocal );
570  }
571  break;
572  case kReplica:
573  G4Exception("G4ITNavigator::LocateGlobalPointWithinVolume()",
574  "GeomNav0001", FatalException,
575  "Not applicable for replicated volumes.");
576  break;
577  }
578  }
579 
580  // Reset the state variables
581  // - which would have been affected
582  // by the 'equivalent' call to LocateGlobalPointAndSetup
583  // - who's values have been invalidated by the 'move'.
584  //
585  fBlockedPhysicalVolume = 0;
586  fBlockedReplicaNo = -1;
587  fEntering = false;
588  fEnteredDaughter = false; // Boundary not encountered, did not enter
589  fExiting = false;
590  fExitedMother = false; // Boundary not encountered, did not exit
591 }
G4SmartVoxelHeader * GetVoxelHeader() const
G4VPhysicalVolume * GetTopVolume() const
G4int GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
G4SmartVoxelNode * ParamVoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4bool fExitedMother
G4GLOB_DLL std::ostream G4cout
EVolume GetTopVolumeType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4NavigationHistory fHistory
G4LogicalVolume * GetLogicalVolume() const
G4SmartVoxelNode * VoxelLocate(G4SmartVoxelHeader *pHead, const G4ThreeVector &localPoint)
G4bool fEnteredDaughter
#define G4endl
Definition: G4ios.hh:61
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const
G4ThreeVector ComputeLocalPoint(const G4ThreeVector &rGlobPoint) const
G4RotationMatrix G4ITNavigator::NetRotation ( ) const
inline
G4ThreeVector G4ITNavigator::NetTranslation ( ) const
inline
void G4ITNavigator::NewNavigatorState ( )

Definition at line 606 of file G4ITNavigator.cc.

References ResetState().

Referenced by G4ITStepProcessor::InitDefineStep().

607 {
608  fpSaveState = new G4SaveNavigatorState();
609  ResetState();
610 }
virtual void ResetState()
void G4ITNavigator::PrintState ( ) const

Definition at line 1582 of file G4ITNavigator.cc.

References fVerbose, G4cout, G4endl, G4VPhysicalVolume::GetName(), CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by ComputeSafety(), ComputeStep(), and LocateGlobalPointAndSetup().

1583 {
1584  G4int oldcoutPrec = G4cout.precision(4);
1585  if( fVerbose == 4 )
1586  {
1587  G4cout << "The current state of G4ITNavigator is: " << G4endl;
1588  G4cout << " ValidExitNormal= " << fValidExitNormal << G4endl
1589  << " ExitNormal = " << fExitNormal << G4endl
1590  << " Exiting = " << fExiting << G4endl
1591  << " Entering = " << fEntering << G4endl
1592  << " BlockedPhysicalVolume= " ;
1593  if (fBlockedPhysicalVolume==0)
1594  G4cout << "None";
1595  else
1596  G4cout << fBlockedPhysicalVolume->GetName();
1597  G4cout << G4endl
1598  << " BlockedReplicaNo = " << fBlockedReplicaNo << G4endl
1599  << " LastStepWasZero = " << fLastStepWasZero << G4endl
1600  << G4endl;
1601  }
1602  if( ( 1 < fVerbose) && (fVerbose < 4) )
1603  {
1604  G4cout << std::setw(30) << " ExitNormal " << " "
1605  << std::setw( 5) << " Valid " << " "
1606  << std::setw( 9) << " Exiting " << " "
1607  << std::setw( 9) << " Entering" << " "
1608  << std::setw(15) << " Blocked:Volume " << " "
1609  << std::setw( 9) << " ReplicaNo" << " "
1610  << std::setw( 8) << " LastStepZero " << " "
1611  << G4endl;
1612  G4cout << "( " << std::setw(7) << fExitNormal.x()
1613  << ", " << std::setw(7) << fExitNormal.y()
1614  << ", " << std::setw(7) << fExitNormal.z() << " ) "
1615  << std::setw( 5) << fValidExitNormal << " "
1616  << std::setw( 9) << fExiting << " "
1617  << std::setw( 9) << fEntering << " ";
1618  if ( fBlockedPhysicalVolume==0 )
1619  G4cout << std::setw(15) << "None";
1620  else
1621  G4cout << std::setw(15)<< fBlockedPhysicalVolume->GetName();
1622  G4cout << std::setw( 9) << fBlockedReplicaNo << " "
1623  << std::setw( 8) << fLastStepWasZero << " "
1624  << G4endl;
1625  }
1626  if( fVerbose > 2 )
1627  {
1628  G4cout.precision(8);
1629  G4cout << " Current Localpoint = " << fLastLocatedPointLocal << G4endl;
1630  G4cout << " PreviousSftOrigin = " << fPreviousSftOrigin << G4endl;
1631  G4cout << " PreviousSafety = " << fPreviousSafety << G4endl;
1632  }
1633  G4cout.precision(oldcoutPrec);
1634 }
double x() const
int G4int
Definition: G4Types.hh:78
double z() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
double y() const
#define G4endl
Definition: G4ios.hh:61
G4VPhysicalVolume * G4ITNavigator::ResetHierarchyAndLocate ( const G4ThreeVector point,
const G4ThreeVector direction,
const G4TouchableHistory h 
)
virtual

Definition at line 123 of file G4ITNavigator.cc.

References fHistory, G4TouchableHistory::GetHistory(), LocateGlobalPointAndSetup(), ResetState(), and SetupHierarchy().

Referenced by G4ITStepProcessor::DoStepping(), G4ITStepProcessor::InitDefineStep(), and G4ITStepProcessor::SetInitialStep().

126 {
127  ResetState();
128  fHistory = *h.GetHistory();
129  SetupHierarchy();
130  fLastTriedStepComputation= false; // Redundant, but best
131  return LocateGlobalPointAndSetup(p, &direction, true, false);
132 }
virtual void ResetState()
const char * p
Definition: xmltok.h:285
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4NavigationHistory fHistory
virtual void SetupHierarchy()
const G4NavigationHistory * GetHistory() const
void G4ITNavigator::ResetStackAndState ( )
inline
void G4ITNavigator::ResetState ( )
protectedvirtual

Definition at line 1116 of file G4ITNavigator.cc.

References fEnteredDaughter, fExitedMother, and fWasLimitedByGeometry.

Referenced by NewNavigatorState(), and ResetHierarchyAndLocate().

1117 {
1118  fWasLimitedByGeometry = false;
1119  fEntering = false;
1120  fExiting = false;
1121  fLocatedOnEdge = false;
1122  fLastStepWasZero = false;
1123  fEnteredDaughter = false;
1124  fExitedMother = false;
1125  fPushed = false;
1126 
1127  fValidExitNormal = false;
1128  fExitNormal = G4ThreeVector(0,0,0);
1129 
1130  fPreviousSftOrigin = G4ThreeVector(0,0,0);
1131  fPreviousSafety = 0.0;
1132 
1133  fNumberZeroSteps = 0;
1134 
1135  fBlockedPhysicalVolume = 0;
1136  fBlockedReplicaNo = -1;
1137 
1138  fLastLocatedPointLocal = G4ThreeVector( kInfinity, -kInfinity, 0.0 );
1139  fLocatedOutsideWorld = false;
1140 }
CLHEP::Hep3Vector G4ThreeVector
G4bool fExitedMother
G4bool fEnteredDaughter
G4bool fWasLimitedByGeometry
void G4ITNavigator::RestoreSavedState ( )

Definition at line 665 of file G4ITNavigator.cc.

References fEnteredDaughter, fExitedMother, and fWasLimitedByGeometry.

Referenced by CheckNextStep(), ComputeSafety(), and SetNavigatorState().

666 {
667  fExitNormal = fpSaveState->sExitNormal;
668  fValidExitNormal = fpSaveState->sValidExitNormal;
669  fExiting = fpSaveState->sExiting;
670  fEntering = fpSaveState->sEntering;
671 
672  fBlockedPhysicalVolume = fpSaveState->spBlockedPhysicalVolume;
673  fBlockedReplicaNo = fpSaveState->sBlockedReplicaNo,
674 
675  fLastStepWasZero = fpSaveState->sLastStepWasZero;
676 
677  // !>
678  fPreviousSftOrigin = fpSaveState->sPreviousSftOrigin ;
679  fPreviousSafety = fpSaveState->sPreviousSafety ;
680  fNumberZeroSteps = fpSaveState->sNumberZeroSteps ;
681  fLocatedOnEdge = fpSaveState->sLocatedOnEdge ;
682  fWasLimitedByGeometry = fpSaveState->sWasLimitedByGeometry;
683  fPushed = fpSaveState->sPushed;
684  fNumberZeroSteps = fpSaveState->sNumberZeroSteps;
685  fEnteredDaughter= fpSaveState->sEnteredDaughter ;
686  fExitedMother = fpSaveState->sExitedMother ;
687 
688  fLastLocatedPointLocal = fpSaveState->sLastLocatedPointLocal ;
689  fLocatedOutsideWorld = fpSaveState->sLocatedOutsideWorld;
690  // <!
691 }
G4bool fExitedMother
G4bool fEnteredDaughter
G4bool fWasLimitedByGeometry
void G4ITNavigator::SetGeometricallyLimitedStep ( )
inline
void G4ITNavigator::SetNavigatorState ( G4ITNavigatorState_Lock navState)

Definition at line 600 of file G4ITNavigator.cc.

References RestoreSavedState().

Referenced by G4ITStepProcessor::DoDefinePhysicalStepLength(), G4ITStepProcessor::DoStepping(), and G4ITStepProcessor::InitDefineStep().

601 {
602  fpSaveState = (G4SaveNavigatorState*) navState;
603  if(navState) RestoreSavedState();
604 }
void RestoreSavedState()
void G4ITNavigator::SetPushVerbosity ( G4bool  mode)
inline
void G4ITNavigator::SetSavedState ( )

Definition at line 621 of file G4ITNavigator.cc.

References fEnteredDaughter, fExitedMother, and fWasLimitedByGeometry.

Referenced by CheckNextStep(), ComputeSafety(), and GetNavigatorState().

622 {
623  // !>
624  // This check can be avoid if instead, at every first step of a track,
625  // the IT tracking uses NewNavigatorSate
626  // The normal tracking would just call once NewNavigatorState() before tracking
627 
628 // if(fpSaveState == 0)
629 // fpSaveState = new G4SaveNavigatorState;
630  // <!
631 
632  // fSaveExitNormal = fExitNormal;
633  fpSaveState->sExitNormal = fExitNormal;
634  fpSaveState->sValidExitNormal = fValidExitNormal;
635  fpSaveState->sExiting = fExiting;
636  fpSaveState->sEntering = fEntering;
637 
638  fpSaveState->spBlockedPhysicalVolume = fBlockedPhysicalVolume;
639  fpSaveState->sBlockedReplicaNo = fBlockedReplicaNo,
640 
641  fpSaveState->sLastStepWasZero = fLastStepWasZero;
642 
643  // !>
644  fpSaveState->sPreviousSftOrigin = fPreviousSftOrigin;
645  fpSaveState->sPreviousSafety = fPreviousSafety;
646  fpSaveState->sNumberZeroSteps = fNumberZeroSteps;
647  fpSaveState->sLocatedOnEdge = fLocatedOnEdge;
648  fpSaveState->sWasLimitedByGeometry= fWasLimitedByGeometry;
649  fpSaveState->sPushed=fPushed;
650  fpSaveState->sNumberZeroSteps=fNumberZeroSteps;
651  fpSaveState->sEnteredDaughter = fEnteredDaughter;
652  fpSaveState->sExitedMother = fExitedMother;
653 
654  fpSaveState->sLastLocatedPointLocal = fLastLocatedPointLocal;
655  fpSaveState->sLocatedOutsideWorld = fLocatedOutsideWorld;
656  // <!
657 }
G4bool fExitedMother
G4bool fEnteredDaughter
G4bool fWasLimitedByGeometry
void G4ITNavigator::SetupHierarchy ( )
protectedvirtual

Definition at line 1150 of file G4ITNavigator.cc.

References G4VSolid::ComputeDimensions(), G4VPVParameterisation::ComputeSolid(), G4VPVParameterisation::ComputeTransformation(), G4ReplicaNavigation::ComputeTransformation(), fHistory, G4NavigationHistory::GetDepth(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4NavigationHistory::GetReplicaNo(), G4NavigationHistory::GetVolume(), G4NavigationHistory::GetVolumeType(), kNormal, kParameterised, kReplica, G4TouchableHistory::MoveUpHistory(), G4LogicalVolume::SetSolid(), and G4LogicalVolume::UpdateMaterial().

Referenced by ResetHierarchyAndLocate().

1151 {
1152  G4int i;
1153  const G4int cdepth = fHistory.GetDepth();
1154  G4VPhysicalVolume *current;
1155  G4VSolid *pSolid;
1156  G4VPVParameterisation *pParam;
1157 
1158  for ( i=1; i<=cdepth; i++ )
1159  {
1160  current = fHistory.GetVolume(i);
1161  switch ( fHistory.GetVolumeType(i) )
1162  {
1163  case kNormal:
1164  break;
1165  case kReplica:
1166  freplicaNav.ComputeTransformation(fHistory.GetReplicaNo(i), current);
1167  break;
1168  case kParameterised:
1169  G4int replicaNo;
1170  pParam = current->GetParameterisation();
1171  replicaNo = fHistory.GetReplicaNo(i);
1172  pSolid = pParam->ComputeSolid(replicaNo, current);
1173 
1174  // Set up dimensions & transform in solid/physical volume
1175  //
1176  pSolid->ComputeDimensions(pParam, replicaNo, current);
1177  pParam->ComputeTransformation(replicaNo, current);
1178 
1179  G4TouchableHistory touchable( fHistory );
1180  touchable.MoveUpHistory(); // move up to the parent level
1181 
1182  // Set up the correct solid and material in Logical Volume
1183  //
1184  G4LogicalVolume *pLogical = current->GetLogicalVolume();
1185  pLogical->SetSolid( pSolid );
1186  pLogical->UpdateMaterial( pParam ->
1187  ComputeMaterial(replicaNo, current, &touchable) );
1188  break;
1189  }
1190  }
1191 }
void UpdateMaterial(G4Material *pMaterial)
virtual void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4VSolid.cc:137
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4int GetDepth() const
void SetSolid(G4VSolid *pSolid)
EVolume GetVolumeType(G4int n) const
void ComputeTransformation(const G4int replicaNo, G4VPhysicalVolume *pVol, G4ThreeVector &point) const
int G4int
Definition: G4Types.hh:78
virtual G4VPVParameterisation * GetParameterisation() const =0
G4int GetReplicaNo(G4int n) const
G4NavigationHistory fHistory
G4LogicalVolume * GetLogicalVolume() const
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
G4VPhysicalVolume * GetVolume(G4int n) const
void G4ITNavigator::SetVerboseLevel ( G4int  level)
inline
void G4ITNavigator::SetWorldVolume ( G4VPhysicalVolume pWorld)
inline
G4int G4ITNavigator::SeverityOfZeroStepping ( G4int noZeroSteps) const
inline
EVolume G4ITNavigator::VolumeType ( const G4VPhysicalVolume pVol) const
inlineprotected

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const G4ITNavigator n 
)
friend

Definition at line 1743 of file G4ITNavigator.cc.

1744 {
1745  os << "Current History: " << G4endl << n.fHistory;
1746  return os;
1747 }
G4NavigationHistory fHistory
#define G4endl
Definition: G4ios.hh:61

Field Documentation

G4bool G4ITNavigator::fEnteredDaughter
protected
G4bool G4ITNavigator::fExitedMother
protected
G4NavigationHistory G4ITNavigator::fHistory
protected
G4ThreeVector G4ITNavigator::fLastStepEndPointLocal
protected

Definition at line 385 of file G4ITNavigator.hh.

Referenced by ComputeStep(), G4ITNavigator(), and GetLocalExitNormal().

G4ThreeVector G4ITNavigator::fStepEndPoint
protected

Definition at line 382 of file G4ITNavigator.hh.

Referenced by ComputeSafety(), ComputeStep(), and G4ITNavigator().

G4int G4ITNavigator::fVerbose
protected
G4bool G4ITNavigator::fWasLimitedByGeometry
protected
G4double G4ITNavigator::kCarTolerance
protected

Definition at line 358 of file G4ITNavigator.hh.

Referenced by ComputeSafety(), ComputeStep(), G4ITNavigator(), and GetLocalExitNormal().


The documentation for this class was generated from the following files: