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
@@ -34,17 +34,17 @@
// xSemiAxis semi-axis, x, without dimentions
// ySemiAxis semi-axis, y, without dimentions
// zheight height, z
// zTopCut upper cut plane level, z
// zTopCut upper cut plane level, z
//
// The height in Z corresponds to where the elliptical cone hits the
// The height in Z corresponds to where the elliptical cone hits the
// Z-axis if it had no Z cut. Also the cone is centered at zero having a
// base at zTopCut and another at -zTopCut. The semi-major axes at the Z=0
// plane are given by xSemiAxis*zheight and ySemiAxis*zheight so that the
// curved surface of our cone satisfies the equation:
// curved surface of our cone satisfies the equation:
//
// ***************************************************************************
// * *
// * (x/xSemiAxis)^2 + (y/ySemiAxis)^2 = (zheight - z)^2 *
// * (x/xSemiAxis)^2 + (y/ySemiAxis)^2 = (zheight - z)^2 *
// * *
// ***************************************************************************
//
@@ -52,7 +52,7 @@
// 1. halflength in Z = zTopCut
// 2. Dx and Dy = halflength of ellipse axis at z = -zTopCut
// 3. dx and dy = halflength of ellipse axis at z = zTopCut
// ! Attention : dx/dy=Dx/Dy
// ! Attention : dx/dy=Dx/Dy
//
// You need to find xSemiAxis,ySemiAxis and zheight:
//
@@ -87,7 +87,7 @@
class G4EllipticalCone : public G4VSolid
{
public:
G4EllipticalCone(const G4String& pName,
G4double pxSemiAxis,
G4double pySemiAxis,
@@ -97,21 +97,21 @@ class G4EllipticalCone : public G4VSolid
~G4EllipticalCone() override;
// Access functions
//
inline G4double GetSemiAxisMin () const;
inline G4double GetSemiAxisMax () const;
inline G4double GetSemiAxisX () const;
inline G4double GetSemiAxisY () const;
inline G4double GetZMax() const;
inline G4double GetZTopCut() const;
inline void SetSemiAxis (G4double x, G4double y, G4double z);
inline void SetZCut (G4double newzTopCut);
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
// Modifiers
void SetSemiAxis (G4double x, G4double y, G4double z);
void SetZCut (G4double newzTopCut);
// Solid standard methods
//
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
@@ -137,7 +137,7 @@ class G4EllipticalCone : public G4VSolid
G4double DistanceToOut(const G4ThreeVector& p) const override;
G4GeometryType GetEntityType() const override;
G4VSolid* Clone() const override;
G4ThreeVector GetPointOnSurface() const override;
@@ -145,37 +145,38 @@ class G4EllipticalCone : public G4VSolid
std::ostream& StreamInfo(std::ostream& os) const override;
// Visualisation functions
//
G4Polyhedron* GetPolyhedron () const override;
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4VisExtent GetExtent() const override;
G4Polyhedron* CreatePolyhedron() const override;
G4EllipticalCone(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4EllipticalCone(__void__&);
// Copy constructor and assignment operator
G4EllipticalCone(const G4EllipticalCone& rhs);
G4EllipticalCone& operator=(const G4EllipticalCone& rhs);
// Copy constructor and assignment operator.
G4EllipticalCone& operator=(const G4EllipticalCone& rhs);
protected:
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
private:
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector& p) const;
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
private:
G4double halfCarTol;
G4double fCubicVolume = 0.0;
G4double fSurfaceArea = 0.0;
G4double fMinZBaseArea = 0.0;
G4double fMaxZBaseArea = 0.0;
G4double xSemiAxis, ySemiAxis, zheight, zTopCut;
G4double cosAxisMin, invXX, invYY;
};
@@ -63,26 +63,3 @@ G4double G4EllipticalCone::GetZTopCut() const
{
return zTopCut;
}
inline
void G4EllipticalCone::SetSemiAxis (G4double newxSemiAxis,
G4double newySemiAxis,
G4double newzMax)
{
xSemiAxis = newxSemiAxis;
ySemiAxis = newySemiAxis;
zheight = newzMax;
if (zTopCut > +zheight) { zTopCut = +zheight; }
G4double axmin = std::min(xSemiAxis,ySemiAxis);
cosAxisMin = axmin/std::sqrt(1. + axmin*axmin);
invXX = 1/(xSemiAxis*xSemiAxis);
invYY = 1/(ySemiAxis*ySemiAxis);
fRebuildPolyhedron = true;
}
inline
void G4EllipticalCone::SetZCut (G4double newzTopCut)
{
zTopCut = std::min(newzTopCut,zheight);
fRebuildPolyhedron = true;
}
@@ -117,31 +117,33 @@ class G4EllipticalTube : public G4VSolid
inline G4double GetDx() const;
inline G4double GetDy() const;
inline G4double GetDz() const;
// Modifiers
//
inline void SetDx( G4double Dx );
inline void SetDy( G4double Dy );
inline void SetDz( G4double Dz );
G4EllipticalTube(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects
G4EllipticalTube(__void__&);
// Copy constructor and assignment operator
G4EllipticalTube(const G4EllipticalTube& rhs);
G4EllipticalTube& operator=(const G4EllipticalTube& rhs);
// Copy constructor and assignment operator
private:
// Check parameters and set pre-calculated values
void CheckParameters();
// Check parameters and set pre-calculated values
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
// Calculate surface area and cache it
G4double GetCachedSurfaceArea() const;
// Calculate surface area and cache it
private:
@@ -152,7 +154,7 @@ class G4EllipticalTube : public G4VSolid
G4double fDz; // half length in Z
G4double fCubicVolume = 0.0; // volume
G4double fSurfaceArea = 0.0; // surface area
G4double fSurfaceArea = 0.0; // surface area
// Cached pre-calculated values
G4double fRsph; // R of bounding sphere
@@ -50,7 +50,7 @@ void G4EllipticalTube::SetDx(G4double Dx)
fDx = Dx;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fSurfaceArea = GetCachedSurfaceArea();
fRebuildPolyhedron = true;
}
@@ -60,7 +60,7 @@ void G4EllipticalTube::SetDy( G4double Dy )
fDy = Dy;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fSurfaceArea = GetCachedSurfaceArea();
fRebuildPolyhedron = true;
}
@@ -70,6 +70,6 @@ void G4EllipticalTube::SetDz( G4double Dz )
fDz = Dz;
CheckParameters();
fCubicVolume = 0.;
fSurfaceArea = 0.;
fSurfaceArea = GetCachedSurfaceArea();
fRebuildPolyhedron = true;
}
@@ -95,11 +95,11 @@ class G4Hype : public G4VSolid
inline G4double GetInnerStereo () const;
inline G4double GetOuterStereo () const;
inline void SetInnerRadius (G4double newIRad);
inline void SetOuterRadius (G4double newORad);
inline void SetZHalfLength (G4double newHLZ);
inline void SetInnerStereo (G4double newISte);
inline void SetOuterStereo (G4double newOSte);
void SetInnerRadius (G4double newIRad);
void SetOuterRadius (G4double newORad);
void SetZHalfLength (G4double newHLZ);
void SetInnerStereo (G4double newISte);
void SetOuterStereo (G4double newOSte);
EInside Inside(const G4ThreeVector& p) const override;
@@ -158,10 +158,6 @@ class G4Hype : public G4VSolid
G4double r2, G4double tan2Phi, G4double s[2] );
// intersection with hyperbolic surface
private:
G4double asinh(G4double arg);
protected:
G4double innerRadius;
@@ -172,25 +168,27 @@ class G4Hype : public G4VSolid
// precalculated parameters, squared quantities
G4double tanInnerStereo;
G4double tanOuterStereo;
G4double tanInnerStereo; // tan of Inner Stereo angle
G4double tanOuterStereo; // tan of Outer Stereo angle
G4double tanInnerStereo2; // squared tan of Inner Stereo angle
G4double tanOuterStereo2; // squared tan of Outer Stereo angle
G4double innerRadius2; // squared Inner Radius
G4double outerRadius2; // squared Outer Radius
G4double endInnerRadius2; // squared endcap Inner Radius
G4double endOuterRadius2; // squared endcap Outer Radius
G4double endInnerRadius; // endcap Inner Radius
G4double endOuterRadius; // endcap Outer Radius
G4double endInnerRadius; // endcap Inner Radius
G4double endOuterRadius; // endcap Outer Radius
// Used by distanceToOut
enum ESide {outerFace,innerFace,leftCap, rightCap};
enum ESide { outerFace, innerFace, leftCap, rightCap };
private:
G4double fCubicVolume = 0.0;
G4double fSurfaceArea = 0.0;
G4double fInnerSurfaceArea = 0.0;
G4double fOuterSurfaceArea = 0.0;
G4double fHalfTol;
@@ -28,102 +28,48 @@
inline
G4double G4Hype::GetInnerRadius () const
{
return innerRadius;
}
{
return innerRadius;
}
inline
G4double G4Hype::GetOuterRadius () const
{
return outerRadius;
}
G4double G4Hype::GetOuterRadius() const
{
return outerRadius;
}
inline
G4double G4Hype::GetZHalfLength () const
{
return halfLenZ;
}
G4double G4Hype::GetZHalfLength() const
{
return halfLenZ;
}
inline
G4double G4Hype::GetInnerStereo () const
{
return innerStereo;
}
G4double G4Hype::GetInnerStereo() const
{
return innerStereo;
}
inline
G4double G4Hype::GetOuterStereo () const
{
return outerStereo;
}
inline
void G4Hype::SetInnerRadius (G4double newIRad)
{
innerRadius = newIRad;
innerRadius2 = newIRad*newIRad;
endInnerRadius2 = HypeInnerRadius2(halfLenZ);
endInnerRadius = std::sqrt(endInnerRadius2);
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
inline
void G4Hype::SetOuterRadius (G4double newORad)
{
outerRadius = newORad;
outerRadius2 = newORad*newORad;
endOuterRadius2 = HypeOuterRadius2(halfLenZ);
endOuterRadius = std::sqrt(endOuterRadius2);
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
inline
void G4Hype::SetZHalfLength (G4double newHLZ)
{
halfLenZ = newHLZ ;
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
inline
void G4Hype::SetInnerStereo (G4double newISte)
{
innerStereo = std::fabs(newISte);
tanInnerStereo = std::tan(innerStereo);
tanInnerStereo2 = tanInnerStereo*tanInnerStereo;
endInnerRadius2 = HypeInnerRadius2(halfLenZ);
endInnerRadius = std::sqrt(endInnerRadius2);
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
inline
void G4Hype::SetOuterStereo (G4double newOSte)
{
outerStereo = std::fabs(newOSte);
tanOuterStereo = std::tan(outerStereo);
tanOuterStereo2 = tanOuterStereo*tanOuterStereo;
endOuterRadius2 = HypeOuterRadius2(halfLenZ);
endOuterRadius = std::sqrt(endOuterRadius2);
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
G4double G4Hype::GetOuterStereo() const
{
return outerStereo;
}
inline
G4bool G4Hype::InnerSurfaceExists() const
{
return (innerRadius > DBL_MIN) || (innerStereo != 0);
}
{
return (endInnerRadius2 > 0.);
}
inline
G4double G4Hype::HypeInnerRadius2(G4double zVal) const
{
return (tanInnerStereo2*zVal*zVal+innerRadius2);
}
{
return (tanInnerStereo2*zVal*zVal + innerRadius2);
}
inline
G4double G4Hype::HypeOuterRadius2(G4double zVal) const
{
return (tanOuterStereo2*zVal*zVal+outerRadius2);
}
{
return (tanOuterStereo2*zVal*zVal + outerRadius2);
}
@@ -76,23 +76,16 @@ class G4Paraboloid : public G4VSolid
~G4Paraboloid() override;
// Access functions
inline G4double GetZHalfLength() const;
inline G4double GetRadiusMinusZ() const;
inline G4double GetRadiusPlusZ() const;
inline G4double GetCubicVolume() override;
inline G4double GetSurfaceArea() override;
inline G4double CalculateSurfaceArea() const;
// Modifiers functions
inline void SetZHalfLength(G4double dz);
inline void SetRadiusMinusZ(G4double R1);
inline void SetRadiusPlusZ(G4double R2);
void SetZHalfLength(G4double dz);
void SetRadiusMinusZ(G4double R1);
void SetRadiusPlusZ(G4double R2);
// Solid standard methods
void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const override;
G4bool CalculateExtent(const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
@@ -116,42 +109,45 @@ class G4Paraboloid : public G4VSolid
std::ostream& StreamInfo(std::ostream& os) const override;
G4double GetCubicVolume() override;
G4double GetSurfaceArea() override;
G4ThreeVector GetPointOnSurface() const override;
// Visualisation functions
void DescribeYourselfTo(G4VGraphicsScene& scene) const override;
G4Polyhedron* CreatePolyhedron() const override;
G4Polyhedron* GetPolyhedron () const override;
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
G4Paraboloid(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
// persistifiable objects.
// Copy constructor and assignment operator.
G4Paraboloid(const G4Paraboloid& rhs);
G4Paraboloid& operator=(const G4Paraboloid& rhs);
// Copy constructor and assignment operator.
protected:
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
private:
// Making this mutable to allow GetPointOnSurface to have access to
// area function.
mutable G4double fSurfaceArea = 0.0;
G4double CalculateSurfaceArea() const;
G4double fSurfaceArea = 0.0;
G4double fCubicVolume = 0.0;
G4double dz, r1, r2;
G4double k1, k2;
// Defined to make some calculations easier to follow
// Cached values
G4double dz = 0.0; // half height
G4double r1 = 0.0; // radius at -dz
G4double r2 = 0.0; // radius at dz
G4double k1 = 0.0; // k1 = 0.5*(r2*r2 - r1*r1)/dz
G4double k2 = 0.0; // k2 = 0.5*(r2*r2 + r1*r1)
mutable G4bool fRebuildPolyhedron = false;
mutable G4Polyhedron* fpPolyhedron = nullptr;
};
#include "G4Paraboloid.icc"
#endif // defined(G4GEOM_USE_UPARABOLOID) && defined(G4GEOM_USE_SYS_USOLIDS)
#endif // G4Paraboloid_HH
#endif // G4PARABOLOID_HH
@@ -26,13 +26,13 @@
// Implementation of inline methods of G4Paraboloid
// --------------------------------------------------------------------
inline
inline
G4double G4Paraboloid::GetZHalfLength() const
{
return dz;
}
inline
inline
G4double G4Paraboloid::GetRadiusPlusZ() const
{
return r2;
@@ -43,121 +43,3 @@ G4double G4Paraboloid::GetRadiusMinusZ() const
{
return r1;
}
inline
void G4Paraboloid::SetZHalfLength(G4double pDz)
{
if(pDz <= 0)
{
G4Exception("G4Paraboloid::SetZHalfLength()", "GeomSolids0002",
FatalException, "Invalid dimensions.");
}
else
{
dz = pDz;
k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
k2 = (sqr(r2) + sqr(r1)) / 2;
// This informs GetSurfaceArea() and GetCubicVolume() that it needs
// to recalculate buffered value.
//
fSurfaceArea = 0.;
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
}
inline
void G4Paraboloid::SetRadiusPlusZ(G4double pR2)
{
if(pR2 <= 0 || pR2 <= r1)
{
G4Exception("G4Paraboloid::SetRadiusPlusZ()", "GeomSolids0002",
FatalException, "Invalid dimensions.");
}
else
{
r2 = pR2;
k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
k2 = (sqr(r2) + sqr(r1)) / 2;
// This informs GetSurfaceArea() and GetCubicVolume() that it needs
// to recalculate buffered value.
//
fSurfaceArea = 0.;
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
}
inline
void G4Paraboloid::SetRadiusMinusZ(G4double pR1)
{
if(pR1 < 0 || pR1 >= r2)
{
G4Exception("G4Paraboloid::SetRadiusMinusZ()", "GeomSolids0002",
FatalException, "Invalid dimensions.");
}
else
{
r1 = pR1;
k1 = (sqr(r2) - sqr(r1)) / (2 * dz);
k2 = (sqr(r2) + sqr(r1)) / 2;
// This informs GetSurfaceArea() and GetCubicVolume() that it needs
// to recalculate buffered value.
//
fSurfaceArea = 0.;
fCubicVolume = 0.;
fRebuildPolyhedron = true;
}
}
inline
G4double G4Paraboloid::GetCubicVolume()
{
if(fCubicVolume != 0. ) {;}
else
{
fCubicVolume = CLHEP::twopi * k2 * dz;
}
return fCubicVolume;
}
inline
G4double G4Paraboloid::CalculateSurfaceArea() const
{
G4double h1, h2, A1, A2;
h1 = k2/k1 + dz;
h2 = k2/k1 - dz;
// Calculate surface area for the paraboloid full paraboloid
// cutoff at z = dz (not the cutoff area though).
A1 = sqr(r2) + 4 * sqr(h1);
A1 *= sqr(A1); // Sets A1 = A1^3
A1 = CLHEP::pi * r2 /6 / sqr(h1) * ( std::sqrt(A1) - r2 * r2 * r2);
// Calculate surface area for the paraboloid full paraboloid
// cutoff at z = -dz (not the cutoff area though).
A2 = sqr(r1) + 4 * sqr(h2);
A2 *= sqr(A2);// Sets A2 = A2^3
if(h2 != 0)
{ A2 = CLHEP::pi * r1 /6 / sqr(h2) * ( std::sqrt(A2) - r1 * r1 * r1); }
else
{ A2 = 0.; }
return fSurfaceArea = A1 - A2 + (sqr(r1) + sqr(r2))*CLHEP::pi;
}
inline
G4double G4Paraboloid::GetSurfaceArea()
{
if(fSurfaceArea == 0.) CalculateSurfaceArea();
return fSurfaceArea;
}