Import Geant4 6.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:41:53 +02:00
parent 4aea781e80
commit 96686e0c8f
6560 changed files with 153347 additions and 238155 deletions
+20 -24
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Box.cc,v 1.20 2003/06/16 16:53:34 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Box.cc,v 1.24 2003/11/03 18:17:31 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
//
@@ -35,7 +35,7 @@
// and information before exception in DistanceToOut(p,v,...)
// 15.11.00 - D.Williams, V.Grichine: bug fixed in CalculateExtent - change
// algorithm for rotated vertices
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Box.hh"
@@ -70,13 +70,11 @@ G4Box::G4Box(const G4String& pName,
}
else
{
G4cout << "ERROR - G4Box()::G4Box(): " << GetName() << G4endl
<< " Dimensions too small ! - "
<< pX << ", " << pY << ", " << pZ << G4endl;
G4cerr << "ERROR - G4Box()::G4Box(): " << GetName() << G4endl
<< " Dimensions too small ! - "
<< pX << ", " << pY << ", " << pZ << G4endl;
G4Exception("G4Box::G4Box() - invalid dimensions");
G4Exception("G4Box::G4Box()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
}
@@ -96,13 +94,11 @@ void G4Box::SetXHalfLength(G4double dx)
fDx = dx;
else
{
G4cout << "ERROR - G4Box()::SetXHalfLength(): " << GetName() << G4endl
<< " Dimension X too small ! - "
<< dx << G4endl;
G4cerr << "ERROR - G4Box()::SetXHalfLength(): " << GetName() << G4endl
<< " Dimension X too small ! - "
<< dx << G4endl;
G4Exception("G4Box::SetXHalfLength() - invalid dimensions");
G4Exception("G4Box::SetXHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
}
@@ -112,13 +108,11 @@ void G4Box::SetYHalfLength(G4double dy)
fDy = dy;
else
{
G4cout << "ERROR - G4Box()::SetYHalfLength(): " << GetName() << G4endl
<< " Dimension Y too small ! - "
<< dy << G4endl;
G4cerr << "ERROR - G4Box()::SetYHalfLength(): " << GetName() << G4endl
<< " Dimension Y too small ! - "
<< dy << G4endl;
G4Exception("G4Box::SetYHalfLength() - invalid dimensions");
G4Exception("G4Box::SetYHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
}
@@ -128,13 +122,11 @@ void G4Box::SetZHalfLength(G4double dz)
fDz = dz;
else
{
G4cout << "ERROR - G4Box()::SetZHalfLength(): " << GetName() << G4endl
<< " Dimension Z too small ! - "
<< dz << G4endl;
G4cerr << "ERROR - G4Box()::SetZHalfLength(): " << GetName() << G4endl
<< " Dimension Z too small ! - "
<< dz << G4endl;
G4Exception("G4Box::SetZHalfLength() - invalid dimensions");
G4Exception("G4Box::SetZHalfLength()", "InvalidSetup",
FatalException, "Invalid dimensions. Too small.");
}
}
@@ -724,7 +716,9 @@ G4double G4Box::DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("G4Box::DistanceToOut() - Invalid enum");
G4Exception("G4Box::DistanceToOut()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
@@ -738,7 +732,7 @@ G4double G4Box::DistanceToOut( const G4ThreeVector& p,const G4ThreeVector& v,
G4double G4Box::DistanceToOut(const G4ThreeVector& p) const
{
G4double safx1,safx2,safy1,safy2,safz1,safz2,safe;
G4double safx1,safx2,safy1,safy2,safz1,safz2,safe=0.0;
#ifdef G4CSGDEBUG
if( Inside(p) == kOutside )
@@ -750,8 +744,8 @@ G4double G4Box::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 << "G4Box::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Box::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Box::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -813,7 +807,9 @@ G4Box::CreateRotatedVertices(const G4AffineTransform& pTransform) const
else
{
DumpInfo();
G4Exception("G4Box::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Box::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
+4 -2
View File
@@ -21,9 +21,11 @@
// ********************************************************************
//
//
// $Id: G4CSGSolid.cc,v 1.5 2003/06/16 16:53:35 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4CSGSolid.cc,v 1.6 2003/11/03 18:17:31 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
#include "G4CSGSolid.hh"
// Constructor
+22 -24
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Cons.cc,v 1.25 2003/06/16 16:53:36 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Cons.cc,v 1.29 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4Cons
//
@@ -41,7 +41,7 @@
// 17.08.00 V.Grichine: if one and only one Rmin=0, it'll be 1e3*kRadTolerance
// 05.10.00 V.Grichine: bugs fixed in Distance ToIn(p,v)
// 26.06.02 V.Grichine: bugs fixed in Distance ToIn(p,v)
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Cons.hh"
@@ -93,13 +93,11 @@ G4Cons::G4Cons( const G4String& pName,
fDz = pDz ;
else
{
G4cout << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Negative Z half-length ! - "
<< pDz << G4endl;
G4cerr << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Negative Z half-length ! - "
<< pDz << G4endl;
G4Exception("G4Cons::G4Cons() - invalid Z half-length");
G4Exception("G4Cons::G4Cons()", "InvalidSetup",
FatalException, "Invalid Z half-length.");
}
// Check radii
@@ -116,15 +114,12 @@ G4Cons::G4Cons( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRmin1 = " << pRmin1 << ", pRmin2 = " << pRmin2
<< ", pRmax1 = " << pRmax1 << ", pRmax2 = " << pRmax2 << G4endl;
G4cerr << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Invalide values for radii ! - "
<< " pRmin1 = " << pRmin1 << ", pRmin2 = " << pRmin2
<< ", pRmax1 = " << pRmax1 << ", pRmax2 = " << pRmax2 << G4endl;
G4Exception("G4Cons::G4Cons() - invalid radii") ;
G4Exception("G4Cons::G4Cons()", "InvalidSetup",
FatalException, "Invalid radii.") ;
}
// Check angles
@@ -139,13 +134,11 @@ G4Cons::G4Cons( const G4String& pName,
if ( pDPhi > 0 ) fDPhi = pDPhi ;
else
{
G4cout << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4cerr << "ERROR - G4Cons()::G4Cons(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4Exception("G4Cons::G4Cons() - invalid pDPhi") ;
G4Exception("G4Cons::G4Cons()", "InvalidSetup",
FatalException, "Invalid pDPhi.") ;
}
// Ensure pSPhi in 0-2PI or -2PI-0 range if shape crosses 0
@@ -657,7 +650,9 @@ G4ThreeVector G4Cons::SurfaceNormal( const G4ThreeVector& p) const
break ;
default:
DumpInfo();
G4Exception("G4Cons::SurfaceNormal() - Logic error") ;
G4Exception("G4Cons::SurfaceNormal()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.") ;
break ;
}
return norm ;
@@ -1275,7 +1270,7 @@ G4double G4Cons::DistanceToIn( const G4ThreeVector& p,
G4double G4Cons::DistanceToIn(const G4ThreeVector& p) const
{
G4double safe, rho, safeR1, safeR2, safeZ ;
G4double safe=0.0, rho, safeR1, safeR2, safeZ ;
G4double tanRMin, secRMin, pRMin ;
G4double tanRMax, secRMax, pRMax ;
G4double phiC, cosPhiC, sinPhiC, safePhi, ePhi ;
@@ -2012,7 +2007,9 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl<< G4endl ;
G4cout << "Proposed distance :" << G4endl<< G4endl ;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl ;
G4Exception("G4Cons::DistanceToOut() - Invalid enum") ;
G4Exception("G4Cons::DistanceToOut()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.") ;
break ;
}
}
@@ -2026,7 +2023,7 @@ G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
G4double G4Cons::DistanceToOut(const G4ThreeVector& p) const
{
G4double safe,rho,safeR1,safeR2,safeZ ;
G4double safe=0.0,rho,safeR1,safeR2,safeZ ;
G4double tanRMin,secRMin,pRMin ;
G4double tanRMax,secRMax,pRMax ;
G4double safePhi,phiC,cosPhiC,sinPhiC,ePhi ;
@@ -2043,9 +2040,8 @@ G4double G4Cons::DistanceToOut(const G4ThreeVector& p) const
G4cout << "p.z() = " << p.z()/mm << " mm" << G4endl << G4endl ;
G4cout << "pho at z = " << sqrt( p.x()*p.x()+p.y()*p.y() )/mm << " mm"
<< G4endl << G4endl ;
G4cout << "G4Cons::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Cons::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Cons::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -2185,7 +2181,9 @@ G4Cons::CreateRotatedVertices(const G4AffineTransform& pTransform) const
else
{
DumpInfo();
G4Exception("G4Cons::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Cons::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices ;
}
+612
View File
@@ -0,0 +1,612 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4Orb.cc,v 1.9 2003/11/05 10:56:58 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4Orb
//
// Implementation for G4Orb class
//
// History:
//
// 20.08.03 V.Grichine - created
// --------------------------------------------------------------------
#include <assert.h>
#include "G4Orb.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
#include "G4VPVParameterisation.hh"
#include "meshdefs.hh"
#include "G4VGraphicsScene.hh"
#include "G4Polyhedron.hh"
#include "G4NURBS.hh"
#include "G4NURBSbox.hh"
// Private enum: Not for external use - used by distanceToOut
enum ESide {kNull,kRMax};
// used by normal
enum ENorm {kNRMax};
const G4double G4Orb::fEpsilon = 2.e-11; // relative tolerance of fRmax
////////////////////////////////////////////////////////////////////////
//
// constructor - check positive radius
//
G4Orb::G4Orb( const G4String& pName,G4double pRmax )
: G4CSGSolid(pName)
{
// Check radius
if (pRmax >= 10*kCarTolerance ) fRmax = pRmax;
else
{
G4Exception("G4Orb::G4Orb()", "InvalidSetup", FatalException,
"Invalid radius > 10*kCarTolerance.");
}
fRmaxTolerance = std::max( kRadTolerance, fEpsilon*fRmax);
}
/////////////////////////////////////////////////////////////////////
//
// Destructor
G4Orb::~G4Orb()
{
}
//////////////////////////////////////////////////////////////////////////
//
// Dispatch to parameterisation for replication mechanism dimension
// computation & modification.
void G4Orb::ComputeDimensions( G4VPVParameterisation* p,
const G4int n,
const G4VPhysicalVolume* pRep)
{
p->ComputeDimensions(*this,n,pRep);
}
////////////////////////////////////////////////////////////////////////////
//
// Calculate extent under transform and specified limit
G4bool G4Orb::CalculateExtent( const EAxis pAxis,
const G4VoxelLimits& pVoxelLimit,
const G4AffineTransform& pTransform,
G4double& pMin, G4double& pMax ) const
{
// Compute x/y/z mins and maxs for bounding box respecting limits,
// with early returns if outside limits. Then switch() on pAxis,
// and compute exact x and y limit for x/y case
G4double xoffset,xMin,xMax;
G4double yoffset,yMin,yMax;
G4double zoffset,zMin,zMax;
G4double diff1,diff2,maxDiff,newMin,newMax;
G4double xoff1,xoff2,yoff1,yoff2;
xoffset=pTransform.NetTranslation().x();
xMin=xoffset-fRmax;
xMax=xoffset+fRmax;
if (pVoxelLimit.IsXLimited())
{
if ( (xMin>pVoxelLimit.GetMaxXExtent()+kCarTolerance)
|| (xMax<pVoxelLimit.GetMinXExtent()-kCarTolerance) )
{
return false;
}
else
{
if (xMin<pVoxelLimit.GetMinXExtent())
{
xMin=pVoxelLimit.GetMinXExtent();
}
if (xMax>pVoxelLimit.GetMaxXExtent())
{
xMax=pVoxelLimit.GetMaxXExtent();
}
}
}
yoffset=pTransform.NetTranslation().y();
yMin=yoffset-fRmax;
yMax=yoffset+fRmax;
if (pVoxelLimit.IsYLimited())
{
if ( (yMin>pVoxelLimit.GetMaxYExtent()+kCarTolerance)
|| (yMax<pVoxelLimit.GetMinYExtent()-kCarTolerance) )
{
return false;
}
else
{
if (yMin<pVoxelLimit.GetMinYExtent())
{
yMin=pVoxelLimit.GetMinYExtent();
}
if (yMax>pVoxelLimit.GetMaxYExtent())
{
yMax=pVoxelLimit.GetMaxYExtent();
}
}
}
zoffset=pTransform.NetTranslation().z();
zMin=zoffset-fRmax;
zMax=zoffset+fRmax;
if (pVoxelLimit.IsZLimited())
{
if ( (zMin>pVoxelLimit.GetMaxZExtent()+kCarTolerance)
|| (zMax<pVoxelLimit.GetMinZExtent()-kCarTolerance) )
{
return false;
}
else
{
if (zMin<pVoxelLimit.GetMinZExtent())
{
zMin=pVoxelLimit.GetMinZExtent();
}
if (zMax>pVoxelLimit.GetMaxZExtent())
{
zMax=pVoxelLimit.GetMaxZExtent();
}
}
}
// Known to cut sphere
switch (pAxis)
{
case kXAxis:
yoff1=yoffset-yMin;
yoff2=yMax-yoffset;
if ( yoff1 >= 0 && yoff2 >= 0 )
{
// Y limits cross max/min x => no change
//
pMin=xMin;
pMax=xMax;
}
else
{
// 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);
maxDiff=(diff1>diff2) ? diff1:diff2;
newMin=xoffset-maxDiff;
newMax=xoffset+maxDiff;
pMin=(newMin<xMin) ? xMin : newMin;
pMax=(newMax>xMax) ? xMax : newMax;
}
break;
case kYAxis:
xoff1=xoffset-xMin;
xoff2=xMax-xoffset;
if (xoff1>=0&&xoff2>=0)
{
// X limits cross max/min y => no change
//
pMin=yMin;
pMax=yMax;
}
else
{
// 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);
maxDiff=(diff1>diff2) ? diff1:diff2;
newMin=yoffset-maxDiff;
newMax=yoffset+maxDiff;
pMin=(newMin<yMin) ? yMin : newMin;
pMax=(newMax>yMax) ? yMax : newMax;
}
break;
case kZAxis:
pMin=zMin;
pMax=zMax;
break;
default:
break;
}
pMin -= fRmaxTolerance;
pMax += fRmaxTolerance;
return true;
}
///////////////////////////////////////////////////////////////////////////
//
// Return whether point inside/outside/on surface
// Split into radius checks
//
EInside G4Orb::Inside( const G4ThreeVector& p ) const
{
G4double rad2,tolRMax;
EInside in;
rad2 = p.x()*p.x()+p.y()*p.y()+p.z()*p.z() ;
// G4double rad = sqrt(rad2);
// Check radial surface
// sets `in'
tolRMax = fRmax - fRmaxTolerance*0.5 ;
if ( rad2 <= tolRMax*tolRMax ) in = kInside ;
else
{
tolRMax = fRmax + fRmaxTolerance*0.5 ;
if ( rad2 <= tolRMax*tolRMax ) in = kSurface ;
else in = kOutside ;
}
return in;
}
/////////////////////////////////////////////////////////////////////
//
// Return unit normal of surface closest to p
// - note if point on z axis, ignore phi divided sides
// - unsafe if point close to z axis a rmin=0 - no explicit checks
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());
switch (side)
{
case kNRMax:
norm = G4ThreeVector(p.x()/rad,p.y()/rad,p.z()/rad);
break;
default:
DumpInfo();
G4Exception("G4Orb::SurfaceNormal()", "LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
return norm;
}
///////////////////////////////////////////////////////////////////////////////
//
// Calculate distance to shape from outside, along normalised vector
// - return kInfinity if no intersection, or intersection distance <= tolerance
//
// -> If point is outside outer radius, compute intersection with rmax
// - if no intersection return
// - if valid phi,theta return intersection Dist
G4double G4Orb::DistanceToIn( const G4ThreeVector& p,
const G4ThreeVector& v ) const
{
G4double snxt = kInfinity ; // snxt = default return value
G4double rad2, pDotV3d, tolORMax2, tolIRMax2 ;
G4double c, d2, s = kInfinity ;
// General Precalcs
rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z() ;
pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z() ;
// Radial Precalcs
tolORMax2 = (fRmax+fRmaxTolerance*0.5)*(fRmax+fRmaxTolerance*0.5) ;
tolIRMax2 = (fRmax-fRmaxTolerance*0.5)*(fRmax-fRmaxTolerance*0.5) ;
// Outer spherical shell intersection
// - Only if outside tolerant fRmax
// - Check for if inside and outer G4Orb heading through solid (-> 0)
// - No intersect -> no intersection with G4Orb
//
// Shell eqn: x^2+y^2+z^2 = RSPH^2
//
// => (px+svx)^2+(py+svy)^2+(pz+svz)^2=R^2
//
// => (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))
c = rad2 - fRmax*fRmax ;
if ( c > fRmaxTolerance*fRmax )
{
// If outside tolerant boundary of outer G4Orb
// [ should be sqrt(rad2) - fRmax > fRmaxTolerance*0.5 ]
d2 = pDotV3d*pDotV3d - c ;
if ( d2 >= 0 )
{
s = -pDotV3d - sqrt(d2) ;
if (s >= 0 ) return snxt = s;
}
else // No intersection with G4Orb
{
return snxt = kInfinity;
}
}
else
{
if ( c > -fRmaxTolerance*fRmax ) // on surface
{
if ( pDotV3d >= 0 ) return snxt = kInfinity;
else return snxt = 0.;
}
else // inside ???
{
G4cout<<"G4Orb::DistanceToIn(p,v) is called from inside ???"<<G4endl;
}
}
return snxt;
}
//////////////////////////////////////////////////////////////////////
//
// Calculate distance (<= actual) to closest surface of shape from outside
// - Calculate distance to radial plane
// - Return 0 if point inside
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());
safe = rad - fRmax;
if( safe < 0 ) safe = 0. ;
return safe;
}
/////////////////////////////////////////////////////////////////////
//
// Calculate distance to surface of shape from `inside', allowing for tolerance
//
G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
const G4ThreeVector& v,
const G4bool calcNorm,
G4bool *validNorm,
G4ThreeVector *n ) const
{
G4double snxt = kInfinity; // ??? snxt is default return value
ESide side = kNull;
G4double rad2,pDotV3d;
G4double xi,yi,zi; // Intersection point
G4double c,d2;
rad2 = p.x()*p.x() + p.y()*p.y() + p.z()*p.z();
pDotV3d = p.x()*v.x() + p.y()*v.y() + p.z()*v.z();
// Radial Intersection from G4Orb::DistanceToIn
//
// Outer spherical shell intersection
// - Only if outside tolerant fRmax
// - Check for if inside and outer G4Orb heading through solid (-> 0)
// - No intersect -> no intersection with G4Orb
//
// Shell eqn: x^2+y^2+z^2=RSPH^2
//
// => (px+svx)^2+(py+svy)^2+(pz+svz)^2=R^2
//
// => (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))
const G4double Rmax_plus = fRmax + fRmaxTolerance*0.5;
if( rad2 <= Rmax_plus*Rmax_plus )
{
c = rad2-fRmax*fRmax ;
if ( c < fRmaxTolerance*fRmax)
{
// Within tolerant Outer radius
//
// The test is
// rad - fRmax < 0.5*fRmaxTolerance
// => rad < fRmax + 0.5*kRadTol
// => rad2 < (fRmax + 0.5*kRadTol)^2
// => rad2 < fRmax^2 + 2.*0.5*fRmax*kRadTol + 0.25*kRadTol*kRadTol
// => rad2 - fRmax^2 <~ fRmax*kRadTol
d2 = pDotV3d*pDotV3d - c;
if( ( c > -fRmaxTolerance*fRmax) && // on tolerant surface
( ( pDotV3d >= 0 ) || ( d2 < 0 )) ) // leaving outside from Rmax
// not re-entering
{
if(calcNorm)
{
*validNorm = true ;
*n = G4ThreeVector(p.x()/fRmax,p.y()/fRmax,p.z()/fRmax) ;
}
return snxt = 0;
}
else
{
snxt = -pDotV3d + sqrt(d2); // second root since inside Rmax
side = kRMax ;
}
}
}
else // p is outside ???
{
G4cout.precision(16);
G4cout << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
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"
<< G4endl << G4endl;
G4cout << "Direction:" << G4endl << G4endl;
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4cout<<"G4Orb::DistanceToOut(p,v,...): snxt = kInfinity ???"<<G4endl;
}
if (calcNorm) // Output switch operator
{
switch( side )
{
case kRMax:
xi=p.x()+snxt*v.x();
yi=p.y()+snxt*v.y();
zi=p.z()+snxt*v.z();
*n=G4ThreeVector(xi/fRmax,yi/fRmax,zi/fRmax);
*validNorm=true;
break;
default:
G4cout.precision(16);
G4cout << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
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 << "Direction:" << G4endl << G4endl;
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("G4Orb::DistanceToOut(p,v,...)",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
return snxt;
}
/////////////////////////////////////////////////////////////////////////
//
// Calcluate distance (<=actual) to closest surface of shape from inside
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());
#ifdef G4CSGDEBUG
if( Inside(p) == kOutside )
{
G4cout.precision(16) ;
G4cout << G4endl ;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl ;
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 ;
G4Exception("G4Orb::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
safe = fRmax - rad;
if ( safe < 0. ) safe = 0.;
return safe;
}
//////////////////////////////////////////////////////////////////////////
//
// G4EntityType
G4GeometryType G4Orb::GetEntityType() const
{
return G4String("G4Orb");
}
//////////////////////////////////////////////////////////////////////////
//
// Stream object contents to an output stream
std::ostream& G4Orb::StreamInfo( std::ostream& os ) const
{
os << "-----------------------------------------------------------\n"
<< " *** Dump for solid - " << GetName() << " ***\n"
<< " ===================================================\n"
<< " Solid type: G4Orb\n"
<< " Parameters: \n"
<< " outer radius: " << fRmax/mm << " mm \n"
<< "-----------------------------------------------------------\n";
return os;
}
/////////////////////////////////////////////////////////////////////////////
//
// Methods for visualisation
void G4Orb::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
{
scene.AddThis (*this);
}
G4Polyhedron* G4Orb::CreatePolyhedron () const
{
return new G4PolyhedronSphere (0., fRmax, 0., 2*pi, 0., pi);
}
G4NURBS* G4Orb::CreateNURBS () const
{
return new G4NURBSbox (fRmax, fRmax, fRmax); // Box for now!!!
}
// End of G4Orb.cc
//
/////////////////////////////////////////////////////////////////////
+18 -20
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Para.cc,v 1.14 2003/06/16 16:53:37 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Para.cc,v 1.18 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4Para
//
@@ -33,7 +33,7 @@
// 31.10.96 V.Grichine: Modifications according G4Box/Tubs before to commit
// 18.11.99 V.Grichine: kUndef was added to ESide
// 14.02.02 V.Grichine: bug fixed in Inside according to proposal of D.Wright
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Para.hh"
@@ -73,13 +73,11 @@ void G4Para::SetAllParameters( G4double pDx, G4double pDy, G4double pDz,
}
else
{
G4cout << "ERROR - G4Para()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid dimensions ! - "
<< pDx << ", " << pDy << ", " << pDz << G4endl;
G4cerr << "ERROR - G4Para()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid dimensions ! - "
<< pDx << ", " << pDy << ", " << pDz << G4endl;
G4Exception("G4Para::SetAllParameters() - Invalid Length Parameters");
G4Exception("G4Para::SetAllParameters()", "InvalidSetup",
FatalException, "Invalid Length Parameters.");
}
}
@@ -97,13 +95,11 @@ G4Para::G4Para(const G4String& pName,
}
else
{
G4cout << "ERROR - G4Para()::G4Para(): " << GetName() << G4endl
<< " Invalid dimensions ! - "
<< pDx << ", " << pDy << ", " << pDz << G4endl;
G4cerr << "ERROR - G4Para()::G4Para(): " << GetName() << G4endl
<< " Invalid dimensions ! - "
<< pDx << ", " << pDy << ", " << pDz << G4endl;
G4Exception("G4Para::G4Para() - Invalid Length Parameters");
G4Exception("G4Para::G4Para()", "InvalidSetup",
FatalException, "Invalid Length Parameters.");
}
}
@@ -142,11 +138,10 @@ G4Para::G4Para( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Para()::G4Para(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl;
G4cerr << "ERROR - G4Para()::G4Para(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl;
G4Exception("G4Para::G4Para() - Invalid vertice coordinates");
G4Exception("G4Para::G4Para()", "InvalidSetup",
FatalException, "Invalid vertice coordinates.");
}
}
@@ -706,7 +701,7 @@ G4double G4Para::DistanceToIn( const G4ThreeVector& p,
G4double G4Para::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe;
G4double safe=0.0;
G4double distz1,distz2,disty1,disty2,distx1,distx2;
G4double trany,cosy,tranx,cosx;
@@ -983,7 +978,8 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
break;
default:
DumpInfo();
G4Exception("G4Para::DistanceToOut() - Invalid enum");
G4Exception("G4Para::DistanceToOut()", "LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
@@ -997,7 +993,7 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
G4double G4Para::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe;
G4double safe=0.0;
G4double distz1,distz2,disty1,disty2,distx1,distx2;
G4double trany,cosy,tranx,cosx;
@@ -1011,8 +1007,8 @@ G4double G4Para::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 << "G4Para::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Para::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Para::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -1098,7 +1094,9 @@ G4Para::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
else
{
DumpInfo();
G4Exception("G4Para::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Para::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
+111 -96
View File
@@ -21,25 +21,27 @@
// ********************************************************************
//
//
// $Id: G4Sphere.cc,v 1.19 2003/06/16 16:53:38 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Sphere.cc,v 1.27 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4Sphere
//
// Implementation for G4Sphere class
//
// History:
// 28.03.94 P.Kent: old C++ code converted to tolerant geometry
// 17.09.96 V.Grichine: final modifications to commit
// 09.10.98 V.Grichine: modifications in Distance ToOut(p,v,...)
// 12.11.98 V.Grichine: bug fixed in DistanceToIn(p,v), theta intersections
// 25.11.98 V.Grichine: bug fixed in DistanceToIn(p,v), phi intersections
// 18.11.99 V.Grichine: side = kNull in Distance ToOut(p,v,...)
// 06.03.00 V.Grichine: modifications in Distance ToOut(p,v,...)
// 30.01.02 V.Grichine: bug fixed in Inside(p), && -> || at l.451
// 19.06.02 V.Grichine: bug fixed in Inside(p), && -> && fDTheta - kAngTolerance
//
// ********************************************************************
// 30.10.03 J.Apostolakis: new algorithm in Inside for SPhi-sections
// 29.10.03 J.Apostolakis: fix in Inside for SPhi-0.5*kAngTol < phi < SPhi, SPhi<0
// 19.06.02 V.Grichine: bug fixed in Inside(p), && -> && fDTheta - kAngTolerance
// 30.01.02 V.Grichine: bug fixed in Inside(p), && -> || at l.451
// 06.03.00 V.Grichine: modifications in Distance ToOut(p,v,...)
// 18.11.99 V.Grichine: side = kNull in Distance ToOut(p,v,...)
// 25.11.98 V.Grichine: bug fixed in DistanceToIn(p,v), phi intersections
// 12.11.98 V.Grichine: bug fixed in DistanceToIn(p,v), theta intersections
// 09.10.98 V.Grichine: modifications in Distance ToOut(p,v,...)
// 17.09.96 V.Grichine: final modifications to commit
// 28.03.94 P.Kent: old C++ code converted to tolerant geometry
// --------------------------------------------------------------------
#include <assert.h>
@@ -53,6 +55,7 @@
#include "meshdefs.hh"
#include "G4VGraphicsScene.hh"
#include "G4VisExtent.hh"
#include "G4Polyhedron.hh"
#include "G4NURBS.hh"
#include "G4NURBSbox.hh"
@@ -84,6 +87,7 @@ G4Sphere::G4Sphere( const G4String& pName,
G4double pSTheta, G4double pDTheta )
: G4CSGSolid(pName)
{
fEpsilon = 1.0e-14;
// Check radii
@@ -93,13 +97,11 @@ G4Sphere::G4Sphere( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRmin = " << pRmin << ", pRmax = " << pRmax << G4endl;
G4cerr << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Invalide values for radii ! - "
<< " pRmin = " << pRmin << ", pRmax = " << pRmax << G4endl;
G4Exception("G4Sphere::G4Sphere() - invalid radii");
G4Exception("G4Sphere::G4Sphere()", "InvalidSetup", FatalException,
"Invalid radii");
}
// Check angles
@@ -114,13 +116,11 @@ G4Sphere::G4Sphere( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4cerr << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Negative Z delta-Phi ! - "
<< pDPhi << G4endl;
G4Exception("G4Sphere::G4Sphere() - invalid DPhi");
G4Exception("G4Sphere::G4Sphere()", "InvalidSetup", FatalException,
"Invalid DPhi.");
}
// Convert fSPhi to 0-2PI
@@ -143,9 +143,9 @@ G4Sphere::G4Sphere( const G4String& pName,
if (pSTheta<0 || pSTheta>M_PI)
{
G4cout << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl;
G4Exception("G4Sphere::G4Sphere() - stheta outside 0-PI range");
G4Exception("G4Sphere::G4Sphere()", "InvalidSetup", FatalException,
"stheta outside 0-PI range.");
}
else
{
@@ -162,13 +162,11 @@ G4Sphere::G4Sphere( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Negative delta-Theta ! - "
<< pDTheta << G4endl;
G4cerr << "ERROR - G4Sphere()::G4Sphere(): " << GetName() << G4endl
<< " Negative delta-Theta ! - "
<< pDTheta << G4endl;
G4Exception("G4Sphere::G4Sphere() - invalid pDTheta");
G4Exception("G4Sphere::G4Sphere()", "InvalidSetup", FatalException,
"Invalid pDTheta.");
}
}
@@ -433,12 +431,13 @@ EInside G4Sphere::Inside( const G4ThreeVector& p ) const
{
G4double rho,rho2,rad2,tolRMin,tolRMax;
G4double pPhi,pTheta;
EInside in;
EInside in=kOutside;
rho2 = p.x()*p.x() + p.y()*p.y() ;
rad2 = rho2 + p.z()*p.z() ;
// G4double rad = sqrt(rad2);
// if(rad2 >= 1.369e+19) DBG();
// G4double rad = sqrt(rad2);
// Check radial surfaces
// sets `in'
@@ -446,8 +445,19 @@ EInside G4Sphere::Inside( const G4ThreeVector& p ) const
else tolRMin = 0 ;
tolRMax = fRmax - kRadTolerance*0.5 ;
// const G4double fractionTolerance = 1.0e-12;
const G4double flexRadMaxTolerance = // kRadTolerance;
std::max(kRadTolerance, fEpsilon * fRmax);
const G4double Rmax_minus = fRmax - flexRadMaxTolerance*0.5;
const G4double flexRadMinTolerance = std::max(kRadTolerance,
fEpsilon * fRmin);
const G4double Rmin_plus = (fRmin > 0) ? fRmin + flexRadMinTolerance*0.5 : 0 ;
if ( rad2 <= tolRMax*tolRMax && rad2 >= tolRMin*tolRMin ) in = kInside ;
if(rad2 <= Rmax_minus*Rmax_minus && rad2 >= Rmin_plus*Rmin_plus) in = kInside ;
// if ( rad2 <= tolRMax*tolRMax && rad2 >= tolRMin*tolRMin ) in = kInside ;
// if ( rad <= tolRMax && rad >= tolRMin ) in = kInside ;
else
{
tolRMax = fRmax + kRadTolerance*0.5 ;
@@ -455,68 +465,32 @@ EInside G4Sphere::Inside( const G4ThreeVector& p ) const
if ( tolRMin < 0.0 ) tolRMin = 0.0 ;
if ( rad2 <= tolRMax*tolRMax && rad2 >= tolRMin*tolRMin ) in = kSurface ;
if ( rad2 <= tolRMax*tolRMax && rad2 >= tolRMin*tolRMin ) in = kSurface ;
// if ( rad <= tolRMax && rad >= tolRMin ) in = kSurface ;
else return in = kOutside ;
}
// Phi boundaries : Do not check if it has no phi boundary!
// (in != kOutside)
// (in != kOutside). It is new J.Apostolakis proposal of 30.10.03
if ( ( fDPhi < 2*M_PI - kAngTolerance ) &&
( (p.x() != 0.0 ) || (p.y() != 0.0) ) )
{
pPhi = atan2(p.y(),p.x()) ;
if ( pPhi < 0.0) pPhi += 2*M_PI ; // 0<=pPhi<2pi
if ( fSPhi >= 0.0 )
{
if (in == kInside)
{
if ( (pPhi < fSPhi + kAngTolerance*0.5)
|| (pPhi > fSPhi + fDPhi - kAngTolerance*0.5) )
{
// Not `inside' tolerant bounds
//
if ( (pPhi >= fSPhi - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + kAngTolerance*0.5) )
{
in = kSurface ;
}
else
{
return in = kOutside ;
}
}
}
else // in==kSurface
{
if ( (pPhi < fSPhi - kAngTolerance*0.5)
|| (pPhi > fSPhi + fDPhi + kAngTolerance*0.5) ) // && bug216
{
return in = kOutside ;
}
}
}
else
{
if ( pPhi < fSPhi + 2*M_PI ) pPhi += 2*M_PI ;
if ( (pPhi < fSPhi + 2*M_PI + kAngTolerance*0.5)
|| (pPhi > fSPhi + fDPhi + 2*M_PI - kAngTolerance*0.5) )
{
// Not `inside' tolerant bounds
//
if ( (pPhi >= fSPhi + 2*M_PI - kAngTolerance*0.5)
&& (pPhi <= fSPhi + fDPhi + 2*M_PI + kAngTolerance*0.5) )
{
in = kSurface ;
}
else
{
return in = kOutside ;
}
}
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 > fSPhi + fDPhi + kAngTolerance*0.5) ) return in = kOutside ;
else if (in == kInside) // else it's kSurface anyway already
{
if ( (pPhi < fSPhi + kAngTolerance*0.5) ||
(pPhi > fSPhi + fDPhi - kAngTolerance*0.5) ) in = kSurface ;
}
}
// Theta bondaries
// (in!=kOutside)
@@ -550,6 +524,7 @@ EInside G4Sphere::Inside( const G4ThreeVector& p ) const
}
}
}
// if (in == kInside) DBG();
return in;
}
@@ -693,7 +668,8 @@ G4ThreeVector G4Sphere::SurfaceNormal( const G4ThreeVector& p ) const
break;
default:
DumpInfo();
G4Exception("G4Sphere::SurfaceNormal() - Logic error");
G4Exception("G4Sphere::SurfaceNormal()", "LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
} // end case
@@ -832,8 +808,11 @@ G4double G4Sphere::DistanceToIn( const G4ThreeVector& p,
// => s=-pDotV3d+-sqrt(pDotV3d^2-(rad2-R^2))
c = rad2 - fRmax*fRmax ;
const G4double flexRadMaxTolerance = // kRadTolerance;
std::max(kRadTolerance, fEpsilon * fRmax);
if (c > kRadTolerance*fRmax)
// if (c > kRadTolerance*fRmax)
if (c > flexRadMaxTolerance*fRmax)
{
// If outside toleranct boundary of outer G4Sphere
// [should be sqrt(rad2)-fRmax > kRadTolerance*0.5]
@@ -1181,8 +1160,7 @@ G4double G4Sphere::DistanceToIn( const G4ThreeVector& p,
zi = p.z() ;
rhoi2 = rho2 ;
radi2 = rad2 ;
}
if ( (radi2 <= tolORMax2)
} if ( (radi2 <= tolORMax2)
&& (radi2 >= tolORMin2)
&& ((yi*cosCPhi-xi*sinCPhi) >= 0) )
{
@@ -1681,7 +1659,7 @@ G4double G4Sphere::DistanceToIn( const G4ThreeVector& p,
G4double G4Sphere::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe,safeRMin,safeRMax,safePhi,safeTheta;
G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
G4double rho2,rad,rho;
G4double phiC,cosPhiC,sinPhiC,cosPsi,ePhi;
G4double pTheta,dTheta1,dTheta2;
@@ -1820,6 +1798,8 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
rho2=p.x()*p.x()+p.y()*p.y();
rad2=rho2+p.z()*p.z();
// G4double rad=sqrt(rad2);
pTheta=atan2(sqrt(rho2),p.z());
pDotV2d=p.x()*v.x()+p.y()*v.y();
@@ -1873,17 +1853,19 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
//
// => s=-pDotV3d+-sqrt(pDotV3d^2-(rad2-R^2))
//
const G4double fractionTolerance = 1.0e-14;
const G4double flexRadMaxTolerance = std::max(kRadTolerance,
fractionTolerance * fRmax);
// const G4double fractionTolerance = 1.0e-12;
const G4double flexRadMaxTolerance = // kRadTolerance;
std::max(kRadTolerance, fEpsilon * fRmax);
const G4double Rmax_plus = fRmax + flexRadMaxTolerance*0.5;
const G4double flexRadMinTolerance = std::max(kRadTolerance,
fractionTolerance * fRmin);
const G4double Rmin_minus= (fRmin>0) ? fRmin-flexRadMinTolerance*0.5 : 0 ;
fEpsilon * fRmin);
const G4double Rmin_minus= (fRmin > 0) ? fRmin-flexRadMinTolerance*0.5 : 0 ;
if(rad2 <= Rmax_plus*Rmax_plus && rad2 >= Rmin_minus*Rmin_minus)
// if(rad <= Rmax_plus && rad >= Rmin_minus)
{
c=rad2-fRmax*fRmax ;
c = rad2 - fRmax*fRmax;
if (c < flexRadMaxTolerance*fRmax)
{
@@ -1896,7 +1878,7 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
// => rad2 < fRmax^2 + 2.*0.5*fRmax*kRadTol + 0.25*kRadTol*kRadTol
// => rad2 - fRmax^2 <~ fRmax*kRadTol
d2=pDotV3d*pDotV3d-c ;
d2 = pDotV3d*pDotV3d - c;
if( (c >- flexRadMaxTolerance*fRmax) // on tolerant surface
&& ((pDotV3d >=0) || (d2 < 0)) ) // leaving outside from Rmax
@@ -2471,10 +2453,35 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("G4Sphere::DistanceToOut() - Invalid enum");
G4Exception("G4Sphere::DistanceToOut(p,v,...)",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
if (snxt == kInfinity)
{
G4cout.precision(24);
G4cout << G4endl;
DumpInfo();
G4cout << "Position:" << G4endl << G4endl;
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"
<< G4endl << G4endl;
G4cout << "Direction:" << G4endl << G4endl;
G4cout << "v.x() = " << v.x() << G4endl;
G4cout << "v.y() = " << v.y() << G4endl;
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("G4Sphere::DistanceToOut(p,v,...)",
"Notification", JustWarning,
"Logic error: snxt = kInfinity ???");
DBG();
}
return snxt;
}
@@ -2484,7 +2491,7 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
G4double G4Sphere::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe,safeRMin,safeRMax,safePhi,safeTheta;
G4double safe=0.0,safeRMin,safeRMax,safePhi,safeTheta;
G4double rho2,rad,rho;
G4double phiC,cosPhiC,sinPhiC,ePhi;
G4double pTheta,dTheta1,dTheta2;
@@ -2502,8 +2509,8 @@ G4double G4Sphere::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 << "G4Sphere::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Sphere::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Sphere::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -2703,7 +2710,9 @@ G4Sphere::CreateRotatedVertices( const G4AffineTransform& pTransform,
else
{
DumpInfo();
G4Exception("G4Sphere::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Sphere::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
delete[] cosCrossTheta;
@@ -2747,6 +2756,12 @@ std::ostream& G4Sphere::StreamInfo( std::ostream& os ) const
//
// Methods for visualisation
G4VisExtent G4Sphere::GetExtent() const
{
return G4VisExtent(-fRmax, fRmax,-fRmax, fRmax,-fRmax, fRmax );
}
void G4Sphere::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
{
scene.AddThis (*this);
+22 -22
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Torus.cc,v 1.29 2003/06/16 16:53:40 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Torus.cc,v 1.33 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4Torus
@@ -39,7 +39,7 @@
// 03.10.00 E.Medernach: SafeNewton added
// 11.01.01 E.Medernach: Use G4PolynomialSolver to find roots
//
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Torus.hh"
@@ -89,13 +89,11 @@ G4Torus::SetAllParameters( G4double pRmin,
}
else
{
G4cout << "ERROR - G4Torus()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid swept radius !" << G4endl
<< "pRtor = " << pRtor << ", pRmax = " << pRmax << G4endl;
G4cerr << "ERROR - G4Torus()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid swept radius !" << G4endl
<< "pRtor = " << pRtor << ", pRmax = " << pRmax << G4endl;
G4Exception("G4Torus::SetAllParameters() - invalid swept radius");
G4Exception("G4Torus::SetAllParameters()",
"InvalidSetup", FatalException, "Invalid swept radius.");
}
// Check radii
@@ -108,13 +106,11 @@ G4Torus::SetAllParameters( G4double pRmin,
}
else
{
G4cout << "ERROR - G4Torus()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRmin = " << pRmin << ", pRmax = " << pRmax << G4endl;
G4cerr << "ERROR - G4Torus()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRmin = " << pRmin << ", pRmax = " << pRmax << G4endl;
G4Exception("G4Torus::SetAllParameters() - invalid radii");
G4Exception("G4Torus::SetAllParameters()",
"InvalidSetup", FatalException, "Invalid radii.");
}
// Check angles
@@ -125,13 +121,11 @@ G4Torus::SetAllParameters( G4double pRmin,
if (pDPhi > 0) fDPhi = pDPhi ;
else
{
G4cout << "ERROR - G4Torus::SetAllParameters(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4cerr << "ERROR - G4Torus::SetAllParameters(): " << GetName() << G4endl
<< " Negative Z delta-Phi ! - "
<< pDPhi << G4endl;
G4Exception("G4Torus::SetAllParameters() - invalid dphi");
G4Exception("G4Torus::SetAllParameters()",
"InvalidSetup", FatalException, "Invalid dphi.");
}
}
@@ -1134,7 +1128,9 @@ G4ThreeVector G4Torus::SurfaceNormal( const G4ThreeVector& p ) const
break;
default:
DumpInfo();
G4Exception("G4Torus::SurfaceNormal() - Logic error");
G4Exception("G4Torus::SurfaceNormal()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break ;
}
return norm ;
@@ -1508,7 +1504,7 @@ G4double G4Torus::DistanceToIn( const G4ThreeVector& p,
G4double G4Torus::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe, safe1, safe2 ;
G4double safe=0.0, safe1, safe2 ;
G4double phiC, cosPhiC, sinPhiC, safePhi, ePhi, cosPsi ;
G4double rho2, rho, pt2, pt ;
@@ -2075,7 +2071,9 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl;
G4cout << "Proposed distance :" << G4endl << G4endl;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl;
G4Exception("G4Torus::DistanceToOut() - Invalid enum");
G4Exception("G4Torus::DistanceToOut()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
@@ -2094,7 +2092,7 @@ G4double G4Torus::DistanceToOut( const G4ThreeVector& p,
G4double G4Torus::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe,safeR1,safeR2;
G4double safe=0.0,safeR1,safeR2;
G4double rho2,rho,pt2,pt ;
G4double safePhi,phiC,cosPhiC,sinPhiC,ePhi;
rho2 = p.x()*p.x() + p.y()*p.y() ;
@@ -2112,8 +2110,8 @@ G4double G4Torus::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 << "G4Torus::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Torus::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Torus::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
#if DEBUGTORUS
@@ -2232,7 +2230,9 @@ G4Torus::CreateRotatedVertices( const G4AffineTransform& pTransform,
else
{
DumpInfo();
G4Exception("G4Torus::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Torus::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
+70 -76
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Trap.cc,v 1.17 2003/06/16 16:53:42 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Trap.cc,v 1.22 2003/12/04 10:44:07 grichine Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4Trap
//
@@ -36,10 +36,10 @@
// 04.06.99 S.Giani: Fixed CalculateExtent in rotated case.
// 19.11.99 V.Grichine: kUndef was added to Eside enum
// 13.12.99 V.Grichine: bug fixed in DistanceToIn(p,v)
//
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Trap.hh"
#include "globals.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
@@ -106,19 +106,14 @@ G4Trap::G4Trap( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl
<< " X - "
<< pDx1 << ", " << pDx2 << ", " << pDx3 << ", " << pDx4 << G4endl
<< " Y - " << pDy1 << ", " << pDy2 << G4endl
<< " Z - " << pDz << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl
<< " X - "
<< pDx1 << ", " << pDx2 << ", " << pDx3 << ", " << pDx4 << G4endl
<< " Y - " << pDy1 << ", " << pDy2 << G4endl
<< " Z - " << pDz << G4endl;
G4Exception("G4Trap::G4Trap() - Invalid length G4Trap parameters");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Invalid length G4Trap parameters.");
}
}
@@ -149,7 +144,8 @@ G4Trap::G4Trap( const G4String& pName,
if (!good)
{
DumpInfo();
G4Exception("G4Trap::G4Trap() - face at ~-Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-Y not planar.");
}
// Top side with normal approx. +Y
@@ -157,9 +153,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+Y not planar.");
}
// Front side with normal approx. -X
@@ -167,9 +163,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-X not planar.");
}
// Back side iwth normal approx. +X
@@ -177,9 +173,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+X not planar.");
}
fDz = (pt[7]).z() ;
@@ -199,9 +195,9 @@ G4Trap::G4Trap( const G4String& pName,
}
else
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - Invalid vertice coordinates");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Invalid vertice coordinates.");
}
}
@@ -258,9 +254,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-Y not planar.");
}
// Top side with normal approx. +Y
@@ -268,9 +264,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+Y not planar.");
}
// Front side with normal approx. -X
@@ -278,9 +274,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-X not planar.");
}
// Back side iwth normal approx. +X
@@ -288,16 +284,16 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+X not planar.");
}
}
else
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - Invalid length G4Trap parameters");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Invalid length G4Trap parameters.");
}
}
@@ -353,9 +349,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-Y not planar.");
}
// Top side with normal approx. +Y
@@ -363,9 +359,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+Y not planar.");
}
// Front side with normal approx. -X
@@ -373,9 +369,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-X not planar.");
}
// Back side iwth normal approx. +X
@@ -383,16 +379,16 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+X not planar.");
}
}
else
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - Invalid length G4Trap parameters");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Invalid length G4Trap parameters.");
}
}
@@ -449,9 +445,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-Y not planar.");
}
// Top side with normal approx. +Y
@@ -459,9 +455,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+Y not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+Y not planar.");
}
// Front side with normal approx. -X
@@ -469,9 +465,9 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~-X not planar.");
}
// Back side iwth normal approx. +X
@@ -479,16 +475,16 @@ G4Trap::G4Trap( const G4String& pName,
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+X not planar");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Face at ~+X not planar.");
}
}
else
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - Invalid length G4Trap parameters");
G4Exception("G4Trap::G4Trap()", "InvalidSetup", FatalException,
"Invalid length G4Trap parameters.");
}
}
@@ -512,6 +508,7 @@ G4Trap::G4Trap( const G4String& pName )
fDx4 (1.),
fTalpha2 (0.)
{
MakePlanes();
}
///////////////////////////////////////////////////////////////////////
@@ -551,19 +548,14 @@ void G4Trap::SetAllParameters ( G4double pDz,
}
else
{
G4cout << "ERROR - G4Trap()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl
<< " X - "
<< pDx1 << ", " << pDx2 << ", " << pDx3 << ", " << pDx4 << G4endl
<< " Y - " << pDy1 << ", " << pDy2 << G4endl
<< " Z - " << pDz << G4endl;
G4cerr << "ERROR - G4Trap()::SetAllParameters(): " << GetName() << G4endl
<< " Invalid dimensions !" << G4endl
<< " X - "
<< pDx1 << ", " << pDx2 << ", " << pDx3 << ", " << pDx4 << G4endl
<< " Y - " << pDy1 << ", " << pDy2 << G4endl
<< " Z - " << pDz << G4endl;
G4Exception("G4Trap::SetAllParameters() - Invalid Length Parameters");
G4Exception("G4Trap::SetAllParameters()", "InvalidSetup",
FatalException, "Invalid Length Parameters.");
}
}
@@ -599,9 +591,9 @@ G4bool G4Trap::MakePlanes()
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]) ;
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-Y not planar");
G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
"Face at ~-Y not planar.");
}
// Top side with normal approx. +Y
@@ -609,9 +601,9 @@ G4bool G4Trap::MakePlanes()
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+Y not planar");
G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
"Face at ~+Y not planar.");
}
// Front side with normal approx. -X
@@ -619,9 +611,9 @@ G4bool G4Trap::MakePlanes()
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~-X not planar");
G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
"Face at ~-X not planar.");
}
// Back side iwth normal approx. +X
@@ -629,9 +621,9 @@ G4bool G4Trap::MakePlanes()
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4cout << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::G4Trap(): " << GetName() << G4endl;
G4Exception("G4Trap::G4Trap() - face at ~+X not planar");
G4cerr << "ERROR - G4Trap()::MakePlanes(): " << GetName() << G4endl;
G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
"Face at ~+X not planar");
}
return good;
@@ -701,9 +693,9 @@ G4bool G4Trap::MakePlane( const G4ThreeVector& p1,
}
else
{
G4cout << "ERROR - G4Trap()::MakePlane(): " << GetName() << G4endl;
G4cerr << "ERROR - G4Trap()::MakePlane(): " << GetName() << G4endl;
G4Exception("G4Trap::MakePlane() - Invalid parameters") ;
G4Exception("G4Trap::MakePlanes()", "InvalidSetup", FatalException,
"Invalid parameters.") ;
}
// Calculate D: p1 in in plane so D=-n.p1.Vect()
@@ -1236,7 +1228,7 @@ G4double G4Trap::DistanceToIn( const G4ThreeVector& p,
G4double G4Trap::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe,Dist;
G4double safe=0.0,Dist;
G4int i;
safe=fabs(p.z())-fDz;
for (i=0;i<4;i++)
@@ -1531,7 +1523,7 @@ G4double G4Trap::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
G4double G4Trap::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe,Dist;
G4double safe=0.0,Dist;
G4int i;
#ifdef G4CSGDEBUG
@@ -1544,8 +1536,8 @@ G4double G4Trap::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 << "G4Trap::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Trap::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Trap::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -1610,7 +1602,9 @@ G4Trap::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
else
{
DumpInfo();
G4Exception("G4Trap::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Trap::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
+16 -17
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Trd.cc,v 1.13 2003/06/16 16:53:43 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Trd.cc,v 1.17 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// Implementation for G4Trd class
@@ -30,8 +30,7 @@
// History:
// ~1996, V.Grichine, 1st implementation based on old code of P.Kent
// 07.05.00, V.Grichine, in d = DistanceToIn(p,v), if d<0.5*kCarTolerance, d=0
//
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Trd.hh"
@@ -87,19 +86,15 @@ void G4Trd::CheckAndSetAllParameters ( G4double pdx1, G4double pdx2,
}
else
{
G4cout << "ERROR - G4Trd()::CheckAndSetAllParameters(): " << GetName()
<< G4endl
<< " Invalid dimensions, some are < 0 !" << G4endl
<< " X - " << pdx1 << ", " << pdx2 << G4endl
<< " Y - " << pdy1 << ", " << pdy2 << G4endl
<< " Z - " << pdz << G4endl;
G4cerr << "ERROR - G4Trd()::CheckAndSetAllParameters(): " << GetName()
<< G4endl
<< " Invalid dimensions, some are < 0 !" << G4endl
<< " X - " << pdx1 << ", " << pdx2 << G4endl
<< " Y - " << pdy1 << ", " << pdy2 << G4endl
<< " Z - " << pdz << G4endl;
G4Exception("G4Trd::CheckAndSetAllParameters() - Invalid parameters");
G4Exception("G4Trd::CheckAndSetAllParameters()",
"InvalidSetup", FatalException,
"Invalid parameters.");
}
}
}
@@ -702,7 +697,7 @@ G4double G4Trd::DistanceToIn( const G4ThreeVector& p,
G4double G4Trd::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe;
G4double safe=0.0;
G4double tanxz,distx,safx;
G4double tanyz,disty,safy;
G4double zbase;
@@ -1125,7 +1120,9 @@ G4double G4Trd::DistanceToOut( const G4ThreeVector& p,
break;
default:
DumpInfo();
G4Exception("G4Trd::DistanceToOut() - Invalid enum");
G4Exception("G4Trd::DistanceToOut()",
"LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break;
}
}
@@ -1139,7 +1136,7 @@ G4double G4Trd::DistanceToOut( const G4ThreeVector& p,
G4double G4Trd::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe;
G4double safe=0.0;
G4double tanxz,xdist,saf1;
G4double tanyz,ydist,saf2;
G4double zbase;
@@ -1154,8 +1151,8 @@ G4double G4Trd::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 << "G4Trd::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4cerr << "G4Trd::DistanceToOut(p) - point p is outside ?!" << G4endl ;
G4Exception("G4Trd::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?" );
}
#endif
@@ -1222,7 +1219,9 @@ G4Trd::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
else
{
DumpInfo();
G4Exception("G4Trd::CreateRotatedVertices() - Out of memory");
G4Exception("G4Trd::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices;
}
+20 -24
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4Tubs.cc,v 1.36 2003/06/16 16:53:44 gunter Exp $
// GEANT4 tag $Name: geant4-05-02 $
// $Id: G4Tubs.cc,v 1.40 2003/11/03 18:17:32 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4Tubs
@@ -48,8 +48,7 @@
// 20.02.01 V.Grichine: bug fixed in Inside(p) and CalculateExtent was
// simplified base on G4Box::CalculateExtent
// 20.07.01 V.Grichine: bug fixed in Inside(p)
//
// ********************************************************************
// --------------------------------------------------------------------
#include "G4Tubs.hh"
@@ -85,13 +84,11 @@ G4Tubs::G4Tubs( const G4String &pName,
}
else
{
G4cout << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Negative Z half-length ! - "
<< pDz << G4endl;
G4cerr << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Negative Z half-length ! - "
<< pDz << G4endl;
G4Exception("G4Tubs::G4Tubs() - invalid Z half-length");
G4Exception("G4Tubs::G4Tubs()", "InvalidSetup", FatalException,
"Invalid Z half-length");
}
if ( pRMin < pRMax && pRMin >= 0 ) // Check radii
{
@@ -100,13 +97,11 @@ G4Tubs::G4Tubs( const G4String &pName,
}
else
{
G4cout << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRMin = " << pRMin << ", pRMax = " << pRMax << G4endl;
G4cerr << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Invalid values for radii !" << G4endl
<< " pRMin = " << pRMin << ", pRMax = " << pRMax << G4endl;
G4Exception("G4Tubs::G4Tubs() - invalid radii");
G4Exception("G4Tubs::G4Tubs()", "InvalidSetup", FatalException,
"Invalid radii.");
}
if ( pDPhi >= 2.0*M_PI ) // Check angles
{
@@ -120,13 +115,11 @@ G4Tubs::G4Tubs( const G4String &pName,
}
else
{
G4cout << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4cerr << "ERROR - G4Tubs()::G4Tubs(): " << GetName() << G4endl
<< " Negative delta-Phi ! - "
<< pDPhi << G4endl;
G4Exception("G4Tubs::G4Tubs() - invalid dphi");
G4Exception("G4Tubs::G4Tubs()", "InvalidSetup", FatalException,
"Invalid dphi.");
}
}
@@ -656,7 +649,8 @@ G4ThreeVector G4Tubs::SurfaceNormal( const G4ThreeVector& p ) const
default:
{
DumpInfo();
G4Exception("G4Tubs::SurfaceNormal() - Logic error") ;
G4Exception("G4Tubs::SurfaceNormal()", "LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break ;
}
}
@@ -1037,7 +1031,7 @@ G4double G4Tubs::DistanceToIn( const G4ThreeVector& p,
G4double G4Tubs::DistanceToIn( const G4ThreeVector& p ) const
{
G4double safe, rho, safe1, safe2, safe3 ;
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()) ;
@@ -1441,8 +1435,8 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
G4cout << "v.z() = " << v.z() << G4endl << G4endl ;
G4cout << "Proposed distance :" << G4endl << G4endl ;
G4cout << "snxt = " << snxt/mm << " mm" << G4endl << G4endl ;
G4Exception("G4Tubs::DistanceToOut() - Invalid enum") ;
G4Exception("G4Tubs::DistanceToOut()", "LogicError", FatalException,
"Undefined side for valid surface normal to solid.");
break ;
}
}
@@ -1456,7 +1450,7 @@ G4double G4Tubs::DistanceToOut( const G4ThreeVector& p,
G4double G4Tubs::DistanceToOut( const G4ThreeVector& p ) const
{
G4double safe, rho, safeR1, safeR2, safeZ ;
G4double safe=0.0, rho, safeR1, safeR2, safeZ ;
G4double safePhi, phiC, cosPhiC, sinPhiC, ePhi ;
rho = sqrt(p.x()*p.x() + p.y()*p.y()) ;
@@ -1470,8 +1464,8 @@ G4double G4Tubs::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 << "G4Tubs::DistanceToOut(p) - point p is outside !?" << G4endl ;
G4cerr << "G4Tubs::DistanceToOut(p) - point p is outside !?" << G4endl ;
G4Exception("G4Tubs::DistanceToOut(p)",
"Notification", JustWarning, "Point p is outside !?");
}
#endif
@@ -1604,7 +1598,9 @@ G4Tubs::CreateRotatedVertices( const G4AffineTransform& pTransform ) const
else
{
DumpInfo();
G4Exception("G4Tubs::CreateRotatedVertices() - Out of memory !");
G4Exception("G4Tubs::CreateRotatedVertices()",
"FatalError", FatalException,
"Error in allocation of vertices. Out of memory !");
}
return vertices ;
}