Import Geant4 8.0.0 source tree
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Box.cc,v 1.39 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Box.cc,v 1.42 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -79,6 +79,16 @@ G4Box::G4Box(const G4String& pName,
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
|
||||
G4Box::G4Box( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
@@ -942,33 +952,12 @@ std::ostream& G4Box::StreamInfo(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
void G4Box::DescribeYourselfTo (G4VGraphicsScene& scene) const
|
||||
{
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
G4VisExtent G4Box::GetExtent() const
|
||||
{
|
||||
return G4VisExtent (-fDx, fDx, -fDy, fDy, -fDz, fDz);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4Box::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronBox (fDx, fDy, fDz);
|
||||
}
|
||||
|
||||
G4NURBS* G4Box::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (fDx, fDy, fDz);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// GetPointOnSurface
|
||||
//
|
||||
// Return a point (G4ThreeVector) randomly and uniformly selected on the solid surface
|
||||
// Return a point (G4ThreeVector) randomly and uniformly selected
|
||||
// on the solid surface
|
||||
|
||||
G4ThreeVector G4Box::GetPointOnSurface() const
|
||||
{
|
||||
@@ -1005,3 +994,26 @@ G4ThreeVector G4Box::GetPointOnSurface() const
|
||||
return G4ThreeVector(px,py,pz);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
void G4Box::DescribeYourselfTo (G4VGraphicsScene& scene) const
|
||||
{
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
G4VisExtent G4Box::GetExtent() const
|
||||
{
|
||||
return G4VisExtent (-fDx, fDx, -fDy, fDy, -fDz, fDz);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4Box::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronBox (fDx, fDy, fDz);
|
||||
}
|
||||
|
||||
G4NURBS* G4Box::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (fDx, fDy, fDz);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4CSGSolid.cc,v 1.10 2005/03/23 17:16:31 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4CSGSolid.cc,v 1.11 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "G4Polyhedron.hh"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor
|
||||
// - Base class constructor
|
||||
|
||||
@@ -38,6 +40,16 @@ G4CSGSolid::G4CSGSolid(const G4String& name) :
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
|
||||
G4CSGSolid::G4CSGSolid( __void__& a )
|
||||
: G4VSolid(a), fCubicVolume(0.), fpPolyhedron(0)
|
||||
{
|
||||
}
|
||||
|
||||
G4CSGSolid::~G4CSGSolid()
|
||||
{
|
||||
delete fpPolyhedron;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Cons.cc,v 1.44 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Cons.cc,v 1.47 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// class G4Cons
|
||||
//
|
||||
@@ -55,11 +55,15 @@
|
||||
|
||||
#include "meshdefs.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private enum: Not for external use - used by distanceToOut
|
||||
@@ -70,14 +74,6 @@ enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
|
||||
|
||||
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Cons::~G4Cons()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
|
||||
@@ -153,6 +149,24 @@ G4Cons::G4Cons( const G4String& pName,
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Cons::G4Cons( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Cons::~G4Cons()
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return whether point inside/outside/on surface
|
||||
@@ -2220,6 +2234,96 @@ std::ostream& G4Cons::StreamInfo(std::ostream& os) const
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
|
||||
G4ThreeVector G4Cons::GetPointOnSurface() const
|
||||
{
|
||||
// declare working variables
|
||||
//
|
||||
G4double Aone, Atwo, Athree, Afour, Afive, slin, slout, phi;
|
||||
G4double zRand, cosu, sinu, rRand1, rRand2, chose, rone, rtwo, qone, qtwo;
|
||||
|
||||
rone = (fRmax1-fRmax2)/(2.*fDz);
|
||||
rtwo = (fRmin1-fRmin2)/(2.*fDz);
|
||||
qone = fDz*(fRmax1+fRmax2)/(fRmax1-fRmax2);
|
||||
qtwo = fDz*(fRmin1+fRmin2)/(fRmin1-fRmin2);
|
||||
|
||||
slin = std::sqrt(sqr(fRmin1-fRmin2)+sqr(2.*fDz));
|
||||
slout = std::sqrt(sqr(fRmax1-fRmax2)+sqr(2.*fDz));
|
||||
Aone = 0.5*fDPhi*(fRmax2 + fRmax1)*slout;
|
||||
Atwo = 0.5*fDPhi*(fRmin2 + fRmin1)*slin;
|
||||
Athree = 0.5*fDPhi*(fRmax1*fRmax1-fRmin1*fRmin1);
|
||||
Afour = 0.5*fDPhi*(fRmax2*fRmax2-fRmin2*fRmin2);
|
||||
Afive = fDz*(fRmax1-fRmin1+fRmax2-fRmin2);
|
||||
|
||||
phi = RandFlat::shoot(fSPhi,fSPhi+fDPhi);
|
||||
cosu = std::cos(phi); sinu = std::sin(phi);
|
||||
rRand1 = RandFlat::shoot(fRmin1,fRmax1);
|
||||
rRand2 = RandFlat::shoot(fRmin2,fRmax2);
|
||||
|
||||
if(fSPhi == 0. && fDPhi == twopi){ Afive = 0.; }
|
||||
chose = RandFlat::shoot(0.,Aone+Atwo+Athree+Afour+2.*Afive);
|
||||
|
||||
if( (chose >= 0.) && (chose < Aone) )
|
||||
{
|
||||
if(fRmin1 != fRmin2)
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (rtwo*cosu*(qtwo-zRand),
|
||||
rtwo*sinu*(qtwo-zRand), zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G4ThreeVector(fRmin1*cosu, fRmin2*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
}
|
||||
}
|
||||
else if( (chose >= Aone) && (chose <= Aone + Atwo) )
|
||||
{
|
||||
if(fRmax1 != fRmax2)
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (rone*cosu*(qone-zRand),
|
||||
rone*sinu*(qone-zRand), zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G4ThreeVector(fRmax1*cosu, fRmax2*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
}
|
||||
}
|
||||
else if( (chose >= Aone + Atwo) && (chose < Aone + Atwo + Athree) )
|
||||
{
|
||||
return G4ThreeVector (rRand1*cosu,rRand1*sinu,-1*fDz);
|
||||
}
|
||||
else if( (chose >= Aone + Atwo + Athree)
|
||||
&& (chose < Aone + Atwo + Athree + Afour) )
|
||||
{
|
||||
return G4ThreeVector (rRand2*cosu,rRand2*sinu,fDz);
|
||||
}
|
||||
else if( (chose >= Aone + Atwo + Athree + Afour)
|
||||
&& (chose < Aone + Atwo + Athree + Afour + Afive) )
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
rRand1 = RandFlat::shoot(fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2),
|
||||
fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2));
|
||||
return G4ThreeVector (rRand1*std::cos(fSPhi),
|
||||
rRand1*std::sin(fSPhi), zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
rRand1 = RandFlat::shoot(fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2),
|
||||
fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2));
|
||||
return G4ThreeVector (rRand1*std::cos(fSPhi+fDPhi),
|
||||
rRand1*std::sin(fSPhi+fDPhi), zRand);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
// * statement, and all its terms. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4Orb.cc,v 1.19 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Orb.cc,v 1.22 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// class G4Orb
|
||||
//
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "meshdefs.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
@@ -50,6 +52,8 @@
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
// Private enum: Not for external use - used by distanceToOut
|
||||
|
||||
enum ESide {kNull,kRMax};
|
||||
@@ -82,6 +86,16 @@ G4Orb::G4Orb( const G4String& pName,G4double pRmax )
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Orb::G4Orb( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
@@ -90,7 +104,6 @@ G4Orb::~G4Orb()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dispatch to parameterisation for replication mechanism dimension
|
||||
@@ -542,7 +555,7 @@ G4double G4Orb::DistanceToOut( const G4ThreeVector& p,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Calcluate distance (<=actual) to closest surface of shape from inside
|
||||
// Calculate distance (<=actual) to closest surface of shape from inside
|
||||
|
||||
G4double G4Orb::DistanceToOut( const G4ThreeVector& p ) const
|
||||
{
|
||||
@@ -595,7 +608,27 @@ std::ostream& G4Orb::StreamInfo( std::ostream& os ) const
|
||||
return os;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
|
||||
G4ThreeVector G4Orb::GetPointOnSurface() const
|
||||
{
|
||||
// generate a random number from zero to 2pi...
|
||||
//
|
||||
G4double phi = RandFlat::shoot(0.,2.*pi);
|
||||
G4double cosphi = std::cos(phi);
|
||||
G4double sinphi = std::sin(phi);
|
||||
|
||||
G4double theta = RandFlat::shoot(0.,pi);
|
||||
G4double costheta = std::cos(theta);
|
||||
G4double sintheta = std::sqrt(1.-sqr(costheta));
|
||||
|
||||
return G4ThreeVector (fRmax*sintheta*cosphi,
|
||||
fRmax*sintheta*sinphi, fRmax*costheta);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
@@ -613,7 +646,3 @@ G4NURBS* G4Orb::CreateNURBS () const
|
||||
{
|
||||
return new G4NURBSbox (fRmax, fRmax, fRmax); // Box for now!!!
|
||||
}
|
||||
|
||||
// End of G4Orb.cc
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Para.cc,v 1.33 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Para.cc,v 1.37 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// class G4Para
|
||||
//
|
||||
@@ -30,10 +30,10 @@
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 23.10.05 V.Grichine: bug fixed in DistanceToOut(p,v,...) for the v.x()<0 case
|
||||
// 28.04.05 V.Grichine: new SurfaceNormal according to J. Apostolakis proposal
|
||||
// 26.04.05 V.Grichine: new SurfaceNormal is default
|
||||
// 30.11.04 V.Grichine: modifications in SurfaceNormal for edges/vertices and in
|
||||
// constructor with vertices
|
||||
// 30.11.04 V.Grichine: modifications in SurfaceNormal for edges/vertices and
|
||||
// in constructor with vertices
|
||||
// 14.02.02 V.Grichine: bug fixed in Inside according to proposal of D.Wright
|
||||
// 18.11.99 V.Grichine: kUndef was added to ESide
|
||||
// 31.10.96 V.Grichine: Modifications according G4Box/Tubs before to commit
|
||||
@@ -54,6 +54,8 @@
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
// Private enum: Not for external use
|
||||
|
||||
enum ESide {kUndef,kPX,kMX,kPY,kMY,kPZ,kMZ};
|
||||
@@ -155,6 +157,16 @@ G4Para::G4Para( const G4String& pName,
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Para::G4Para( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
@@ -444,7 +456,7 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
G4int noSurfaces = 0;
|
||||
G4double distx,disty,distz;
|
||||
G4double newpx,newpy,xshift;
|
||||
G4double calpha,salpha; // Sin/Cos(alpha) - needed to recalc G4Parameter
|
||||
G4double calpha,salpha; // Sin/Cos(alpha) - needed to recalc G4Parameter
|
||||
G4double tntheta,cosntheta; // tan and cos of normal's theta component
|
||||
G4double ycomp;
|
||||
G4double delta = 0.5*kCarTolerance;
|
||||
@@ -453,8 +465,8 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
newpy = p.y()-fTthetaSphi*p.z();
|
||||
|
||||
calpha = 1/std::sqrt(1+fTalpha*fTalpha);
|
||||
if (fTalpha) salpha = -calpha/fTalpha; // NOTE: actually use MINUS std::sin(alpha)
|
||||
else salpha = 0.;
|
||||
if (fTalpha) {salpha = -calpha/fTalpha;} // NOTE: using MINUS std::sin(alpha)
|
||||
else {salpha = 0.;}
|
||||
|
||||
// xshift = newpx*calpha+newpy*salpha;
|
||||
xshift = newpx - newpy*fTalpha;
|
||||
@@ -468,27 +480,29 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
cosntheta = 1/std::sqrt(1+tntheta*tntheta);
|
||||
ycomp = 1/std::sqrt(1+fTthetaSphi*fTthetaSphi);
|
||||
|
||||
G4ThreeVector nX = G4ThreeVector( calpha*cosntheta, salpha*cosntheta,-tntheta*cosntheta);
|
||||
G4ThreeVector nX = G4ThreeVector( calpha*cosntheta,
|
||||
salpha*cosntheta,
|
||||
-tntheta*cosntheta);
|
||||
G4ThreeVector nY = G4ThreeVector( 0, ycomp,-fTthetaSphi*ycomp);
|
||||
G4ThreeVector nZ = G4ThreeVector( 0, 0, 1.0);
|
||||
|
||||
if (distx <= delta)
|
||||
{
|
||||
noSurfaces ++;
|
||||
if ( xshift >= 0.) sumnorm += nX;
|
||||
else sumnorm -= nX;
|
||||
if ( xshift >= 0.) {sumnorm += nX;}
|
||||
else {sumnorm -= nX;}
|
||||
}
|
||||
if (disty <= delta)
|
||||
{
|
||||
noSurfaces ++;
|
||||
if ( newpy >= 0.) sumnorm += nY;
|
||||
else sumnorm -= nY;
|
||||
if ( newpy >= 0.) {sumnorm += nY;}
|
||||
else {sumnorm -= nY;}
|
||||
}
|
||||
if (distz <= delta)
|
||||
{
|
||||
noSurfaces ++;
|
||||
if ( p.z() >= 0.) sumnorm += nZ;
|
||||
else sumnorm -= nZ;
|
||||
if ( p.z() >= 0.) {sumnorm += nZ;}
|
||||
else {sumnorm -= nZ;}
|
||||
}
|
||||
if ( noSurfaces == 0 )
|
||||
{
|
||||
@@ -498,8 +512,8 @@ G4ThreeVector G4Para::SurfaceNormal( const G4ThreeVector& p ) const
|
||||
#endif
|
||||
norm = ApproxSurfaceNormal(p);
|
||||
}
|
||||
else if ( noSurfaces == 1 ) norm = sumnorm;
|
||||
else norm = sumnorm.unit();
|
||||
else if ( noSurfaces == 1 ) {norm = sumnorm;}
|
||||
else {norm = sumnorm.unit();}
|
||||
|
||||
return norm;
|
||||
}
|
||||
@@ -541,13 +555,13 @@ G4ThreeVector G4Para::ApproxSurfaceNormal( const G4ThreeVector& p ) const
|
||||
|
||||
if (distx<disty)
|
||||
{
|
||||
if (distx<distz) side=kNX;
|
||||
else side=kNZ;
|
||||
if (distx<distz) {side=kNX;}
|
||||
else {side=kNZ;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (disty<distz) side=kNY;
|
||||
else side=kNZ;
|
||||
if (disty<distz) {side=kNY;}
|
||||
else {side=kNZ;}
|
||||
}
|
||||
|
||||
switch (side)
|
||||
@@ -1005,9 +1019,9 @@ G4double G4Para::DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
|
||||
}
|
||||
tntheta=fTthetaCphi*calpha+fTthetaSphi*salpha;
|
||||
cosntheta=-1/std::sqrt(1+tntheta*tntheta);
|
||||
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
|
||||
return snxt=0;
|
||||
*n=G4ThreeVector(calpha*cosntheta,salpha*cosntheta,-tntheta*cosntheta);
|
||||
}
|
||||
return snxt=0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,13 +1221,117 @@ std::ostream& G4Para::StreamInfo( std::ostream& os ) const
|
||||
<< " half length Y: " << fDy/mm << " mm \n"
|
||||
<< " half length Z: " << fDz/mm << " mm \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"
|
||||
<< " std::tan(theta)*std::cos(phi): " << fTthetaCphi/degree
|
||||
<< " degrees \n"
|
||||
<< " std::tan(theta)*std::sin(phi): " << fTthetaSphi/degree
|
||||
<< " degrees \n"
|
||||
<< "-----------------------------------------------------------\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnPlane
|
||||
// Auxiliary method for Get Point on Surface
|
||||
//
|
||||
|
||||
G4ThreeVector G4Para::GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1,
|
||||
G4ThreeVector p2, G4ThreeVector p3,
|
||||
G4double& area) const
|
||||
{
|
||||
G4double lambda1, lambda2, chose, aOne, aTwo;
|
||||
G4ThreeVector t, u, v, w, Area, normal;
|
||||
|
||||
t = p1 - p0;
|
||||
u = p2 - p1;
|
||||
v = p3 - p2;
|
||||
w = p0 - p3;
|
||||
|
||||
Area = G4ThreeVector(w.y()*v.z() - w.z()*v.y(),
|
||||
w.z()*v.x() - w.x()*v.z(),
|
||||
w.x()*v.y() - w.y()*v.x());
|
||||
|
||||
aOne = 0.5*Area.mag();
|
||||
|
||||
Area = G4ThreeVector(t.y()*u.z() - t.z()*u.y(),
|
||||
t.z()*u.x() - t.x()*u.z(),
|
||||
t.x()*u.y() - t.y()*u.x());
|
||||
|
||||
aTwo = 0.5*Area.mag();
|
||||
|
||||
area = aOne + aTwo;
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo);
|
||||
|
||||
if( (chose>=0.) && (chose < aOne) )
|
||||
{
|
||||
lambda1 = RandFlat::shoot(0.,1.);
|
||||
lambda2 = RandFlat::shoot(0.,lambda1);
|
||||
return (p2+lambda1*v+lambda2*w);
|
||||
}
|
||||
|
||||
// else
|
||||
|
||||
lambda1 = RandFlat::shoot(0.,1.);
|
||||
lambda2 = RandFlat::shoot(0.,lambda1);
|
||||
return (p0+lambda1*t+lambda2*u);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
//
|
||||
// Return a point (G4ThreeVector) randomly and uniformly
|
||||
// selected on the solid surface
|
||||
|
||||
G4ThreeVector G4Para::GetPointOnSurface() const
|
||||
{
|
||||
G4ThreeVector One, Two, Three, Four, Five, Six;
|
||||
G4ThreeVector pt[8] ;
|
||||
G4double chose, aOne, aTwo, aThree, aFour, aFive, aSix;
|
||||
|
||||
pt[0] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha-fDx,
|
||||
-fDz*fTthetaSphi-fDy, -fDz);
|
||||
pt[1] = G4ThreeVector(-fDz*fTthetaCphi-fDy*fTalpha+fDx,
|
||||
-fDz*fTthetaSphi-fDy, -fDz);
|
||||
pt[2] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha-fDx,
|
||||
-fDz*fTthetaSphi+fDy, -fDz);
|
||||
pt[3] = G4ThreeVector(-fDz*fTthetaCphi+fDy*fTalpha+fDx,
|
||||
-fDz*fTthetaSphi+fDy, -fDz);
|
||||
pt[4] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha-fDx,
|
||||
+fDz*fTthetaSphi-fDy, +fDz);
|
||||
pt[5] = G4ThreeVector(+fDz*fTthetaCphi-fDy*fTalpha+fDx,
|
||||
+fDz*fTthetaSphi-fDy, +fDz);
|
||||
pt[6] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha-fDx,
|
||||
+fDz*fTthetaSphi+fDy, +fDz);
|
||||
pt[7] = G4ThreeVector(+fDz*fTthetaCphi+fDy*fTalpha+fDx,
|
||||
+fDz*fTthetaSphi+fDy, +fDz);
|
||||
|
||||
// make sure we provide the points in a clockwise fashion
|
||||
|
||||
One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
|
||||
Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
|
||||
Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
|
||||
Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
|
||||
Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
|
||||
Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo+aThree+aFour+aFive+aSix);
|
||||
|
||||
if( (chose>=0.) && (chose<aOne) )
|
||||
{ return One; }
|
||||
else if(chose>=aOne && chose<aOne+aTwo)
|
||||
{ return Two; }
|
||||
else if(chose>=aOne+aTwo && chose<aOne+aTwo+aThree)
|
||||
{ return Three; }
|
||||
else if(chose>=aOne+aTwo+aThree && chose<aOne+aTwo+aThree+aFour)
|
||||
{ return Four; }
|
||||
else if(chose>=aOne+aTwo+aThree+aFour && chose<aOne+aTwo+aThree+aFour+aFive)
|
||||
{ return Five; }
|
||||
return Six;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
@@ -1238,46 +1356,3 @@ G4NURBS* G4Para::CreateNURBS () const
|
||||
// return new G4NURBSbox (fDx, fDy, fDz);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Return a point (G4ThreeVector) randomly and uniformly selected on the solid surface
|
||||
|
||||
G4ThreeVector G4Para::GetPointOnSurface() const
|
||||
{
|
||||
G4double px, py, pz, select, sumS;
|
||||
G4double Sxy, Sxz, Syz;
|
||||
|
||||
Sxy = fDx*fDy;
|
||||
Sxz = fDx*fDz;
|
||||
Syz = fDy*fDz;
|
||||
|
||||
sumS = Sxy + Sxz + Syz;
|
||||
select = sumS*G4UniformRand();
|
||||
|
||||
if( select < Sxy )
|
||||
{
|
||||
px = -fDx +2*fDx*G4UniformRand();
|
||||
py = -fDy +2*fDy*G4UniformRand();
|
||||
|
||||
if(G4UniformRand() > 0.5) pz = fDz;
|
||||
else pz = -fDz;
|
||||
}
|
||||
else if ( ( select - Sxy ) < Sxz )
|
||||
{
|
||||
px = -fDx +2*fDx*G4UniformRand();
|
||||
pz = -fDz +2*fDz*G4UniformRand();
|
||||
|
||||
if(G4UniformRand() > 0.5) py = fDy;
|
||||
else py = -fDy;
|
||||
}
|
||||
else
|
||||
{
|
||||
py = -fDy +2*fDy*G4UniformRand();
|
||||
pz = -fDz +2*fDz*G4UniformRand();
|
||||
|
||||
if(G4UniformRand() > 0.5) px = fDx;
|
||||
else px = -fDx;
|
||||
}
|
||||
return G4ThreeVector(px,py,pz);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Sphere.cc,v 1.48 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Sphere.cc,v 1.53 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// class G4Sphere
|
||||
//
|
||||
@@ -30,6 +30,7 @@
|
||||
//
|
||||
// History:
|
||||
//
|
||||
// 22.07.05 O.Link : Added check for intersection with double cone
|
||||
// 03.05.05 V.Grichine: SurfaceNormal(p) according to J. Apostolakis proposal
|
||||
// 16.09.04 V.Grichine: bug fixed in SurfaceNormal(p), theta normals
|
||||
// 16.07.04 V.Grichine: bug fixed in DistanceToOut(p,v), Rmin go outside
|
||||
@@ -56,6 +57,8 @@
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "meshdefs.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
@@ -64,6 +67,8 @@
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
// Private enum: Not for external use - used by distanceToOut
|
||||
|
||||
enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
|
||||
@@ -72,14 +77,6 @@ enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kSTheta,kETheta};
|
||||
|
||||
enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNSTheta,kNETheta};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Sphere::~G4Sphere()
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
|
||||
@@ -174,6 +171,24 @@ G4Sphere::G4Sphere( const G4String& pName,
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Sphere::G4Sphere( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Sphere::~G4Sphere()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dispatch to parameterisation for replication mechanism dimension
|
||||
@@ -2218,6 +2233,16 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
|
||||
}
|
||||
if (s > flexRadMaxTolerance*0.5 ) // && s<sr)
|
||||
{
|
||||
// check against double cone solution
|
||||
zi=p.z()+s*v.z();
|
||||
if (fSTheta<pi*0.5 && zi<0)
|
||||
{
|
||||
s = kInfinity ; // wrong cone
|
||||
}
|
||||
if (fSTheta>pi*0.5 && zi>0)
|
||||
{
|
||||
s = kInfinity ; // wrong cone
|
||||
}
|
||||
stheta = s ;
|
||||
sidetheta = kSTheta ;
|
||||
}
|
||||
@@ -2245,6 +2270,16 @@ G4double G4Sphere::DistanceToOut( const G4ThreeVector& p,
|
||||
}
|
||||
if (s > flexRadMaxTolerance*0.5 && s < stheta )
|
||||
{
|
||||
// check against double cone solution
|
||||
zi=p.z()+s*v.z();
|
||||
if (fSTheta+fDTheta<pi*0.5 && zi<0)
|
||||
{
|
||||
s = kInfinity ; // wrong cone
|
||||
}
|
||||
if (fSTheta+fDTheta>pi*0.5 && zi>0)
|
||||
{
|
||||
s = kInfinity ; // wrong cone
|
||||
}
|
||||
stheta = s ;
|
||||
sidetheta = kETheta ;
|
||||
}
|
||||
@@ -2899,6 +2934,92 @@ std::ostream& G4Sphere::StreamInfo( std::ostream& os ) const
|
||||
return os;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
|
||||
G4ThreeVector G4Sphere::GetPointOnSurface() const
|
||||
{
|
||||
G4double zRand, aOne, aTwo, aThr, aFou, aFiv, chose, phi, sinphi, cosphi;
|
||||
G4double height1, height2, slant1, slant2, costheta, sintheta,theta,rRand;
|
||||
|
||||
height1 = (fRmax-fRmin)*std::cos(fSTheta);
|
||||
height2 = (fRmax-fRmin)*std::cos(fSTheta+fDTheta);
|
||||
slant1 = std::sqrt(sqr((fRmax - fRmin)*std::sin(fSTheta))
|
||||
+ height1*height1);
|
||||
slant2 = std::sqrt(sqr((fRmax - fRmin)*std::sin(fSTheta+fDTheta))
|
||||
+ height2*height2);
|
||||
rRand = RandFlat::shoot(fRmin,fRmax);
|
||||
|
||||
aOne = fRmax*fRmax*fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta));
|
||||
aTwo = fRmin*fRmin*fDPhi*(std::cos(fSTheta)-std::cos(fSTheta+fDTheta));
|
||||
aThr = fDPhi*((fRmax + fRmin)*std::sin(fSTheta))*slant1;
|
||||
aFou = fDPhi*((fRmax + fRmin)*std::sin(fSTheta+fDTheta))*slant2;
|
||||
aFiv = 0.5*fDTheta*(fRmax*fRmax-fRmin*fRmin);
|
||||
|
||||
phi = RandFlat::shoot(fSPhi, fSPhi + fDPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
theta = RandFlat::shoot(fSTheta,fSTheta+fDTheta);
|
||||
costheta = std::cos(theta);
|
||||
sintheta = std::sqrt(1.-sqr(costheta));
|
||||
|
||||
if( (fSPhi==0) && (fDPhi==2.*pi) || (fDPhi==2.*pi) ) {aFiv = 0;}
|
||||
if(fSTheta == 0) {aThr=0;}
|
||||
if(fDTheta + fSTheta == pi) {aFou = 0;}
|
||||
if(fSTheta == 0.5*pi) {aThr = pi*(fRmax*fRmax-fRmin*fRmin);}
|
||||
if(fSTheta + fDTheta == 0.5*pi) { aFou = pi*(fRmax*fRmax-fRmin*fRmin);}
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo+aThr+aFou+2.*aFiv);
|
||||
if( (chose>=0.) && (chose<aOne) )
|
||||
{
|
||||
return G4ThreeVector(fRmax*sintheta*cosphi,
|
||||
fRmax*sintheta*sinphi, fRmax*costheta);
|
||||
}
|
||||
else if( (chose>=aOne) && (chose<aOne+aTwo) )
|
||||
{
|
||||
return G4ThreeVector(fRmin*sintheta*cosphi,
|
||||
fRmin*sintheta*sinphi, fRmin*costheta);
|
||||
}
|
||||
else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThr) )
|
||||
{
|
||||
if (fSTheta != 0.5*pi)
|
||||
{
|
||||
zRand = RandFlat::shoot(fRmin*std::cos(fSTheta),fRmax*std::cos(fSTheta));
|
||||
return G4ThreeVector(std::tan(fSTheta)*zRand*cosphi,
|
||||
std::tan(fSTheta)*zRand*sinphi,zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G4ThreeVector(rRand*cosphi, rRand*sinphi, 0.);
|
||||
}
|
||||
}
|
||||
else if( (chose>=aOne+aTwo+aThr) && (chose<aOne+aTwo+aThr+aFou) )
|
||||
{
|
||||
if(fSTheta + fDTheta != 0.5*pi)
|
||||
{
|
||||
zRand = RandFlat::shoot(fRmin*std::cos(fSTheta+fDTheta),
|
||||
fRmax*std::cos(fSTheta+fDTheta));
|
||||
return G4ThreeVector (std::tan(fSTheta+fDTheta)*zRand*cosphi,
|
||||
std::tan(fSTheta+fDTheta)*zRand*sinphi,zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G4ThreeVector(rRand*cosphi, rRand*sinphi, 0.);
|
||||
}
|
||||
}
|
||||
else if( (chose>=aOne+aTwo+aThr+aFou) && (chose<aOne+aTwo+aThr+aFou+aFiv) )
|
||||
{
|
||||
return G4ThreeVector(rRand*sintheta*std::cos(fSPhi),
|
||||
rRand*sintheta*std::sin(fSPhi),rRand*costheta);
|
||||
}
|
||||
else
|
||||
{
|
||||
return G4ThreeVector(rRand*sintheta*std::cos(fSPhi+fDPhi),
|
||||
rRand*sintheta*std::sin(fSPhi+fDPhi),rRand*costheta);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Trap.cc,v 1.37 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Trap.cc,v 1.40 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
// class G4Trap
|
||||
//
|
||||
@@ -53,11 +53,15 @@
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accuracy of coplanarity
|
||||
@@ -70,14 +74,6 @@ const G4double kCoplanar_Tolerance = 1E-4 ;
|
||||
|
||||
enum Eside {kUndef,ks0,ks1,ks2,ks3,kPZ,kMZ};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Trap::~G4Trap()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor - check and set half-widths as well as angles:
|
||||
@@ -525,6 +521,24 @@ G4Trap::G4Trap( const G4String& pName )
|
||||
MakePlanes();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Trap::G4Trap( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
|
||||
G4Trap::~G4Trap()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Set all parameters, as for constructor - check and set half-widths
|
||||
@@ -1759,7 +1773,107 @@ std::ostream& G4Trap::StreamInfo( std::ostream& os ) const
|
||||
return os;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnPlane
|
||||
//
|
||||
// Auxiliary method for Get Point on Surface
|
||||
|
||||
G4ThreeVector G4Trap::GetPointOnPlane(G4ThreeVector p0, G4ThreeVector p1,
|
||||
G4ThreeVector p2, G4ThreeVector p3,
|
||||
G4double& area) const
|
||||
{
|
||||
G4double lambda1, lambda2, chose, aOne, aTwo;
|
||||
G4ThreeVector t, u, v, w, Area, normal;
|
||||
|
||||
t = p1 - p0;
|
||||
u = p2 - p1;
|
||||
v = p3 - p2;
|
||||
w = p0 - p3;
|
||||
|
||||
Area = G4ThreeVector(w.y()*v.z() - w.z()*v.y(),
|
||||
w.z()*v.x() - w.x()*v.z(),
|
||||
w.x()*v.y() - w.y()*v.x());
|
||||
|
||||
aOne = 0.5*Area.mag();
|
||||
|
||||
Area = G4ThreeVector(t.y()*u.z() - t.z()*u.y(),
|
||||
t.z()*u.x() - t.x()*u.z(),
|
||||
t.x()*u.y() - t.y()*u.x());
|
||||
|
||||
aTwo = 0.5*Area.mag();
|
||||
|
||||
area = aOne + aTwo;
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo);
|
||||
|
||||
if( (chose>=0.) && (chose < aOne) )
|
||||
{
|
||||
lambda1 = RandFlat::shoot(0.,1.);
|
||||
lambda2 = RandFlat::shoot(0.,lambda1);
|
||||
return (p2+lambda1*v+lambda2*w);
|
||||
}
|
||||
|
||||
// else
|
||||
|
||||
lambda1 = RandFlat::shoot(0.,1.);
|
||||
lambda2 = RandFlat::shoot(0.,lambda1);
|
||||
|
||||
return (p0+lambda1*t+lambda2*u);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
|
||||
G4ThreeVector G4Trap::GetPointOnSurface() const
|
||||
{
|
||||
G4double aOne, aTwo, aThree, aFour, aFive, aSix, chose;
|
||||
G4ThreeVector One, Two, Three, Four, Five, Six, test;
|
||||
G4ThreeVector pt[8];
|
||||
|
||||
pt[0] = G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1-fDx1,
|
||||
-fDz*fTthetaSphi-fDy1,-fDz);
|
||||
pt[1] = G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1+fDx1,
|
||||
-fDz*fTthetaSphi-fDy1,-fDz);
|
||||
pt[2] = G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1-fDx2,
|
||||
-fDz*fTthetaSphi+fDy1,-fDz);
|
||||
pt[3] = G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1+fDx2,
|
||||
-fDz*fTthetaSphi+fDy1,-fDz);
|
||||
pt[4] = G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2-fDx3,
|
||||
+fDz*fTthetaSphi-fDy2,+fDz);
|
||||
pt[5] = G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2+fDx3,
|
||||
+fDz*fTthetaSphi-fDy2,+fDz);
|
||||
pt[6] = G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2-fDx4,
|
||||
+fDz*fTthetaSphi+fDy2,+fDz);
|
||||
pt[7] = G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2+fDx4,
|
||||
+fDz*fTthetaSphi+fDy2,+fDz);
|
||||
|
||||
// make sure we provide the points in a clockwise fashion
|
||||
|
||||
One = GetPointOnPlane(pt[0],pt[1],pt[3],pt[2], aOne);
|
||||
Two = GetPointOnPlane(pt[4],pt[5],pt[7],pt[6], aTwo);
|
||||
Three = GetPointOnPlane(pt[6],pt[7],pt[3],pt[2], aThree);
|
||||
Four = GetPointOnPlane(pt[4],pt[5],pt[1],pt[0], aFour);
|
||||
Five = GetPointOnPlane(pt[0],pt[2],pt[6],pt[4], aFive);
|
||||
Six = GetPointOnPlane(pt[1],pt[3],pt[7],pt[5], aSix);
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo+aThree+aFour+aFive+aSix);
|
||||
if( (chose>=0.) && (chose<aOne) )
|
||||
{ return One; }
|
||||
else if( (chose>=aOne) && (chose<aOne+aTwo) )
|
||||
{ return Two; }
|
||||
else if( (chose>=aOne+aTwo) && (chose<aOne+aTwo+aThree) )
|
||||
{ return Three; }
|
||||
else if( (chose>=aOne+aTwo+aThree) && (chose<aOne+aTwo+aThree+aFour) )
|
||||
{ return Four; }
|
||||
else if( (chose>=aOne+aTwo+aThree+aFour)
|
||||
&& (chose<aOne+aTwo+aThree+aFour+aFive) )
|
||||
{ return Five; }
|
||||
return Six;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Trd.cc,v 1.30 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Trd.cc,v 1.32 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// Implementation for G4Trd class
|
||||
@@ -34,9 +34,8 @@
|
||||
// 07.12.04, V.Grichine, SurfaceNoramal with edges/vertices.
|
||||
// 07.05.00, V.Grichine, in d = DistanceToIn(p,v), if d<0.5*kCarTolerance, d=0
|
||||
// ~1996, V.Grichine, 1st implementation based on old code of P.Kent
|
||||
//
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4Trd.hh"
|
||||
|
||||
@@ -50,6 +49,8 @@
|
||||
#include "G4NURBS.hh"
|
||||
#include "G4NURBSbox.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor - check & set half widths
|
||||
@@ -108,6 +109,16 @@ void G4Trd::CheckAndSetAllParameters ( G4double pdx1, G4double pdx2,
|
||||
fpPolyhedron = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Trd::G4Trd( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
@@ -1333,29 +1344,13 @@ std::ostream& G4Trd::StreamInfo( std::ostream& os ) const
|
||||
return os;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
void G4Trd::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4Trd::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronTrd2 (fDx1, fDx2, fDy1, fDy2, fDz);
|
||||
}
|
||||
|
||||
G4NURBS* G4Trd::CreateNURBS () const
|
||||
{
|
||||
// return new G4NURBSbox (fDx, fDy, fDz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// GetPointOnSurface
|
||||
//
|
||||
// Return a point (G4ThreeVector) randomly and uniformly selected on the solid surface
|
||||
// Return a point (G4ThreeVector) randomly and uniformly
|
||||
// selected on the solid surface
|
||||
|
||||
G4ThreeVector G4Trd::GetPointOnSurface() const
|
||||
{
|
||||
@@ -1400,8 +1395,8 @@ G4ThreeVector G4Trd::GetPointOnSurface() const
|
||||
px = -tmp + 2*tmp*G4UniformRand();
|
||||
tmp = fDy1 + (pz + fDz)*tgY;
|
||||
|
||||
if(G4UniformRand() > 0.5) py = tmp;
|
||||
else py = -tmp;
|
||||
if(G4UniformRand() > 0.5) { py = tmp; }
|
||||
else { py = -tmp; }
|
||||
}
|
||||
else // Syz
|
||||
{
|
||||
@@ -1410,8 +1405,28 @@ G4ThreeVector G4Trd::GetPointOnSurface() const
|
||||
py = -tmp + 2*tmp*G4UniformRand();
|
||||
tmp = fDx1 + (pz + fDz)*tgX;
|
||||
|
||||
if(G4UniformRand() > 0.5) px = tmp;
|
||||
else px = -tmp;
|
||||
if(G4UniformRand() > 0.5) { px = tmp; }
|
||||
else { px = -tmp; }
|
||||
}
|
||||
return G4ThreeVector(px,py,pz);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
void G4Trd::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddSolid (*this);
|
||||
}
|
||||
|
||||
G4Polyhedron* G4Trd::CreatePolyhedron () const
|
||||
{
|
||||
return new G4PolyhedronTrd2 (fDx1, fDx2, fDy1, fDy2, fDz);
|
||||
}
|
||||
|
||||
G4NURBS* G4Trd::CreateNURBS () const
|
||||
{
|
||||
// return new G4NURBSbox (fDx, fDy, fDz);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Tubs.cc,v 1.54 2005/06/08 16:14:25 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Tubs.cc,v 1.57 2005/11/09 15:03:09 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// class G4Tubs
|
||||
@@ -51,6 +51,8 @@
|
||||
// 18.06.98 V.Grichine: n-normalisation in DistanceToOut(p,v)
|
||||
//
|
||||
// 1994-95 P.Kent: implementation
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4Tubs.hh"
|
||||
|
||||
@@ -59,6 +61,8 @@
|
||||
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "meshdefs.hh"
|
||||
|
||||
#include "G4VGraphicsScene.hh"
|
||||
@@ -68,6 +72,8 @@
|
||||
#include "G4NURBScylinder.hh"
|
||||
#include "G4NURBStubesector.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
|
||||
@@ -143,6 +149,16 @@ G4Tubs::G4Tubs( const G4String &pName,
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Tubs::G4Tubs( __void__& a )
|
||||
: G4CSGSolid(a)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Destructor
|
||||
@@ -1723,11 +1739,80 @@ std::ostream& G4Tubs::StreamInfo( std::ostream& os ) const
|
||||
return os;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GetPointOnSurface
|
||||
|
||||
G4ThreeVector G4Tubs::GetPointOnSurface() const
|
||||
{
|
||||
G4double xRand, yRand, zRand, phi, cosphi, sinphi, chose,
|
||||
aOne, aTwo, aThr, aFou;
|
||||
G4double rRand;
|
||||
|
||||
aOne = 2.*fDz*fDPhi*fRMax;
|
||||
aTwo = 2.*fDz*fDPhi*fRMin;
|
||||
aThr = 0.5*fDPhi*(fRMax*fRMax-fRMin*fRMin);
|
||||
aFou = 2.*fDz*(fRMax-fRMin);
|
||||
|
||||
phi = RandFlat::shoot(fSPhi, fSPhi+fDPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
|
||||
rRand = RandFlat::shoot(fRMin,fRMax);
|
||||
|
||||
if( (fSPhi == 0) && (fDPhi == twopi) ) { aFou = 0; }
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo+2.*aThr+2.*aFou);
|
||||
|
||||
if( (chose >=0) && (chose < aOne) )
|
||||
{
|
||||
xRand = fRMax*cosphi;
|
||||
yRand = fRMax*sinphi;
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
else if( (chose >= aOne) && (chose < aOne + aTwo) )
|
||||
{
|
||||
xRand = fRMin*cosphi;
|
||||
yRand = fRMin*sinphi;
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
else if( (chose >= aOne + aTwo) && (chose < aOne + aTwo + aThr) )
|
||||
{
|
||||
xRand = rRand*cosphi;
|
||||
yRand = rRand*sinphi;
|
||||
zRand = fDz;
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
else if( (chose >= aOne + aTwo + aThr) && (chose < aOne + aTwo + 2.*aThr) )
|
||||
{
|
||||
xRand = rRand*cosphi;
|
||||
yRand = rRand*sinphi;
|
||||
zRand = -1.*fDz;
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
else if( (chose >= aOne + aTwo + 2.*aThr)
|
||||
&& (chose < aOne + aTwo + 2.*aThr + aFou) )
|
||||
{
|
||||
xRand = rRand*std::cos(fSPhi);
|
||||
yRand = rRand*std::sin(fSPhi);
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
xRand = rRand*std::cos(fSPhi+fDPhi);
|
||||
yRand = rRand*std::sin(fSPhi+fDPhi);
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector (xRand, yRand, zRand);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Methods for visualisation
|
||||
|
||||
|
||||
void G4Tubs::DescribeYourselfTo ( G4VGraphicsScene& scene ) const
|
||||
{
|
||||
scene.AddSolid (*this) ;
|
||||
|
||||
Reference in New Issue
Block a user