Import Geant4 8.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:36:02 +02:00
parent d93e1e39a9
commit 8a51e0bc40
5471 changed files with 99628 additions and 55248 deletions
@@ -20,8 +20,8 @@
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4VTwistedFaceted.cc,v 1.2 2005/04/04 11:56:59 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4VTwistedFaceted.cc,v 1.10 2005/12/06 09:22:13 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// --------------------------------------------------------------------
@@ -53,6 +53,8 @@
#include "G4NURBScylinder.hh"
#include "G4NURBStubesector.hh"
#include "Randomize.hh"
//=====================================================================
//* constructors ------------------------------------------------------
@@ -140,8 +142,7 @@ G4VTwistedFaceted( const G4String &pname, // Name of instance
// tilt angle
//
fAlph = - pAlph ; // important: definition of angle alpha
// is different in equations !!!
fAlph = pAlph ;
fTAlph = std::tan(fAlph) ;
fTheta = pTheta ;
@@ -188,6 +189,17 @@ G4VTwistedFaceted( const G4String &pname, // Name of instance
}
//=====================================================================
//* Fake default constructor ------------------------------------------
G4VTwistedFaceted::G4VTwistedFaceted( __void__& a )
: G4VSolid(a),
fLowerEndcap(0), fUpperEndcap(0), fSide0(0),
fSide90(0), fSide180(0), fSide270(0),
fCubicVolume(0.), fpPolyhedron(0)
{
}
//=====================================================================
//* destructor --------------------------------------------------------
@@ -455,7 +467,7 @@ EInside G4VTwistedFaceted::Inside(const G4ThreeVector& p) const
return fLastInside.inside;
} else {
tmpp = const_cast<G4ThreeVector*>(&(fLastInside.p));
tmpin = const_cast<EInside*>(&(fLastInside.inside));
tmpin = const_cast<EInside*>(&(fLastInside.inside));
tmpp->set(p.x(), p.y(), p.z());
}
@@ -464,12 +476,14 @@ EInside G4VTwistedFaceted::Inside(const G4ThreeVector& p) const
G4double phi = p.z()/(2*fDz) * fPhiTwist ; // rotate the point to z=0
G4double cphi = std::cos(-phi) ;
G4double sphi = std::sin(-phi) ;
G4double posx = p.x() * cphi - p.y() * sphi ;
G4double posy = p.x() * sphi + p.y() * cphi ;
G4double posz = p.z() ;
posx += fdeltaX * ( -phi/fPhiTwist) ; // shift
posy += fdeltaY * ( -phi/fPhiTwist) ;
G4double px = p.x() + fdeltaX * ( -phi/fPhiTwist) ; // shift
G4double py = p.y() + fdeltaY * ( -phi/fPhiTwist) ;
G4double pz = p.z() ;
G4double posx = px * cphi - py * sphi ; // rotation
G4double posy = px * sphi + py * cphi ;
G4double posz = pz ;
G4double xMin = Xcoef(posy,phi,fTAlph) - 2*Xcoef(posy,phi,0.) ;
G4double xMax = Xcoef(posy,phi,fTAlph) ;
@@ -557,12 +571,12 @@ G4ThreeVector G4VTwistedFaceted::SurfaceNormal(const G4ThreeVector& p) const
G4ThreeVector *tmpp = const_cast<G4ThreeVector*>(&(fLastNormal.p));
G4ThreeVector *tmpnormal = const_cast<G4ThreeVector*>(&(fLastNormal.vec));
G4VSurface **tmpsurface = const_cast<G4VSurface**>(fLastNormal.surface);
G4VTwistSurface **tmpsurface = const_cast<G4VTwistSurface**>(fLastNormal.surface);
tmpp->set(p.x(), p.y(), p.z());
G4double distance = kInfinity;
G4VSurface *surfaces[6];
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0 ;
surfaces[1] = fSide90 ;
@@ -655,7 +669,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
// Find intersections and choose nearest one
//
G4VSurface *surfaces[6];
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
@@ -669,6 +683,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p,
G4int i;
G4int besti = -1;
for (i=0; i < 6 ; i++)
//for (i=1; i < 2 ; i++)
{
#ifdef G4SPECSDEBUG
@@ -747,7 +762,7 @@ G4double G4VTwistedFaceted::DistanceToIn (const G4ThreeVector& p) const
// Find intersections and choose nearest one
//
G4VSurface *surfaces[6];
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
@@ -836,7 +851,7 @@ G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p,
// if the particle is exiting from the volume, return 0
//
G4ThreeVector normal = SurfaceNormal(p);
G4VSurface *blockedsurface = fLastNormal.surface[0];
G4VTwistSurface *blockedsurface = fLastNormal.surface[0];
if (normal*v > 0)
{
if (calcNorm)
@@ -856,7 +871,7 @@ G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p,
G4double distance = kInfinity;
// find intersections and choose nearest one.
G4VSurface *surfaces[6];
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
@@ -943,7 +958,7 @@ G4double G4VTwistedFaceted::DistanceToOut( const G4ThreeVector& p ) const
// find intersections and choose nearest one
//
G4VSurface *surfaces[6];
G4VTwistSurface *surfaces[6];
surfaces[0] = fSide0;
surfaces[1] = fSide90 ;
@@ -1060,31 +1075,31 @@ void G4VTwistedFaceted::CreateSurfaces()
if ( fDx1 == fDx2 && fDx3 == fDx4 ) // special case : Box
{
fSide0 = new G4TwistedTrapBoxSide("0deg", fPhiTwist, fDz, fTheta, fPhi,
fDy1, fDx1, fDy2, fDx3, fAlph, 0.*deg);
fSide180 = new G4TwistedTrapBoxSide("180deg", fPhiTwist, fDz, fTheta,
fPhi+pi , fDy1, fDx1, fDy2, fDx3, fAlph, 180.*deg);
fSide0 = new G4TwistBoxSide("0deg", fPhiTwist, fDz, fTheta, fPhi,
fDy1, fDx1, fDx1, fDy2, fDx3, fDx3, fAlph, 0.*deg);
fSide180 = new G4TwistBoxSide("180deg", fPhiTwist, fDz, fTheta, fPhi+pi,
fDy1, fDx1, fDx1, fDy2, fDx3, fDx3, fAlph, 180.*deg);
}
else // default general case
{
fSide0 = new G4TwistedTrapAlphaSide("0deg" ,fPhiTwist, fDz, fTheta,
fSide0 = new G4TwistTrapAlphaSide("0deg" ,fPhiTwist, fDz, fTheta,
fPhi, fDy1, fDx1, fDx2, fDy2, fDx3, fDx4, fAlph, 0.*deg);
fSide180 = new G4TwistedTrapAlphaSide("180deg", fPhiTwist, fDz, fTheta,
fSide180 = new G4TwistTrapAlphaSide("180deg", fPhiTwist, fDz, fTheta,
fPhi+pi, fDy1, fDx2, fDx1, fDy2, fDx4, fDx3, fAlph, 180.*deg);
}
// create parallel sides
//
fSide90 = new G4TwistedTrapParallelSide("90deg", fPhiTwist, fDz, fTheta,
fSide90 = new G4TwistTrapParallelSide("90deg", fPhiTwist, fDz, fTheta,
fPhi, fDy1, fDx1, fDx2, fDy2, fDx3, fDx4, fAlph, 0.*deg);
fSide270 = new G4TwistedTrapParallelSide("270deg", fPhiTwist, fDz, fTheta,
fSide270 = new G4TwistTrapParallelSide("270deg", fPhiTwist, fDz, fTheta,
fPhi+pi, fDy1, fDx2, fDx1, fDy2, fDx4, fDx3, fAlph, 180.*deg);
// create endcaps
//
fUpperEndcap = new G4FlatTrapSide("UpperCap",fPhiTwist, fDx3, fDx4, fDy2,
fUpperEndcap = new G4TwistTrapFlatSide("UpperCap",fPhiTwist, fDx3, fDx4, fDy2,
fDz, fAlph, fPhi, fTheta, 1 );
fLowerEndcap = new G4FlatTrapSide("LowerCap",fPhiTwist, fDx1, fDx2, fDy1,
fLowerEndcap = new G4TwistTrapFlatSide("LowerCap",fPhiTwist, fDx1, fDx2, fDy1,
fDz, fAlph, fPhi, fTheta, -1 );
// Set neighbour surfaces
@@ -1095,6 +1110,7 @@ void G4VTwistedFaceted::CreateSurfaces()
fSide270->SetNeighbours(fSide180 , fLowerEndcap , fSide0 , fUpperEndcap );
fUpperEndcap->SetNeighbours( fSide180, fSide270 , fSide0 , fSide90 );
fLowerEndcap->SetNeighbours( fSide180, fSide270 , fSide0 , fSide90 );
}
@@ -1119,5 +1135,153 @@ G4Polyhedron* G4VTwistedFaceted::GetPolyhedron() const
delete fpPolyhedron;
fpPolyhedron = CreatePolyhedron();
}
return fpPolyhedron;
}
//=====================================================================
//* GetPointInSolid ---------------------------------------------------
G4ThreeVector G4VTwistedFaceted::GetPointInSolid(G4double z) const
{
// this routine is only used for a test
// can be deleted ...
if ( z == fDz ) z -= 0.1*fDz ;
if ( z == -fDz ) z += 0.1*fDz ;
G4double phi = z/(2*fDz)*fPhiTwist ;
return G4ThreeVector(fdeltaX * phi/fPhiTwist, fdeltaY * phi/fPhiTwist, z ) ;
}
//=====================================================================
//* GetPointOnSurface -------------------------------------------------
G4ThreeVector G4VTwistedFaceted::GetPointOnSurface() const
{
G4double phi = CLHEP::RandFlat::shoot(-fPhiTwist/2.,fPhiTwist/2.);
G4double u , umin, umax ; // variable for twisted surfaces
G4double y ; // variable for flat surface (top and bottom)
// Compute the areas. Attention: Only correct for trapezoids
// where the twisting is done along the z-axis. In the general case
// the computed surface area is more difficult. However this simplification
// does not affect the tracking through the solid.
G4double a1 = fSide0->GetSurfaceArea();
G4double a2 = fSide90->GetSurfaceArea();
G4double a3 = fSide180->GetSurfaceArea() ;
G4double a4 = fSide270->GetSurfaceArea() ;
G4double a5 = fLowerEndcap->GetSurfaceArea() ;
G4double a6 = fUpperEndcap->GetSurfaceArea() ;
#ifdef G4SPECSDEBUG
G4cout << "Surface 0 deg = " << a1 << G4endl ;
G4cout << "Surface 90 deg = " << a2 << G4endl ;
G4cout << "Surface 180 deg = " << a3 << G4endl ;
G4cout << "Surface 270 deg = " << a4 << G4endl ;
G4cout << "Surface Lower = " << a5 << G4endl ;
G4cout << "Surface Upper = " << a6 << G4endl ;
#endif
G4double chose = CLHEP::RandFlat::shoot(0.,a1 + a2 + a3 + a4 + a5 + a6) ;
if(chose < a1)
{
umin = fSide0->GetBoundaryMin(phi) ;
umax = fSide0->GetBoundaryMax(phi) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fSide0->SurfacePoint(phi, u, true) ; // point on 0deg surface
}
else if( (chose >= a1) && (chose < a1 + a2 ) )
{
umin = fSide90->GetBoundaryMin(phi) ;
umax = fSide90->GetBoundaryMax(phi) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fSide90->SurfacePoint(phi, u, true); // point on 90deg surface
}
else if( (chose >= a1 + a2 ) && (chose < a1 + a2 + a3 ) )
{
umin = fSide180->GetBoundaryMin(phi) ;
umax = fSide180->GetBoundaryMax(phi) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fSide180->SurfacePoint(phi, u, true); // point on 180 deg surface
}
else if( (chose >= a1 + a2 + a3 ) && (chose < a1 + a2 + a3 + a4 ) )
{
umin = fSide270->GetBoundaryMin(phi) ;
umax = fSide270->GetBoundaryMax(phi) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fSide270->SurfacePoint(phi, u, true); // point on 270 deg surface
}
else if( (chose >= a1 + a2 + a3 + a4 ) && (chose < a1 + a2 + a3 + a4 + a5 ) )
{
y = CLHEP::RandFlat::shoot(-fDy1,fDy1) ;
umin = fLowerEndcap->GetBoundaryMin(y) ;
umax = fLowerEndcap->GetBoundaryMax(y) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fLowerEndcap->SurfacePoint(u,y,true); // point on lower endcap
}
else {
y = CLHEP::RandFlat::shoot(-fDy2,fDy2) ;
umin = fUpperEndcap->GetBoundaryMin(y) ;
umax = fUpperEndcap->GetBoundaryMax(y) ;
u = CLHEP::RandFlat::shoot(umin,umax) ;
return fUpperEndcap->SurfacePoint(u,y,true) ; // point on upper endcap
}
}
//=====================================================================
//* CreatePolyhedron --------------------------------------------------
G4Polyhedron* G4VTwistedFaceted::CreatePolyhedron () const
{
const G4int m = 8 ; // number of meshes
const G4int n = 20 ;
const G4int nnodes = 4*(m-1)*(n-2) + 2*m*m ;
const G4int nfaces = 4*(m-1)*(n-1) + 2*(m-1)*(m-1) ;
G4Polyhedron *ph=new G4Polyhedron;
G4double xyz[nnodes ][3]; // number of nodes
G4int faces[nfaces][4] ; // number of faces
fLowerEndcap->GetFacets(m,m,xyz,faces,0) ;
fUpperEndcap->GetFacets(m,m,xyz,faces,1) ;
fSide270->GetFacets(m,n,xyz,faces,2) ;
fSide0->GetFacets(m,n,xyz,faces,3) ;
fSide90->GetFacets(m,n,xyz,faces,4) ;
fSide180->GetFacets(m,n,xyz,faces,5) ;
ph->createPolyhedron(nnodes,nfaces,xyz,faces);
return ph;
}