Import Geant4 11.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2025-06-26 09:17:29 +02:00
parent 20a218bbe1
commit a499fb82e9
1941 changed files with 203285 additions and 95593 deletions
@@ -27,16 +27,15 @@
//
// Class description:
//
// A class that provides an estimate of the isotropic safety - the
// minimum distance from a global point to the nearest boundary
// of the current volume or the nearest daughter volumes.
// This estimate can be an underestimate, either because a solid
// provides an underestimate (for speed) or in order to avoid
// substantial additional computations.
//
// A class that provides an estimate of the isotropic safety, the minimum
// distance from a global point to the nearest boundary of the current volume
// or the nearest daughter volumes.
// This estimate can be an underestimate, either because a solid provides an
// underestimate (for speed) or in order to avoid substantial additional
// computations.
// Obtains from the navigator the current transformation history.
// Author: John Apostolakis, CERN - February 2023
// Author: John Apostolakis (CERN), February 2023
// --------------------------------------------------------------------
#ifndef G4SafetyCalculator_HH
#define G4SafetyCalculator_HH 1
@@ -64,38 +63,61 @@
class G4VPhysicalVolume;
/**
* @brief G4SafetyCalculator is a class that provides an estimate of the
* isotropic safety (the minimum distance from a global point to the nearest
* boundary of the current volume or the nearest daughter volumes).
*/
class G4SafetyCalculator
{
public:
/**
* Constructor, initialisers and setup.
*/
G4SafetyCalculator( const G4Navigator& navigator,
const G4NavigationHistory& navHistory );
// Constructor - initialisers and setup.
/**
* Copy constructor & assignment operator not allowed.
*/
G4SafetyCalculator(const G4SafetyCalculator&) = delete;
G4SafetyCalculator& operator=(const G4SafetyCalculator&) = delete;
// Copy constructor & assignment operator not allowed.
/**
* Destructor. No actions.
*/
~G4SafetyCalculator() = default;
// Destructor. No actions.
/**
* Calculates the isotropic distance to the nearest boundary from the
* specified point in the global coordinate system.
* @param[in] globalPoint The point in global coordinates; it *must* be
* located exactly within the current volume (it also must
* *not* be in a daughter volume.
* @param[in] physicalVolume Current volume.
* @param[in] pProposedMaxLength The calculation will not look beyond
* the proposed maximum length to avoid extra volume safety
* calculations.
* @param[in] verbose Flag to enable verbosity (default is false).
* @returns An underestimate of the safety distance (and typically will be
* if complex volumes are involved.
*/
G4double SafetyInCurrentVolume(const G4ThreeVector& globalpoint,
G4VPhysicalVolume* physicalVolume,
const G4double pProposedMaxLength = DBL_MAX,
G4bool verbose = false );
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
// The globalpoint utilised *must* be located exactly within the
// current volume (it also must *not* be in a daughter volume).
// The value returned can be an underestimate (and typically will be
// if complex volumes are involved).
// The calculation will not look beyond the proposed maximum length
// to avoid extra volume safety calculations. The geometry must be closed.
/**
* Accessor & modifier for custom external navigation.
*/
G4VExternalNavigation* GetExternalNavigation() const;
void SetExternalNavigation(G4VExternalNavigation* externalNav);
// Accessor & modifier for custom external navigation.
/**
* Compares estimates of the safety, and reports if found difference(s).
*/
void CompareSafetyValues( G4double oldSafety,
G4double newValue,
G4VPhysicalVolume* motherPhysical,
@@ -104,56 +126,72 @@ class G4SafetyCalculator
G4double maxLength,
G4bool enteredVolume,
G4bool exitedVolume );
// Compare estimates of the safety, and report if difference(s) found.
protected:
/**
* Prepare state of sub-navigators by informing them of current point.
* @param[in] pointLocal Point in local coordinates.
* @param[in] motherPhysical Pointer to current volume where to relocate
* in case an external custom navigator is used.
*/
void QuickLocateWithinVolume(const G4ThreeVector& pointLocal,
G4VPhysicalVolume* motherPhysical);
// Prepare state of sub-navigators by informing them of current point.
G4VPhysicalVolume* motherPhysical);
/**
* Computes point in local coordinates system, given a position
* vector in world coordinate system.
* @param[in] rGlobPoint Point in global coordinates.
* @returns The point in local coordinates system.
*/
inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return position vector in local coordinate system, given a position
// vector in world coordinate system.
/**
* Computes the local direction of the specified vector in the reference
* system of the volume that was found by LocateGlobalPointAndSetup().
* @param[in] pVec Vector in global coordinates.
* @returns The local direction of the specified vector in global
* coordinates.
*/
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup().
// The Local Coordinates of point in world coordinate system.
/**
* Characterises the daughter of logical volume.
*/
inline EVolume CharacteriseDaughters(const G4LogicalVolume* pLog) const;
// Characterise daughter of logical volume.
/**
* Gets regular structure ID of first daughter.
*/
inline G4int GetDaughtersRegularStructureId(const G4LogicalVolume* pLv) const;
// Get regular structure ID of first daughter.
private:
// BEGIN -- Tracking Invariants part 1
//
// BEGIN -- Tracking Invariants part 1 ------------------------------------
/** Associated navigator. Needed for optimisation. */
const G4Navigator& fNavigator;
// Associated navigator. Needed for details of current state,
// for optimisation
/** Associated navigator's navigation history. Transformation and history
of the current path through the geometrical hierarchy. */
const G4NavigationHistory& fNavHistory;
// Associated navigator's navigation history. Transformation and history
// of the current path through the geometrical hierarchy.
//
// END -- Tracking Invariants part 1
// END -- Tracking Invariants part 1 ------------------------------------
/** Cached tolerance. */
G4double fkCarTolerance;
// Cached tolerance.
// BEGIN State information
//
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety = 0.0;
// Memory of last safety origin & value. Used in ComputeStep to ensure
// that origin of current Step is in the same volume as the point of the
// last relocation.
// BEGIN State information ------------------------------------------------
// Helpers/Utility classes - their state can change
//
/** Previous safety origin. */
G4ThreeVector fPreviousSftOrigin;
/** Memory of last safety origin & value. Used in ComputeStep() to ensure
that origin of current Step is in the same volume as the point of the
last relocation. */
G4double fPreviousSafety = 0.0;
/** Helpers/Utility classes - their state can change. */
G4NormalNavigation fnormalNav;
G4VoxelNavigation fvoxelNav;
G4ParameterisedNavigation fparamNav;
@@ -164,41 +202,7 @@ class G4SafetyCalculator
};
// Auxiliary inline methods -- copied from G4Navigator
// Return local coordinates given point in the world coord system.
//
inline G4ThreeVector
G4SafetyCalculator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
{
return fNavHistory.GetTopTransform().TransformPoint(pGlobalPoint);
}
// Returns local direction given vector direction in world coord system.
//
inline G4ThreeVector
G4SafetyCalculator::ComputeLocalAxis(const G4ThreeVector& pVec) const
{
return fNavHistory.GetTopTransform().TransformAxis(pVec);
}
inline EVolume
G4SafetyCalculator::CharacteriseDaughters(const G4LogicalVolume* pLog) const
{
return pLog->CharacteriseDaughters();
}
inline G4int
G4SafetyCalculator::GetDaughtersRegularStructureId(const G4LogicalVolume* pLog) const
{
G4int regId = 0;
G4VPhysicalVolume *pVol;
if ( pLog->GetNoDaughters() == 1 )
{
pVol = pLog->GetDaughter(0);
regId = pVol->GetRegularStructureId();
}
return regId;
}
#include "G4SafetyCalculator.icc"
#endif