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;
71 enum ESide {kNull,kRMin,kRMax,kSPhi,kEPhi,kPZ,kMZ};
74 enum ENorm {kNRMin,kNRMax,kNSPhi,kNEPhi,kNZ};
83 G4double pZ1, G4double pZ2,
84 G4double pRmin1, G4double pRmax1,
85 G4double pRmin2, G4double pRmax2)
89 kRadTolerance (G4GeometryTolerance::GetInstance()->GetRadialTolerance()),
90 kAngTolerance (G4GeometryTolerance::GetInstance()->GetAngularTolerance()),
91 fRmin1(pRmin1), fRmin2(pRmin2),
92 fRmax1(pRmax1), fRmax2(pRmax2),
93 fDz((pZ2 - pZ1) * 0.5), fZshift(pZ1 + fDz),
95 halfCarTolerance (kCarTolerance*0.5),
96 halfRadTolerance (kRadTolerance*0.5),
97 halfAngTolerance (kAngTolerance*0.5)
104 message <<
"Invalid Z half-length for Solid: " << GetName() << G4endl
106 G4Exception(
"G4ShiftedCone::G4ShiftedCone()",
"GeomSolids0002",
112 if (((pRmin1>=pRmax1) || (pRmin2>=pRmax2) || (pRmin1<0)) && (pRmin2<0))
115 message <<
"Invalid values of radii for Solid: " << GetName() << G4endl
116 <<
" pRmin1 = " << pRmin1 <<
", pRmin2 = " << pRmin2
117 <<
", pRmax1 = " << pRmax1 <<
", pRmax2 = " << pRmax2;
118 G4Exception(
"G4ShiftedCone::G4ShiftedCone()",
"GeomSolids0002",
135 : G4CSGSolid(
a), kRadTolerance(0.), kAngTolerance(0.),
136 fRmin1(0.), fRmin2(0.), fRmax1(0.), fRmax2(0.),
137 fDz(0.), fZshift(0.),
141 halfCarTolerance(0.), halfRadTolerance(0.), halfAngTolerance(0.)
158 : G4CSGSolid(rhs), kRadTolerance(rhs.kRadTolerance),
159 kAngTolerance(rhs.kAngTolerance), fRmin1(rhs.fRmin1), fRmin2(rhs.fRmin2),
160 fRmax1(rhs.fRmax1), fRmax2(rhs.fRmax2), fDz(rhs.fDz), fZshift(rhs.fZshift),
166 halfCarTolerance(rhs.halfCarTolerance),
167 halfRadTolerance(rhs.halfRadTolerance),
168 halfAngTolerance(rhs.halfAngTolerance)
180 if (
this == &rhs) {
return *
this; }
212 G4double r2,
rl, rh, tolRMin, tolRMax;
219 else { in = kInside; }
221 r2 =
p.x()*
p.x() +
p.y()*
p.y() ;
228 if ( tolRMin < 0 ) { tolRMin = 0; }
231 if ( (r2<tolRMin*tolRMin) || (r2>tolRMax*tolRMax) ) {
return in = kOutside; }
234 else { tolRMin = 0.0; }
239 if ( (r2 < tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax) ) { in = kSurface; }
270 const G4VPhysicalVolume* )
273 message <<
"ComputeDimensions is not implemented for Solid: " << GetName();
274 G4Exception(
"G4ShiftedCone::ComputeDimensions()",
"GeomSolids0002",
309 if (pMin.x() >= pMax.x() || pMin.y() >= pMax.y() || pMin.z() >= pMax.z())
312 message <<
"Bad bounding box (min >= max) for solid: "
314 <<
"\npMin = " << pMin
315 <<
"\npMax = " << pMax;
316 G4Exception(
"G4ShiftedCone::BoundingLimits()",
"GeomMgt0001",
327 const G4VoxelLimits& pVoxelLimit,
328 const G4AffineTransform& pTransform,
330 G4double& pMax )
const
341 if (
true)
return bbox.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
343 if (bbox.BoundingBoxVsVoxelLimits(pAxis,pVoxelLimit,pTransform,pMin,pMax))
345 return exist = (pMin < pMax) ?
true :
false;
353 G4double z1 =
GetZ1();
354 G4double z2 =
GetZ2();
359 const G4int NSTEPS = 24;
360 G4double astep =
twopi/NSTEPS;
361 G4int ksteps = (dphi <= astep) ? 1 : (G4int)((dphi-
deg)/astep) + 1;
362 G4double ang = dphi/ksteps;
364 G4double sinHalf =
std::sin(0.5*ang);
365 G4double cosHalf =
std::cos(0.5*ang);
366 G4double sinStep = 2.*sinHalf*cosHalf;
367 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
368 G4double rext1 = rmax1/cosHalf;
369 G4double rext2 = rmax2/cosHalf;
373 if (rmin1 == 0 && rmin2 == 0 && dphi ==
twopi)
375 G4double sinCur = sinHalf;
376 G4double cosCur = cosHalf;
378 G4ThreeVectorList baseA(NSTEPS),baseB(NSTEPS);
379 for (G4int
k=0;
k<NSTEPS; ++
k)
381 baseA[
k].set(rext1*cosCur,rext1*sinCur, z1);
382 baseB[
k].set(rext2*cosCur,rext2*sinCur, z2);
384 G4double sinTmp = sinCur;
385 sinCur = sinCur*cosStep + cosCur*sinStep;
386 cosCur = cosCur*cosStep - sinTmp*sinStep;
388 std::vector<const G4ThreeVectorList *> polygons(2);
389 polygons[0] = &baseA;
390 polygons[1] = &baseB;
391 G4BoundingEnvelope benv(
bmin,
bmax,polygons);
392 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
401 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
402 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
405 G4ThreeVectorList pols[NSTEPS+2];
406 for (G4int
k=0;
k<ksteps+2; ++
k) pols[
k].resize(4);
407 pols[0][0].set(rmin2*cosStart,rmin2*sinStart, z2);
408 pols[0][1].set(rmin1*cosStart,rmin1*sinStart, z1);
409 pols[0][2].set(rmax1*cosStart,rmax1*sinStart, z1);
410 pols[0][3].set(rmax2*cosStart,rmax2*sinStart, z2);
411 for (G4int
k=1;
k<ksteps+1; ++
k)
413 pols[
k][0].set(rmin2*cosCur,rmin2*sinCur, z2);
414 pols[
k][1].set(rmin1*cosCur,rmin1*sinCur, z1);
415 pols[
k][2].set(rext1*cosCur,rext1*sinCur, z1);
416 pols[
k][3].set(rext2*cosCur,rext2*sinCur, z2);
418 G4double sinTmp = sinCur;
419 sinCur = sinCur*cosStep + cosCur*sinStep;
420 cosCur = cosCur*cosStep - sinTmp*sinStep;
422 pols[ksteps+1][0].set(rmin2*cosEnd,rmin2*sinEnd, z2);
423 pols[ksteps+1][1].set(rmin1*cosEnd,rmin1*sinEnd, z1);
424 pols[ksteps+1][2].set(rmax1*cosEnd,rmax1*sinEnd, z1);
425 pols[ksteps+1][3].set(rmax2*cosEnd,rmax2*sinEnd, z2);
428 std::vector<const G4ThreeVectorList *> polygons;
429 polygons.resize(ksteps+2);
430 for (G4int
k=0;
k<ksteps+2; ++
k) polygons[
k] = &pols[
k];
431 G4BoundingEnvelope benv(
bmin,
bmax,polygons);
432 exist = benv.CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
445 G4int noSurfaces = 0;
447 G4double distZ, distRMin, distRMax;
449 G4double tanRMin, secRMin, pRMin, widRMin;
450 G4double tanRMax, secRMax, pRMax, widRMax;
452 G4ThreeVector
norm, sumnorm(0.,0.,0.), nZ = G4ThreeVector(0.,0.,1.);
453 G4ThreeVector nR, nr(0.,0.,0.), nPs, nPe;
457 distZ = std::fabs(std::fabs(
z) -
fDz);
458 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y());
461 secRMin = std::sqrt(1 + tanRMin*tanRMin);
462 pRMin =
rho -
z*tanRMin;
464 distRMin = std::fabs(pRMin - widRMin)/secRMin;
467 secRMax = std::sqrt(1+tanRMax*tanRMax);
468 pRMax =
rho -
z*tanRMax;
470 distRMax = std::fabs(pRMax - widRMax)/secRMax;
494 nR = G4ThreeVector(
p.x()/
rho/secRMax,
p.y()/
rho/secRMax, -tanRMax/secRMax);
497 nr = G4ThreeVector(-
p.x()/
rho/secRMin,-
p.y()/
rho/secRMin,tanRMin/secRMin);
527 if (
z >= 0.) { sumnorm += nZ; }
528 else { sumnorm -= nZ; }
530 if ( noSurfaces == 0 )
533 G4Exception(
"G4ShiftedCone::SurfaceNormal(p)",
"GeomSolids1002",
534 JustWarning,
"Point p is not on surface !?" );
538 else if ( noSurfaces == 1 ) {
norm = sumnorm; }
539 else {
norm = sumnorm.unit(); }
554 G4double distZ, distRMin, distRMax;
555 G4double tanRMin, secRMin, pRMin, widRMin ;
556 G4double tanRMax, secRMax, pRMax, widRMax ;
560 distZ = std::fabs(std::fabs(
z) -
fDz) ;
561 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
564 secRMin = std::sqrt(1 + tanRMin*tanRMin) ;
565 pRMin =
rho -
z*tanRMin ;
567 distRMin = std::fabs(pRMin - widRMin)/secRMin ;
570 secRMax = std::sqrt(1+tanRMax*tanRMax) ;
571 pRMax =
rho -
z*tanRMax ;
573 distRMax = std::fabs(pRMax - widRMax)/secRMax ;
575 if (distRMin < distRMax)
577 if (distZ < distRMin)
590 if (distZ < distRMax)
628 norm = G4ThreeVector(-
p.x()/
rho, -
p.y()/
rho, tanRMin/secRMin) ;
632 norm = G4ThreeVector(
p.x()/
rho,
p.y()/
rho, -tanRMax/secRMax) ;
635 if (
z > 0) {
norm = G4ThreeVector(0,0,1); }
636 else {
norm = G4ThreeVector(0,0,-1); }
646 G4Exception(
"G4ShiftedCone::ApproxSurfaceNormal()",
647 "GeomSolids1002", JustWarning,
648 "Undefined side for valid surface normal to solid.");
679 const G4ThreeVector&
v )
const
681 G4double snxt = kInfinity ;
684 G4double tanRMax,secRMax,rMaxAv;
685 G4double tanRMin,secRMin,rMinAv;
688 G4double tolORMin,tolIRMin,tolIRMin2 ;
689 G4double tolIRMax,tolIRMax2 ;
690 G4double tolODz,tolIDz ;
692 G4double
sd,xi,yi,zi,ri=0.,risec,rhoi2;
695 G4double nt1,nt2,nt3 ;
705 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
717 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
726 if (std::fabs(
z) >= tolIDz)
730 sd = (std::fabs(
z) -
fDz)/std::fabs(
v.z()) ;
732 if(
sd < 0.0 ) {
sd = 0.0; }
734 xi =
p.x() +
sd*
v.x() ;
735 yi =
p.y() +
sd*
v.y() ;
736 rhoi2 = xi*xi + yi*yi ;
760 tolIRMin2 = tolIRMin*tolIRMin ;
767 if ( tolIRMax > 0 ) { tolIRMax2 = tolIRMax*tolIRMax; }
768 else { tolIRMax2 = 0.0; }
770 if ( (tolIRMin2 <= rhoi2) && (rhoi2 <= tolIRMax2) )
811 t1 = 1.0 -
v.z()*
v.z() ;
812 t2 =
p.x()*
v.x() +
p.y()*
v.y() ;
813 t3 =
p.x()*
p.x() +
p.y()*
p.y() ;
814 rin = tanRMin*
z + rMinAv ;
815 rout = tanRMax*
z + rMaxAv ;
820 nt1 =
t1 - (tanRMax*
v.z())*(tanRMax*
v.z()) ;
821 nt2 =
t2 - tanRMax*
v.z()*rout ;
822 nt3 =
t3 - rout*rout ;
838 if ((rout < 0) && (nt3 <= 0))
843 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
844 else {
sd = -
b + std::sqrt(
d); }
848 if ((
b <= 0) && (
c >= 0))
850 sd=
c/(-
b+std::sqrt(
d));
856 sd = -
b + std::sqrt(
d) ;
874 if (std::fabs(zi) <= tolODz)
900 && (nt2 < 0) && (
d >= 0) && (std::fabs(
z) <= tolIDz) )
907 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
908 Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
919 if (
Normal.dot(
v) <= 0 ) {
return 0.0; }
930 if (
sd < 0 ) {
return kInfinity; }
935 if ((std::fabs(zi) <= tolODz) && (nt2 < 0))
969 nt1 =
t1 - (tanRMin*
v.z())*(tanRMin*
v.z()) ;
970 nt2 =
t2 - tanRMin*
v.z()*rin ;
985 if(
b>0){
sd =
c/( -
b-std::sqrt(
d));}
986 else {
sd = -
b + std::sqrt(
d) ;}
997 if ( std::fabs(zi) <= tolODz )
1026 xi =
p.x() +
sd*
v.x() ;
1027 yi =
p.y() +
sd*
v.y() ;
1028 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1029 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1030 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1050 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1051 else {
sd = -
b + std::sqrt(
d); }
1053 ri = rMinAv + zi*tanRMin ;
1057 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1061 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1090 xi =
p.x() +
sd*
v.x() ;
1091 yi =
p.y() +
sd*
v.y() ;
1092 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1093 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1094 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1101 if (
b>0) {
sd = -
b - std::sqrt(
d); }
1102 else {
sd =
c/(-
b+std::sqrt(
d)); }
1104 ri = rMinAv + zi*tanRMin ;
1106 if ( (
sd >= 0) && (ri > 0) && (std::fabs(zi) <= tolODz) )
1110 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1139 xi =
p.x() +
sd*
v.x() ;
1140 yi =
p.y() +
sd*
v.y() ;
1141 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1142 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1143 if (
Normal.dot(
v) <= 0 ) {
return sd; }
1157 if ( std::fabs(
z) <= tolODz )
1182 if (
b>0) {
sd = -
b - std::sqrt(
d); }
1183 else {
sd =
c/(-
b+std::sqrt(
d)); }
1185 ri = rMinAv + zi*tanRMin ;
1189 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1190 else {
sd = -
b + std::sqrt(
d); }
1194 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1198 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1213 else {
return kInfinity; }
1225 if (
b>0) {
sd =
c/(-
b-std::sqrt(
d)); }
1226 else {
sd = -
b + std::sqrt(
d) ; }
1229 if ( (
sd >= 0) && (std::fabs(zi) <= tolODz) )
1233 G4double fTerm =
sd-std::fmod(
sd,
dRmax);
1353 G4double safe=0.0,
rho, safeR1, safeR2, safeZ;
1354 G4double tanRMin, secRMin, pRMin ;
1355 G4double tanRMax, secRMax, pRMax ;
1359 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
1360 safeZ = std::fabs(
z) -
fDz ;
1365 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1367 safeR1 = (pRMin -
rho)/secRMin ;
1370 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1372 safeR2 = (
rho - pRMax)/secRMax ;
1374 if ( safeR1 > safeR2) { safe = safeR1; }
1375 else { safe = safeR2; }
1380 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1382 safe = (
rho - pRMax)/secRMax ;
1384 if ( safeZ > safe ) { safe = safeZ; }
1405 if ( safe < 0.0 ) { safe = 0.0; }
1416 const G4ThreeVector&
v,
1417 const G4bool calcNorm,
1419 G4ThreeVector *
n)
const
1423 G4double snxt,srd,pdist ;
1425 G4double tanRMax, secRMax, rMaxAv ;
1426 G4double tanRMin, secRMin, rMinAv ;
1428 G4double
t1,
t2,
t3, rout, rin, nt1, nt2, nt3 ;
1429 G4double
b,
c,
d, sr2, sr3 ;
1434 G4double slentol = kInfinity ;
1439 G4double zi, ri, deltaRoi2, xi, yi, risec ;
1451 snxt = pdist/
v.z() ;
1458 *
n = G4ThreeVector(0,0,1) ;
1464 else if (
v.z() < 0.0 )
1470 snxt = -pdist/
v.z() ;
1477 *
n = G4ThreeVector(0,0,-1) ;
1507 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
1511 t1 = 1.0 -
v.z()*
v.z() ;
1512 t2 =
p.x()*
v.x() +
p.y()*
v.y() ;
1513 t3 =
p.x()*
p.x() +
p.y()*
p.y() ;
1514 rout = tanRMax*
z + rMaxAv ;
1516 nt1 =
t1 - (tanRMax*
v.z())*(tanRMax*
v.z()) ;
1517 nt2 =
t2 - tanRMax*
v.z()*rout ;
1518 nt3 =
t3 - rout*rout ;
1522 deltaRoi2 = snxt*snxt*
t1 + 2*snxt*
t2 +
t3
1525 else if (
v.z() < 0.0 )
1527 deltaRoi2 = snxt*snxt*
t1 + 2*snxt*
t2 +
t3
1535 if ( nt1 && (deltaRoi2 > 0.0) )
1552 risec = std::sqrt(
t3)*secRMax ;
1554 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1561 if (
b>0) { srd = -
b - std::sqrt(
d); }
1562 else { srd =
c/(-
b+std::sqrt(
d)) ; }
1564 zi =
z + srd*
v.z() ;
1565 ri = tanRMax*zi + rMaxAv ;
1580 if (
b>0) { sr2 =
c/(-
b-std::sqrt(
d)); }
1581 else { sr2 = -
b + std::sqrt(
d); }
1582 zi =
z + sr2*
v.z() ;
1583 ri = tanRMax*zi + rMaxAv ;
1612 risec = std::sqrt(
t3)*secRMax;
1614 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1619 else if ( nt2 && (deltaRoi2 > 0.0) )
1625 risec = std::sqrt(
t3)*secRMax;
1627 *
n = G4ThreeVector(
p.x()/risec,
p.y()/risec,-tanRMax/secRMax);
1652 xi =
p.x() + slentol*
v.x();
1653 yi =
p.y() + slentol*
v.y();
1654 risec = std::sqrt(xi*xi + yi*yi)*secRMax;
1655 G4ThreeVector
Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax);
1668 slentol = kInfinity ;
1677 nt1 =
t1 - (tanRMin*
v.z())*(tanRMin*
v.z()) ;
1681 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
1683 rin = tanRMin*
z + rMinAv ;
1684 nt2 =
t2 - tanRMin*
v.z()*rin ;
1685 nt3 =
t3 - rin*rin ;
1702 if (calcNorm) { *validNorm =
false; }
1708 if (
b>0) { sr2 = -
b - std::sqrt(
d); }
1709 else { sr2 =
c/(-
b+std::sqrt(
d)); }
1710 zi =
z + sr2*
v.z() ;
1711 ri = tanRMin*zi + rMinAv ;
1723 if (
b>0) { sr3 =
c/(-
b-std::sqrt(
d)); }
1724 else { sr3 = -
b + std::sqrt(
d) ; }
1733 zi =
z + sr3*
v.z() ;
1734 ri = tanRMin*zi + rMinAv ;
1772 xi =
p.x() + slentol*
v.x() ;
1773 yi =
p.y() + slentol*
v.y() ;
1774 if( sidetol==
kRMax )
1776 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1777 Normal = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
1781 risec = std::sqrt(xi*xi + yi*yi)*secRMin ;
1782 Normal = G4ThreeVector(-xi/risec,-yi/risec,tanRMin/secRMin) ;
1800 slentol = kInfinity ;
1963 xi =
p.x() + snxt*
v.x() ;
1964 yi =
p.y() + snxt*
v.y() ;
1965 risec = std::sqrt(xi*xi + yi*yi)*secRMax ;
1966 *
n = G4ThreeVector(xi/risec,yi/risec,-tanRMax/secRMax) ;
1970 *validNorm = false ;
1995 *
n = G4ThreeVector(0,0,1) ;
1999 *
n = G4ThreeVector(0,0,-1) ;
2006 G4int oldprc =
message.precision(16) ;
2007 message <<
"Undefined side for valid surface normal to solid."
2009 <<
"Position:" << G4endl << G4endl
2010 <<
"p.x() = " <<
p.x()/
mm <<
" mm" << G4endl
2011 <<
"p.y() = " <<
p.y()/
mm <<
" mm" << G4endl
2012 <<
"p.z() = " <<
p.z()/
mm <<
" mm" << G4endl << G4endl
2013 <<
"pho at z = " << std::sqrt(
p.x()*
p.x()+
p.y()*
p.y() )/
mm
2014 <<
" mm" << G4endl << G4endl ;
2015 if(
p.x() != 0. ||
p.y() != 0.)
2018 <<
" degree" << G4endl << G4endl ;
2020 message <<
"Direction:" << G4endl << G4endl
2021 <<
"v.x() = " <<
v.x() << G4endl
2022 <<
"v.y() = " <<
v.y() << G4endl
2023 <<
"v.z() = " <<
v.z() << G4endl<< G4endl
2024 <<
"Proposed distance :" << G4endl<< G4endl
2025 <<
"snxt = " << snxt/
mm <<
" mm" << G4endl ;
2027 G4Exception(
"G4ShiftedCone::DistanceToOut(p,v,..)",
"GeomSolids1002",
2043 G4double safe=0.0,
rho, safeR1, safeR2, safeZ;
2044 G4double tanRMin, secRMin, pRMin;
2045 G4double tanRMax, secRMax, pRMax;
2050 G4int oldprc=G4cout.precision(16) ;
2053 G4cout <<
"Position:" << G4endl << G4endl ;
2054 G4cout <<
"p.x() = " <<
p.x()/
mm <<
" mm" << G4endl ;
2055 G4cout <<
"p.y() = " <<
p.y()/
mm <<
" mm" << G4endl ;
2056 G4cout <<
"p.z() = " <<
p.z()/
mm <<
" mm" << G4endl << G4endl ;
2057 G4cout <<
"pho at z = " << std::sqrt(
p.x()*
p.x()+
p.y()*
p.y() )/
mm
2058 <<
" mm" << G4endl << G4endl ;
2059 if( (
p.x() != 0.) || (
p.x() != 0.) )
2061 G4cout <<
"point phi = " << std::atan2(
p.y(),
p.x())/
degree
2062 <<
" degree" << G4endl << G4endl ;
2064 G4cout.precision(oldprc) ;
2065 G4Exception(
"G4ShiftedCone::DistanceToOut(p)",
"GeomSolids1002",
2066 JustWarning,
"Point p is outside !?" );
2072 rho = std::sqrt(
p.x()*
p.x() +
p.y()*
p.y()) ;
2073 safeZ =
fDz - std::fabs(
z) ;
2078 secRMin = std::sqrt(1.0 + tanRMin*tanRMin) ;
2080 safeR1 = (
rho - pRMin)/secRMin ;
2084 safeR1 = kInfinity ;
2088 secRMax = std::sqrt(1.0 + tanRMax*tanRMax) ;
2090 safeR2 = (pRMax -
rho)/secRMax ;
2092 if (safeR1 < safeR2) { safe = safeR1; }
2093 else { safe = safeR2; }
2094 if (safeZ < safe) { safe = safeZ ; }
2112 if ( safe < 0 ) { safe = 0; }
2123 return G4String(
"G4ShiftedCone");
2141 G4int oldprc =
os.precision(16);
2142 os <<
"-----------------------------------------------------------\n"
2143 <<
" *** Dump for solid - " << GetName() <<
" ***\n"
2144 <<
" ===================================================\n"
2145 <<
" Solid type: G4ShiftedCone\n"
2146 <<
" Parameters: \n"
2147 <<
" inside -fDz radius: " <<
fRmin1/
mm <<
" mm \n"
2148 <<
" outside -fDz radius: " <<
fRmax1/
mm <<
" mm \n"
2149 <<
" inside +fDz radius: " <<
fRmin2/
mm <<
" mm \n"
2150 <<
" outside +fDz radius: " <<
fRmax2/
mm <<
" mm \n"
2151 <<
" Z1 : " <<
GetZ1()/
mm <<
" mm \n"
2152 <<
" Z2 : " <<
GetZ2()/
mm <<
" mm \n"
2155 <<
"-----------------------------------------------------------\n";
2156 os.precision(oldprc);
2190 G4bool fPhiFullCone =
true;
2192 G4double chose = G4RandFlat::shoot(0.,Aone+Atwo+Athree+Afour+2.*Afive);
2194 if( (chose >= 0.) && (chose < Aone) )
2198 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2199 return G4ThreeVector (rone*cosu*(qone-zRand),
2200 rone*sinu*(qone-zRand), zRand +
fZshift);
2208 else if( (chose >= Aone) && (chose < Aone + Atwo) )
2212 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2213 return G4ThreeVector (rtwo*cosu*(qtwo-zRand),
2214 rtwo*sinu*(qtwo-zRand), zRand +
fZshift);
2222 else if( (chose >= Aone + Atwo) && (chose < Aone + Atwo + Athree) )
2224 return G4ThreeVector (rRand1*cosu, rRand1*sinu, -1*
fDz +
fZshift);
2226 else if( (chose >= Aone + Atwo + Athree)
2227 && (chose < Aone + Atwo + Athree + Afour) )
2229 return G4ThreeVector (rRand2*cosu,rRand2*sinu,
fDz +
fZshift);
2231 else if( (chose >= Aone + Atwo + Athree + Afour)
2232 && (chose < Aone + Atwo + Athree + Afour + Afive) )
2234 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2242 G4double zRand = G4RandFlat::shoot(-1.*
fDz,
fDz);
2256 scene.AddSolid (*
this);
2264 return new G4PolyhedronPcon(