Skip to content
Snippets Groups Projects
Commit edb68473 authored by John Chapman's avatar John Chapman
Browse files

Optimizations for `G4Trd` from Evgueni Tcherniaev

These changes will lead to a change in the physics history because
in addition to optimisation, some improvements have been made to
make `G4Trd` consistent with `G4Trap`. So, any measurement of the
performance should be done with high statistics to reduce possible
influence of the change in the physics history. See ATLASSIM-3353
parent 3a51360e
No related branches found
No related tags found
No related merge requests found
......@@ -100,10 +100,14 @@ class G4Trd : public G4CSGSolid
inline void SetYHalfLength2(G4double val);
inline void SetZHalfLength(G4double val);
void SetAllParameters ( G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz );
// Methods of solid
inline G4double GetCubicVolume();
inline G4double GetSurfaceArea();
G4double GetCubicVolume();
G4double GetSurfaceArea();
void ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
......@@ -131,14 +135,6 @@ class G4Trd : public G4CSGSolid
G4double DistanceToOut( const G4ThreeVector& p ) const;
void CheckAndSetAllParameters ( G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz );
void SetAllParameters ( G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz );
G4GeometryType GetEntityType() const;
G4ThreeVector GetPointOnSurface() const;
......@@ -154,9 +150,6 @@ class G4Trd : public G4CSGSolid
public: // without description
enum ESide {kUndefined, kPX,kMX,kPY,kMY,kPZ,kMZ};
// Codes for faces (kPX=plus x face,kMY= minus y face etc)
G4Trd(__void__&);
// Fake default constructor for usage restricted to direct object
// persistency for clients requiring preallocation of memory for
......@@ -172,13 +165,23 @@ class G4Trd : public G4CSGSolid
// Creates the List of transformed vertices in the format required
// for G4CSGSolid:: ClipCrossSection and ClipBetweenSections
private:
void CheckParameters();
// Check parameters
void MakePlanes();
// Set side planes
G4ThreeVector ApproxSurfaceNormal( const G4ThreeVector& p ) const;
// Algorithm for SurfaceNormal() following the original
// specification for points not on the surface
private:
G4double halfCarTolerance;
G4double fDx1,fDx2,fDy1,fDy2,fDz;
struct { G4double a,b,c,d; } fPlanes[4];
};
#include "G4Trd.icc"
......
......@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Trd.icc 83572 2014-09-01 15:23:27Z gcosmo $
// $Id: G4Trd.icc 104354 2017-05-26 07:56:20Z evc $
//
// --------------------------------------------------------------------
// GEANT 4 inline definitions file
......@@ -67,69 +67,29 @@ G4double G4Trd::GetZHalfLength() const
inline
void G4Trd::SetXHalfLength1(G4double val)
{
fDx1= val;
fCubicVolume= 0.;
fSurfaceArea=0;
fRebuildPolyhedron = true;
SetAllParameters(val,fDx2,fDy1,fDy2,fDz);
}
inline
void G4Trd::SetXHalfLength2(G4double val)
{
fDx2= val;
fCubicVolume= 0.;
fSurfaceArea=0;
fRebuildPolyhedron = true;
SetAllParameters(fDx1,val,fDy1,fDy2,fDz);
}
inline
void G4Trd::SetYHalfLength1(G4double val)
{
fDy1= val;
fCubicVolume= 0.;
fSurfaceArea=0;
fRebuildPolyhedron = true;
SetAllParameters(fDx1,fDx2,val,fDy2,fDz);
}
inline
void G4Trd::SetYHalfLength2(G4double val)
{
fDy2= val;
fCubicVolume= 0.;
fSurfaceArea=0;
fRebuildPolyhedron = true;
SetAllParameters(fDx1,fDx2,fDy1,val,fDz);
}
inline
void G4Trd::SetZHalfLength(G4double val)
{
fDz= val;
fCubicVolume= 0.;
fSurfaceArea=0;
fRebuildPolyhedron = true;
}
inline
G4double G4Trd::GetCubicVolume()
{
if(fCubicVolume != 0.) {;}
else
{
fCubicVolume = 2*fDz*( (fDx1+fDx2)*(fDy1+fDy2)
+ (fDx2-fDx1)*(fDy2-fDy1)/3 );
}
return fCubicVolume;
}
inline
G4double G4Trd::GetSurfaceArea()
{
if(fSurfaceArea != 0.) {;}
else
{
fSurfaceArea = 4*(fDx1*fDy1+fDx2*fDy2)
+ 2*((fDy1+fDy2)*std::sqrt(4*fDz*fDz+(fDx2-fDx1)*(fDx2-fDx1))
+ (fDx1+fDx2) *std::sqrt(4*fDz*fDz+(fDy2-fDy1)*(fDy2-fDy1)) );
}
return fSurfaceArea;
SetAllParameters(fDx1,fDx2,fDy1,fDy2,val);
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment