Import Geant4 8.0.0 source tree
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4Polycone.cc,v 1.20 2004/12/10 16:22:38 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-07-01 $
|
||||
// $Id: G4Polycone.cc,v 1.28 2005/11/17 14:08:00 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-08-00 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
@@ -40,11 +40,15 @@
|
||||
#include "G4PolyconeSide.hh"
|
||||
#include "G4PolyPhiFace.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "G4Polyhedron.hh"
|
||||
#include "G4EnclosingCylinder.hh"
|
||||
#include "G4ReduciblePolygon.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
//
|
||||
// Constructor (GEANT3 style parameters)
|
||||
//
|
||||
@@ -55,7 +59,7 @@ G4Polycone::G4Polycone( const G4String& name,
|
||||
const G4double zPlane[],
|
||||
const G4double rInner[],
|
||||
const G4double rOuter[] )
|
||||
: G4VCSGfaceted( name )
|
||||
: G4VCSGfaceted( name ), genericPcon(false)
|
||||
{
|
||||
//
|
||||
// Some historical ugliness
|
||||
@@ -118,14 +122,16 @@ G4Polycone::G4Polycone( const G4String& name,
|
||||
G4int numRZ,
|
||||
const G4double r[],
|
||||
const G4double z[] )
|
||||
: G4VCSGfaceted( name )
|
||||
: G4VCSGfaceted( name ), genericPcon(true)
|
||||
{
|
||||
original_parameters = 0;
|
||||
|
||||
G4ReduciblePolygon *rz = new G4ReduciblePolygon( r, z, numRZ );
|
||||
|
||||
Create( phiStart, phiTotal, rz );
|
||||
|
||||
// Set original_parameters struct for consistency
|
||||
//
|
||||
SetOriginalParameters();
|
||||
|
||||
delete rz;
|
||||
}
|
||||
|
||||
@@ -299,6 +305,17 @@ void G4Polycone::Create( G4double phiStart,
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Fake default constructor - sets only member data and allocates memory
|
||||
// for usage restricted to object persistency.
|
||||
//
|
||||
G4Polycone::G4Polycone( __void__& a )
|
||||
: G4VCSGfaceted(a), genericPcon(false),
|
||||
original_parameters(0), enclosingCylinder(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Destructor
|
||||
//
|
||||
@@ -353,6 +370,7 @@ void G4Polycone::CopyStuff( const G4Polycone &source )
|
||||
endPhi = source.endPhi;
|
||||
phiIsOpen = source.phiIsOpen;
|
||||
numCorner = source.numCorner;
|
||||
genericPcon= source.genericPcon;
|
||||
|
||||
//
|
||||
// The corner array
|
||||
@@ -387,7 +405,7 @@ void G4Polycone::CopyStuff( const G4Polycone &source )
|
||||
//
|
||||
G4bool G4Polycone::Reset()
|
||||
{
|
||||
if (!original_parameters)
|
||||
if (genericPcon)
|
||||
{
|
||||
G4cerr << "Solid " << GetName() << " built using generic construct."
|
||||
<< G4endl << "Specify original parameters first !" << G4endl;
|
||||
@@ -501,7 +519,7 @@ std::ostream& G4Polycone::StreamInfo( std::ostream& os ) const
|
||||
<< " starting phi angle : " << startPhi/degree << " degrees \n"
|
||||
<< " ending phi angle : " << endPhi/degree << " degrees \n";
|
||||
G4int i=0;
|
||||
if (original_parameters)
|
||||
if (!genericPcon)
|
||||
{
|
||||
G4int numPlanes = original_parameters->Num_z_planes;
|
||||
os << " number of Z planes: " << numPlanes << "\n"
|
||||
@@ -537,6 +555,254 @@ std::ostream& G4Polycone::StreamInfo( std::ostream& os ) const
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnCone
|
||||
//
|
||||
// Auxiliary method for Get Point On Surface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnCone(G4double fRmin1, G4double fRmax1,
|
||||
G4double fRmin2, G4double fRmax2,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
// declare working variables
|
||||
//
|
||||
G4double Aone, Atwo, Afive, phi, zRand, fDPhi, fSPhi, cosu, sinu;
|
||||
G4double rRand1, chose, rone, rtwo, qone, qtwo,
|
||||
fDz = std::fabs((zTwo-zOne)/2.);
|
||||
G4ThreeVector point, offset;
|
||||
offset = G4ThreeVector(0.,0.,0.5*(zTwo+zOne));
|
||||
fSPhi = startPhi; fDPhi = endPhi - startPhi;
|
||||
|
||||
rone = (fRmax1-fRmax2)/(2.*fDz);
|
||||
rtwo = (fRmin1-fRmin2)/(2.*fDz);
|
||||
qone = fDz*(fRmax1+fRmax2)/(fRmax1-fRmax2);
|
||||
qtwo = fDz*(fRmin1+fRmin2)/(fRmin1-fRmin2);
|
||||
|
||||
Aone = 0.5*fDPhi*(fRmax2 + fRmax1)*(sqr(fRmin1-fRmin2)+sqr(zTwo-zOne));
|
||||
Atwo = 0.5*fDPhi*(fRmin2 + fRmin1)*(sqr(fRmax1-fRmax2)+sqr(zTwo-zOne));
|
||||
Afive = fDz*(fRmax1-fRmin1+fRmax2-fRmin2);
|
||||
totArea = Aone+Atwo+2.*Afive;
|
||||
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosu = std::cos(phi);
|
||||
sinu = std::sin(phi);
|
||||
|
||||
if( (startPhi == 0) && (endPhi == twopi) ) { Afive = 0; }
|
||||
chose = RandFlat::shoot(0.,Aone+Atwo+2.*Afive);
|
||||
|
||||
if( (chose >= 0) && (chose < Aone) )
|
||||
{
|
||||
if(fRmax1 != fRmax2)
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
point = G4ThreeVector (rone*cosu*(qone-zRand),
|
||||
rone*sinu*(qone-zRand), zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
point = G4ThreeVector(fRmax1*cosu, fRmax1*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
}
|
||||
}
|
||||
else if(chose >= Aone && chose < Aone + Atwo)
|
||||
{
|
||||
if(fRmin1 != fRmin2)
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
point = G4ThreeVector (rtwo*cosu*(qtwo-zRand),
|
||||
rtwo*sinu*(qtwo-zRand), zRand);
|
||||
}
|
||||
else
|
||||
{
|
||||
point = G4ThreeVector(fRmin1*cosu, fRmin1*sinu,
|
||||
RandFlat::shoot(-1.*fDz,fDz));
|
||||
}
|
||||
}
|
||||
else if( (chose >= Aone + Atwo + Afive) && (chose < Aone + Atwo + 2.*Afive) )
|
||||
{
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
rRand1 = RandFlat::shoot(fRmin2-((zRand-fDz)/(2.*fDz))*(fRmin1-fRmin2),
|
||||
fRmax2-((zRand-fDz)/(2.*fDz))*(fRmax1-fRmax2));
|
||||
point = G4ThreeVector (rRand1*std::cos(startPhi),
|
||||
rRand1*std::sin(startPhi), 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));
|
||||
point = G4ThreeVector (rRand1*std::cos(endPhi),
|
||||
rRand1*std::sin(endPhi), zRand);
|
||||
}
|
||||
return point+offset;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnTubs
|
||||
//
|
||||
// Auxiliary method for GetPoint On Surface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnTubs(G4double fRMin, G4double fRMax,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
G4double xRand,yRand,zRand,phi,cosphi,sinphi,chose,
|
||||
aOne,aTwo,aFou,rRand,fDz,fSPhi,fDPhi;
|
||||
fDz = std::fabs(0.5*(zTwo-zOne));
|
||||
fSPhi = startPhi;
|
||||
fDPhi = endPhi-startPhi;
|
||||
|
||||
aOne = 2.*fDz*fDPhi*fRMax;
|
||||
aTwo = 2.*fDz*fDPhi*fRMin;
|
||||
aFou = 2.*fDz*(fRMax-fRMin);
|
||||
totArea = aOne+aTwo+2.*aFou;
|
||||
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
rRand = RandFlat::shoot(fRMin,fRMax);
|
||||
|
||||
if(startPhi == 0 && endPhi == twopi)
|
||||
aFou = 0;
|
||||
|
||||
chose = RandFlat::shoot(0.,aOne+aTwo+2.*aFou);
|
||||
if( (chose >= 0) && (chose < aOne) )
|
||||
{
|
||||
xRand = fRMax*cosphi;
|
||||
yRand = fRMax*sinphi;
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector(xRand, yRand, zRand+0.5*(zTwo+zOne));
|
||||
}
|
||||
else if( (chose >= aOne) && (chose < aOne + aTwo) )
|
||||
{
|
||||
xRand = fRMin*cosphi;
|
||||
yRand = fRMin*sinphi;
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector(xRand, yRand, zRand+0.5*(zTwo+zOne));
|
||||
}
|
||||
else if( (chose >= aOne+aTwo) && (chose <aOne+aTwo+aFou) )
|
||||
{
|
||||
xRand = rRand*std::cos(fSPhi+fDPhi);
|
||||
yRand = rRand*std::sin(fSPhi+fDPhi);
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector(xRand, yRand, zRand+0.5*(zTwo+zOne));
|
||||
}
|
||||
|
||||
// else
|
||||
|
||||
xRand = rRand*std::cos(fSPhi+fDPhi);
|
||||
yRand = rRand*std::sin(fSPhi+fDPhi);
|
||||
zRand = RandFlat::shoot(-1.*fDz,fDz);
|
||||
return G4ThreeVector(xRand, yRand, zRand+0.5*(zTwo+zOne));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnCut
|
||||
//
|
||||
// Auxiliary method for Get Point On Surface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnCut(G4double fRMin1, G4double fRMax1,
|
||||
G4double fRMin2, G4double fRMax2,
|
||||
G4double zOne, G4double zTwo,
|
||||
G4double& totArea) const
|
||||
{
|
||||
if( (fRMin1 == fRMin2) && (fRMax1 == fRMax2) )
|
||||
{
|
||||
return GetPointOnTubs(fRMin1, fRMax1,zOne,zTwo,totArea);
|
||||
}
|
||||
return GetPointOnCone(fRMin1,fRMax1,fRMin2,fRMax2,zOne,zTwo,totArea);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// GetPointOnSurface
|
||||
//
|
||||
G4ThreeVector G4Polycone::GetPointOnSurface() const
|
||||
{
|
||||
G4double Area=0,totArea=0,Achose1=0,Achose2=0,phi,cosphi,sinphi,rRand;
|
||||
G4int i=0;
|
||||
G4int numPlanes = original_parameters->Num_z_planes;
|
||||
|
||||
phi = RandFlat::shoot(startPhi,endPhi);
|
||||
cosphi = std::cos(phi);
|
||||
sinphi = std::sin(phi);
|
||||
|
||||
rRand = RandFlat::shoot(original_parameters->Rmin[0],
|
||||
original_parameters->Rmax[0]);
|
||||
|
||||
std::vector<G4double> areas; // (numPlanes+1);
|
||||
std::vector<G4ThreeVector> points; // (numPlanes-1);
|
||||
|
||||
areas.push_back(pi*(sqr(original_parameters->Rmax[0])
|
||||
-sqr(original_parameters->Rmin[0])));
|
||||
|
||||
for(i=0; i<numPlanes-1; i++)
|
||||
{
|
||||
Area = (original_parameters->Rmin[i]+original_parameters->Rmin[i+1])*
|
||||
std::sqrt(sqr(original_parameters->Rmin[i]
|
||||
-original_parameters->Rmin[i+1])+
|
||||
sqr(original_parameters->Z_values[i+1]
|
||||
-original_parameters->Z_values[i]));
|
||||
|
||||
Area += (original_parameters->Rmax[i]+original_parameters->Rmax[i+1])*
|
||||
std::sqrt(sqr(original_parameters->Rmax[i]
|
||||
-original_parameters->Rmax[i+1])+
|
||||
sqr(original_parameters->Z_values[i+1]
|
||||
-original_parameters->Z_values[i]));
|
||||
|
||||
Area *= 0.5*(endPhi-startPhi);
|
||||
|
||||
if(startPhi==0.&& endPhi == twopi)
|
||||
{
|
||||
Area += std::fabs(original_parameters->Z_values[i+1]
|
||||
-original_parameters->Z_values[i])*
|
||||
(original_parameters->Rmax[i]
|
||||
+original_parameters->Rmax[i+1]
|
||||
-original_parameters->Rmin[i]
|
||||
-original_parameters->Rmin[i+1]);
|
||||
}
|
||||
areas.push_back(Area);
|
||||
totArea += Area;
|
||||
}
|
||||
|
||||
areas.push_back(pi*(sqr(original_parameters->Rmax[numPlanes-1])-
|
||||
sqr(original_parameters->Rmin[numPlanes-1])));
|
||||
|
||||
totArea += (areas[0]+areas[numPlanes]);
|
||||
G4double chose = RandFlat::shoot(0.,totArea);
|
||||
|
||||
if( (chose>=0.) && (chose<areas[0]) )
|
||||
{
|
||||
return G4ThreeVector(rRand*cosphi, rRand*sinphi,
|
||||
original_parameters->Z_values[0]);
|
||||
}
|
||||
|
||||
for (i=0; i<numPlanes-1; i++)
|
||||
{
|
||||
Achose1 += areas[i];
|
||||
Achose2 = (Achose1+areas[i+1]);
|
||||
if(chose>=Achose1 && chose<Achose2)
|
||||
{
|
||||
return GetPointOnCut(original_parameters->Rmin[i],
|
||||
original_parameters->Rmax[i],
|
||||
original_parameters->Rmin[i+1],
|
||||
original_parameters->Rmax[i+1],
|
||||
original_parameters->Z_values[i],
|
||||
original_parameters->Z_values[i+1], Area);
|
||||
}
|
||||
}
|
||||
|
||||
rRand = RandFlat::shoot(original_parameters->Rmin[numPlanes-1],
|
||||
original_parameters->Rmax[numPlanes-1]);
|
||||
|
||||
return G4ThreeVector(rRand*cosphi,rRand*sinphi,
|
||||
original_parameters->Z_values[numPlanes-1]);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// CreatePolyhedron
|
||||
//
|
||||
@@ -545,7 +811,7 @@ G4Polyhedron* G4Polycone::CreatePolyhedron() const
|
||||
//
|
||||
// This has to be fixed in visualization. Fake it for the moment.
|
||||
//
|
||||
if (original_parameters)
|
||||
if (!genericPcon)
|
||||
{
|
||||
return new G4PolyhedronPcon( original_parameters->Start_angle,
|
||||
original_parameters->Opening_angle,
|
||||
@@ -557,8 +823,9 @@ G4Polyhedron* G4Polycone::CreatePolyhedron() const
|
||||
else
|
||||
{
|
||||
G4cerr << "ERROR - G4Polycone::CreatePolyhedron(): " << GetName() << G4endl
|
||||
<< " Visualization of this type of G4Polycone" << G4endl
|
||||
<< " is not supported at this time !" << G4endl;
|
||||
<< " Visualization of the 'generic' G4Polycone type" << G4endl
|
||||
<< " is not supported at this time !" << G4endl
|
||||
<< " Use the alternative constructor instead." << G4endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -578,6 +845,7 @@ G4NURBS *G4Polycone::CreateNURBS() const
|
||||
//
|
||||
|
||||
G4PolyconeHistorical::G4PolyconeHistorical()
|
||||
: Z_values(0), Rmin(0), Rmax(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user