Import Geant4 7.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 11:11:55 +02:00
parent e083ffb441
commit 516dbf1a58
5914 changed files with 202605 additions and 71141 deletions
+32 -26
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Box.cc,v 1.26 2004/01/26 09:03:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Box.cc,v 1.28.2.1 2004/12/02 09:30:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
//
//
//
@@ -100,6 +100,8 @@ void G4Box::SetXHalfLength(G4double dx)
G4Exception("G4Box::SetXHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
fCubicVolume= 0.;
fpPolyhedron = 0;
}
void G4Box::SetYHalfLength(G4double dy)
@@ -114,6 +116,8 @@ void G4Box::SetYHalfLength(G4double dy)
G4Exception("G4Box::SetYHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
fCubicVolume= 0.;
fpPolyhedron = 0;
}
void G4Box::SetZHalfLength(G4double dz)
@@ -128,6 +132,8 @@ void G4Box::SetZHalfLength(G4double dz)
G4Exception("G4Box::SetZHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
fCubicVolume= 0.;
fpPolyhedron = 0;
}
@@ -334,23 +340,23 @@ EInside G4Box::Inside(const G4ThreeVector& p) const
{
EInside in = kOutside ;
if ( fabs(p.x()) <= fDx - kCarTolerance*0.5 )
if ( std::fabs(p.x()) <= fDx - kCarTolerance*0.5 )
{
if (fabs(p.y()) <= fDy - kCarTolerance*0.5 )
if (std::fabs(p.y()) <= fDy - kCarTolerance*0.5 )
{
if (fabs(p.z()) <= fDz - kCarTolerance*0.5 ) in = kInside ;
else if (fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
if (std::fabs(p.z()) <= fDz - kCarTolerance*0.5 ) in = kInside ;
else if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
}
else if (fabs(p.y()) <= fDy + kCarTolerance*0.5 )
else if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 )
{
if (fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5 ) in = kSurface ;
}
}
else if (fabs(p.x()) <= fDx + kCarTolerance*0.5 )
else if (std::fabs(p.x()) <= fDx + kCarTolerance*0.5 )
{
if (fabs(p.y()) <= fDy + kCarTolerance*0.5 )
if (std::fabs(p.y()) <= fDy + kCarTolerance*0.5 )
{
if (fabs(p.z()) <= fDz + kCarTolerance*0.5) in = kSurface ;
if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5) in = kSurface ;
}
}
return in ;
@@ -369,9 +375,9 @@ G4ThreeVector G4Box::SurfaceNormal( const G4ThreeVector& p) const
// Calculate distances as if in 1st octant
distx = fabs(fabs(p.x()) - fDx) ;
disty = fabs(fabs(p.y()) - fDy) ;
distz = fabs(fabs(p.z()) - fDz) ;
distx = std::fabs(std::fabs(p.x()) - fDx) ;
disty = std::fabs(std::fabs(p.y()) - fDy) ;
distz = std::fabs(std::fabs(p.z()) - fDz) ;
if ( distx <= disty )
{
@@ -431,9 +437,9 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) cons
G4double stmp ;
G4double sOut=kInfinity, sOuty=kInfinity, sOutz=kInfinity ;
safx = fabs(p.x()) - fDx ; // minimum distance to x surface of shape
safy = fabs(p.y()) - fDy ;
safz = fabs(p.z()) - fDz ;
safx = std::fabs(p.x()) - fDx ; // minimum distance to x surface of shape
safy = std::fabs(p.y()) - fDy ;
safz = std::fabs(p.z()) - fDz ;
// Will we intersect?
// If safx/y/z is >-tol/2 the point is outside/on the box's x/y/z extent.
@@ -452,12 +458,12 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) cons
if ( v.x())
{
stmp = 1.0/fabs(v.x()) ;
stmp = 1.0/std::fabs(v.x()) ;
if (safx >= 0.0)
{
smin = safx*stmp ;
smax = (fDx+fabs(p.x()))*stmp ;
smax = (fDx+std::fabs(p.x()))*stmp ;
}
else
{
@@ -470,12 +476,12 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) cons
if ( v.y())
{
stmp = 1.0/fabs(v.y()) ;
stmp = 1.0/std::fabs(v.y()) ;
if (safy >= 0.0)
{
sminy = safy*stmp ;
smaxy = (fDy+fabs(p.y()))*stmp ;
smaxy = (fDy+std::fabs(p.y()))*stmp ;
if (sminy > smin) smin=sminy ;
if (smaxy < smax) smax=smaxy ;
@@ -497,12 +503,12 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p,const G4ThreeVector& v) cons
if ( v.z() )
{
stmp = 1.0/fabs(v.z()) ;
stmp = 1.0/std::fabs(v.z()) ;
if ( safz >= 0.0)
{
sminz = safz*stmp ;
smaxz = (fDz+fabs(p.z()))*stmp ;
smaxz = (fDz+std::fabs(p.z()))*stmp ;
if (sminz > smin) smin = sminz ;
if (smaxz < smax) smax = smaxz ;
@@ -540,9 +546,9 @@ G4double G4Box::DistanceToIn(const G4ThreeVector& p) const
{
G4double safex, safey, safez, safe = 0.0 ;
safex = fabs(p.x()) - fDx ;
safey = fabs(p.y()) - fDy ;
safez = fabs(p.z()) - fDz ;
safex = std::fabs(p.x()) - fDx ;
safey = std::fabs(p.y()) - fDy ;
safez = std::fabs(p.z()) - fDz ;
if (safex > safe) safe = safex ;
if (safey > safe) safe = safey ;
+12 -3
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4CSGSolid.cc,v 1.6 2003/11/03 18:17:31 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4CSGSolid.cc,v 1.9 2004/10/13 13:14:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
// --------------------------------------------------------------------
@@ -32,7 +32,7 @@
// - Base class constructor
G4CSGSolid::G4CSGSolid(const G4String& name) :
G4VSolid(name)
G4VSolid(name), fCubicVolume(0.), fpPolyhedron(0)
{
}
@@ -52,3 +52,12 @@ std::ostream& G4CSGSolid::StreamInfo(std::ostream& os) const
return os;
}
G4Polyhedron* G4CSGSolid::GetPolyhedron () const
{
if (!fpPolyhedron)
{
fpPolyhedron = CreatePolyhedron();
}
return fpPolyhedron;
}
+139 -134
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Cons.cc,v 1.31 2004/01/26 09:03:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Cons.cc,v 1.34 2004/12/10 16:22:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-05 $
//
// class G4Cons
//
@@ -30,6 +30,7 @@
//
// History:
//
// 26.07.04 V.Grichine: bugs fixed in Distance ToIn(p,v):dIn=dOut=0 in 3/10^8
// 23.01.04 V.Grichine: bugs fixed in Distance ToIn(p,v)
// 26.06.02 V.Grichine: bugs fixed in Distance ToIn(p,v)
// 05.10.00 V.Grichine: bugs fixed in Distance ToIn(p,v)
@@ -125,9 +126,9 @@ G4Cons::G4Cons( const G4String& pName,
// Check angles
if ( pDPhi >= 2.0*M_PI )
if ( pDPhi >= twopi )
{
fDPhi=2*M_PI;
fDPhi=twopi;
fSPhi=0;
}
else
@@ -144,10 +145,10 @@ G4Cons::G4Cons( const G4String& pName,
// Ensure pSPhi in 0-2PI or -2PI-0 range if shape crosses 0
if ( pSPhi < 0 ) fSPhi = 2.0*M_PI - fmod(fabs(pSPhi),2.0*M_PI) ;
else fSPhi = fmod(pSPhi,2.0*M_PI) ;
if ( pSPhi < 0 ) fSPhi = twopi - std::fmod(std::fabs(pSPhi),twopi) ;
else fSPhi = std::fmod(pSPhi,twopi) ;
if (fSPhi + fDPhi > 2.0*M_PI) fSPhi -= 2.0*M_PI ;
if (fSPhi + fDPhi > twopi) fSPhi -= twopi ;
}
}
@@ -160,8 +161,8 @@ EInside G4Cons::Inside(const G4ThreeVector& p) const
G4double r2, rl, rh, pPhi, tolRMin, tolRMax ;
EInside in;
if (fabs(p.z()) > fDz + kCarTolerance*0.5 ) return in = kOutside;
else if(fabs(p.z()) >= fDz - kCarTolerance*0.5 ) in = kSurface;
if (std::fabs(p.z()) > fDz + kCarTolerance*0.5 ) return in = kOutside;
else if(std::fabs(p.z()) >= fDz - kCarTolerance*0.5 ) in = kSurface;
else in = kInside;
r2 = p.x()*p.x() + p.y()*p.y() ;
@@ -182,13 +183,13 @@ EInside G4Cons::Inside(const G4ThreeVector& p) const
{
if (r2 < tolRMin*tolRMin || r2 >= tolRMax*tolRMax) in = kSurface;
}
if ( ( fDPhi < 2*M_PI - kAngTolerance ) &&
if ( ( fDPhi < twopi - kAngTolerance ) &&
( (p.x() != 0.0 ) || (p.y() != 0.0) ) )
{
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < fSPhi - kAngTolerance*0.5 ) pPhi += 2*M_PI ;
else if ( pPhi > fSPhi + fDPhi + kAngTolerance*0.5 ) pPhi -= 2*M_PI;
if ( pPhi < fSPhi - kAngTolerance*0.5 ) pPhi += twopi ;
else if ( pPhi > fSPhi + fDPhi + kAngTolerance*0.5 ) pPhi -= twopi;
if ( (pPhi < fSPhi - kAngTolerance*0.5) ||
(pPhi > fSPhi + fDPhi + kAngTolerance*0.5) ) return in = kOutside;
@@ -199,7 +200,7 @@ EInside G4Cons::Inside(const G4ThreeVector& p) const
(pPhi > fSPhi + fDPhi - kAngTolerance*0.5) ) in = kSurface ;
}
}
else if( fDPhi < 2*M_PI - kAngTolerance ) in = kSurface ;
else if( fDPhi < twopi - kAngTolerance ) in = kSurface ;
return in ;
}
@@ -228,7 +229,7 @@ G4bool G4Cons::CalculateExtent( const EAxis pAxis,
G4double& pMax ) const
{
if ( !pTransform.IsRotated() &&
fDPhi == 2.0*M_PI && fRmin1 == 0 && fRmin2 == 0 )
fDPhi == twopi && fRmin1 == 0 && fRmin2 == 0 )
{
// Special case handling for unrotated solid cones
// Compute z/x/y mins and maxs for bounding box respecting limits,
@@ -331,8 +332,8 @@ G4bool G4Cons::CalculateExtent( const EAxis pAxis,
// Y limits don't cross max/min x => compute max delta x,
// hence new mins/maxs
diff1 = sqrt(RMax*RMax - yoff1*yoff1) ;
diff2 = sqrt(RMax*RMax - yoff2*yoff2) ;
diff1 = std::sqrt(RMax*RMax - yoff1*yoff1) ;
diff2 = std::sqrt(RMax*RMax - yoff2*yoff2) ;
maxDiff = (diff1>diff2) ? diff1:diff2 ;
newMin = xoffset - maxDiff ;
newMax = xoffset + maxDiff ;
@@ -355,8 +356,8 @@ G4bool G4Cons::CalculateExtent( const EAxis pAxis,
// X limits don't cross max/min y => compute max delta y,
// hence new mins/maxs
diff1 = sqrt(RMax*RMax - xoff1*xoff1) ;
diff2 = sqrt(RMax*RMax-xoff2*xoff2) ;
diff1 = std::sqrt(RMax*RMax - xoff1*xoff1) ;
diff2 = std::sqrt(RMax*RMax-xoff2*xoff2) ;
maxDiff = (diff1 > diff2) ? diff1:diff2 ;
newMin = yoffset - maxDiff ;
newMax = yoffset + maxDiff ;
@@ -446,20 +447,20 @@ G4ThreeVector G4Cons::SurfaceNormal( const G4ThreeVector& p) const
G4double tanRMin, secRMin, pRMin, widRMin ;
G4double tanRMax, secRMax, pRMax, widRMax ;
distZ = fabs(fabs(p.z()) - fDz) ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
distZ = std::fabs(std::fabs(p.z()) - fDz) ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
tanRMin = (fRmin2 - fRmin1)*0.5/fDz ;
secRMin = sqrt(1 + tanRMin*tanRMin) ;
secRMin = std::sqrt(1 + tanRMin*tanRMin) ;
pRMin = rho - p.z()*tanRMin ;
widRMin = fRmin2 - fDz*tanRMin ;
distRMin = fabs(pRMin - widRMin)/secRMin ;
distRMin = std::fabs(pRMin - widRMin)/secRMin ;
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1+tanRMax*tanRMax) ;
secRMax = std::sqrt(1+tanRMax*tanRMax) ;
pRMax = rho - p.z()*tanRMax ;
widRMax = fRmax2 - fDz*tanRMax ;
distRMax = fabs(pRMax - widRMax)/secRMax ;
distRMax = std::fabs(pRMax - widRMax)/secRMax ;
if (distRMin < distRMax) // First minimum
{
@@ -487,16 +488,16 @@ G4ThreeVector G4Cons::SurfaceNormal( const G4ThreeVector& p) const
side = kNRMax ;
}
}
if ( fDPhi < 2.0*M_PI && rho ) // Protected against (0,0,z)
if ( fDPhi < twopi && rho ) // Protected against (0,0,z)
{
phi = atan2(p.y(),p.x()) ;
phi = std::atan2(p.y(),p.x()) ;
if (phi < 0) phi += 2*M_PI ;
if (phi < 0) phi += twopi ;
if (fSPhi < 0) distSPhi = fabs(phi - (fSPhi + 2.0*M_PI))*rho ;
else distSPhi = fabs(phi - fSPhi)*rho ;
if (fSPhi < 0) distSPhi = std::fabs(phi - (fSPhi + twopi))*rho ;
else distSPhi = std::fabs(phi - fSPhi)*rho ;
distEPhi = fabs(phi - fSPhi - fDPhi)*rho ;
distEPhi = std::fabs(phi - fSPhi - fDPhi)*rho ;
// Find new minimum
@@ -524,10 +525,10 @@ G4ThreeVector G4Cons::SurfaceNormal( const G4ThreeVector& p) const
else norm = G4ThreeVector(0,0,-1) ;
break ;
case kNSPhi:
norm = G4ThreeVector(sin(fSPhi),-cos(fSPhi),0) ;
norm = G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0) ;
break ;
case kNEPhi:
norm=G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0) ;
norm=G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0) ;
break ;
default:
DumpInfo();
@@ -592,24 +593,24 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
//
// Set phi divided flag and precalcs
//
if (fDPhi < 2.0*M_PI)
if (fDPhi < twopi)
{
seg = true ;
hDPhi = 0.5*fDPhi ; // half delta phi
cPhi = fSPhi + hDPhi ; ;
hDPhiOT = hDPhi + 0.5*kAngTolerance ; // outers tol' half delta phi
hDPhiIT = hDPhi - 0.5*kAngTolerance ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
cosHDPhiOT = cos(hDPhiOT) ;
cosHDPhiIT = cos(hDPhiIT) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
cosHDPhiOT = std::cos(hDPhiOT) ;
cosHDPhiIT = std::cos(hDPhiIT) ;
}
else seg = false ;
// Cone Precalcs
tanRMin = (fRmin2 - fRmin1)*0.5/fDz ;
secRMin = sqrt(1.0 + tanRMin*tanRMin) ;
secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
rMinAv = (fRmin1 + fRmin2)*0.5 ;
if (rMinAv > kRadTolerance*0.5)
@@ -623,7 +624,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
rMinIAv = 0.0 ;
}
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1.0 + tanRMax*tanRMax) ;
secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
rMaxAv = (fRmax1 + fRmax2)*0.5 ;
rMaxOAv = rMaxAv + kRadTolerance*0.5 ;
@@ -632,11 +633,11 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
tolIDz = fDz - kCarTolerance*0.5 ;
tolODz = fDz + kCarTolerance*0.5 ;
if (fabs(p.z()) >= tolIDz)
if (std::fabs(p.z()) >= tolIDz)
{
if ( p.z()*v.z() < 0 ) // at +Z going in -Z or visa versa
{
s = (fabs(p.z()) - fDz)/fabs(v.z()) ; // Z intersect distance
s = (std::fabs(p.z()) - fDz)/std::fabs(v.z()) ; // Z intersect distance
if( s < 0.0 ) s = 0.0 ; // negative dist -> zero
@@ -682,7 +683,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
{
// Psi = angle made with central (average) phi of shape
cosPsi = (xi*cosCPhi + yi*sinCPhi)/sqrt(rhoi2) ;
cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
if (cosPsi >= cosHDPhiIT) return s ;
}
@@ -695,7 +696,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
{
// Psi = angle made with central (average) phi of shape
cosPsi = (xi*cosCPhi + yi*sinCPhi)/sqrt(rhoi2) ;
cosPsi = (xi*cosCPhi + yi*sinCPhi)/std::sqrt(rhoi2) ;
if (cosPsi >= cosHDPhiIT) return s ;
}
@@ -741,16 +742,16 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
nt2 = t2 - tanRMax*v.z()*rout ;
nt3 = t3 - rout*rout ;
if (fabs(nt1) > kRadTolerance) // Equation quadratic => 2 roots
if (std::fabs(nt1) > kRadTolerance) // Equation quadratic => 2 roots
{
if ( nt3 > rout*kRadTolerance*secRMax || rout < 0 )
{
// If outside real cone (should be rho-rout>kRadTolerance*0.5
// NOT rho^2 etc) saves a sqrt() at expense of accuracy
b = nt2/nt1 ;
c = nt3/nt1 ;
d = b*b-c ;
if ( nt3 > rout*kRadTolerance*secRMax || rout < 0 )
{
// If outside real cone (should be rho-rout>kRadTolerance*0.5
// NOT rho^2 etc) saves a std::sqrt() at expense of accuracy
if (d >= 0)
{
@@ -760,19 +761,19 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
// Inside `shadow cone' with -ve radius
// -> 2nd root could be on real cone
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
}
else
{
if ( b <= 0 && c >= 0 ) // both >=0, try smaller root
{
s = -b - sqrt(d) ;
s = -b - std::sqrt(d) ;
}
else
{
if ( c <= 0 ) // second >=0
{
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
}
else // both negative, travel away
{
@@ -784,7 +785,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
{
zi = p.z() + s*v.z() ;
if (fabs(zi) <= tolODz)
if (std::fabs(zi) <= tolODz)
{
// Z ok. Check phi intersection if reqd
@@ -809,14 +810,18 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
if ( t3 > (rin + kRadTolerance*0.5*secRMin)*
(rin + kRadTolerance*0.5*secRMin) &&
nt2 < 0 &&
fabs(p.z()) <= tolIDz )
nt2 < 0 &&
d >= 0 &&
// nt2 < -kCarTolerance*secRMax/2/fDz &&
// t2 < std::sqrt(t3)*v.z()*tanRMax &&
// d > kCarTolerance*secRMax*(rout-b*tanRMax*v.z())/nt1 &&
std::fabs(p.z()) <= tolIDz )
{
// Inside cones, delta r -ve, inside z extent
if (seg)
{
cosPsi = (p.x()*cosCPhi + p.y()*sinCPhi)/sqrt(t3) ;
cosPsi = (p.x()*cosCPhi + p.y()*sinCPhi)/std::sqrt(t3) ;
if (cosPsi >= cosHDPhiIT) return 0.0 ;
}
@@ -826,7 +831,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
}
else // Single root case
{
if ( fabs(nt2) > kRadTolerance )
if ( std::fabs(nt2) > kRadTolerance )
{
s = -0.5*nt3/nt2 ;
@@ -835,7 +840,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
{
zi = p.z() + s*v.z() ;
if (fabs(zi) <= tolODz && nt2 < 0)
if (std::fabs(zi) <= tolODz && nt2 < 0)
{
// Z ok. Check phi intersection if reqd
@@ -885,13 +890,13 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
d = b*b-c ;
if (d >= 0) // > 0
{
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
if ( s >= 0 ) // > 0
{
zi = p.z() + s*v.z() ;
if ( fabs(zi) <= tolODz )
if ( std::fabs(zi) <= tolODz )
{
if ( seg )
{
@@ -920,13 +925,13 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
if ( d >= 0 ) // > 0
{
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
zi = p.z() + s*v.z() ;
ri = rMinAv + zi*tanRMin ;
if ( ri >= 0 )
{
if ( s >= 0 && fabs(zi) <= tolODz ) // s > 0
if ( s >= 0 && std::fabs(zi) <= tolODz ) // s > 0
{
if ( seg )
{
@@ -941,11 +946,11 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
}
else
{
s = -b - sqrt(d) ;
s = -b - std::sqrt(d) ;
zi = p.z() + s*v.z() ;
ri = rMinAv + zi*tanRMin ;
if ( s >= 0 && ri >= 0 && fabs(zi) <= tolODz ) // s>0
if ( s >= 0 && ri >= 0 && std::fabs(zi) <= tolODz ) // s>0
{
if ( seg )
{
@@ -967,7 +972,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
// ----> if not:
// -2nd root with validity check
if ( fabs(p.z()) <= tolODz )
if ( std::fabs(p.z()) <= tolODz )
{
if ( nt2 > 0 )
{
@@ -975,7 +980,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
if ( seg )
{
cosPsi = (p.x()*cosCPhi + p.y()*sinCPhi)/sqrt(t3) ;
cosPsi = (p.x()*cosCPhi + p.y()*sinCPhi)/std::sqrt(t3) ;
if (cosPsi >= cosHDPhiIT) return 0.0 ;
}
@@ -992,16 +997,16 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
if ( d >= 0 ) // > 0
{
s = -b - sqrt(d) ;
s = -b - std::sqrt(d) ;
zi = p.z() + s*v.z() ;
ri = rMinAv + zi*tanRMin ;
if ( ri > 0 ) // 2nd root
{
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
zi = p.z() + s*v.z() ;
if ( s >= 0 && fabs(zi) <= tolODz ) // s>0
if ( s >= 0 && std::fabs(zi) <= tolODz ) // s>0
{
if ( seg )
{
@@ -1027,10 +1032,10 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
if ( d > 0 )
{
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
zi = p.z() + s*v.z() ;
if ( s >= 0 && fabs(zi) <= tolODz ) // s>0
if ( s >= 0 && std::fabs(zi) <= tolODz ) // s>0
{
if ( seg )
{
@@ -1062,8 +1067,8 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
{
// First phi surface (`S'tarting phi)
sinSPhi = sin(fSPhi) ;
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ;
cosSPhi = std::cos(fSPhi) ;
Comp = v.x()*sinSPhi - v.y()*cosSPhi ;
if ( Comp < 0 ) // Component in outwards normal dirn
@@ -1080,7 +1085,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
zi = p.z() + s*v.z() ;
if ( fabs(zi) <= tolODz )
if ( std::fabs(zi) <= tolODz )
{
xi = p.x() + s*v.x() ;
yi = p.y() + s*v.y() ;
@@ -1102,8 +1107,8 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
// Second phi surface (`E'nding phi)
ePhi = fSPhi + fDPhi ;
sinEPhi = sin(ePhi) ;
cosEPhi = cos(ePhi) ;
sinEPhi = std::sin(ePhi) ;
cosEPhi = std::cos(ePhi) ;
Comp = -(v.x()*sinEPhi - v.y()*cosEPhi) ;
if ( Comp < 0 ) // Component in outwards normal dirn
@@ -1119,7 +1124,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
zi = p.z() + s*v.z() ;
if (fabs(zi) <= tolODz)
if (std::fabs(zi) <= tolODz)
{
xi = p.x() + s*v.x() ;
yi = p.y() + s*v.y() ;
@@ -1158,18 +1163,18 @@ G4double G4Cons::DistanceToIn(const G4ThreeVector& p) const
G4double phiC, cosPhiC, sinPhiC, safePhi, ePhi ;
G4double cosPsi ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
safeZ = fabs(p.z()) - fDz ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
safeZ = std::fabs(p.z()) - fDz ;
if ( fRmin1 || fRmin2 )
{
tanRMin = (fRmin2 - fRmin1)*0.5/fDz ;
secRMin = sqrt(1.0 + tanRMin*tanRMin) ;
secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
pRMin = tanRMin*p.z() + (fRmin1 + fRmin2)*0.5 ;
safeR1 = (pRMin - rho)/secRMin ;
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1.0 + tanRMax*tanRMax) ;
secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
pRMax = tanRMax*p.z() + (fRmax1 + fRmax2)*0.5 ;
safeR2 = (rho - pRMax)/secRMax ;
@@ -1179,32 +1184,32 @@ G4double G4Cons::DistanceToIn(const G4ThreeVector& p) const
else
{
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1.0 + tanRMax*tanRMax) ;
secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
pRMax = tanRMax*p.z() + (fRmax1 + fRmax2)*0.5 ;
safe = (rho - pRMax)/secRMax ;
}
if ( safeZ > safe ) safe = safeZ ;
if ( fDPhi < 2.0*M_PI && rho )
if ( fDPhi < twopi && rho )
{
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
// Psi=angle from central phi to point
cosPsi = (p.x()*cosPhiC + p.y()*sinPhiC)/rho ;
if ( cosPsi < cos(fDPhi*0.5) ) // Point lies outside phi range
if ( cosPsi < std::cos(fDPhi*0.5) ) // Point lies outside phi range
{
if ( (p.y()*cosPhiC - p.x()*sinPhiC) <= 0.0 )
{
safePhi = fabs(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = std::fabs(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = fabs(p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = std::fabs(p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if ( safePhi > safe ) safe = safePhi ;
}
@@ -1311,7 +1316,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
// \--------u-------/ \-----------v----------/ \---------w--------/
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1.0 + tanRMax*tanRMax) ;
secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
rMaxAv = (fRmax1 + fRmax2)*0.5 ;
@@ -1353,7 +1358,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
{
if (calcNorm)
{
risec = sqrt(t3)*secRMax ;
risec = std::sqrt(t3)*secRMax ;
*validNorm = true ;
*n = G4ThreeVector(p.x()/risec,p.y()/risec,-tanRMax/secRMax) ;
}
@@ -1362,7 +1367,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
else
{
sider = kRMax ;
sr = -b - sqrt(d) ; // was +srqrt(d), vmg 28.04.99
sr = -b - std::sqrt(d) ; // was +srqrt(d), vmg 28.04.99
zi = p.z() + sr*v.z() ;
ri = tanRMax*zi + rMaxAv ;
@@ -1380,7 +1385,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
// Safety: if both roots -ve ensure that sr cannot `win'
// distance to out
sr2 = -b + sqrt(d) ;
sr2 = -b + std::sqrt(d) ;
zi = p.z() + sr2*v.z() ;
ri = tanRMax*zi + rMaxAv ;
@@ -1409,7 +1414,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
if ( calcNorm )
{
risec = sqrt(t3)*secRMax ;
risec = std::sqrt(t3)*secRMax ;
*validNorm = true ;
*n = G4ThreeVector(p.x()/risec,p.y()/risec,-tanRMax/secRMax) ;
}
@@ -1422,7 +1427,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
if ( calcNorm )
{
risec = sqrt(t3)*secRMax ;
risec = std::sqrt(t3)*secRMax ;
*validNorm = true ;
*n = G4ThreeVector(p.x()/risec,p.y()/risec,-tanRMax/secRMax) ;
}
@@ -1451,7 +1456,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
xi = p.x() + slentol*v.x() ;
yi = p.y() + slentol*v.y() ;
risec = sqrt(xi*xi + yi*yi)*secRMax ;
risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
G4ThreeVector Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
if ( Normal.dot(v) > 0 ) // We will leave the Cone immediatelly
@@ -1478,7 +1483,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
if ( nt1 )
{
secRMin = sqrt(1.0 + tanRMin*tanRMin) ;
secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
rMinAv = (fRmin1 + fRmin2)*0.5 ;
rin = tanRMin*p.z() + rMinAv ;
nt2 = t2 - tanRMin*v.z()*rin ;
@@ -1505,7 +1510,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
}
else
{
sr2 = -b - sqrt(d) ;
sr2 = -b - std::sqrt(d) ;
zi = p.z() + sr2*v.z() ;
ri = tanRMin*zi + rMinAv ;
@@ -1520,7 +1525,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
}
if( (ri<0) || (sr2 < kRadTolerance*0.5) )
{
sr3 = -b + sqrt(d) ;
sr3 = -b + std::sqrt(d) ;
// Safety: if both roots -ve ensure that sr cannot `win'
// distancetoout
@@ -1570,7 +1575,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
xi = p.x() + slentol*v.x() ;
yi = p.y() + slentol*v.y() ;
risec = sqrt(xi*xi + yi*yi)*secRMin ;
risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMin/secRMin) ;
if( Normal.dot(v) > 0 )
@@ -1600,16 +1605,16 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
//
// Phi Intersection
if ( fDPhi < 2.0*M_PI )
if ( fDPhi < twopi )
{
sinSPhi = sin(fSPhi) ;
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ;
cosSPhi = std::cos(fSPhi) ;
ePhi = fSPhi + fDPhi ;
sinEPhi = sin(ePhi) ;
cosEPhi = cos(ePhi) ;
sinEPhi = std::sin(ePhi) ;
cosEPhi = std::cos(ePhi) ;
cPhi = fSPhi + fDPhi*0.5 ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
if ( p.x() || p.y() ) // Check if on z axis (rho not needed later)
{
@@ -1681,7 +1686,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
if ( pDistS <= pDistE ) sidephi = kSPhi ;
else sidephi = kEPhi ;
if ( fDPhi > M_PI )
if ( fDPhi > pi )
{
if (compS < 0 && compE < 0) sphi = 0.0 ;
else sphi = kInfinity ;
@@ -1699,7 +1704,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
{
// Outside full starting plane, inside full ending plane
if ( fDPhi > M_PI )
if ( fDPhi > pi )
{
if ( compE < 0.0 )
{
@@ -1759,7 +1764,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
// Must be pDistS<0&&pDistE>0
// Inside full starting plane, outside full ending plane
if (fDPhi > M_PI)
if (fDPhi > pi)
{
if ( compS < 0.0 )
{
@@ -1815,7 +1820,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
// On z axis + travel not || to z axis -> if phi of vector direction
// within phi of shape, Step limited by rmax, else Step =0
vphi = atan2(v.y(),v.x()) ;
vphi = std::atan2(v.y(),v.x()) ;
if ( fSPhi < vphi && vphi < fSPhi + fDPhi ) sphi = kInfinity ;
else
@@ -1844,7 +1849,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
// (divide by frmax for unit vector)
xi = p.x() + snxt*v.x() ;
yi = p.y() + snxt*v.y() ;
risec = sqrt(xi*xi + yi*yi)*secRMax ;
risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
*n = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
*validNorm = true ;
break ;
@@ -1852,17 +1857,17 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
*validNorm=false ; // Rmin is inconvex
break ;
case kSPhi:
if ( fDPhi <= M_PI )
if ( fDPhi <= pi )
{
*n = G4ThreeVector(sin(fSPhi),-cos(fSPhi),0) ;
*n = G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0) ;
*validNorm = true ;
}
else *validNorm = false ;
break ;
case kEPhi:
if ( fDPhi <= M_PI )
if ( fDPhi <= pi )
{
*n = G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0) ;
*n = G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0) ;
*validNorm = true ;
}
else *validNorm = false ;
@@ -1883,11 +1888,11 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "pho at z = " << sqrt( p.x()*p.x()+p.y()*p.y() )/mm << " mm"
G4cout << "pho at z = " << std::sqrt( p.x()*p.x()+p.y()*p.y() )/mm << " mm"
<< G4endl << G4endl ;
if( p.x() != 0. || p.x() != 0.)
{
G4cout << "point phi = " << atan2(p.y(),p.x())/degree << " degree"
G4cout << "point phi = " << std::atan2(p.y(),p.x())/degree << " degree"
<< G4endl << G4endl ;
}
G4cout << "Direction:" << G4endl << G4endl ;
@@ -1926,11 +1931,11 @@ G4double G4Cons::DistanceToOut(const G4ThreeVector& p) const
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl ;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl ;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "pho at z = " << sqrt( p.x()*p.x()+p.y()*p.y() )/mm << " mm"
G4cout << "pho at z = " << std::sqrt( p.x()*p.x()+p.y()*p.y() )/mm << " mm"
<< G4endl << G4endl ;
if( p.x() != 0. || p.x() != 0.)
{
G4cout << "point phi = " << atan2(p.y(),p.x())/degree << " degree"
G4cout << "point phi = " << std::atan2(p.y(),p.x())/degree << " degree"
<< G4endl << G4endl ;
}
G4Exception("G4Cons::DistanceToOut(p)", "Notification", JustWarning,
@@ -1938,20 +1943,20 @@ G4double G4Cons::DistanceToOut(const G4ThreeVector& p) const
}
#endif
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
safeZ = fDz - fabs(p.z()) ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
safeZ = fDz - std::fabs(p.z()) ;
if (fRmin1 || fRmin2)
{
tanRMin = (fRmin2 - fRmin1)*0.5/fDz ;
secRMin = sqrt(1.0 + tanRMin*tanRMin) ;
secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
pRMin = tanRMin*p.z() + (fRmin1 + fRmin2)*0.5 ;
safeR1 = (rho - pRMin)/secRMin ;
}
else safeR1 = kInfinity ;
tanRMax = (fRmax2 - fRmax1)*0.5/fDz ;
secRMax = sqrt(1.0 + tanRMax*tanRMax) ;
secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
pRMax = tanRMax*p.z() + (fRmax1+fRmax2)*0.5 ;
safeR2 = (pRMax - rho)/secRMax ;
@@ -1961,22 +1966,22 @@ G4double G4Cons::DistanceToOut(const G4ThreeVector& p) const
// Check if phi divided, Calc distances closest phi plane
if (fDPhi < 2.0*M_PI)
if (fDPhi < twopi)
{
// Above/below central phi of G4Cons?
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
if ( (p.y()*cosPhiC - p.x()*sinPhiC) <= 0 )
{
safePhi = -(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = -(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = (p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = (p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if (safePhi < safe) safe = safePhi ;
}
@@ -2021,13 +2026,13 @@ G4Cons::CreateRotatedVertices(const G4AffineTransform& pTransform) const
// G4double RMax = (fRmax2 >= fRmax1) ? fRmax2 : fRmax1 ;
meshRMax1 = fRmax1/cos(meshAngle*0.5) ;
meshRMax2 = fRmax2/cos(meshAngle*0.5) ;
meshRMax1 = fRmax1/std::cos(meshAngle*0.5) ;
meshRMax2 = fRmax2/std::cos(meshAngle*0.5) ;
// If complete in phi, set start angle such that mesh will be at RMax
// on the x axis. Will give better extent calculations when not rotated.
if (fDPhi == M_PI*2.0 && fSPhi == 0.0 )
if (fDPhi == twopi && fSPhi == 0.0 )
{
sAngle = -meshAngle*0.5 ;
}
@@ -2045,8 +2050,8 @@ G4Cons::CreateRotatedVertices(const G4AffineTransform& pTransform) const
// Compute coordinates of cross section at section crossSection
crossAngle = sAngle + crossSection*meshAngle ;
cosCrossAngle = cos(crossAngle) ;
sinCrossAngle = sin(crossAngle) ;
cosCrossAngle = std::cos(crossAngle) ;
sinCrossAngle = std::sin(crossAngle) ;
rMaxX1 = meshRMax1*cosCrossAngle ;
rMaxY1 = meshRMax1*sinCrossAngle ;
+25 -21
View File
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4Orb.cc,v 1.12 2004/01/26 09:05:55 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Orb.cc,v 1.15 2004/12/02 09:31:28 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
//
// class G4Orb
//
@@ -29,8 +29,10 @@
//
// History:
//
// 30.06.04 V.Grichine - bug fixed in DistanceToIn(p,v) on Rmax surface
// 20.08.03 V.Grichine - created
// --------------------------------------------------------------------
//
//////////////////////////////////////////////////////////////
#include <assert.h>
@@ -211,8 +213,8 @@ G4bool G4Orb::CalculateExtent( const EAxis pAxis,
// Y limits don't cross max/min x => compute max delta x,
// hence new mins/maxs
//
diff1=sqrt(fRmax*fRmax-yoff1*yoff1);
diff2=sqrt(fRmax*fRmax-yoff2*yoff2);
diff1=std::sqrt(fRmax*fRmax-yoff1*yoff1);
diff2=std::sqrt(fRmax*fRmax-yoff2*yoff2);
maxDiff=(diff1>diff2) ? diff1:diff2;
newMin=xoffset-maxDiff;
newMax=xoffset+maxDiff;
@@ -235,8 +237,8 @@ G4bool G4Orb::CalculateExtent( const EAxis pAxis,
// X limits don't cross max/min y => compute max delta y,
// hence new mins/maxs
//
diff1=sqrt(fRmax*fRmax-xoff1*xoff1);
diff2=sqrt(fRmax*fRmax-xoff2*xoff2);
diff1=std::sqrt(fRmax*fRmax-xoff1*xoff1);
diff2=std::sqrt(fRmax*fRmax-xoff2*xoff2);
maxDiff=(diff1>diff2) ? diff1:diff2;
newMin=yoffset-maxDiff;
newMax=yoffset+maxDiff;
@@ -272,7 +274,7 @@ EInside G4Orb::Inside( const G4ThreeVector& p ) const
rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z() ;
// G4double rad = sqrt(rad2);
// G4double rad = std::sqrt(rad2);
// Check radial surface
// sets `in'
@@ -298,7 +300,7 @@ G4ThreeVector G4Orb::SurfaceNormal( const G4ThreeVector& p ) const
{
ENorm side = kNRMax;
G4ThreeVector norm;
G4double rad = sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
G4double rad = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
switch (side)
{
@@ -354,20 +356,20 @@ G4double G4Orb::DistanceToIn( const G4ThreeVector& p,
// => (px^2+py^2+pz^2) +2s(pxvx+pyvy+pzvz)+s^2(vx^2+vy^2+vz^2)=R^2
// => rad2 +2s(pDotV3d) +s^2 =R^2
//
// => s=-pDotV3d+-sqrt(pDotV3d^2-(rad2-R^2))
// => s=-pDotV3d+-std::sqrt(pDotV3d^2-(rad2-R^2))
c = rad2 - fRmax*fRmax ;
if ( c > fRmaxTolerance*fRmax )
{
// If outside tolerant boundary of outer G4Orb
// [ should be sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ]
// [ should be std::sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ]
d2 = pDotV3d*pDotV3d - c ;
if ( d2 >= 0 )
{
s = -pDotV3d - sqrt(d2) ;
s = -pDotV3d - std::sqrt(d2) ;
if (s >= 0 ) return snxt = s;
@@ -380,8 +382,10 @@ G4double G4Orb::DistanceToIn( const G4ThreeVector& p,
else
{
if ( c > -fRmaxTolerance*fRmax ) // on surface
{
if ( pDotV3d >= 0 ) return snxt = kInfinity;
{
d2 = pDotV3d*pDotV3d - c ;
// if ( pDotV3d >= 0 ) return snxt = kInfinity;
if ( d2 < fRmaxTolerance*fRmax || pDotV3d >= 0 ) return snxt = kInfinity;
else return snxt = 0.;
}
else // inside ???
@@ -401,7 +405,7 @@ G4double G4Orb::DistanceToIn( const G4ThreeVector& p,
G4double G4Orb::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe=0.0, rad = sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
G4double safe=0.0, rad = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
safe = rad - fRmax;
if( safe < 0 ) safe = 0. ;
return safe;
@@ -442,7 +446,7 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
// => (px^2+py^2+pz^2) +2s(pxvx+pyvy+pzvz)+s^2(vx^2+vy^2+vz^2)=R^2
// => rad2 +2s(pDotV3d) +s^2 =R^2
//
// => s=-pDotV3d+-sqrt(pDotV3d^2-(rad2-R^2))
// => s=-pDotV3d+-std::sqrt(pDotV3d^2-(rad2-R^2))
const G4double Rmax_plus = fRmax + fRmaxTolerance*0.5;
@@ -463,8 +467,8 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
d2 = pDotV3d*pDotV3d - c;
if( ( c > -fRmaxTolerance*fRmax) && // on tolerant surface
( ( pDotV3d >= 0 ) || ( d2 < 0 )) ) // leaving outside from Rmax
if( ( c > -fRmaxTolerance*fRmax) && // on tolerant surface
( ( pDotV3d >= 0 ) || ( d2 < 0 )) ) // leaving outside from Rmax
// not re-entering
{
if(calcNorm)
@@ -476,7 +480,7 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
}
else
{
snxt = -pDotV3d + sqrt(d2); // second root since inside Rmax
snxt = -pDotV3d + std::sqrt(d2); // second root since inside Rmax
side = kRMax ;
}
}
@@ -490,7 +494,7 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
G4cout << "p.x() = " << p.x()/mm << " mm" << G4endl;
G4cout << "p.y() = " << p.y()/mm << " mm" << G4endl;
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl;
G4cout << "Rp = "<< sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/mm << " mm"
G4cout << "Rp = "<< std::sqrt( p.x()*p.x()+p.y()*p.y()+p.z()*p.z() )/mm << " mm"
<< G4endl << G4endl;
G4cout << "Direction:" << G4endl << G4endl;
G4cout << "v.x() = " << v.x() << G4endl;
@@ -540,7 +544,7 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
G4double G4Orb::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe=0.0,rad = sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
G4double safe=0.0,rad = std::sqrt(p.x()*p.x()+p.y()*p.y()+p.z()*p.z());
#ifdef G4CSGDEBUG
if( Inside(p) == kOutside )
+52 -50
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Para.cc,v 1.20 2004/01/26 09:03:19 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Para.cc,v 1.22.2.1 2004/12/02 09:30:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
//
// class G4Para
//
@@ -67,9 +67,9 @@ void G4Para::SetAllParameters( G4double pDx, G4double pDy, G4double pDz,
fDx=pDx;
fDy=pDy;
fDz=pDz;
fTalpha=tan(pAlpha);
fTthetaCphi=tan(pTheta)*cos(pPhi);
fTthetaSphi=tan(pTheta)*sin(pPhi);
fTalpha=std::tan(pAlpha);
fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
}
else
{
@@ -79,6 +79,8 @@ void G4Para::SetAllParameters( G4double pDx, G4double pDy, G4double pDz,
G4Exception("G4Para::SetAllParameters()", "InvalidSetup",
FatalException, "Invalid Length Parameters.");
}
fCubicVolume = 0.;
fpPolyhedron = 0;
}
///////////////////////////////////////////////////////////////////////////
@@ -239,7 +241,7 @@ G4bool G4Para::CalculateExtent( const EAxis pAxis,
*(zMin-pt[2].z())/(pt[6].z()-pt[2].z()) ;
temp[3] = pt[2].y()+(pt[6].y()-pt[2].y())
*(zMax-pt[2].z())/(pt[6].z()-pt[2].z()) ;
yMax = yoffset - fabs(fDz*fTthetaSphi) - fDy - fDy ;
yMax = yoffset - std::fabs(fDz*fTthetaSphi) - fDy - fDy ;
yMin = -yMax ;
for(i=0;i<4;i++)
{
@@ -284,7 +286,7 @@ G4bool G4Para::CalculateExtent( const EAxis pAxis,
temp[7] = pt[1].x()+(pt[5].x()-pt[1].x())
*(zMax-pt[1].z())/(pt[5].z()-pt[1].z()) ;
xMax = xoffset - fabs(fDz*fTthetaCphi) - fDx - fDx -fDx - fDx;
xMax = xoffset - std::fabs(fDz*fTthetaCphi) - fDx - fDx -fDx - fDx;
xMin = -xMax ;
for(i=0;i<8;i++)
{
@@ -395,13 +397,13 @@ EInside G4Para::Inside( const G4ThreeVector& p ) const
EInside in = kOutside;
yt1 = p.y() - fTthetaSphi*p.z();
yt = fabs(yt1) ;
yt = std::fabs(yt1) ;
// xt = fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt );
// xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt );
xt = fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt1 );
xt = std::fabs( p.x() - fTthetaCphi*p.z() - fTalpha*yt1 );
if ( fabs( p.z() ) <= fDz - kCarTolerance*0.5)
if ( std::fabs( p.z() ) <= fDz - kCarTolerance*0.5)
{
if (yt <= fDy - kCarTolerance*0.5)
{
@@ -413,7 +415,7 @@ EInside G4Para::Inside( const G4ThreeVector& p ) const
if ( xt <= fDx + kCarTolerance*0.5 ) in = kSurface;
}
}
else if ( fabs(p.z()) <= fDz + kCarTolerance*0.5 )
else if ( std::fabs(p.z()) <= fDz + kCarTolerance*0.5 )
{
if ( yt <= fDy + kCarTolerance*0.5)
{
@@ -441,10 +443,10 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
newpx=p.x()-fTthetaCphi*p.z();
newpy=p.y()-fTthetaSphi*p.z();
calpha=1/sqrt(1+fTalpha*fTalpha);
calpha=1/std::sqrt(1+fTalpha*fTalpha);
if (fTalpha)
{
salpha=-calpha/fTalpha; // NOTE: actually use MINUS sin(alpha)
salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
}
else
{
@@ -453,9 +455,9 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
xshift=newpx*calpha+newpy*salpha;
distx=fabs(fabs(xshift)-fDx*calpha);
disty=fabs(fabs(newpy)-fDy);
distz=fabs(fabs(p.z())-fDz);
distx=std::fabs(std::fabs(xshift)-fDx*calpha);
disty=std::fabs(std::fabs(newpy)-fDy);
distz=std::fabs(std::fabs(p.z())-fDz);
if (distx<disty)
{
@@ -474,22 +476,22 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
if (xshift<0)
{
cosntheta=-1/sqrt(1+tntheta*tntheta);
cosntheta=-1/std::sqrt(1+tntheta*tntheta);
}
else
{
cosntheta=1/sqrt(1+tntheta*tntheta);
cosntheta=1/std::sqrt(1+tntheta*tntheta);
}
norm=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
break;
case kNY:
if (newpy<0)
{
ycomp=-1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
}
else
{
ycomp=1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
}
norm=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
break;
@@ -562,7 +564,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p,
}
else
{
if (fabs(p.z())<=fDz) // Inside
if (std::fabs(p.z())<=fDz) // Inside
{
smin=0;
smax=kInfinity;
@@ -608,7 +610,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p,
}
else
{
if (fabs(yt)<=fDy)
if (std::fabs(yt)<=fDy)
{
tmin=0;
tmax=kInfinity;
@@ -662,7 +664,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p,
}
else
{
if (fabs(xt)<=fDx)
if (std::fabs(xt)<=fDx)
{
tmin=0;
tmax=kInfinity;
@@ -722,7 +724,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p ) const
// Transformed x into `box' system
//
cosy=1.0/sqrt(1.0+fTthetaSphi*fTthetaSphi);
cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
disty1=(trany-fDy)*cosy;
disty2=(-fDy-trany)*cosy;
@@ -730,7 +732,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p ) const
if (disty2>safe) safe=disty2;
tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
cosx=1.0/sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
distx1=(tranx-fDx)*cosx;
distx2=(-fDx-tranx)*cosx;
@@ -826,7 +828,7 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
if (calcNorm)
{
*validNorm=true; // Leaving via plus Y
ycomp=1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
*n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
}
return snxt=0;
@@ -849,7 +851,7 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
if (calcNorm)
{
*validNorm=true; // Leaving via minus Y
ycomp=-1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
*n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
}
return snxt=0;
@@ -879,17 +881,17 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
if (calcNorm)
{
*validNorm=true; // Leaving via plus X
calpha=1/sqrt(1+fTalpha*fTalpha);
calpha=1/std::sqrt(1+fTalpha*fTalpha);
if (fTalpha)
{
salpha=-calpha/fTalpha; // NOTE: actually use MINUS sin(alpha)
salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
}
else
{
salpha=0;
}
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
cosntheta=1/sqrt(1+tntheta*tntheta);
cosntheta=1/std::sqrt(1+tntheta*tntheta);
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
}
return snxt=0;
@@ -912,17 +914,17 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
if (calcNorm)
{
*validNorm=true; // Leaving via minus X
calpha=1/sqrt(1+fTalpha*fTalpha);
calpha=1/std::sqrt(1+fTalpha*fTalpha);
if (fTalpha)
{
salpha=-calpha/fTalpha; // NOTE: actually use MINUS sin(alpha)
salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
}
else
{
salpha=0;
}
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
cosntheta=-1/sqrt(1+tntheta*tntheta);
cosntheta=-1/std::sqrt(1+tntheta*tntheta);
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
return snxt=0;
}
@@ -941,39 +943,39 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
*n=G4ThreeVector(0,0,1);
break;
case kMY:
ycomp=-1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=-1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
*n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
break;
case kPY:
ycomp=1/sqrt(1+fTthetaSphi*fTthetaSphi);
ycomp=1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
*n=G4ThreeVector(0,ycomp,-fTthetaSphi*ycomp);
break;
case kMX:
calpha=1/sqrt(1+fTalpha*fTalpha);
calpha=1/std::sqrt(1+fTalpha*fTalpha);
if (fTalpha)
{
salpha=-calpha/fTalpha; // NOTE: actually use MINUS sin(alpha)
salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
}
else
{
salpha=0;
}
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
cosntheta=-1/sqrt(1+tntheta*tntheta);
cosntheta=-1/std::sqrt(1+tntheta*tntheta);
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
break;
case kPX:
calpha=1/sqrt(1+fTalpha*fTalpha);
calpha=1/std::sqrt(1+fTalpha*fTalpha);
if (fTalpha)
{
salpha=-calpha/fTalpha; // NOTE: actually use MINUS sin(alpha)
salpha=-calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
}
else
{
salpha=0;
}
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
cosntheta=1/sqrt(1+tntheta*tntheta);
cosntheta=1/std::sqrt(1+tntheta*tntheta);
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
break;
default:
@@ -1029,7 +1031,7 @@ G4double G4Para::DistanceToOut( const G4ThreeVector& p ) const
// Transformed x into `box' system
//
cosy=1.0/sqrt(1.0+fTthetaSphi*fTthetaSphi);
cosy=1.0/std::sqrt(1.0+fTthetaSphi*fTthetaSphi);
disty1=(fDy-trany)*cosy;
disty2=(fDy+trany)*cosy;
@@ -1037,7 +1039,7 @@ G4double G4Para::DistanceToOut( const G4ThreeVector& p ) const
if (disty2<safe) safe=disty2;
tranx=p.x()-fTthetaCphi*p.z()-fTalpha*trany;
cosx=1.0/sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
cosx=1.0/std::sqrt(1.0+fTalpha*fTalpha+fTthetaCphi*fTthetaCphi);
distx1=(fDx-tranx)*cosx;
distx2=(fDx+tranx)*cosx;
@@ -1124,9 +1126,9 @@ std::ostream& G4Para::StreamInfo( std::ostream& os ) const
<< " half length X: " << fDx/mm << " mm \n"
<< " half length Y: " << fDy/mm << " mm \n"
<< " half length Z: " << fDz/mm << " mm \n"
<< " tan(alpha) : " << fTalpha/degree << " degrees \n"
<< " tan(theta)*cos(phi): " << fTthetaCphi/degree << " degrees \n"
<< " tan(theta)*sin(phi): " << fTthetaSphi/degree << " degrees \n"
<< " std::tan(alpha) : " << fTalpha/degree << " degrees \n"
<< " std::tan(theta)*std::cos(phi): " << fTthetaCphi/degree << " degrees \n"
<< " std::tan(theta)*std::sin(phi): " << fTthetaSphi/degree << " degrees \n"
<< "-----------------------------------------------------------\n";
return os;
@@ -1143,9 +1145,9 @@ void G4Para::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
G4Polyhedron* G4Para::CreatePolyhedron () const
{
G4double phi = atan2(fTthetaSphi, fTthetaCphi);
G4double alpha = atan(fTalpha);
G4double theta = atan(sqrt(fTthetaCphi*fTthetaCphi
G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
G4double alpha = std::atan(fTalpha);
G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi
+fTthetaSphi*fTthetaSphi));
return new G4PolyhedronPara(fDx, fDy, fDz, alpha, theta, phi);
File diff suppressed because it is too large Load Diff
+160 -158
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Torus.cc,v 1.36 2004/03/18 10:53:22 grichine Exp $
// GEANT4 tag $Name: geant4-06-01 $
// $Id: G4Torus.cc,v 1.40 2004/12/10 16:22:37 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-05 $
//
//
// class G4Torus
@@ -88,6 +88,8 @@ G4Torus::SetAllParameters( G4double pRmin,
G4double pSPhi,
G4double pDPhi )
{
fCubicVolume= 0.;
fpPolyhedron = 0;
if ( pRtor >= pRmax + kCarTolerance ) // Check swept radius
{
fRtor = pRtor ;
@@ -120,7 +122,7 @@ G4Torus::SetAllParameters( G4double pRmin,
// Check angles
if ( pDPhi >= 2.0*M_PI ) fDPhi = 2*M_PI ;
if ( pDPhi >= twopi ) fDPhi = twopi ;
else
{
if (pDPhi > 0) fDPhi = pDPhi ;
@@ -138,10 +140,10 @@ G4Torus::SetAllParameters( G4double pRmin,
fSPhi = pSPhi;
if (fSPhi < 0) fSPhi = 2.0*M_PI-fmod(fabs(fSPhi),2.0*M_PI) ;
else fSPhi = fmod(fSPhi,2.0*M_PI) ;
if (fSPhi < 0) fSPhi = twopi-std::fmod(std::fabs(fSPhi),twopi) ;
else fSPhi = std::fmod(fSPhi,twopi) ;
if (fSPhi+fDPhi > 2.0*M_PI) fSPhi-=2.0*M_PI ;
if (fSPhi+fDPhi > twopi) fSPhi-=twopi ;
}
//////////////////////////////////////////////////////////////////////
@@ -268,7 +270,7 @@ G4int G4Torus::SolveBiQuadratic( G4double c[], G4double s[] ) const
q = 0.125*A2*A - 0.5*A*B + C;
r = - 3.0/256*A2*A2 + 1.0/16*A2*B - 0.25*A*C + D;
// y^4 + py^2 + r = 0 and z=y^2 so y = +-sqrt(z1) and y = +-sqrt(z2)
// y^4 + py^2 + r = 0 and z=y^2 so y = +-std::sqrt(z1) and y = +-std::sqrt(z2)
if(q==0)
{
@@ -285,15 +287,15 @@ G4int G4Torus::SolveBiQuadratic( G4double c[], G4double s[] ) const
{
if(s[0]==0) // Three roots and one of them == 0
{
s[2] = sqrt(s[1]) ;
s[2] = std::sqrt(s[1]) ;
s[1] = s[0] ;
s[0] = -s[2] ;
num++ ;
}
else // Four roots
{
s[2] = sqrt(s[0]) ;
s[3] = sqrt(s[1]) ;
s[2] = std::sqrt(s[0]) ;
s[3] = std::sqrt(s[1]) ;
s[0] = -s[3] ;
s[1] = -s[2] ;
num +=2 ;
@@ -308,7 +310,7 @@ G4int G4Torus::SolveBiQuadratic( G4double c[], G4double s[] ) const
}
else // Two roots
{
s[0] = -sqrt(s[1]) ;
s[0] = -std::sqrt(s[1]) ;
s[1] = -s[0] ;
}
}
@@ -321,7 +323,7 @@ G4int G4Torus::SolveBiQuadratic( G4double c[], G4double s[] ) const
if(s[0]==0) ;
else
{
s[1] = sqrt(s[0]) ;
s[1] = std::sqrt(s[0]) ;
s[0] = -s[1] ;
num +=1 ;
}
@@ -374,11 +376,11 @@ G4int G4Torus::SolveBiQuadratic( G4double c[], G4double s[] ) const
v = 2 * z - p;
if (u==0) u = 0 ;
else if (u > 0) u = sqrt(u) ;
else if (u > 0) u = std::sqrt(u) ;
else return 0 ;
if (v==0) v = 0 ;
else if (v > 0) v = sqrt(v);
else if (v > 0) v = std::sqrt(v);
else return 0 ;
coeffs[ 0 ] = z - u;
@@ -444,7 +446,7 @@ G4int G4Torus::SolveCubic( G4double c[], G4double s[] ) const
}
else // one single and one double solution
{
G4double u = pow(-q,1./3.);
G4double u = std::pow(-q,1./3.);
s[ 0 ] = 2 * u;
s[ 1 ] = - u;
num = 2;
@@ -452,19 +454,19 @@ G4int G4Torus::SolveCubic( G4double c[], G4double s[] ) const
}
else if (D < 0) // Casus irreducibilis: three real solutions
{
G4double phi = 1.0/3 * acos(-q / sqrt(-p3));
G4double t = 2 * sqrt(-p);
G4double phi = 1.0/3 * std::acos(-q / std::sqrt(-p3));
G4double t = 2 * std::sqrt(-p);
s[ 0 ] = t * cos(phi);
s[ 1 ] = - t * cos(phi + M_PI / 3);
s[ 2 ] = - t * cos(phi - M_PI / 3);
s[ 0 ] = t * std::cos(phi);
s[ 1 ] = - t * std::cos(phi + pi / 3);
s[ 2 ] = - t * std::cos(phi - pi / 3);
num = 3;
}
else // one real solution
{
G4double sqrt_D = sqrt(D);
G4double u = pow(sqrt_D - q,1./3.);
G4double v = - pow(sqrt_D + q,1./3.);
G4double sqrt_D = std::sqrt(D);
G4double u = std::pow(sqrt_D - q,1./3.);
G4double v = - std::pow(sqrt_D + q,1./3.);
s[ 0 ] = u + v;
num = 1;
@@ -516,7 +518,7 @@ G4int G4Torus::SolveBiQuadraticNew( G4double c[], G4double s[] ) const
if( D>0 ) return 0;
else
{
s[0] = sqrt( sqrt( -D ) );
s[0] = std::sqrt( std::sqrt( -D ) );
s[1] = -s[0];
return 2;
}
@@ -549,7 +551,7 @@ G4int G4Torus::SolveBiQuadraticNew( G4double c[], G4double s[] ) const
G4double vm1 = -1.0e99, vm2 ;
for( i=0; i<3; i++ )
{
v[i] = fabs( s[i] ) ;
v[i] = std::fabs( s[i] ) ;
if( v[i] > vm1 ) vm1 = v[i] ;
}
if( vm1 == v[0] )
@@ -574,13 +576,13 @@ G4int G4Torus::SolveBiQuadraticNew( G4double c[], G4double s[] ) const
else if( vm2 == v[1] ) j = 1 ;
else j = 2 ;
w1 = sqrt( s[i] );
w2 = sqrt( s[j] );
w1 = std::sqrt( s[i] );
w2 = std::sqrt( s[j] );
}
else
{
num = 2;
w1 = w2 = sqrt( s[1] );
w1 = w2 = std::sqrt( s[1] );
}
if( w1*w2 != 0. ) w3 = -q/( 8.0*w1*w2 ) ;
else w3 = 0.0 ;
@@ -641,17 +643,17 @@ G4int G4Torus::SolveCubicNew( G4double c[], G4double s[],
if( cubic_discr > delta )
{
h2 = sqrt( cubic_discr );
h2 = std::sqrt( cubic_discr );
u = -h1+h2;
v = -h1-h2;
if( u < 0 ) u = -pow(-u,1./3.);
else u = pow(u,1./3.);
if( v < 0 ) v = -pow(-v,1./3.);
else v = pow(v,1./3.);
if( u < 0 ) u = -std::pow(-u,1./3.);
else u = std::pow(u,1./3.);
if( v < 0 ) v = -std::pow(-v,1./3.);
else v = std::pow(v,1./3.);
s[0] = u+v-sub;
s[1] = -(u+v)/2.0-sub;
s[2] = fabs(u-v)*sqrt(3.0)/2.0;
if( fabs(u) <= eps || fabs(v) <= eps )
s[2] = std::fabs(u-v)*std::sqrt(3.0)/2.0;
if( std::fabs(u) <= eps || std::fabs(v) <= eps )
{
y[0] = s[0] ;
for( i=0; i<2; i++ )
@@ -662,25 +664,25 @@ G4int G4Torus::SolveCubicNew( G4double c[], G4double s[],
return 1;
}
}
else if( fabs(cubic_discr) <= delta )
else if( std::fabs(cubic_discr) <= delta )
{
cubic_discr = 0.;
if( h1 < 0 ) u = pow(-h1,1./3.);
else u = -pow(h1,1./3.);
if( h1 < 0 ) u = std::pow(-h1,1./3.);
else u = -std::pow(h1,1./3.);
s[0] = u + u - sub ;
s[1] = -u - sub ;
s[2] = s[1] ;
if( fabs(h1) <= eps )
if( std::fabs(h1) <= eps )
{
y[0] = s[0];
for( i=0; i<2; i++ )
{
h1 = (3.0*y[i]+2.*A)*y[i]+B;
if( fabs(h1) > delta )
if( std::fabs(h1) > delta )
y[i+1] = y[i]-(((y[i]+A)*y[i]+B)*y[i]+C)/h1;
else
{
@@ -695,12 +697,12 @@ G4int G4Torus::SolveCubicNew( G4double c[], G4double s[],
}
else
{
h3 =fabs(p/3.);
h3 = sqrt(h3*h3*h3);
h2 = acos(-h1/h3)/3.;
h1 = pow(h3,1./3.);
u = h1*cos(h2);
v = sqrt(3.)*h1*sin(h2);
h3 =std::fabs(p/3.);
h3 = std::sqrt(h3*h3*h3);
h2 = std::acos(-h1/h3)/3.;
h1 = std::pow(h3,1./3.);
u = h1*std::cos(h2);
v = std::sqrt(3.)*h1*std::sin(h2);
s[0] = u+u-sub;
s[1] = -u-v-sub;
s[2] = -u+v-sub;
@@ -745,7 +747,7 @@ G4int G4Torus::SolveQuadratic( G4double c[], G4double s[] ) const
}
else if (D > 0)
{
G4double sqrt_D = sqrt(D);
G4double sqrt_D = std::sqrt(D);
s[ 0 ] = - p - sqrt_D ; // in ascending order !
s[ 1 ] = - p + sqrt_D ;
@@ -763,7 +765,7 @@ G4bool G4Torus::CalculateExtent( const EAxis pAxis,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax) const
{
if (!pTransform.IsRotated() && fDPhi==2.0*M_PI && fRmin==0)
if (!pTransform.IsRotated() && fDPhi==twopi && fRmin==0)
{
// Special case handling for unrotated solid torus
// Compute x/y/z mins and maxs for bounding box respecting limits,
@@ -860,8 +862,8 @@ G4bool G4Torus::CalculateExtent( const EAxis pAxis,
// Y limits don't cross max/min x => compute max delta x,
// hence new mins/maxs
//
diff1 = sqrt(fRmax*fRmax - yoff1*yoff1) ;
diff2 = sqrt(fRmax*fRmax - yoff2*yoff2) ;
diff1 = std::sqrt(fRmax*fRmax - yoff1*yoff1) ;
diff2 = std::sqrt(fRmax*fRmax - yoff2*yoff2) ;
maxDiff = (diff1 > diff2) ? diff1:diff2 ;
newMin = xoffset - maxDiff ;
newMax = xoffset + maxDiff ;
@@ -885,8 +887,8 @@ G4bool G4Torus::CalculateExtent( const EAxis pAxis,
// X limits don't cross max/min y => compute max delta y,
// hence new mins/maxs
//
diff1 = sqrt(fRmax*fRmax - xoff1*xoff1) ;
diff2 = sqrt(fRmax*fRmax - xoff2*xoff2) ;
diff1 = std::sqrt(fRmax*fRmax - xoff1*xoff1) ;
diff2 = std::sqrt(fRmax*fRmax - xoff2*xoff2) ;
maxDiff = (diff1 > diff2) ? diff1 : diff2 ;
newMin = yoffset - maxDiff ;
newMax = yoffset + maxDiff ;
@@ -974,7 +976,7 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
EInside in = kOutside ;
// General precals
r2 = p.x()*p.x() + p.y()*p.y() ;
pt2 = r2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*sqrt(r2) ;
pt2 = r2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*std::sqrt(r2) ;
if (fRmin) tolRMin = fRmin + kRadTolerance*0.5 ;
else tolRMin = 0 ;
@@ -983,7 +985,7 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
if (pt2 >= tolRMin*tolRMin && pt2 <= tolRMax*tolRMax )
{
if ( fDPhi == 2*M_PI || pt2 == 0 ) // on torus swept axis
if ( fDPhi == twopi || pt2 == 0 ) // on torus swept axis
{
in = kInside ;
}
@@ -992,15 +994,15 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
// Try inner tolerant phi boundaries (=>inside)
// if not inside, try outer tolerant phi boundaries
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < -kAngTolerance*0.5 ) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( pPhi < -kAngTolerance*0.5 ) pPhi += twopi ; // 0<=pPhi<2pi
if ( fSPhi >= 0 )
{
if ( (abs(pPhi) < kAngTolerance*0.5)
&& (abs(fSPhi + fDPhi - 2*M_PI) < kAngTolerance*0.5) )
if ( (std::abs(pPhi) < kAngTolerance*0.5)
&& (std::abs(fSPhi + fDPhi - twopi) < kAngTolerance*0.5) )
{
pPhi += 2*M_PI ; // 0 <= pPhi < 2pi
pPhi += twopi ; // 0 <= pPhi < 2pi
}
if ( (pPhi >= fSPhi - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + kAngTolerance*0.5) )
@@ -1010,7 +1012,7 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
}
else // fSPhi < 0
{
if ( (pPhi <= fSPhi + 2*M_PI - kAngTolerance*0.5)
if ( (pPhi <= fSPhi + twopi - kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi + kAngTolerance*0.5) ) ;
else
{
@@ -1028,21 +1030,21 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
if (pt2 >= tolRMin*tolRMin && pt2 <= tolRMax*tolRMax)
{
if (fDPhi == 2*M_PI || pt2 == 0 ) // Continuous in phi or on z-axis
if (fDPhi == twopi || pt2 == 0 ) // Continuous in phi or on z-axis
{
in = kSurface ;
}
else // Try outer tolerant phi boundaries only
{
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < -kAngTolerance*0.5 ) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( pPhi < -kAngTolerance*0.5 ) pPhi += twopi ; // 0<=pPhi<2pi
if ( fSPhi >= 0 )
{
if ( (abs(pPhi) < kAngTolerance*0.5)
&& (abs(fSPhi + fDPhi - 2*M_PI) < kAngTolerance*0.5) )
if ( (std::abs(pPhi) < kAngTolerance*0.5)
&& (std::abs(fSPhi + fDPhi - twopi) < kAngTolerance*0.5) )
{
pPhi += 2*M_PI ; // 0 <= pPhi < 2pi
pPhi += twopi ; // 0 <= pPhi < 2pi
}
if ( (pPhi >= fSPhi - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + kAngTolerance*0.5) )
@@ -1052,7 +1054,7 @@ EInside G4Torus::Inside( const G4ThreeVector& p ) const
}
else // fSPhi < 0
{
if ( (pPhi <= fSPhi + 2*M_PI - kAngTolerance*0.5)
if ( (pPhi <= fSPhi + twopi - kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi + kAngTolerance*0.5) ) ;
else
{
@@ -1079,16 +1081,16 @@ G4ThreeVector G4Torus::SurfaceNormal( const G4ThreeVector& p ) const
G4double distRMin,distRMax,distSPhi,distEPhi,distMin;
rho2 = p.x()*p.x() + p.y()*p.y();
rho = sqrt(rho2) ;
pt2 = fabs(rho2+p.z()*p.z() +fRtor*fRtor - 2*fRtor*rho) ;
pt = sqrt(pt2) ;
rho = std::sqrt(rho2) ;
pt2 = std::fabs(rho2+p.z()*p.z() +fRtor*fRtor - 2*fRtor*rho) ;
pt = std::sqrt(pt2) ;
distRMax = fabs(pt - fRmax) ;
distRMax = std::fabs(pt - fRmax) ;
if(fRmin) // First minimum radius
{
distRMin = fabs(pt - fRmin) ;
distRMin = std::fabs(pt - fRmin) ;
if (distRMin < distRMax)
{
@@ -1106,16 +1108,16 @@ G4ThreeVector G4Torus::SurfaceNormal( const G4ThreeVector& p ) const
distMin = distRMax ;
side = kNRMax ;
}
if (fDPhi < 2.0*M_PI && rho )
if (fDPhi < twopi && rho )
{
phi = atan2(p.y(),p.x()) ; // Protected against (0,0,z) (above rho !=0)
phi = std::atan2(p.y(),p.x()) ; // Protected against (0,0,z) (above rho !=0)
if (phi < 0) phi += 2*M_PI ;
if (phi < 0) phi += twopi ;
if (fSPhi < 0 ) distSPhi = fabs(phi-(fSPhi+2.0*M_PI))*rho ;
else distSPhi = fabs(phi-fSPhi)*rho ;
if (fSPhi < 0 ) distSPhi = std::fabs(phi-(fSPhi+twopi))*rho ;
else distSPhi = std::fabs(phi-fSPhi)*rho ;
distEPhi = fabs(phi - fSPhi - fDPhi)*rho ;
distEPhi = std::fabs(phi - fSPhi - fDPhi)*rho ;
if (distSPhi < distEPhi) // Find new minimum
{
@@ -1139,10 +1141,10 @@ G4ThreeVector G4Torus::SurfaceNormal( const G4ThreeVector& p ) const
p.z()/pt ) ;
break;
case kNSPhi:
norm = G4ThreeVector(sin(fSPhi),-cos(fSPhi),0) ;
norm = G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0) ;
break;
case kNEPhi:
norm = G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0) ;
norm = G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0) ;
break;
default:
DumpInfo();
@@ -1207,17 +1209,17 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
// Set phi divided flag and precalcs
if ( fDPhi < 2.0*M_PI )
if ( fDPhi < twopi )
{
seg = true ;
hDPhi = 0.5*fDPhi ; // half delta phi
cPhi = fSPhi + hDPhi ;
hDPhiOT = hDPhi+0.5*kAngTolerance ; // outers tol' half delta phi
hDPhiIT = hDPhi - 0.5*kAngTolerance ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
cosHDPhiOT = cos(hDPhiOT) ;
cosHDPhiIT = cos(hDPhiIT) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
cosHDPhiOT = std::cos(hDPhiOT) ;
cosHDPhiIT = std::cos(hDPhiIT) ;
}
else seg = false ;
@@ -1239,9 +1241,9 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
G4int i, j, num ;
G4double Rtor2 = fRtor*fRtor, Rmax2 = fRmax*fRmax, Rmin2 = fRmin*fRmin ;
G4double rho2 = p.x()*p.x()+p.y()*p.y();
G4double rho = sqrt(rho2) ;
G4double pt2 = fabs(rho2+p.z()*p.z() +Rtor2 - 2*fRtor*rho) ;
// G4double pt = sqrt(pt2) ;
G4double rho = std::sqrt(rho2) ;
G4double pt2 = std::fabs(rho2+p.z()*p.z() +Rtor2 - 2*fRtor*rho) ;
// G4double pt = std::sqrt(pt2) ;
G4double pDotV = p.x()*v.x() + p.y()*v.y() + p.z()*v.z() ;
G4double pRad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z() ;
G4double vDotNmax = pDotV - fRtor*(v.x()*p.x() + v.y()*p.y())/rho ;
@@ -1320,7 +1322,7 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
yi = p.y() + s[i]*v.y() ;
rhoi2 = xi*xi + yi*yi ;
inum = xi*cosCPhi + yi*sinCPhi ;
cosPsi = inum/sqrt(rhoi2) ;
cosPsi = inum/std::sqrt(rhoi2) ;
if (cosPsi >= cosHDPhiIT)
{
@@ -1407,7 +1409,7 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
yi = p.y() + s[i]*v.y() ;
rhoi2 = xi*xi + yi*yi ;
inum = xi*cosCPhi + yi*sinCPhi ;
cosPsi = inum/sqrt(rhoi2) ;
cosPsi = inum/std::sqrt(rhoi2) ;
if ( cosPsi >= cosHDPhiIT && s[i] < snxt )
{
@@ -1438,8 +1440,8 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
if (seg)
{
sinSPhi = sin(fSPhi) ; // First phi surface (`S'tarting phi)
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ; // First phi surface (`S'tarting phi)
cosSPhi = std::cos(fSPhi) ;
Comp = v.x()*sinSPhi - v.y()*cosSPhi ; // Component in outwards
// normal direction
if (Comp < 0 )
@@ -1457,7 +1459,7 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
yi = p.y() + sphi*v.y() ;
zi = p.z() + sphi*v.z() ;
rhoi2 = xi*xi + yi*yi ;
it2 = fabs(rhoi2 + zi*zi + Rtor2 - 2*fRtor*sqrt(rhoi2)) ;
it2 = std::fabs(rhoi2 + zi*zi + Rtor2 - 2*fRtor*std::sqrt(rhoi2)) ;
if ( it2 >= tolORMin2 && it2 <= tolORMax2 )
{
@@ -1470,8 +1472,8 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
}
}
ePhi=fSPhi+fDPhi; // Second phi surface (`E'nding phi)
sinEPhi=sin(ePhi);
cosEPhi=cos(ePhi);
sinEPhi=std::sin(ePhi);
cosEPhi=std::cos(ePhi);
Comp=-(v.x()*sinEPhi-v.y()*cosEPhi);
if ( Comp < 0 ) // Component in outwards normal dirn
@@ -1489,7 +1491,7 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
yi = p.y() + sphi*v.y() ;
zi = p.z() + sphi*v.z() ;
rhoi2 = xi*xi + yi*yi ;
it2 = fabs(rhoi2 + zi*zi + Rtor2 - 2*fRtor*sqrt(rhoi2)) ;
it2 = std::fabs(rhoi2 + zi*zi + Rtor2 - 2*fRtor*std::sqrt(rhoi2)) ;
if (it2 >= tolORMin2 && it2 <= tolORMax2)
{
@@ -1530,9 +1532,9 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p ) const
#endif
rho2 = p.x()*p.x() + p.y()*p.y() ;
rho = sqrt(rho2) ;
pt2 = fabs(rho2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*rho) ;
pt = sqrt(pt2) ;
rho = std::sqrt(rho2) ;
pt2 = std::fabs(rho2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*rho) ;
pt = std::sqrt(pt2) ;
safe1 = fRmin - pt ;
safe2 = pt - fRmax ;
@@ -1540,23 +1542,23 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p ) const
if (safe1 > safe2) safe = safe1;
else safe = safe2;
if ( fDPhi < 2.0*M_PI && rho )
if ( fDPhi < twopi && rho )
{
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
cosPsi = (p.x()*cosPhiC + p.y()*sinPhiC)/rho ;
if (cosPsi < cos(fDPhi*0.5) ) // Psi=angle from central phi to point
if (cosPsi < std::cos(fDPhi*0.5) ) // Psi=angle from central phi to point
{ // Point lies outside phi range
if ((p.y()*cosPhiC - p.x()*sinPhiC) <= 0 )
{
safePhi = fabs(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = std::fabs(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = fabs(p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = std::fabs(p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if (safePhi > safe) safe = safePhi ;
}
@@ -1604,9 +1606,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
G4int i,j,num ;
G4double Rtor2 = fRtor*fRtor, Rmax2 = fRmax*fRmax, Rmin2 = fRmin*fRmin ;
G4double rho2 = p.x()*p.x()+p.y()*p.y();
G4double rho = sqrt(rho2) ;
G4double pt2 = fabs(rho2 + p.z()*p.z() + Rtor2 - 2*fRtor*rho) ;
G4double pt = sqrt(pt2) ;
G4double rho = std::sqrt(rho2) ;
G4double pt2 = std::fabs(rho2 + p.z()*p.z() + Rtor2 - 2*fRtor*rho) ;
G4double pt = std::sqrt(pt2) ;
G4double pDotV = p.x()*v.x() + p.y()*v.y() + p.z()*v.z() ;
G4double pRad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z() ;
@@ -1730,16 +1732,16 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
}
} // if(Rmin)
}
if (fDPhi < 2.0*M_PI) // Phi Intersections
if (fDPhi < twopi) // Phi Intersections
{
sinSPhi = sin(fSPhi) ;
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ;
cosSPhi = std::cos(fSPhi) ;
ePhi = fSPhi + fDPhi ;
sinEPhi = sin(ePhi) ;
cosEPhi = cos(ePhi) ;
sinEPhi = std::sin(ePhi) ;
cosEPhi = std::cos(ePhi) ;
cPhi = fSPhi + fDPhi*0.5 ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
if ( p.x() || p.y() ) // Check if on z axis (rho not needed later)
{
@@ -1819,7 +1821,7 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
{
sidephi = kEPhi ;
}
if (fDPhi>M_PI)
if (fDPhi>pi)
{
if (compS<0&&compE<0) sphi=0;
else sphi=kInfinity;
@@ -1843,7 +1845,7 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
{
// Outside full starting plane, inside full ending plane
if (fDPhi>M_PI)
if (fDPhi>pi)
{
if (compE<0)
{
@@ -1911,7 +1913,7 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
// Must be pDistS<0&&pDistE>0
// Inside full starting plane, outside full ending plane
if (fDPhi>M_PI)
if (fDPhi>pi)
{
if (compS<0)
{
@@ -1984,7 +1986,7 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
// On z axis + travel not || to z axis -> if phi of vector direction
// within phi of shape, Step limited by rmax, else Step =0
vphi=atan2(v.y(),v.x());
vphi=std::atan2(v.y(),v.x());
if (fSPhi<vphi&&vphi<fSPhi+fDPhi)
{
sphi=kInfinity;
@@ -2021,9 +2023,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
yi =p.y() + snxt*v.y() ;
zi = p.z() + snxt*v.z() ;
rhoi2 = xi*xi + yi*yi ;
rhoi = sqrt(rhoi2) ;
it2 = fabs(rhoi2 + zi*zi + fRtor*fRtor - 2*fRtor*rhoi) ;
it = sqrt(it2) ;
rhoi = std::sqrt(rhoi2) ;
it2 = std::fabs(rhoi2 + zi*zi + fRtor*fRtor - 2*fRtor*rhoi) ;
it = std::sqrt(it2) ;
iDotxyNmax = (1-fRtor/rhoi) ;
if(iDotxyNmax >= -kRadTolerance) // really convex part of Rmax
{
@@ -2046,9 +2048,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
#if DEBUGTORUS
G4cout << "G4Torus::DistanceToOut Side is SPhi" << G4endl ;
#endif
if (fDPhi <= M_PI )
if (fDPhi <= pi )
{
*n=G4ThreeVector(sin(fSPhi),-cos(fSPhi),0);
*n=G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0);
*validNorm=true;
}
else *validNorm = false ;
@@ -2058,9 +2060,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
#if DEBUGTORUS
G4cout << "G4Torus::DistanceToOut Side is EPhi" << G4endl ;
#endif
if (fDPhi <= M_PI)
if (fDPhi <= pi)
{
*n=G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0);
*n=G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0);
*validNorm=true;
}
else *validNorm = false ;
@@ -2112,9 +2114,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p ) const
G4double rho2,rho,pt2,pt ;
G4double safePhi,phiC,cosPhiC,sinPhiC,ePhi;
rho2 = p.x()*p.x() + p.y()*p.y() ;
rho = sqrt(rho2) ;
pt2 = fabs(rho2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*rho) ;
pt = sqrt(pt2) ;
rho = std::sqrt(rho2) ;
pt2 = std::fabs(rho2 + p.z()*p.z() + fRtor*fRtor - 2*fRtor*rho) ;
pt = std::sqrt(pt2) ;
#ifdef G4CSGDEBUG
if( Inside(p) == kOutside )
@@ -2146,20 +2148,20 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p ) const
// Check if phi divided, Calc distances closest phi plane
if (fDPhi<2.0*M_PI) // Above/below central phi of Torus?
if (fDPhi<twopi) // Above/below central phi of Torus?
{
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
if ((p.y()*cosPhiC-p.x()*sinPhiC)<=0)
{
safePhi = -(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = -(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = (p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = (p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if (safePhi < safe) safe = safePhi ;
}
@@ -2201,12 +2203,12 @@ G4Torus::CreateRotatedVertices( const G4AffineTransform& pTransform,
noCrossSections=kMaxMeshSections;
}
meshAngle = fDPhi/(noCrossSections - 1) ;
meshRMax = (fRtor + fRmax)/cos(meshAngle*0.5) ;
meshRMax = (fRtor + fRmax)/std::cos(meshAngle*0.5) ;
// If complete in phi, set start angle such that mesh will be at fRmax
// on the x axis. Will give better extent calculations when not rotated.
if ( fDPhi == M_PI*2.0 && fSPhi == 0 )
if ( fDPhi == pi*2.0 && fSPhi == 0 )
{
sAngle = -meshAngle*0.5 ;
}
@@ -2224,8 +2226,8 @@ G4Torus::CreateRotatedVertices( const G4AffineTransform& pTransform,
// Compute coordinates of cross section at section crossSection
crossAngle=sAngle+crossSection*meshAngle;
cosCrossAngle=cos(crossAngle);
sinCrossAngle=sin(crossAngle);
cosCrossAngle=std::cos(crossAngle);
sinCrossAngle=std::sin(crossAngle);
rMaxX=meshRMax*cosCrossAngle;
rMaxY=meshRMax*sinCrossAngle;
@@ -2302,7 +2304,7 @@ G4NURBS* G4Torus::CreateNURBS () const
G4NURBS* pNURBS;
if (fRmin != 0)
{
if (fDPhi >= 2.0 * M_PI)
if (fDPhi >= 2.0 * pi)
{
pNURBS = new G4NURBStube(fRmin, fRmax, fRtor);
}
@@ -2313,7 +2315,7 @@ G4NURBS* G4Torus::CreateNURBS () const
}
else
{
if (fDPhi >= 2.0 * M_PI)
if (fDPhi >= 2.0 * pi)
{
pNURBS = new G4NURBScylinder (fRmax, fRtor);
}
@@ -2398,7 +2400,7 @@ G4double G4Torus::SolveNumeric( const G4ThreeVector& p,
<< " Rmax = " << GetRmax() << G4endl ;
#endif
if (fabs(GetRmin()) > POLEPSILON)
if (std::fabs(GetRmin()) > POLEPSILON)
{
#if DEBUGTORUS
@@ -2420,7 +2422,7 @@ G4double G4Torus::SolveNumeric( const G4ThreeVector& p,
// PROBLEM: This may be a problem of precision
// if we are near kCarTolerance ...
//
if (fabs(lambda) < kCarTolerance)
if (std::fabs(lambda) < kCarTolerance)
{
G4double Lx,Ly,Lz;
G4double scal;
@@ -2614,13 +2616,13 @@ G4double G4Torus::SolveNumeric( const G4ThreeVector& p,
(p.y()+ lambda*v.y())*(p.y()+ lambda*v.y()) +
(p.z()+ lambda*v.z())*(p.z()+ lambda*v.z())) > POLEPSILON)
{
G4double theta = atan2(p.y() + lambda*v.y(),p.x() + lambda*v.x());
G4double theta = std::atan2(p.y() + lambda*v.y(),p.x() + lambda*v.x());
#if DEBUGTORUS
G4cout << "G4Torus::SolveNumeric theta = " << theta << G4endl;
#endif
if (theta < 0) theta += 2*M_PI;
if (theta < 0) theta += twopi;
// We have to verify if this root is inside the region between
// fSPhi and fSPhi + fDPhi
@@ -2650,7 +2652,7 @@ G4double G4Torus::SolveNumeric( const G4ThreeVector& p,
// and [fSPhi + fDPhi]
G4double IntersectPlanar ;
IntersectPlanar = -(p.y()-p.x()*tan(fSPhi))/(v.y()-v.x()*tan(fSPhi));
IntersectPlanar = -(p.y()-p.x()*std::tan(fSPhi))/(v.y()-v.x()*std::tan(fSPhi));
#if DEBUGTORUS
G4cout << "G4Torus::SolveNumeric IntersectPlanar = "
@@ -2661,8 +2663,8 @@ G4double G4Torus::SolveNumeric( const G4ThreeVector& p,
//
if (IntersectPlanar < lambda)
{
IntersectPlanar = - (p.y() - p.x()*tan(fSPhi + fDPhi))
/ (v.y() - v.x()*tan(fSPhi + fDPhi)) ;
IntersectPlanar = - (p.y() - p.x()*std::tan(fSPhi + fDPhi))
/ (v.y() - v.x()*std::tan(fSPhi + fDPhi)) ;
#if DEBUGTORUS
G4cout << "G4Torus::SolveNumeric IntersectPlanar (2) = "
<< IntersectPlanar << G4endl ;
@@ -2800,13 +2802,13 @@ void G4Torus::BVMIntersection( G4double x,G4double y,G4double z,
}
else
{
d = sqrt(d) ;
d = std::sqrt(d) ;
NewL[2] = (d - b)/(2*a);
NewL[3] = (-d - b)/(2*a);
if (NewL[2] < 0.0) valid[2] = 0;
if (fabs(z + NewL[2]*dz) - Rmin > POLEPSILON) valid[2] = 0;
if (std::fabs(z + NewL[2]*dz) - Rmin > POLEPSILON) valid[2] = 0;
if (NewL[3] < 0.0) valid[3] = 0;
if (fabs(z + NewL[3]*dz) - Rmin > POLEPSILON) valid[3] = 0;
if (std::fabs(z + NewL[3]*dz) - Rmin > POLEPSILON) valid[3] = 0;
}
}
else
@@ -2822,20 +2824,20 @@ void G4Torus::BVMIntersection( G4double x,G4double y,G4double z,
/* SQRT Test ---------------------------------------------------
// Try This to see precision issue with sqrt(~ 0)
// Try This to see precision issue with std::sqrt(~ 0)
//
G4double DistToZ ;
G4double result;
G4double guess;
DistToZ = sqrt(x*x + y*y) ;
DistToZ = std::sqrt(x*x + y*y) ;
if ((DistToZ < (Rmax - Rmin)) || (DistToZ > (Rmax + Rmin)))
{
return -1.0 ;
}
result = sqrt((Rmin + Rmax - DistToZ)*(Rmin - Rmax + DistToZ));
result = std::sqrt((Rmin + Rmax - DistToZ)*(Rmin - Rmax + DistToZ));
if (dz < 0)
{
@@ -2893,13 +2895,13 @@ void G4Torus::BVMIntersection( G4double x,G4double y,G4double z,
}
else
{
d = sqrt(d) ;
d = std::sqrt(d) ;
NewL[4] = (d - b)/(2*a);
NewL[5] = (-d - b)/(2*a);
if (NewL[4] < 0.0) valid[4] = 0;
if (fabs(z + NewL[4]*dz) - Rmin > POLEPSILON) valid[4] = 0;
if (std::fabs(z + NewL[4]*dz) - Rmin > POLEPSILON) valid[4] = 0;
if (NewL[5] < 0.0) valid[5] = 0;
if (fabs(z + NewL[5]*dz) - Rmin > POLEPSILON) valid[5] = 0;
if (std::fabs(z + NewL[5]*dz) - Rmin > POLEPSILON) valid[5] = 0;
}
}
else
@@ -3019,7 +3021,7 @@ G4double G4Torus::DistanceToTorus ( G4double x, G4double y, G4double z,
case 1:
if (SortL[0] < POLEPSILON)
{
if (fabs(TorusEquation(x,y,z,Rmax,Rmin)) < TORUSPRECISION)
if (std::fabs(TorusEquation(x,y,z,Rmax,Rmin)) < TORUSPRECISION)
{
return 0.0;
}
@@ -3035,7 +3037,7 @@ G4double G4Torus::DistanceToTorus ( G4double x, G4double y, G4double z,
case 3:
if (SortL[0] < POLEPSILON)
{
if (fabs(TorusEquation(x,y,z,Rmax,Rmin)) < TORUSPRECISION)
if (std::fabs(TorusEquation(x,y,z,Rmax,Rmin)) < TORUSPRECISION)
{
return 0.0;
}
+75 -66
View File
@@ -21,22 +21,23 @@
// ********************************************************************
//
//
// $Id: G4Trap.cc,v 1.24 2004/01/26 09:03:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Trap.cc,v 1.28 2004/12/02 09:31:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
//
// class G4Trap
//
// Implementation for G4Trap class
//
// History:
// 21.03.95 P.Kent: Modified for `tolerant' geometry
// 09.09.96 V. Grichine: Final modifications before to commit
// 01.11.96 V.Grichine: Costructor for Right Angular Wedge from STEP, G4Trd/Para
// 08.12.97 J.Allison: Added "nominal" constructor and method SetAllParameters.
// 04.06.99 S.Giani: Fixed CalculateExtent in rotated case.
// 19.11.99 V.Grichine: kUndef was added to Eside enum
// 15.11.04 V.Grichine: bug fixed in G4Trap("name",G4ThreeVector[8] vp)
// 13.12.99 V.Grichine: bug fixed in DistanceToIn(p,v)
// --------------------------------------------------------------------
// 19.11.99 V.Grichine: kUndef was added to Eside enum
// 04.06.99 S.Giani: Fixed CalculateExtent in rotated case.
// 08.12.97 J.Allison: Added "nominal" constructor and method SetAllParameters.
// 01.11.96 V.Grichine: Costructor for Right Angular Wedge from STEP, G4Trd/Para
// 09.09.96 V.Grichine: Final modifications before to commit
// 21.03.95 P.Kent: Modified for `tolerant' geometry
//
#include "G4Trap.hh"
#include "globals.hh"
@@ -89,18 +90,18 @@ G4Trap::G4Trap( const G4String& pName,
pDx2 > 0 && pDy2 > 0 && pDx3 > 0 && pDx4 > 0 )
{
fDz=pDz;
fTthetaCphi=tan(pTheta)*cos(pPhi);
fTthetaSphi=tan(pTheta)*sin(pPhi);
fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
fDy1=pDy1;
fDx1=pDx1;
fDx2=pDx2;
fTalpha1=tan(pAlp1);
fTalpha1=std::tan(pAlp1);
fDy2=pDy2;
fDx3=pDx3;
fDx4=pDx4;
fTalpha2=tan(pAlp2);
fTalpha2=std::tan(pAlp2);
MakePlanes();
}
@@ -127,20 +128,25 @@ G4Trap::G4Trap( const G4String& pName,
const G4ThreeVector pt[8] )
: G4CSGSolid(pName)
{
if ( pt[0].z()<0 && pt[0].z()==pt[1].z()
&& pt[0].z()==pt[2].z() && pt[0].z()==pt[3].z()
&& pt[4].z()>0 && pt[4].z()==pt[5].z()
&& pt[4].z()==pt[6].z() && pt[4].z()==pt[7].z()
&& (pt[0].z()+pt[4].z())== 0
&& pt[0].y()==pt[1].y() && pt[2].y()==pt[3].y()
&& pt[4].y()==pt[5].y() && pt[6].y()==pt[7].y()
&& (pt[0].y()+pt[2].y()+pt[4].y()+pt[6].y())==0 )
// Start with check of centering - the center of gravity trap line
// should cross the origin of frame
if ( pt[0].z() < 0
&& pt[0].z() == pt[1].z() && pt[0].z() == pt[2].z() && pt[0].z() == pt[3].z()
&& pt[4].z() > 0
&& pt[4].z() == pt[5].z() && pt[4].z() == pt[6].z() && pt[4].z() == pt[7].z()
&& ( pt[0].z() + pt[4].z() ) == 0
&& pt[0].y() == pt[1].y() && pt[2].y() == pt[3].y()
&& pt[4].y() == pt[5].y() && pt[6].y() == pt[7].y()
&& ( pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y() ) == 0
&& ( pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() ) == 0 )
{
G4bool good;
// Bottom side with normal approx. -Y
//
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
good = MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
DumpInfo();
@@ -149,8 +155,9 @@ G4Trap::G4Trap( const G4String& pName,
}
// Top side with normal approx. +Y
//
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
good = MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
@@ -159,8 +166,9 @@ G4Trap::G4Trap( const G4String& pName,
}
// Front side with normal approx. -X
//
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
good = MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
@@ -169,29 +177,28 @@ G4Trap::G4Trap( const G4String& pName,
}
// Back side iwth normal approx. +X
//
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
good = MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+X not planar.");
}
fDz = (pt[7]).z() ;
fDy1 = ((pt[2]).y()-(pt[1]).y())*0.5 ;
fDx1 = ((pt[1]).x()-(pt[0]).x())*0.5 ;
fDx2 = ((pt[3]).x()-(pt[2]).x())*0.5 ;
fTalpha1 = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/fDy1 ;
fDy1 = ((pt[2]).y()-(pt[1]).y())*0.5;
fDx1 = ((pt[1]).x()-(pt[0]).x())*0.5;
fDx2 = ((pt[3]).x()-(pt[2]).x())*0.5;
fTalpha1 = ((pt[2]).x()+(pt[3]).x()-(pt[1]).x()-(pt[0]).x())*0.25/fDy1;
fDy2 = ((pt[6]).y()-(pt[5]).y())*0.5 ;
fDx3 = ((pt[5]).x()-(pt[4]).x())*0.5 ;
fDx4 = ((pt[7]).x()-(pt[6]).x())*0.5 ;
fTalpha2 = ((pt[6]).x()+(pt[7]).x()-(pt[5]).x()-(pt[4]).x())*0.25/fDy2 ;
fDy2 = ((pt[6]).y()-(pt[5]).y())*0.5;
fDx3 = ((pt[5]).x()-(pt[4]).x())*0.5;
fDx4 = ((pt[7]).x()-(pt[6]).x())*0.5;
fTalpha2 = ((pt[6]).x()+(pt[7]).x()-(pt[5]).x()-(pt[4]).x())*0.25/fDy2;
fTthetaCphi = ((pt[4]).x()+fDy2*fTalpha2+fDx3)/fDz ;
fTthetaSphi = ((pt[4]).y()+fDy2)/fDz ;
fTthetaCphi = ((pt[4]).x()+fDy2*fTalpha2+fDx3)/fDz;
fTthetaSphi = ((pt[4]).y()+fDy2)/fDz;
}
else
{
@@ -408,13 +415,13 @@ G4Trap::G4Trap( const G4String& pName,
if ( pDz>0 && pDy>0 && pDx>0 )
{
fDz = pDz ;
fTthetaCphi = tan(pTheta)*cos(pPhi) ;
fTthetaSphi = tan(pTheta)*sin(pPhi) ;
fTthetaCphi = std::tan(pTheta)*std::cos(pPhi) ;
fTthetaSphi = std::tan(pTheta)*std::sin(pPhi) ;
fDy1 = pDy ;
fDx1 = pDx ;
fDx2 = pDx ;
fTalpha1 = tan(pAlpha) ;
fTalpha1 = std::tan(pAlpha) ;
fDy2 = pDy ;
fDx3 = pDx ;
@@ -528,21 +535,23 @@ void G4Trap::SetAllParameters ( G4double pDz,
G4double pDx4,
G4double pAlp2 )
{
fCubicVolume= 0.;
fpPolyhedron = 0;
if ( pDz>0 && pDy1>0 && pDx1>0 && pDx2>0 && pDy2>0 && pDx3>0 && pDx4>0 )
{
fDz=pDz;
fTthetaCphi=tan(pTheta)*cos(pPhi);
fTthetaSphi=tan(pTheta)*sin(pPhi);
fTthetaCphi=std::tan(pTheta)*std::cos(pPhi);
fTthetaSphi=std::tan(pTheta)*std::sin(pPhi);
fDy1=pDy1;
fDx1=pDx1;
fDx2=pDx2;
fTalpha1=tan(pAlp1);
fTalpha1=std::tan(pAlp1);
fDy2=pDy2;
fDx3=pDx3;
fDx4=pDx4;
fTalpha2=tan(pAlp2);
fTalpha2=std::tan(pAlp2);
MakePlanes();
}
@@ -654,7 +663,7 @@ G4bool G4Trap::MakePlane( const G4ThreeVector& p1,
v14 = p4-p1;
Vcross=v12.cross(v13);
if (fabs(Vcross.dot(v14)/(Vcross.mag()*v14.mag())) > kCoplanar_Tolerance)
if (std::fabs(Vcross.dot(v14)/(Vcross.mag()*v14.mag())) > kCoplanar_Tolerance)
{
good=false;
}
@@ -683,7 +692,7 @@ G4bool G4Trap::MakePlane( const G4ThreeVector& p1,
// c = +(p4.x() - p2.x())*(p3.y() - p1.y())
// - (p3.x() - p1.x())*(p4.y() - p2.y()) ;
s=sqrt(a*a+b*b+c*c); // so now vector plane.(a,b,c) is unit
s=std::sqrt(a*a+b*b+c*c); // so now vector plane.(a,b,c) is unit
if( s > 0 )
{
@@ -796,7 +805,7 @@ G4bool G4Trap::CalculateExtent( const EAxis pAxis,
temp[3] = pt[2].y()+(pt[6].y()-pt[2].y())*(zMax-pt[2].z())
/(pt[6].z()-pt[2].z()) ;
yMax = yoffset - fabs(fDz*fTthetaSphi) - fDy1 - fDy2 ;
yMax = yoffset - std::fabs(fDz*fTthetaSphi) - fDy1 - fDy2 ;
yMin = -yMax ;
for( i = 0 ; i < 4 ; i++ )
@@ -840,7 +849,7 @@ G4bool G4Trap::CalculateExtent( const EAxis pAxis,
temp[7] = pt[1].x()+(pt[5].x()-pt[1].x())
*(zMax-pt[1].z())/(pt[5].z()-pt[1].z()) ;
xMax = xoffset - fabs(fDz*fTthetaCphi) - fDx1 - fDx2 -fDx3 - fDx4 ;
xMax = xoffset - std::fabs(fDz*fTthetaCphi) - fDx1 - fDx2 -fDx3 - fDx4 ;
xMin = -xMax ;
for( i = 0 ; i < 8 ; i++ )
@@ -1021,7 +1030,7 @@ EInside G4Trap::Inside( const G4ThreeVector& p ) const
EInside in;
G4double Dist;
G4int i;
if (fabs(p.z())<=fDz-kCarTolerance/2)
if (std::fabs(p.z())<=fDz-kCarTolerance/2)
{
in=kInside;
for (i=0;i<4;i++)
@@ -1038,7 +1047,7 @@ EInside G4Trap::Inside( const G4ThreeVector& p ) const
}
}
}
else if (fabs(p.z())<=fDz+kCarTolerance/2)
else if (std::fabs(p.z())<=fDz+kCarTolerance/2)
{
in=kSurface;
for (i=0;i<4;i++)
@@ -1069,7 +1078,7 @@ G4ThreeVector G4Trap::SurfaceNormal( const G4ThreeVector& p ) const
G4int i,imin=0;
for (i=0;i<4;i++)
{
Dist=fabs(fPlanes[i].a*p.x()+fPlanes[i].b*p.y()
Dist=std::fabs(fPlanes[i].a*p.x()+fPlanes[i].b*p.y()
+fPlanes[i].c*p.z()+fPlanes[i].d);
if (Dist<safe)
{
@@ -1077,7 +1086,7 @@ G4ThreeVector G4Trap::SurfaceNormal( const G4ThreeVector& p ) const
imin=i;
}
}
safez=fabs(fabs(p.z())-fDz);
safez=std::fabs(std::fabs(p.z())-fDz);
if (safe<safez)
{
return G4ThreeVector(fPlanes[imin].a,fPlanes[imin].b,fPlanes[imin].c);
@@ -1143,7 +1152,7 @@ G4double G4Trap::DistanceToIn( const G4ThreeVector& p,
}
else
{
if (fabs(p.z())<fDz - 0.5*kCarTolerance) // Inside was <=fDz
if (std::fabs(p.z())<fDz - 0.5*kCarTolerance) // Inside was <=fDz
{
smin=0;
smax=kInfinity;
@@ -1230,7 +1239,7 @@ G4double G4Trap::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe=0.0,Dist;
G4int i;
safe=fabs(p.z())-fDz;
safe=std::fabs(p.z())-fDz;
for (i=0;i<4;i++)
{
Dist=fPlanes[i].a*p.x()+fPlanes[i].b*p.y()
@@ -1556,7 +1565,7 @@ G4double G4Trap::DistanceToOut( const G4ThreeVector& p ) const
}
#endif
safe=fDz-fabs(p.z());
safe=fDz-std::fabs(p.z());
if (safe<0) safe=0;
else
{
@@ -1651,10 +1660,10 @@ std::ostream& G4Trap::StreamInfo( std::ostream& os ) const
<< " half length Y of face +fDz: " << fDy2/mm << " mm \n"
<< " half length X of side -fDy2, face +fDz: " << fDx3/mm << " mm \n"
<< " half length X of side +fDy2, face +fDz: " << fDx4/mm << " mm \n"
<< " tan(theta)*cos(phi): " << fTthetaCphi/degree << " degrees \n"
<< " tan(theta)*sin(phi): " << fTthetaSphi/degree << " degrees \n"
<< " tan(alpha), -fDz: " << fTalpha1/degree << " degrees \n"
<< " tan(alpha), +fDz: " << fTalpha2/degree << " degrees \n"
<< " std::tan(theta)*std::cos(phi): " << fTthetaCphi/degree << " degrees \n"
<< " std::tan(theta)*std::sin(phi): " << fTthetaSphi/degree << " degrees \n"
<< " std::tan(alpha), -fDz: " << fTalpha1/degree << " degrees \n"
<< " std::tan(alpha), +fDz: " << fTalpha2/degree << " degrees \n"
<< " trap side plane equations:\n"
<< " " << fPlanes[0].a << " X + " << fPlanes[0].b << " Y + "
<< fPlanes[0].c << " Z + " << fPlanes[0].d << " = 0\n"
@@ -1680,10 +1689,10 @@ void G4Trap::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
G4Polyhedron* G4Trap::CreatePolyhedron () const
{
G4double phi = atan2(fTthetaSphi, fTthetaCphi);
G4double alpha1 = atan(fTalpha1);
G4double alpha2 = atan(fTalpha2);
G4double theta = atan(sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
G4double alpha1 = std::atan(fTalpha1);
G4double alpha2 = std::atan(fTalpha2);
G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
return new G4PolyhedronTrap(fDz, theta, phi,
fDy1, fDx1, fDx2, alpha1,
+43 -41
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Trd.cc,v 1.19 2004/01/26 09:03:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Trd.cc,v 1.22 2004/12/02 09:31:29 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-03 $
//
//
// Implementation for G4Trd class
@@ -97,6 +97,8 @@ void G4Trd::CheckAndSetAllParameters ( G4double pdx1, G4double pdx2,
"Invalid parameters.");
}
}
fCubicVolume= 0.;
fpPolyhedron = 0;
}
//////////////////////////////////////////////////////////////////////////
@@ -318,7 +320,7 @@ EInside G4Trd::Inside( const G4ThreeVector& p ) const
EInside in=kOutside;
G4double x,y,zbase1,zbase2;
if (fabs(p.z())<=fDz-kCarTolerance/2)
if (std::fabs(p.z())<=fDz-kCarTolerance/2)
{
zbase1=p.z()+fDz; // Dist from -ve z plane
zbase2=fDz-p.z(); // Dist from +ve z plane
@@ -326,30 +328,30 @@ EInside G4Trd::Inside( const G4ThreeVector& p ) const
// Check whether inside x tolerance
//
x=0.5*(fDx2*zbase1+fDx1*zbase2)/fDz - kCarTolerance/2;
if (fabs(p.x())<=x)
if (std::fabs(p.x())<=x)
{
y=0.5*((fDy2*zbase1+fDy1*zbase2))/fDz - kCarTolerance/2;
if (fabs(p.y())<=y)
if (std::fabs(p.y())<=y)
{
in=kInside;
}
else if (fabs(p.y())<=y+kCarTolerance)
else if (std::fabs(p.y())<=y+kCarTolerance)
{
in=kSurface;
}
}
else if (fabs(p.x())<=x+kCarTolerance)
else if (std::fabs(p.x())<=x+kCarTolerance)
{
// y = y half width of shape at z of point + tolerant boundary
//
y=0.5*((fDy2*zbase1+fDy1*zbase2))/fDz + kCarTolerance/2;
if (fabs(p.y())<=y)
if (std::fabs(p.y())<=y)
{
in=kSurface;
}
}
}
else if (fabs(p.z())<=fDz+kCarTolerance/2)
else if (std::fabs(p.z())<=fDz+kCarTolerance/2)
{
// Only need to check outer tolerant boundaries
//
@@ -359,12 +361,12 @@ EInside G4Trd::Inside( const G4ThreeVector& p ) const
// x = x half width of shape at z of point plus tolerance
//
x=0.5*(fDx2*zbase1+fDx1*zbase2)/fDz + kCarTolerance/2;
if (fabs(p.x())<=x)
if (std::fabs(p.x())<=x)
{
// y = y half width of shape at z of point
//
y=0.5*((fDy2*zbase1+fDy1*zbase2))/fDz + kCarTolerance/2;
if (fabs(p.y())<=y) in=kSurface;
if (std::fabs(p.y())<=y) in=kSurface;
}
}
return in;
@@ -386,18 +388,18 @@ G4ThreeVector G4Trd::SurfaceNormal( const G4ThreeVector& p ) const
z=2.0*fDz;
tanx=(fDx2-fDx1)/z;
secx=sqrt(1.0+tanx*tanx);
newpx=fabs(p.x())-p.z()*tanx;
secx=std::sqrt(1.0+tanx*tanx);
newpx=std::fabs(p.x())-p.z()*tanx;
widx=fDx2-fDz*tanx;
tany=(fDy2-fDy1)/z;
secy=sqrt(1.0+tany*tany);
newpy=fabs(p.y())-p.z()*tany;
secy=std::sqrt(1.0+tany*tany);
newpy=std::fabs(p.y())-p.z()*tany;
widy=fDy2-fDz*tany;
distx=fabs(newpx-widx)/secx; // perpendicular distance to x side
disty=fabs(newpy-widy)/secy; // to y side
distz=fabs(fabs(p.z())-fDz); // to z side
distx=std::fabs(newpx-widx)/secx; // perpendicular distance to x side
disty=std::fabs(newpy-widy)/secy; // to y side
distz=std::fabs(std::fabs(p.z())-fDz); // to z side
// find closest side
//
@@ -408,7 +410,7 @@ G4ThreeVector G4Trd::SurfaceNormal( const G4ThreeVector& p ) const
// Closest to X
//
fcos=1.0/secx;
// normal=(+/-cos(ang),0,-sin(ang))
// normal=(+/-std::cos(ang),0,-std::sin(ang))
if (p.x()>=0)
norm=G4ThreeVector(fcos,0,-tanx*fcos);
else
@@ -505,7 +507,7 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p,
}
else // v.z=0
{
if (fabs(p.z()) >= fDz ) return snxt ; // Outside & no intersect
if (std::fabs(p.z()) >= fDz ) return snxt ; // Outside & no intersect
else
{
smin = 0 ; // Always inside z range
@@ -553,8 +555,8 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p,
{
// Inside Area - calculate leaving distance
// *Don't* use exact distance to side for tolerance
// = ss1*cos(ang xz)
// = ss1/sqrt(1.0+tanxz*tanxz)
// = ss1*std::cos(ang xz)
// = ss1/std::sqrt(1.0+tanxz*tanxz)
sn1 = 0 ;
if ( ds1 > 0 )
@@ -635,8 +637,8 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p,
{
// Inside Area - calculate leaving distance
// *Don't* use exact distance to side for tolerance
// = ss1*cos(ang yz)
// = ss1/sqrt(1.0+tanyz*tanyz)
// = ss1*std::cos(ang yz)
// = ss1/std::sqrt(1.0+tanyz*tanyz)
sn1 = 0 ;
if ( ds1 > 0 )
@@ -702,7 +704,7 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p ) const
G4double tanyz,disty,safy;
G4double zbase;
safe=fabs(p.z())-fDz;
safe=std::fabs(p.z())-fDz;
if (safe<0) safe=0; // Also used to ensure x/y distances
// POSITIVE
@@ -712,22 +714,22 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p ) const
//
tanxz=(fDx2-fDx1)*0.5/fDz;
// widx=fDx1+tanxz*(fDz+p.z()); // x width at p.z
// distx=fabs(p.x())-widx; // distance to plane
distx=fabs(p.x())-(fDx1+tanxz*zbase);
// distx=std::fabs(p.x())-widx; // distance to plane
distx=std::fabs(p.x())-(fDx1+tanxz*zbase);
if (distx>safe)
{
safx=distx/sqrt(1.0+tanxz*tanxz); // vector Dist=Dist*cos(ang)
safx=distx/std::sqrt(1.0+tanxz*tanxz); // vector Dist=Dist*std::cos(ang)
if (safx>safe) safe=safx;
}
// Find distance along y direction to slanted wall
tanyz=(fDy2-fDy1)*0.5/fDz;
// widy=fDy1+tanyz*(fDz+p.z()); // y width at p.z
// disty=fabs(p.y())-widy; // distance to plane
disty=fabs(p.y())-(fDy1+tanyz*zbase);
// disty=std::fabs(p.y())-widy; // distance to plane
disty=std::fabs(p.y())-(fDy1+tanyz*zbase);
if (disty>safe)
{
safy=disty/sqrt(1.0+tanyz*tanyz); // distance along vector
safy=disty/std::sqrt(1.0+tanyz*tanyz); // distance along vector
if (safy>safe) safe=safy;
}
return safe;
@@ -1097,19 +1099,19 @@ G4double G4Trd::DistanceToOut( const G4ThreeVector& p,
switch (side)
{
case kPX:
cosxz=1.0/sqrt(1.0+tanxz*tanxz);
cosxz=1.0/std::sqrt(1.0+tanxz*tanxz);
*n=G4ThreeVector(cosxz,0,-tanxz*cosxz);
break;
case kMX:
cosxz=-1.0/sqrt(1.0+tanxz*tanxz);
cosxz=-1.0/std::sqrt(1.0+tanxz*tanxz);
*n=G4ThreeVector(cosxz,0,tanxz*cosxz);
break;
case kPY:
cosyz=1.0/sqrt(1.0+tanyz*tanyz);
cosyz=1.0/std::sqrt(1.0+tanyz*tanyz);
*n=G4ThreeVector(0,cosyz,-tanyz*cosyz);
break;
case kMY:
cosyz=-1.0/sqrt(1.0+tanyz*tanyz);
cosyz=-1.0/std::sqrt(1.0+tanyz*tanyz);
*n=G4ThreeVector(0,cosyz,tanyz*cosyz);
break;
case kPZ:
@@ -1155,21 +1157,21 @@ G4double G4Trd::DistanceToOut( const G4ThreeVector& p ) const
}
#endif
safe=fDz-fabs(p.z()); // z perpendicular Dist
safe=fDz-std::fabs(p.z()); // z perpendicular Dist
zbase=fDz+p.z();
// xdist = distance perpendicular to z axis to closest x plane from p
// = (x half width of shape at p.z) - fabs(p.x)
// = (x half width of shape at p.z) - std::fabs(p.x)
//
tanxz=(fDx2-fDx1)*0.5/fDz;
xdist=fDx1+tanxz*zbase-fabs(p.x());
saf1=xdist/sqrt(1.0+tanxz*tanxz); // x*cos(ang_xz) =
xdist=fDx1+tanxz*zbase-std::fabs(p.x());
saf1=xdist/std::sqrt(1.0+tanxz*tanxz); // x*std::cos(ang_xz) =
// shortest (perpendicular)
// distance to plane
tanyz=(fDy2-fDy1)*0.5/fDz;
ydist=fDy1+tanyz*zbase-fabs(p.y());
saf2=ydist/sqrt(1.0+tanyz*tanyz);
ydist=fDy1+tanyz*zbase-std::fabs(p.y());
saf2=ydist/std::sqrt(1.0+tanyz*tanyz);
// Return minimum x/y/z distance
//
+109 -109
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Tubs.cc,v 1.42 2004/01/26 09:03:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4Tubs.cc,v 1.44 2004/12/10 16:22:38 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-00-cand-05 $
//
//
// class G4Tubs
@@ -103,9 +103,9 @@ G4Tubs::G4Tubs( const G4String &pName,
G4Exception("G4Tubs::G4Tubs()", "InvalidSetup", FatalException,
"Invalid radii.");
}
if ( pDPhi >= 2.0*M_PI ) // Check angles
if ( pDPhi >= twopi ) // Check angles
{
fDPhi=2*M_PI;
fDPhi=twopi;
}
else
{
@@ -129,15 +129,15 @@ G4Tubs::G4Tubs( const G4String &pName,
if ( fSPhi < 0 )
{
fSPhi = 2.0*M_PI - fmod(fabs(fSPhi),2.0*M_PI) ;
fSPhi = twopi - std::fmod(std::fabs(fSPhi),twopi) ;
}
else
{
fSPhi = fmod(fSPhi,2.0*M_PI) ;
fSPhi = std::fmod(fSPhi,twopi) ;
}
if (fSPhi + fDPhi > 2.0*M_PI )
if (fSPhi + fDPhi > twopi )
{
fSPhi -= 2.0*M_PI ;
fSPhi -= twopi ;
}
}
@@ -172,7 +172,7 @@ G4bool G4Tubs::CalculateExtent( const EAxis pAxis,
G4double& pMax ) const
{
if ( !pTransform.IsRotated() && fDPhi == 2.0*M_PI && fRMin == 0 )
if ( !pTransform.IsRotated() && fDPhi == twopi && fRMin == 0 )
{
// Special case handling for unrotated solid tubes
// Compute x/y/z mins and maxs fro bounding box respecting limits,
@@ -272,8 +272,8 @@ G4bool G4Tubs::CalculateExtent( const EAxis pAxis,
// Y limits don't cross max/min x => compute max delta x,
// hence new mins/maxs
diff1 = sqrt(fRMax*fRMax - yoff1*yoff1);
diff2 = sqrt(fRMax*fRMax - yoff2*yoff2);
diff1 = std::sqrt(fRMax*fRMax - yoff1*yoff1);
diff2 = std::sqrt(fRMax*fRMax - yoff2*yoff2);
maxDiff = (diff1 > diff2) ? diff1:diff2;
newMin = xoffset - maxDiff;
newMax = xoffset + maxDiff;
@@ -297,8 +297,8 @@ G4bool G4Tubs::CalculateExtent( const EAxis pAxis,
// X limits don't cross max/min y => compute max delta y,
// hence new mins/maxs
diff1 = sqrt(fRMax*fRMax - xoff1*xoff1) ;
diff2 = sqrt(fRMax*fRMax - xoff2*xoff2) ;
diff1 = std::sqrt(fRMax*fRMax - xoff1*xoff1) ;
diff2 = std::sqrt(fRMax*fRMax - xoff2*xoff2) ;
maxDiff = (diff1 > diff2) ? diff1 : diff2 ;
newMin = yoffset - maxDiff ;
newMax = yoffset + maxDiff ;
@@ -395,7 +395,7 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
G4double r2,pPhi,tolRMin,tolRMax;
EInside in = kOutside ;
if (fabs(p.z()) <= fDz - kCarTolerance*0.5)
if (std::fabs(p.z()) <= fDz - kCarTolerance*0.5)
{
r2 = p.x()*p.x() + p.y()*p.y() ;
@@ -406,23 +406,23 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
if (r2 >= tolRMin*tolRMin && r2 <= tolRMax*tolRMax)
{
// if ( fDPhi == 2*M_PI || r2 == 0 ) in = kInside ;
if ( fDPhi == 2*M_PI ) in = kInside ;
// if ( fDPhi == twopi || r2 == 0 ) in = kInside ;
if ( fDPhi == twopi ) in = kInside ;
else
{
// Try inner tolerant phi boundaries (=>inside)
// if not inside, try outer tolerant phi boundaries
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < -kAngTolerance*0.5 ) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( pPhi < -kAngTolerance*0.5 ) pPhi += twopi ; // 0<=pPhi<2pi
if ( fSPhi >= 0 )
{
if ( (abs(pPhi) < kAngTolerance*0.5)
&& (abs(fSPhi + fDPhi - 2*M_PI) < kAngTolerance*0.5) )
if ( (std::abs(pPhi) < kAngTolerance*0.5)
&& (std::abs(fSPhi + fDPhi - twopi) < kAngTolerance*0.5) )
{
pPhi += 2*M_PI ; // 0 <= pPhi < 2pi
pPhi += twopi ; // 0 <= pPhi < 2pi
}
if ( (pPhi >= fSPhi + kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi - kAngTolerance*0.5) )
@@ -437,9 +437,9 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
}
else // fSPhi < 0
{
if ( (pPhi <= fSPhi + 2*M_PI - kAngTolerance*0.5)
if ( (pPhi <= fSPhi + twopi - kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi + kAngTolerance*0.5) ) ;
else if ( (pPhi <= fSPhi + 2*M_PI + kAngTolerance*0.5)
else if ( (pPhi <= fSPhi + twopi + kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi - kAngTolerance*0.5) )
{
in = kSurface ;
@@ -460,21 +460,21 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
if ( (r2 >= tolRMin*tolRMin) && (r2 <= tolRMax*tolRMax) )
{
if ( fDPhi == 2*M_PI || r2 == 0 ) // Continuous in phi or on z-axis
if ( fDPhi == twopi || r2 == 0 ) // Continuous in phi or on z-axis
{
in = kSurface ;
}
else // Try outer tolerant phi boundaries only
{
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < -kAngTolerance*0.5 ) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( pPhi < -kAngTolerance*0.5 ) pPhi += twopi ; // 0<=pPhi<2pi
if ( fSPhi >= 0 )
{
if ( (abs(pPhi) < kAngTolerance*0.5)
&& (abs(fSPhi + fDPhi - 2*M_PI) < kAngTolerance*0.5) )
if ( (std::abs(pPhi) < kAngTolerance*0.5)
&& (std::abs(fSPhi + fDPhi - twopi) < kAngTolerance*0.5) )
{
pPhi += 2*M_PI ; // 0 <= pPhi < 2pi
pPhi += twopi ; // 0 <= pPhi < 2pi
}
if ( (pPhi >= fSPhi - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + kAngTolerance*0.5) )
@@ -484,7 +484,7 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
}
else // fSPhi < 0
{
if ( (pPhi <= fSPhi + 2*M_PI - kAngTolerance*0.5)
if ( (pPhi <= fSPhi + twopi - kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi + kAngTolerance*0.5) ) ;
else
{
@@ -495,7 +495,7 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
}
}
}
else if (fabs(p.z()) <= fDz + kCarTolerance*0.5)
else if (std::fabs(p.z()) <= fDz + kCarTolerance*0.5)
{ // Check within tolerant r limits
r2 = p.x()*p.x() + p.y()*p.y() ;
tolRMin = fRMin - kRadTolerance*0.5 ;
@@ -505,21 +505,21 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
if ( (r2 >= tolRMin*tolRMin) && (r2 <= tolRMax*tolRMax) )
{
if (fDPhi == 2*M_PI || r2 == 0 ) // Continuous in phi or on z-axis
if (fDPhi == twopi || r2 == 0 ) // Continuous in phi or on z-axis
{
in = kSurface ;
}
else // Try outer tolerant phi boundaries
{
pPhi = atan2(p.y(),p.x()) ;
pPhi = std::atan2(p.y(),p.x()) ;
if ( pPhi < -kAngTolerance*0.5 ) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( pPhi < -kAngTolerance*0.5 ) pPhi += twopi ; // 0<=pPhi<2pi
if ( fSPhi >= 0 )
{
if ( (abs(pPhi) < kAngTolerance*0.5)
&& (abs(fSPhi + fDPhi - 2*M_PI) < kAngTolerance*0.5) )
if ( (std::abs(pPhi) < kAngTolerance*0.5)
&& (std::abs(fSPhi + fDPhi - twopi) < kAngTolerance*0.5) )
{
pPhi += 2*M_PI ; // 0 <= pPhi < 2pi
pPhi += twopi ; // 0 <= pPhi < 2pi
}
if ( (pPhi >= fSPhi - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + kAngTolerance*0.5) )
@@ -529,7 +529,7 @@ EInside G4Tubs::Inside( const G4ThreeVector& p ) const
}
else // fSPhi < 0
{
if ( (pPhi <= fSPhi + 2*M_PI - kAngTolerance*0.5)
if ( (pPhi <= fSPhi + twopi - kAngTolerance*0.5)
&& (pPhi >= fSPhi + fDPhi + kAngTolerance*0.5) ) ;
else
{
@@ -555,11 +555,11 @@ G4ThreeVector G4Tubs::SurfaceNormal( const G4ThreeVector& p ) const
G4double rho, phi ;
G4double distZ, distRMin, distRMax, distSPhi, distEPhi, distMin ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
distRMin = fabs(rho - fRMin) ;
distRMax = fabs(rho - fRMax) ;
distZ = fabs(fabs(p.z()) - fDz) ;
distRMin = std::fabs(rho - fRMin) ;
distRMax = std::fabs(rho - fRMax) ;
distZ = std::fabs(std::fabs(p.z()) - fDz) ;
if (distRMin < distRMax) // First minimum
{
@@ -587,21 +587,21 @@ G4ThreeVector G4Tubs::SurfaceNormal( const G4ThreeVector& p ) const
side = kNRMax ;
}
}
if (fDPhi < 2.0*M_PI && rho ) // Protected against (0,0,z)
if (fDPhi < twopi && rho ) // Protected against (0,0,z)
{
phi = atan2(p.y(),p.x()) ;
phi = std::atan2(p.y(),p.x()) ;
if ( phi < 0 ) phi += 2*M_PI ;
if ( phi < 0 ) phi += twopi ;
if ( fSPhi < 0 )
{
distSPhi = fabs(phi - (fSPhi + 2.0*M_PI))*rho ;
distSPhi = std::fabs(phi - (fSPhi + twopi))*rho ;
}
else
{
distSPhi = fabs(phi - fSPhi)*rho ;
distSPhi = std::fabs(phi - fSPhi)*rho ;
}
distEPhi = fabs(phi - fSPhi - fDPhi)*rho ;
distEPhi = std::fabs(phi - fSPhi - fDPhi)*rho ;
if (distSPhi < distEPhi) // Find new minimum
{
@@ -638,12 +638,12 @@ G4ThreeVector G4Tubs::SurfaceNormal( const G4ThreeVector& p ) const
}
case kNSPhi:
{
norm = G4ThreeVector(sin(fSPhi),-cos(fSPhi),0) ;
norm = G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0) ;
break ;
}
case kNEPhi:
{
norm = G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0) ;
norm = G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0) ;
break;
}
default:
@@ -712,17 +712,17 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
// Set phi divided flag and precalcs
if ( fDPhi < 2.0*M_PI )
if ( fDPhi < twopi )
{
seg = true ;
hDPhi = 0.5*fDPhi ; // half delta phi
cPhi = fSPhi + hDPhi ;
hDPhiOT = hDPhi + 0.5*kAngTolerance ; // outers tol' half delta phi
hDPhiIT = hDPhi - 0.5*kAngTolerance ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
cosHDPhiOT = cos(hDPhiOT) ;
cosHDPhiIT = cos(hDPhiIT) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
cosHDPhiOT = std::cos(hDPhiOT) ;
cosHDPhiIT = std::cos(hDPhiIT) ;
}
else
{
@@ -749,11 +749,11 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
tolIDz = fDz - kCarTolerance*0.5 ;
tolODz = fDz + kCarTolerance*0.5 ;
if (fabs(p.z()) >= tolIDz)
if (std::fabs(p.z()) >= tolIDz)
{
if ( p.z()*v.z() < 0 ) // at +Z going in -Z or visa versa
{
s = (fabs(p.z()) - fDz)/fabs(v.z()) ; // Z intersect distance
s = (std::fabs(p.z()) - fDz)/std::fabs(v.z()) ; // Z intersect distance
if(s < 0.0) s = 0.0 ;
@@ -770,7 +770,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
// Psi = angle made with central (average) phi of shape
//
inum = xi*cosCPhi + yi*sinCPhi ;
iden = sqrt(rho2) ;
iden = std::sqrt(rho2) ;
cosPsi = inum/iden ;
if (cosPsi >= cosHDPhiIT) return s ;
}
@@ -814,13 +814,13 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
if (d >= 0) // If real root
{
s = -b - sqrt(d) ;
s = -b - std::sqrt(d) ;
if (s >= 0) // If 'forwards'
{
// Check z intersection
//
zi = p.z() + s*v.z() ;
if (fabs(zi)<=tolODz)
if (std::fabs(zi)<=tolODz)
{
// Z ok. Check phi intersection if reqd
//
@@ -835,7 +835,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
cosPsi = (xi*cosCPhi + yi*sinCPhi)/fRMax ;
if (cosPsi >= cosHDPhiIT) return s ;
}
} // end if fabs(zi)
} // end if std::fabs(zi)
} // end if (s>=0)
} // end if (d>=0)
} // end if (r>=fRMax)
@@ -844,14 +844,14 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
// Inside outer radius :
// check not inside, and heading through tubs (-> 0 to in)
if (t3 > tolIRMin2 && t2 < 0 && fabs(p.z()) <= tolIDz)
if (t3 > tolIRMin2 && t2 < 0 && std::fabs(p.z()) <= tolIDz)
{
// Inside both radii, delta r -ve, inside z extent
if (seg)
{
inum = p.x()*cosCPhi + p.y()*sinCPhi ;
iden = sqrt(t3) ;
iden = std::sqrt(t3) ;
cosPsi = inum/iden ;
if (cosPsi >= cosHDPhiIT) return 0.0 ;
}
@@ -870,14 +870,14 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
// Always want 2nd root - we are outside and know rmax Hit was bad
// - If on surface of rmin also need farthest root
s = -b + sqrt(d) ;
s = -b + std::sqrt(d) ;
if (s >= -0.5*kCarTolerance) // check forwards
{
// Check z intersection
//
if(s < 0.0) s = 0.0 ;
zi = p.z() + s*v.z() ;
if (fabs(zi) <= tolODz)
if (std::fabs(zi) <= tolODz)
{
// Z ok. Check phi
//
@@ -898,7 +898,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
snxt = s ;
}
}
} // end if fabs(zi)
} // end if std::fabs(zi)
} // end if (s>=0)
} // end if (d>=0)
} // end if (fRMin)
@@ -917,8 +917,8 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
{
// First phi surface (`S'tarting phi)
sinSPhi = sin(fSPhi) ;
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ;
cosSPhi = std::cos(fSPhi) ;
Comp = v.x()*sinSPhi - v.y()*cosSPhi ;
if ( Comp < 0 ) // Component in outwards normal dirn
@@ -933,7 +933,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
{
if ( s < 0 ) s = 0.0 ;
zi = p.z() + s*v.z() ;
if ( fabs(zi) <= tolODz )
if ( std::fabs(zi) <= tolODz )
{
xi = p.x() + s*v.x() ;
yi = p.y() + s*v.y() ;
@@ -960,8 +960,8 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
// Second phi surface (`E'nding phi)
ePhi = fSPhi + fDPhi ;
sinEPhi = sin(ePhi) ;
cosEPhi = cos(ePhi) ;
sinEPhi = std::sin(ePhi) ;
cosEPhi = std::cos(ePhi) ;
Comp = -(v.x()*sinEPhi - v.y()*cosEPhi) ;
if (Comp < 0 ) // Component in outwards normal dirn
@@ -976,7 +976,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
{
if ( s < 0 ) s = 0 ;
zi = p.z() + s*v.z() ;
if ( fabs(zi) <= tolODz )
if ( std::fabs(zi) <= tolODz )
{
xi = p.x() + s*v.x() ;
yi = p.y() + s*v.y() ;
@@ -1034,37 +1034,37 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p ) const
G4double safe=0.0, rho, safe1, safe2, safe3 ;
G4double phiC, cosPhiC, sinPhiC, safePhi, ePhi, cosPsi ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
safe1 = fRMin - rho ;
safe2 = rho - fRMax ;
safe3 = fabs(p.z()) - fDz ;
safe3 = std::fabs(p.z()) - fDz ;
if ( safe1 > safe2 ) safe = safe1 ;
else safe = safe2 ;
if ( safe3 > safe ) safe = safe3 ;
if (fDPhi < 2.0*M_PI && rho)
if (fDPhi < twopi && rho)
{
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
// Psi=angle from central phi to point
//
cosPsi = (p.x()*cosPhiC + p.y()*sinPhiC)/rho ;
if ( cosPsi < cos(fDPhi*0.5) )
if ( cosPsi < std::cos(fDPhi*0.5) )
{
// Point lies outside phi range
if ( (p.y()*cosPhiC - p.x()*sinPhiC) <= 0 )
{
safePhi = fabs(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = std::fabs(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = fabs(p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = std::fabs(p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if ( safePhi > safe ) safe = safePhi ;
}
@@ -1174,7 +1174,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
{
b = t2/t1 ;
c = deltaR/t1 ;
sr = -b + sqrt(b*b - c);
sr = -b + std::sqrt(b*b - c);
sider = kRMax ;
}
else
@@ -1216,7 +1216,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
if (deltaR > kRadTolerance*fRMin)
{
sr = -b-sqrt(d2) ;
sr = -b-std::sqrt(d2) ;
sider = kRMin ;
}
else
@@ -1229,7 +1229,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
{
deltaR = t3 - fRMax*fRMax ;
c = deltaR/t1 ;
sr = -b + sqrt(b*b - c) ;
sr = -b + std::sqrt(b*b - c) ;
sider = kRMax ;
}
}
@@ -1239,23 +1239,23 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
deltaR = t3 - fRMax*fRMax ;
b = t2/t1 ;
c = deltaR/t1;
sr = -b + sqrt(b*b - c) ;
sr = -b + std::sqrt(b*b - c) ;
sider = kRMax ;
}
}
// Phi Intersection
if ( fDPhi < 2.0*M_PI )
if ( fDPhi < twopi )
{
sinSPhi = sin(fSPhi) ;
cosSPhi = cos(fSPhi) ;
sinSPhi = std::sin(fSPhi) ;
cosSPhi = std::cos(fSPhi) ;
ePhi = fSPhi + fDPhi ;
sinEPhi = sin(ePhi) ;
cosEPhi = cos(ePhi) ;
sinEPhi = std::sin(ePhi) ;
cosEPhi = std::cos(ePhi) ;
cPhi = fSPhi + fDPhi*0.5 ;
sinCPhi = sin(cPhi) ;
cosCPhi = cos(cPhi) ;
sinCPhi = std::sin(cPhi) ;
cosCPhi = std::cos(cPhi) ;
if ( p.x() || p.y() ) // Check if on z axis (rho not needed later)
{
@@ -1346,7 +1346,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
// On z axis + travel not || to z axis -> if phi of vector direction
// within phi of shape, Step limited by rmax, else Step =0
vphi = atan2(v.y(),v.x()) ;
vphi = std::atan2(v.y(),v.x()) ;
if ( (fSPhi < vphi) && (vphi < fSPhi + fDPhi) )
{
sphi = kInfinity ;
@@ -1388,9 +1388,9 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
break ;
case kSPhi:
if ( fDPhi <= M_PI )
if ( fDPhi <= pi )
{
*n = G4ThreeVector(sin(fSPhi),-cos(fSPhi),0) ;
*n = G4ThreeVector(std::sin(fSPhi),-std::cos(fSPhi),0) ;
*validNorm = true ;
}
else
@@ -1400,9 +1400,9 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
break ;
case kEPhi:
if (fDPhi <= M_PI)
if (fDPhi <= pi)
{
*n = G4ThreeVector(-sin(fSPhi+fDPhi),cos(fSPhi+fDPhi),0) ;
*n = G4ThreeVector(-std::sin(fSPhi+fDPhi),std::cos(fSPhi+fDPhi),0) ;
*validNorm = true ;
}
else
@@ -1452,7 +1452,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe=0.0, rho, safeR1, safeR2, safeZ ;
G4double safePhi, phiC, cosPhiC, sinPhiC, ePhi ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
rho = std::sqrt(p.x()*p.x() + p.y()*p.y()) ;
#ifdef G4CSGDEBUG
if( Inside(p) == kOutside )
@@ -1481,28 +1481,28 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p ) const
{
safe = fRMax - rho ;
}
safeZ = fDz - fabs(p.z()) ;
safeZ = fDz - std::fabs(p.z()) ;
if ( safeZ < safe ) safe = safeZ ;
// Check if phi divided, Calc distances closest phi plane
//
if ( fDPhi < 2.0*M_PI )
if ( fDPhi < twopi )
{
// Above/below central phi of Tubs?
phiC = fSPhi + fDPhi*0.5 ;
cosPhiC = cos(phiC) ;
sinPhiC = sin(phiC) ;
cosPhiC = std::cos(phiC) ;
sinPhiC = std::sin(phiC) ;
if ( (p.y()*cosPhiC - p.x()*sinPhiC) <= 0 )
{
safePhi = -(p.x()*sin(fSPhi) - p.y()*cos(fSPhi)) ;
safePhi = -(p.x()*std::sin(fSPhi) - p.y()*std::cos(fSPhi)) ;
}
else
{
ePhi = fSPhi + fDPhi ;
safePhi = (p.x()*sin(ePhi) - p.y()*cos(ePhi)) ;
safePhi = (p.x()*std::sin(ePhi) - p.y()*std::cos(ePhi)) ;
}
if (safePhi < safe) safe = safePhi ;
}
@@ -1549,13 +1549,13 @@ G4Tubs::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
meshAngle = fDPhi/(noCrossSections - 1) ;
// meshAngle = fDPhi/(noCrossSections) ;
meshRMax = (fRMax+100*kCarTolerance)/cos(meshAngle*0.5) ;
meshRMax = (fRMax+100*kCarTolerance)/std::cos(meshAngle*0.5) ;
meshRMin = fRMin - 100*kCarTolerance ;
// If complete in phi, set start angle such that mesh will be at fRMax
// on the x axis. Will give better extent calculations when not rotated.
if (fDPhi == M_PI*2.0 && fSPhi == 0 ) sAngle = -meshAngle*0.5 ;
if (fDPhi == pi*2.0 && fSPhi == 0 ) sAngle = -meshAngle*0.5 ;
else sAngle = fSPhi ;
vertices = new G4ThreeVectorList();
@@ -1568,8 +1568,8 @@ G4Tubs::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
// Compute coordinates of cross section at section crossSection
crossAngle = sAngle + crossSection*meshAngle ;
cosCrossAngle = cos(crossAngle) ;
sinCrossAngle = sin(crossAngle) ;
cosCrossAngle = std::cos(crossAngle) ;
sinCrossAngle = std::sin(crossAngle) ;
rMaxX = meshRMax*cosCrossAngle ;
rMaxY = meshRMax*sinCrossAngle ;
@@ -1655,7 +1655,7 @@ G4NURBS* G4Tubs::CreateNURBS () const
G4NURBS* pNURBS ;
if (fRMin != 0)
{
if (fDPhi >= 2.0 * M_PI)
if (fDPhi >= twopi)
{
pNURBS = new G4NURBStube (fRMin,fRMax,fDz) ;
}
@@ -1666,7 +1666,7 @@ G4NURBS* G4Tubs::CreateNURBS () const
}
else
{
if (fDPhi >= 2.0 * M_PI)
if (fDPhi >= twopi)
{
pNURBS = new G4NURBScylinder (fRMax,fDz) ;
}