50 #include "G4GeomTools.hh"
51 #include "G4VoxelLimits.hh"
52 #include "G4AffineTransform.hh"
53 #include "G4BoundingEnvelope.hh"
54 #include "G4GeometryTolerance.hh"
56 #include "G4VPVParameterisation.hh"
58 #include "meshdefs.hh"
60 #include "Randomize.hh"
62 #include "G4VGraphicsScene.hh"
64 using namespace CLHEP;
82 G4double pZ1, G4double pZ2,
83 G4double pRmin1, G4double pRmax1,
84 G4double pRmin2, G4double pRmax2)
88 kRadTolerance (G4GeometryTolerance::GetInstance()->GetRadialTolerance()),
89 kAngTolerance (G4GeometryTolerance::GetInstance()->GetAngularTolerance()),
90 fRmin1(pRmin1), fRmin2(pRmin2),
91 fRmax1(pRmax1), fRmax2(pRmax2),
92 fDz((pZ2 - pZ1) * 0.5), fZshift(pZ1 + fDz),
94 halfCarTolerance (kCarTolerance*0.5),
95 halfRadTolerance (kRadTolerance*0.5),
96 halfAngTolerance (kAngTolerance*0.5)
103 message <<
"Invalid Z half-length for Solid: " << GetName() << G4endl
105 G4Exception(
"G4ShiftedCone::G4ShiftedCone()",
"GeomSolids0002",
111 if (((pRmin1>=pRmax1) || (pRmin2>=pRmax2) || (pRmin1<0)) && (pRmin2<0))
114 message <<
"Invalid values of radii for Solid: " << GetName() << G4endl
115 <<
" pRmin1 = " << pRmin1 <<
", pRmin2 = " << pRmin2
116 <<
", pRmax1 = " << pRmax1 <<
", pRmax2 = " << pRmax2;
117 G4Exception(
"G4ShiftedCone::G4ShiftedCone()",
"GeomSolids0002",
134 : G4CSGSolid(
a), kRadTolerance(0.), kAngTolerance(0.),
135 fRmin1(0.), fRmin2(0.), fRmax1(0.), fRmax2(0.),
136 fDz(0.), fZshift(0.),
140 halfCarTolerance(0.), halfRadTolerance(0.), halfAngTolerance(0.)
157 : G4CSGSolid(rhs), kRadTolerance(rhs.kRadTolerance),
158 kAngTolerance(rhs.kAngTolerance), fRmin1(rhs.fRmin1), fRmin2(rhs.fRmin2),
159 fRmax1(rhs.fRmax1), fRmax2(rhs.fRmax2), fDz(rhs.fDz), fZshift(rhs.fZshift),
165 halfCarTolerance(rhs.halfCarTolerance),
166 halfRadTolerance(rhs.halfRadTolerance),
167 halfAngTolerance(rhs.halfAngTolerance)
179 if (
this == &rhs) {
return *
this; }
183 G4CSGSolid::operator=(rhs);
211 G4double r2,
rl, rh, tolRMin, tolRMax;
218 else { in = kInside; }
220 r2 =
p.x()*
p.x() +
p.y()*
p.y() ;
227 if ( tolRMin < 0 ) { tolRMin = 0; }
230 if ( (r2<tolRMin*tolRMin) || (r2>tolRMax*tolRMax) ) {
return in = kOutside; }
233 else { tolRMin = 0.0; }
238 if ( (r2 < tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax) ) { in = kSurface; }
269 const G4VPhysicalVolume* )
272 message <<
"ComputeDimensions is not implemented for Solid: " << GetName();
273 G4Exception(
"G4ShiftedCone::ComputeDimensions()",
"GeomSolids0002",
308 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
311 message <<
"Bad bounding box (min >= max) for solid: "
313 <<
"\npMin = " << pMin
314 <<
"\npMax = " << pMax;
315 G4Exception(
"G4ShiftedCone::BoundingLimits()",
"GeomMgt0001",
326 const G4VoxelLimits& pVoxelLimit,
327 const G4AffineTransform& pTransform,
329 G4double& pMax )
const
340 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
342 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
344 return exist = (pMin < pMax) ?
true :
false;
352 G4double z1 =
GetZ1();
353 G4double z2 =
GetZ2();
358 const G4int NSTEPS = 24;
359 G4double astep =
twopi/NSTEPS;
360 G4int ksteps = (dphi <= astep) ? 1 : (G4int)((dphi-
deg)/astep) + 1;
361 G4double ang = dphi/ksteps;
363 G4double sinHalf =
std::sin(0.5*ang);
364 G4double cosHalf =
std::cos(0.5*ang);
365 G4double sinStep = 2.*sinHalf*cosHalf;
366 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
367 G4double rext1 = rmax1/cosHalf;
368 G4double rext2 = rmax2/cosHalf;
372 if (rmin1 == 0 && rmin2 == 0 && dphi ==
twopi)
374 G4double sinCur = sinHalf;
375 G4double cosCur = cosHalf;
377 G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
378 for (G4int
k=0;
k<NSTEPS; ++
k)
380 baseA[
k].set(rext1*cosCur,rext1*sinCur, z1);
381 baseB[
k].set(rext2*cosCur,rext2*sinCur, z2);
383 G4double sinTmp = sinCur;
384 sinCur = sinCur*cosStep + cosCur*sinStep;
385 cosCur = cosCur*cosStep - sinTmp*sinStep;
387 std::vector<const G4ThreeVectorList *> polygons(2);
388 polygons[0] = &baseA;
389 polygons[1] = &baseB;
390 G4BoundingEnvelope benv(
bmin,
bmax,polygons);
391 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
400 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
401 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
404 G4ThreeVectorList pols[NSTEPS+2];
405 for (G4int
k=0;
k<ksteps+2; ++
k) pols[
k].resize(4);
406 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, z2);
407 pols[0][1].set(rmin1*cosStart,rmin1*sinStart, z1);
408 pols[0][2].set(rmax1*cosStart,rmax1*sinStart, z1);
409 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, z2);
410 for (G4int
k=1;
k<ksteps+1; ++
k)
412 pols[
k][0].set(rmin2*cosCur,rmin2*sinCur, z2);
413 pols[
k][1].set(rmin1*cosCur,rmin1*sinCur, z1);
414 pols[
k][2].set(rext1*cosCur,rext1*sinCur, z1);
415 pols[
k][3].set(rext2*cosCur,rext2*sinCur, z2);
417 G4double sinTmp = sinCur;
418 sinCur = sinCur*cosStep + cosCur*sinStep;
419 cosCur = cosCur*cosStep - sinTmp*sinStep;
421 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, z2);
422 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd, z1);
423 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd, z1);
424 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, z2);
427 std::vector<const G4ThreeVectorList *> polygons;
428 polygons.resize(ksteps+2);
429 for (G4int
k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
430 G4BoundingEnvelope benv(
bmin,
bmax,polygons);
431 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
444 G4int noSurfaces = 0;
446 G4double distZ, distRMin, distRMax;
448 G4double tanRMin, secRMin, pRMin, widRMin;
449 G4double tanRMax, secRMax, pRMax, widRMax;
451 G4ThreeVector
norm, sumnorm(0.,0.,0.), nZ = G4ThreeVector(0.,0.,1.);
452 G4ThreeVector nR, nr(0.,0.,0.), nPs, nPe;
456 distZ = std::fabs(std::fabs(
z) -
fDz);
457 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y());
460 secRMin = std::sqrt(1 + tanRMin*tanRMin);
461 pRMin =
rho -
z*tanRMin;
463 distRMin = std::fabs(pRMin - widRMin)/secRMin;
466 secRMax = std::sqrt(1+tanRMax*tanRMax);
467 pRMax =
rho -
z*tanRMax;
469 distRMax = std::fabs(pRMax - widRMax)/secRMax;
493 nR = G4ThreeVector(
p.x()/
rho/secRMax,
p.y()/
rho/secRMax, -tanRMax/secRMax);
496 nr = G4ThreeVector(-
p.x()/
rho/secRMin,-
p.y()/
rho/secRMin,tanRMin/secRMin);
526 if (
z >= 0.) { sumnorm += nZ; }
527 else { sumnorm -= nZ; }
529 if ( noSurfaces == 0 )
532 G4Exception(
"G4ShiftedCone::SurfaceNormal(p)",
"GeomSolids1002",
533 JustWarning,
"Point p is not on surface !?" );
537 else if ( noSurfaces == 1 ) {
norm = sumnorm; }
538 else {
norm = sumnorm.unit(); }
553 G4double distZ, distRMin, distRMax;
554 G4double tanRMin, secRMin, pRMin, widRMin ;
555 G4double tanRMax, secRMax, pRMax, widRMax ;
559 distZ = std::fabs(std::fabs(
z) -
fDz) ;
560 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
563 secRMin = std::sqrt(1 + tanRMin*tanRMin) ;
564 pRMin =
rho -
z*tanRMin ;
566 distRMin = std::fabs(pRMin - widRMin)/secRMin ;
569 secRMax = std::sqrt(1+tanRMax*tanRMax) ;
570 pRMax =
rho -
z*tanRMax ;
572 distRMax = std::fabs(pRMax - widRMax)/secRMax ;
574 if (distRMin < distRMax)
576 if (distZ < distRMin)
589 if (distZ < distRMax)
627 norm = G4ThreeVector(-
p.x()/
rho, -
p.y()/
rho, tanRMin/secRMin) ;
631 norm = G4ThreeVector(
p.x()/
rho,
p.y()/
rho, -tanRMax/secRMax) ;
634 if (
z > 0) {
norm = G4ThreeVector(0,0,1); }
635 else {
norm = G4ThreeVector(0,0,-1); }
645 G4Exception(
"G4ShiftedCone::ApproxSurfaceNormal()",
646 "GeomSolids1002", JustWarning,
647 "Undefined side for valid surface normal to solid.");
678 const G4ThreeVector&
v )
const
680 G4double snxt = kInfinity ;
683 G4double tanRMax,secRMax,rMaxAv;
684 G4double tanRMin,secRMin,rMinAv;
687 G4double tolORMin,tolIRMin,tolIRMin2 ;
688 G4double tolIRMax,tolIRMax2 ;
689 G4double tolODz,tolIDz ;
691 G4double
sd,xi,yi,zi,ri=0.,risec,rhoi2;
694 G4double nt1,nt2,nt3 ;
704 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
716 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
725 if (std::fabs(
z) >= tolIDz)
729 sd = (std::fabs(
z) -
fDz)/std::fabs(
v.z()) ;
731 if(
sd < 0.0 ) {
sd = 0.0; }
733 xi =
p.x() +
sd*
v.x() ;
734 yi =
p.y() +
sd*
v.y() ;
735 rhoi2 = xi*xi + yi*yi ;
759 tolIRMin2 = tolIRMin*tolIRMin ;
766 if ( tolIRMax > 0 ) { tolIRMax2 = tolIRMax*tolIRMax; }
767 else { tolIRMax2 = 0.0; }
769 if ( (tolIRMin2 <= rhoi2) && (rhoi2 <= tolIRMax2) )
810 t1 = 1.0 -
v.z()*
v.z() ;
811 t2 =
p.x()*
v.x() +
p.y()*
v.y() ;
812 t3 =
p.x()*
p.x() +
p.y()*
p.y() ;
813 rin = tanRMin*
z + rMinAv ;
814 rout = tanRMax*
z + rMaxAv ;
819 nt1 =
t1 - (tanRMax*
v.z())*(tanRMax*
v.z()) ;
820 nt2 =
t2 - tanRMax*
v.z()*rout ;
821 nt3 =
t3 - rout*rout ;
837 if ((rout < 0) && (nt3 <= 0))
842 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
843 else {
sd = -
b + std::sqrt(
d); }
847 if ((
b <= 0) && (
c >= 0))
849 sd=
c/(-
b+std::sqrt(
d));
855 sd = -
b + std::sqrt(
d) ;
873 if (std::fabs(zi) <= tolODz)
899 && (nt2 < 0) && (
d >= 0) && (std::fabs(
z) <= tolIDz) )
906 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
907 Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
918 if (
Normal.dot(
v) <= 0 ) {
return 0.0; }
929 if (
sd < 0 ) {
return kInfinity; }
934 if ((std::fabs(zi) <= tolODz) && (nt2 < 0))
968 nt1 =
t1 - (tanRMin*
v.z())*(tanRMin*
v.z()) ;
969 nt2 =
t2 - tanRMin*
v.z()*rin ;
984 if(
b>0){
sd =
c/( -
b-std::sqrt(
d));}
985 else {
sd = -
b + std::sqrt(
d) ;}
996 if ( std::fabs(zi) <= tolODz )
1025 xi =
p.x() +
sd*
v.x() ;
1026 yi =
p.y() +
sd*
v.y() ;
1027 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1028 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1029 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1049 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1050 else {
sd = -
b + std::sqrt(
d); }
1052 ri = rMinAv + zi*tanRMin ;
1056 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1060 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1089 xi =
p.x() +
sd*
v.x() ;
1090 yi =
p.y() +
sd*
v.y() ;
1091 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1092 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1093 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1100 if (
b>0) {
sd = -
b - std::sqrt(
d); }
1101 else {
sd =
c/(-
b+std::sqrt(
d)); }
1103 ri = rMinAv + zi*tanRMin ;
1105 if ( (
sd >= 0) && (ri > 0) && (std::fabs(zi) <= tolODz) )
1109 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1138 xi =
p.x() +
sd*
v.x() ;
1139 yi =
p.y() +
sd*
v.y() ;
1140 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1141 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1142 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1156 if ( std::fabs(
z) <= tolODz )
1181 if (
b>0) {
sd = -
b - std::sqrt(
d); }
1182 else {
sd =
c/(-
b+std::sqrt(
d)); }
1184 ri = rMinAv + zi*tanRMin ;
1188 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1189 else {
sd = -
b + std::sqrt(
d); }
1193 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1197 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1212 else {
return kInfinity; }
1224 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1225 else {
sd = -
b + std::sqrt(
d) ; }
1228 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1232 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1352 G4double safe=0.0,
rho, safeR1, safeR2, safeZ;
1353 G4double tanRMin, secRMin, pRMin ;
1354 G4double tanRMax, secRMax, pRMax ;
1358 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
1359 safeZ = std::fabs(
z) -
fDz ;
1364 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1366 safeR1 = (pRMin -
rho)/secRMin ;
1369 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1371 safeR2 = (
rho - pRMax)/secRMax ;
1373 if ( safeR1 > safeR2) { safe = safeR1; }
1374 else { safe = safeR2; }
1379 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1381 safe = (
rho - pRMax)/secRMax ;
1383 if ( safeZ > safe ) { safe = safeZ; }
1404 if ( safe < 0.0 ) { safe = 0.0; }
1415 const G4ThreeVector&
v,
1416 const G4bool calcNorm,
1418 G4ThreeVector *
n)
const
1422 G4double snxt,srd,pdist ;
1424 G4double tanRMax, secRMax, rMaxAv ;
1425 G4double tanRMin, secRMin, rMinAv ;
1427 G4double
t1,
t2,
t3, rout, rin, nt1, nt2, nt3 ;
1428 G4double
b,
c,
d, sr2, sr3 ;
1433 G4double slentol = kInfinity ;
1438 G4double zi, ri, deltaRoi2, xi, yi, risec ;
1450 snxt = pdist/
v.z() ;
1457 *
n = G4ThreeVector(0,0,1) ;
1463 else if (
v.z() < 0.0 )
1469 snxt = -pdist/
v.z() ;
1476 *
n = G4ThreeVector(0,0,-1) ;
1506 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1510 t1 = 1.0 -
v.z()*
v.z() ;
1511 t2 =
p.x()*
v.x() +
p.y()*
v.y() ;
1512 t3 =
p.x()*
p.x() +
p.y()*
p.y() ;
1513 rout = tanRMax*
z + rMaxAv ;
1515 nt1 =
t1 - (tanRMax*
v.z())*(tanRMax*
v.z()) ;
1516 nt2 =
t2 - tanRMax*
v.z()*rout ;
1517 nt3 =
t3 - rout*rout ;
1521 deltaRoi2 = snxt*snxt*
t1 + 2*snxt*
t2 +
t3
1524 else if (
v.z() < 0.0 )
1526 deltaRoi2 = snxt*snxt*
t1 + 2*snxt*
t2 +
t3
1534 if ( nt1 && (deltaRoi2 > 0.0) )
1551 risec = std::sqrt(
t3)*secRMax ;
1553 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1560 if (
b>0) { srd = -
b - std::sqrt(
d); }
1561 else { srd =
c/(-
b+std::sqrt(
d)) ; }
1563 zi =
z + srd*
v.z() ;
1564 ri = tanRMax*zi + rMaxAv ;
1579 if (
b>0) { sr2 =
c/(-
b-std::sqrt(
d)); }
1580 else { sr2 = -
b + std::sqrt(
d); }
1581 zi =
z + sr2*
v.z() ;
1582 ri = tanRMax*zi + rMaxAv ;
1611 risec = std::sqrt(
t3)*secRMax;
1613 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1618 else if ( nt2 && (deltaRoi2 > 0.0) )
1624 risec = std::sqrt(
t3)*secRMax;
1626 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1651 xi =
p.x() + slentol*
v.x();
1652 yi =
p.y() + slentol*
v.y();
1653 risec = std::sqrt(xi*xi + yi*yi)*secRMax;
1654 G4ThreeVector
Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax);
1667 slentol = kInfinity ;
1676 nt1 =
t1 - (tanRMin*
v.z())*(tanRMin*
v.z()) ;
1680 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1682 rin = tanRMin*
z + rMinAv ;
1683 nt2 =
t2 - tanRMin*
v.z()*rin ;
1684 nt3 =
t3 - rin*rin ;
1701 if (calcNorm) { *validNorm =
false; }
1707 if (
b>0) { sr2 = -
b - std::sqrt(
d); }
1708 else { sr2 =
c/(-
b+std::sqrt(
d)); }
1709 zi =
z + sr2*
v.z() ;
1710 ri = tanRMin*zi + rMinAv ;
1722 if (
b>0) { sr3 =
c/(-
b-std::sqrt(
d)); }
1723 else { sr3 = -
b + std::sqrt(
d) ; }
1732 zi =
z + sr3*
v.z() ;
1733 ri = tanRMin*zi + rMinAv ;
1771 xi =
p.x() + slentol*
v.x() ;
1772 yi =
p.y() + slentol*
v.y() ;
1773 if( sidetol==
kRMax )
1775 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1776 Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
1780 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1781 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1799 slentol = kInfinity ;
1962 xi =
p.x() + snxt*
v.x() ;
1963 yi =
p.y() + snxt*
v.y() ;
1964 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1965 *
n = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
1969 *validNorm = false ;
1994 *
n = G4ThreeVector(0,0,1) ;
1998 *
n = G4ThreeVector(0,0,-1) ;
2005 G4int oldprc =
message.precision(16) ;
2006 message <<
"Undefined side for valid surface normal to solid."
2008 <<
"Position:" << G4endl << G4endl
2009 <<
"p.x() = " <<
p.x()/
mm <<
" mm" << G4endl
2010 <<
"p.y() = " <<
p.y()/
mm <<
" mm" << G4endl
2011 <<
"p.z() = " <<
p.z()/
mm <<
" mm" << G4endl << G4endl
2012 <<
"pho at z = " << std::sqrt(
p.x()*
p.x()+
p.y()*
p.y() )/
mm
2013 <<
" mm" << G4endl << G4endl ;
2014 if(
p.x() != 0. ||
p.y() != 0.)
2017 <<
" degree" << G4endl << G4endl ;
2019 message <<
"Direction:" << G4endl << G4endl
2020 <<
"v.x() = " <<
v.x() << G4endl
2021 <<
"v.y() = " <<
v.y() << G4endl
2022 <<
"v.z() = " <<
v.z() << G4endl<< G4endl
2023 <<
"Proposed distance :" << G4endl<< G4endl
2024 <<
"snxt = " << snxt/
mm <<
" mm" << G4endl ;
2026 G4Exception(
"G4ShiftedCone::DistanceToOut(p,v,..)",
"GeomSolids1002",
2042 G4double safe=0.0,
rho, safeR1, safeR2, safeZ;
2043 G4double tanRMin, secRMin, pRMin;
2044 G4double tanRMax, secRMax, pRMax;
2049 G4int oldprc=G4cout.precision(16) ;
2052 G4cout <<
"Position:" << G4endl << G4endl ;
2053 G4cout <<
"p.x() = " <<
p.x()/
mm <<
" mm" << G4endl ;
2054 G4cout <<
"p.y() = " <<
p.y()/
mm <<
" mm" << G4endl ;
2055 G4cout <<
"p.z() = " <<
p.z()/
mm <<
" mm" << G4endl << G4endl ;
2056 G4cout <<
"pho at z = " << std::sqrt(
p.x()*
p.x()+
p.y()*
p.y() )/
mm
2057 <<
" mm" << G4endl << G4endl ;
2058 if( (
p.x() != 0.) || (
p.x() != 0.) )
2060 G4cout <<
"point phi = " << std::atan2(
p.y(),
p.x())/
degree
2061 <<
" degree" << G4endl << G4endl ;
2063 G4cout.precision(oldprc) ;
2064 G4Exception(
"G4ShiftedCone::DistanceToOut(p)",
"GeomSolids1002",
2065 JustWarning,
"Point p is outside !?" );
2071 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
2072 safeZ =
fDz - std::fabs(
z) ;
2077 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
2079 safeR1 = (
rho - pRMin)/secRMin ;
2083 safeR1 = kInfinity ;
2087 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
2089 safeR2 = (pRMax -
rho)/secRMax ;
2091 if (safeR1 < safeR2) { safe = safeR1; }
2092 else { safe = safeR2; }
2093 if (safeZ < safe) { safe = safeZ ; }
2111 if ( safe < 0 ) { safe = 0; }
2122 return G4String(
"G4ShiftedCone");
2140 G4int oldprc =
os.precision(16);
2141 os <<
"-----------------------------------------------------------\n"
2142 <<
" *** Dump for solid - " << GetName() <<
" ***\n"
2143 <<
" ===================================================\n"
2144 <<
" Solid type: G4ShiftedCone\n"
2145 <<
" Parameters: \n"
2146 <<
" inside -fDz radius: " <<
fRmin1/
mm <<
" mm \n"
2147 <<
" outside -fDz radius: " <<
fRmax1/
mm <<
" mm \n"
2148 <<
" inside +fDz radius: " <<
fRmin2/
mm <<
" mm \n"
2149 <<
" outside +fDz radius: " <<
fRmax2/
mm <<
" mm \n"
2150 <<
" Z1 : " <<
GetZ1()/
mm <<
" mm \n"
2151 <<
" Z2 : " <<
GetZ2()/
mm <<
" mm \n"
2154 <<
"-----------------------------------------------------------\n";
2155 os.precision(oldprc);
2189 G4bool fPhiFullCone =
true;
2191 G4double chose = G4RandFlat::shoot(0.,Aone+Atwo+Athree+Afour+2.*Afive);
2193 if( (chose >= 0.) && (chose < Aone) )
2197 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2198 return G4ThreeVector (rone*cosu*(qone-zRand),
2199 rone*sinu*(qone-zRand), zRand +
fZshift);
2207 else if( (chose >= Aone) && (chose < Aone + Atwo) )
2211 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2212 return G4ThreeVector (rtwo*cosu*(qtwo-zRand),
2213 rtwo*sinu*(qtwo-zRand), zRand +
fZshift);
2221 else if( (chose >= Aone + Atwo) && (chose < Aone + Atwo + Athree) )
2223 return G4ThreeVector (rRand1*cosu, rRand1*sinu, -1*
fDz +
fZshift);
2225 else if( (chose >= Aone + Atwo + Athree)
2226 && (chose < Aone + Atwo + Athree + Afour) )
2228 return G4ThreeVector (rRand2*cosu,rRand2*sinu,
fDz +
fZshift);
2230 else if( (chose >= Aone + Atwo + Athree + Afour)
2231 && (chose < Aone + Atwo + Athree + Afour + Afive) )
2233 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2241 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2255 scene.AddSolid (*
this);
2263 return new G4PolyhedronPcon(