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
+27 -22
View File
@@ -1,32 +1,37 @@
-------------------------------------------------------------------
# Category geomnav History
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top).
It must **not** be used as a substitute for writing good git commit messages!
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
-------------------------------------------------------------------------------
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2022-05-10 Guilherme Amadio (geomnav-V11-00-05)
- G4Navigator: minor improvements to ComputeSafety/ComputeStep/LocateGlobalPointAndSetup
March 3, 2022 - P.Arce (geomnav-V10-07-06)
-------------
- G4RegularNavigation: reset the zero step counter when a non-zero step was
performed, to avoid aborted events. Correct tabulation.
Fixes as proposed in [GitHub PR #38](https://github.com/Geant4/geant4/pull/38)
## 2022-03-11 Pedro Arce (geomnav-V11-00-04)
- `G4RegularNavigation`: reset the zero step counter when a non-zero step was performed, to avoid aborted events. Correct tabulation.
Fixes as proposed in [GitHub PR #38](https://github.com/Geant4/geant4/pull/38)
January 1, 2022 - G.Cosmo
-------------------------
- G4VIntersectionLocator: fixed compilation warning on Intel-icx compiler
## 2022-02-14 Sergio Losilla (geomnav-V11-00-03)
- /geometry/run/test also checks for overlaps in parallel worlds if
/geometry/run/check_parallel is set to true.
## 2022-01-08 Gabriele Cosmo (geomnav-V11-00-02)
- `G4VIntersectionLocator`: Fixed compilation warning on Intel-icx compiler
for unused data.
## 2022-01-05 Jonas Hahnfeld (geomnav-V11-00-01)
- `G4TransportationManager`: Add constant `kMassNavigatorId`
- `G4SafetyHelper`: Use it
## 2021-12-10 Ben Morgan (geomnav-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
September 25, 2021 - P.Arce (geomnav-V10-07-05)
----------------------------
- Reduce warning messages in GetReplicaNo: only when difference is > kCarTolerance
@@ -48,6 +48,8 @@ class G4UIcmdWithADoubleAndUnit;
class G4TransportationManager;
class G4GeomTestVolume;
#include <vector>
class G4GeometryMessenger : public G4UImessenger
{
public: // with description
@@ -70,16 +72,17 @@ class G4GeometryMessenger : public G4UImessenger
void RecursiveOverlapTest();
G4UIdirectory *geodir, *navdir, *testdir;
G4UIcmdWithABool *chkCmd, *pchkCmd, *verCmd;
G4UIcmdWithABool *chkCmd, *pchkCmd, *verCmd, *parCmd;
G4UIcmdWithoutParameter *recCmd, *resCmd;
G4UIcmdWithADoubleAndUnit *tolCmd;
G4UIcmdWithAnInteger *verbCmd, *rslCmd, *rcsCmd, *rcdCmd, *errCmd;
G4double tol = 0.0;
G4int recLevel = 0, recDepth = -1;
G4bool checkParallelWorlds = false;
G4TransportationManager* tmanager;
G4GeomTestVolume* tvolume = nullptr;
std::vector<G4GeomTestVolume*> tvolumes{};
};
#endif
@@ -92,7 +92,6 @@ class G4SafetyHelper
G4PathFinder* fpPathFinder = nullptr;
G4Navigator* fpMassNavigator = nullptr;
G4int fMassNavigatorId = -1;
G4bool fUseParallelGeometries = false;
// Flag whether to use PathFinder or single (mass) Navigator directly
@@ -153,6 +153,10 @@ class G4TransportationManager
static G4ThreadLocal G4TransportationManager* fTransportationManager;
static G4Navigator* fFirstTrackingNavigator;
public:
static constexpr G4int kMassNavigatorId = 0;
};
#include "G4TransportationManager.icc"
@@ -155,6 +155,12 @@ G4GeometryMessenger::G4GeometryMessenger(G4TransportationManager* tman)
errCmd->SetParameterName("maximum_errors",true);
errCmd->SetDefaultValue(1);
parCmd = new G4UIcmdWithABool( "/geometry/test/check_parallel", this );
parCmd->SetGuidance( "Check for overlaps in parallel worlds." );
parCmd->SetGuidance( "By default, overlaps are only checked in the mass world (FALSE)." );
parCmd->SetParameterName("check_parallel",true);
parCmd->SetDefaultValue(true);
recCmd = new G4UIcmdWithoutParameter( "/geometry/test/run", this );
recCmd->SetGuidance( "Start running the recursive overlap check." );
recCmd->SetGuidance( "Volumes are recursively asked to verify for overlaps" );
@@ -177,7 +183,9 @@ G4GeometryMessenger::~G4GeometryMessenger()
delete tolCmd;
delete verbCmd; delete pchkCmd; delete chkCmd;
delete geodir; delete navdir; delete testdir;
delete tvolume;
for(auto* tvolume: tvolumes) {
delete tvolume;
}
}
//
@@ -188,16 +196,18 @@ G4GeometryMessenger::Init()
{
// Create checker...
//
if (tvolume == nullptr)
if (tvolumes.empty())
{
// Get the world volume
// Get all world volumes
//
G4VPhysicalVolume* world =
tmanager->GetNavigatorForTracking()->GetWorldVolume();
// Test the actual detector...
//
tvolume = new G4GeomTestVolume(world);
const auto noWorlds = tmanager->GetNoWorlds();
const auto fWorld = tmanager->GetWorldsIterator();
for(size_t i=0;i<noWorlds;++i)
{
// Test the actual detector...
//
tvolumes.push_back(new G4GeomTestVolume(fWorld[i]));
}
}
}
@@ -223,15 +233,24 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
Init();
tol = tolCmd->GetNewDoubleValue( newValues )
* tolCmd->GetNewUnitValue( newValues );
tvolume->SetTolerance(tol);
for(auto* tvolume: tvolumes)
{
tvolume->SetTolerance(tol);
}
}
else if (command == verCmd) {
Init();
tvolume->SetVerbosity(verCmd->GetNewBoolValue( newValues ));
for(auto* tvolume: tvolumes)
{
tvolume->SetVerbosity(verCmd->GetNewBoolValue( newValues ));
}
}
else if (command == rslCmd) {
Init();
tvolume->SetResolution(rslCmd->GetNewIntValue( newValues ));
for(auto* tvolume: tvolumes)
{
tvolume->SetResolution(rslCmd->GetNewIntValue( newValues ));
}
}
else if (command == rcsCmd) {
recLevel = rcsCmd->GetNewIntValue( newValues );
@@ -241,7 +260,10 @@ G4GeometryMessenger::SetNewValue( G4UIcommand* command, G4String newValues )
}
else if (command == errCmd) {
Init();
tvolume->SetErrorsThreshold(errCmd->GetNewIntValue( newValues ));
for(auto* tvolume: tvolumes)
{
tvolume->SetErrorsThreshold(errCmd->GetNewIntValue( newValues ));
}
}
else if (command == recCmd) {
Init();
@@ -345,5 +367,15 @@ G4GeometryMessenger::RecursiveOverlapTest()
// Make test on single line supplied by user recursively
//
tvolume->TestRecursiveOverlap( recLevel, recDepth );
if (checkParallelWorlds)
{
for(auto* tvolume: tvolumes)
{
tvolume->TestRecursiveOverlap( recLevel, recDepth );
}
}
else
{
tvolumes.front()->TestRecursiveOverlap( recLevel, recDepth );
}
}
+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 )
@@ -58,8 +58,6 @@ void G4SafetyHelper::InitialiseNavigator()
"GeomNav0003", FatalException,
"Found that existing tracking Navigator has NULL world");
}
fMassNavigatorId = pTransportMgr->ActivateNavigator( fpMassNavigator );
}
void G4SafetyHelper::InitialiseHelper()