Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
+112 -132
View File
@@ -141,12 +141,12 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
G4ThreeVector localPoint, globalDirection;
EInside insideCode;
G4bool considerDirection = (!ignoreDirection) || fLocatedOnEdge;
G4bool considerDirection = pGlobalDirection && ((!ignoreDirection) || fLocatedOnEdge);
fLastTriedStepComputation = false;
fChangedGrandMotherRefFrame = false; // For local exit normal
if( considerDirection && pGlobalDirection != nullptr )
if( considerDirection )
{
globalDirection=*pGlobalDirection;
}
@@ -342,103 +342,96 @@ G4Navigator::LocateGlobalPointAndSetup( const G4ThreeVector& globalPoint,
}
}
if ( insideCode==kOutside )
{
++noLevelsExited;
if ( fHistory.GetDepth() )
{
fBlockedPhysicalVolume = fHistory.GetTopVolume();
fBlockedReplicaNo = fHistory.GetTopReplicaNo();
fHistory.BackLevel();
fExiting = false;
// Point is inside current volume, break out of the loop
if ( insideCode == kInside )
break;
if( noLevelsExited > 1 )
// Point is outside current volume, move up a level in the hierarchy
if ( insideCode == kOutside )
{
++noLevelsExited;
// Exiting world volume
if ( fHistory.GetDepth() == 0 )
{
fLocatedOutsideWorld = true;
fLastLocatedPointLocal = localPoint;
return nullptr;
}
fBlockedPhysicalVolume = fHistory.GetTopVolume();
fBlockedReplicaNo = fHistory.GetTopReplicaNo();
fHistory.BackLevel();
fExiting = false;
if( noLevelsExited > 1 )
{
// The first transformation was done by the sub-navigator
//
if(const auto *mRot = fBlockedPhysicalVolume->GetRotation())
{
// The first transformation was done by the sub-navigator
//
const G4RotationMatrix* mRot = fBlockedPhysicalVolume->GetRotation();
if( mRot )
{
fGrandMotherExitNormal *= (*mRot).inverse();
fChangedGrandMotherRefFrame = true;
}
fGrandMotherExitNormal *= (*mRot).inverse();
fChangedGrandMotherRefFrame = true;
}
}
else
continue;
}
// Point is on the surface of a volume
G4bool isExiting = fExiting;
if( (!fExiting) && considerDirection )
{
// Figure out whether we are exiting this level's volume
// by using the direction
//
G4bool directionExiting = false;
G4ThreeVector localDirection =
fHistory.GetTopTransform().TransformAxis(globalDirection);
// Make sure localPoint in correct reference frame
// ( Was it already correct ? How ? )
//
localPoint= fHistory.GetTopTransform().TransformPoint(globalPoint);
if ( fHistory.GetTopVolumeType() != kReplica )
{
fLastLocatedPointLocal = localPoint;
fLocatedOutsideWorld = true;
// No extra transformation for ExitNormal - is in frame of Top Volume
return nullptr; // Have exited world volume
G4ThreeVector normal = targetSolid->SurfaceNormal(localPoint);
directionExiting = normal.dot(localDirection) > 0.0;
isExiting = isExiting || directionExiting;
}
}
else
if ( insideCode==kSurface )
{
G4bool isExiting = fExiting;
if( (!fExiting) && considerDirection )
{
// Figure out whether we are exiting this level's volume
// by using the direction
//
G4bool directionExiting = false;
G4ThreeVector localDirection =
fHistory.GetTopTransform().TransformAxis(globalDirection);
// Make sure localPoint in correct reference frame
// ( Was it already correct ? How ? )
//
localPoint= fHistory.GetTopTransform().TransformPoint(globalPoint);
if ( fHistory.GetTopVolumeType() != kReplica )
{
G4ThreeVector normal = targetSolid->SurfaceNormal(localPoint);
directionExiting = normal.dot(localDirection) > 0.0;
isExiting = isExiting || directionExiting;
}
}
if( isExiting )
{
++noLevelsExited;
if ( fHistory.GetDepth() )
{
fBlockedPhysicalVolume = fHistory.GetTopVolume();
fBlockedReplicaNo = fHistory.GetTopReplicaNo();
fHistory.BackLevel();
//
// Still on surface but exited volume not necessarily convex
//
fValidExitNormal = false;
// Point is on a surface, but no longer exiting, break out of the loop
if ( !isExiting )
break;
if( noLevelsExited > 1 )
{
// The first transformation was done by the sub-navigator
//
const G4RotationMatrix* mRot =
fBlockedPhysicalVolume->GetRotation();
if( mRot )
{
fGrandMotherExitNormal *= (*mRot).inverse();
fChangedGrandMotherRefFrame = true;
}
}
}
else
{
fLastLocatedPointLocal = localPoint;
fLocatedOutsideWorld = true;
// No extra transformation for ExitNormal, is in frame of Top Vol
return nullptr; // Have exited world volume
}
}
else
{
notKnownContained = false;
}
}
else
++noLevelsExited;
// Point is on the outer surface, leaving world volume
if ( fHistory.GetDepth() == 0 )
{
fLocatedOutsideWorld = true;
fLastLocatedPointLocal = localPoint;
return nullptr;
}
// Point is still on a surface, but exited a volume not necessarily convex
fValidExitNormal = false;
fBlockedPhysicalVolume = fHistory.GetTopVolume();
fBlockedReplicaNo = fHistory.GetTopReplicaNo();
fHistory.BackLevel();
if( noLevelsExited > 1 )
{
// The first transformation was done by the sub-navigator
//
const G4RotationMatrix* mRot =
fBlockedPhysicalVolume->GetRotation();
if( mRot )
{
notKnownContained = false;
fGrandMotherExitNormal *= (*mRot).inverse();
fChangedGrandMotherRefFrame = true;
}
}
} // END while (notKnownContained)
//
// Search downwards until deepest containing volume found,
@@ -772,6 +765,11 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
const G4double pCurrentProposedStepLength,
G4double& pNewSafety)
{
#ifdef G4DEBUG_NAVIGATION
static G4ThreadLocal G4int sNavCScalls = 0;
++sNavCScalls;
#endif
G4ThreeVector localDirection = ComputeLocalAxis(pDirection);
G4double Step = kInfinity;
G4VPhysicalVolume *motherPhysical = fHistory.GetTopVolume();
@@ -787,11 +785,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
fCalculatedExitNormal = false;
// Reset for new step
static G4ThreadLocal G4int sNavCScalls = 0;
++sNavCScalls;
fLastTriedStepComputation = true;
#ifdef G4VERBOSE
if( fVerbose > 0 )
{
@@ -816,6 +809,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
#endif
G4ThreeVector newLocalPoint = ComputeLocalPoint(pGlobalpoint);
if( newLocalPoint != fLastLocatedPointLocal )
{
// Check whether the relocation is within safety
@@ -831,7 +825,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
// Relocate the point within the same volume
//
LocateGlobalPointWithinVolume( pGlobalpoint );
fLastTriedStepComputation = true; // Ensure that this is set again !!
}
}
if ( fHistory.GetTopVolumeType()!=kReplica )
@@ -873,7 +866,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
else // Regular (non-voxelised) structure
{
LocateGlobalPointAndSetup( pGlobalpoint, &pDirection, true, true );
fLastTriedStepComputation = true; // Ensure that this is set again!!
//
// if physical process limits the step, the voxel will not be the
// one given by ComputeStepSkippingEqualMaterials() and the local
@@ -974,8 +966,7 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
// In the case of a replica, it must handle the exiting
// edge/corner problem by itself
//
G4bool exitingReplica = fExitedMother;
G4bool calculatedExitNormal;
fExiting = fExitedMother;
Step = freplicaNav.ComputeStep(pGlobalpoint,
pDirection,
fLastLocatedPointLocal,
@@ -984,14 +975,12 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
pNewSafety,
fHistory,
fValidExitNormal,
calculatedExitNormal,
fCalculatedExitNormal,
fExitNormal,
exitingReplica,
fExiting,
fEntering,
&fBlockedPhysicalVolume,
fBlockedReplicaNo);
fExiting = exitingReplica;
fCalculatedExitNormal = calculatedExitNormal;
}
// Remember last safety origin & value.
@@ -1127,17 +1116,8 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
if ( fValidExitNormal || fCalculatedExitNormal )
{
if ( fHistory.GetTopVolumeType() != kReplica )
{
// Convention: fExitNormal is in the 'grand-mother' coordinate system
//
fGrandMotherExitNormal = fExitNormal;
fCalculatedExitNormal = true;
}
else
{
fGrandMotherExitNormal = fExitNormal;
}
// Convention: fExitNormal is in the 'grand-mother' coordinate system
fGrandMotherExitNormal = fExitNormal;
}
else
{
@@ -1168,8 +1148,6 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
// Do not set fValidExitNormal -- this signifies
// that the solid is convex!
//
fCalculatedExitNormal = true;
}
else
{
@@ -1195,6 +1173,9 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
}
}
if ( fHistory.GetTopVolumeType() != kReplica )
fCalculatedExitNormal = true;
// Now transform it to the global reference frame !!
//
if( fValidExitNormal || fCalculatedExitNormal )
@@ -1243,6 +1224,8 @@ G4double G4Navigator::ComputeStep( const G4ThreeVector& pGlobalpoint,
}
#endif
fLastTriedStepComputation = true;
return Step;
}
@@ -1328,27 +1311,22 @@ void G4Navigator::ResetState()
//
void G4Navigator::SetupHierarchy()
{
const G4int cdepth = fHistory.GetDepth();
G4VPhysicalVolume* current;
G4VSolid* pSolid;
G4VPVParameterisation* pParam;
for ( auto i=1; i<=cdepth; ++i )
const G4int depth = fHistory.GetDepth();
for ( auto i = 1; i <= depth; ++i )
{
current = fHistory.GetVolume(i);
switch ( fHistory.GetVolumeType(i) )
{
case kNormal:
case kExternal:
break;
case kReplica:
freplicaNav.ComputeTransformation(fHistory.GetReplicaNo(i), current);
freplicaNav.ComputeTransformation(fHistory.GetReplicaNo(i), fHistory.GetVolume(i));
break;
case kParameterised:
G4int replicaNo;
pParam = current->GetParameterisation();
replicaNo = fHistory.GetReplicaNo(i);
pSolid = pParam->ComputeSolid(replicaNo, current);
G4VPhysicalVolume* current = fHistory.GetVolume(i);
G4int replicaNo = fHistory.GetReplicaNo(i);
G4VPVParameterisation* pParam = current->GetParameterisation();
G4VSolid* pSolid = pParam->ComputeSolid(replicaNo, current);
// Set up dimensions & transform in solid/physical volume
//
@@ -1814,8 +1792,6 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector& pGlobalpoint,
const G4double pMaxLength,
const G4bool keepState)
{
G4double newSafety = 0.0;
#ifdef G4DEBUG_NAVIGATION
G4int oldcoutPrec = G4cout.precision(8);
if( fVerbose > 0 )
@@ -1849,12 +1825,17 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector& pGlobalpoint,
if( fExitedMother ) { G4cout << " and exited previous volume."; }
G4cout << G4endl;
G4cout << " EndPoint was = " << fStepEndPoint << G4endl;
G4cout << " ---- Exiting ComputeSafety " << G4endl;
PrintState();
G4cout << " Returned value of Safety is zero " << G4endl;
G4cout.precision(oldcoutPrec);
}
#endif
newSafety = 0.0;
return 0.0;
}
else // if( !(endpointOnSurface && stayedOnEndpoint) )
{
G4double newSafety = 0.0;
if (keepState) { SetSavedState(); }
// Pseudo-relocate to this point (updates voxel information only)
@@ -1933,7 +1914,6 @@ G4double G4Navigator::ComputeSafety( const G4ThreeVector& pGlobalpoint,
// We overwrite the Safety 'sphere' - keeping old behaviour
fPreviousSftOrigin = pGlobalpoint;
fPreviousSafety = newSafety;
}
#ifdef G4DEBUG_NAVIGATION
if( fVerbose > 1 )