58 using namespace CLHEP;
70 :
G4OTubs(pName, pRMin, pRMax, pDz, pSPhi, pDPhi),
83 if(pDPhi<
twopi) { fPhiFullCutTube=
false; }
85 if ( ( !pLowNorm.
x()) && ( !pLowNorm.
y())
86 && ( !pHighNorm.
x()) && (!pHighNorm.
y()) )
88 std::ostringstream message;
89 message <<
"Inexisting Low/High Normal to Z plane or Parallel to Z."
91 <<
"Normals to Z plane are (" << pLowNorm <<
" and "
92 << pHighNorm <<
") in solid: " <<
GetName();
93 G4Exception(
"G4CutTubs::G4CutTubs()",
"GeomSolids1001",
99 if (pLowNorm.
mag2() == 0.) { pLowNorm.
setZ(-1.); }
100 if (pHighNorm.
mag2()== 0.) { pHighNorm.
setZ(1.); }
105 if (pLowNorm.
mag2() != 1.) { pLowNorm = pLowNorm.
unit(); }
106 if (pHighNorm.
mag2()!= 1.) { pHighNorm = pHighNorm.
unit(); }
110 if( (pLowNorm.
mag2() != 0.) && (pHighNorm.
mag2()!= 0. ) )
112 if( ( pLowNorm.
z()>= 0. ) || ( pHighNorm.
z() <= 0.))
114 std::ostringstream message;
115 message <<
"Invalid Low or High Normal to Z plane; "
116 "has to point outside Solid." <<
G4endl
117 <<
"Invalid Norm to Z plane (" << pLowNorm <<
" or "
118 << pHighNorm <<
") in solid: " <<
GetName();
119 G4Exception(
"G4CutTubs::G4CutTubs()",
"GeomSolids0002",
124 fHighNorm = pHighNorm;
151 halfCarTolerance(0.), halfRadTolerance(0.), halfAngTolerance(0.)
168 :
G4OTubs(rhs), fLowNorm(rhs.fLowNorm), fHighNorm(rhs.fHighNorm),
169 fPhiFullCutTube(rhs.fPhiFullCutTube),
170 halfCarTolerance(rhs.halfCarTolerance),
171 halfRadTolerance(rhs.halfRadTolerance),
172 halfAngTolerance(rhs.halfAngTolerance)
184 if (
this == &rhs) {
return *
this; }
192 fLowNorm = rhs.fLowNorm; fHighNorm = rhs.fHighNorm;
193 fPhiFullCutTube = rhs.fPhiFullCutTube;
194 halfCarTolerance = rhs.halfCarTolerance;
195 halfRadTolerance = rhs.halfRadTolerance;
196 halfAngTolerance = rhs.halfAngTolerance;
216 xynorm = std::sqrt(norm.
x()*norm.
x()+norm.
y()*norm.
y());
217 znorm = std::abs(norm.
z());
218 G4double zmin = -(dz + rmax*xynorm/znorm);
222 xynorm = std::sqrt(norm.
x()*norm.
x()+norm.
y()*norm.
y());
223 znorm = std::abs(norm.
z());
224 G4double zmax = dz + rmax*xynorm/znorm;
235 pMin.
set(vmin.
x(),vmin.
y(), zmin);
236 pMax.
set(vmax.
x(),vmax.
y(), zmax);
240 pMin.
set(-rmax,-rmax, zmin);
241 pMax.
set( rmax, rmax, zmax);
246 if (pMin.
x() >= pMax.
x() || pMin.
y() >= pMax.
y() || pMin.
z() >= pMax.
z())
248 std::ostringstream message;
249 message <<
"Bad bounding box (min >= max) for solid: "
251 <<
"\npMin = " << pMin
252 <<
"\npMax = " << pMax;
277 if (
true)
return bbox.
CalculateExtent(pAxis,pVoxelLimit,pTransform,pMin,pMax);
281 return exist = (pMin < pMax) ?
true :
false;
293 const G4int NSTEPS = 24;
298 G4double sinHalf = std::sin(0.5*ang);
299 G4double cosHalf = std::cos(0.5*ang);
300 G4double sinStep = 2.*sinHalf*cosHalf;
301 G4double cosStep = 1. - 2.*sinHalf*sinHalf;
306 if (rmin == 0 && dphi ==
twopi)
312 for (
G4int k=0; k<NSTEPS; ++k)
314 baseA[k].set(rext*cosCur,rext*sinCur,zmin);
315 baseB[k].set(rext*cosCur,rext*sinCur,zmax);
318 sinCur = sinCur*cosStep + cosCur*sinStep;
319 cosCur = cosCur*cosStep - sinTmp*sinStep;
321 std::vector<const G4ThreeVectorList *> polygons(2);
322 polygons[0] = &baseA;
323 polygons[1] = &baseB;
333 G4double sinCur = sinStart*cosHalf + cosStart*sinHalf;
334 G4double cosCur = cosStart*cosHalf - sinStart*sinHalf;
338 for (
G4int k=0; k<ksteps+2; ++k) pols[k].resize(4);
339 pols[0][0].set(rmin*cosStart,rmin*sinStart,zmax);
340 pols[0][1].set(rmin*cosStart,rmin*sinStart,zmin);
341 pols[0][2].set(rmax*cosStart,rmax*sinStart,zmin);
342 pols[0][3].set(rmax*cosStart,rmax*sinStart,zmax);
343 for (
G4int k=1; k<ksteps+1; ++k)
345 pols[k][0].set(rmin*cosCur,rmin*sinCur,zmax);
346 pols[k][1].set(rmin*cosCur,rmin*sinCur,zmin);
347 pols[k][2].set(rext*cosCur,rext*sinCur,zmin);
348 pols[k][3].set(rext*cosCur,rext*sinCur,zmax);
351 sinCur = sinCur*cosStep + cosCur*sinStep;
352 cosCur = cosCur*cosStep - sinTmp*sinStep;
354 pols[ksteps+1][0].set(rmin*cosEnd,rmin*sinEnd,zmax);
355 pols[ksteps+1][1].set(rmin*cosEnd,rmin*sinEnd,zmin);
356 pols[ksteps+1][2].set(rmax*cosEnd,rmax*sinEnd,zmin);
357 pols[ksteps+1][3].set(rmax*cosEnd,rmax*sinEnd,zmax);
360 std::vector<const G4ThreeVectorList *> polygons;
361 polygons.resize(ksteps+2);
362 for (
G4int k=0; k<ksteps+2; ++k) polygons[k] = &pols[k];
380 G4double zinLow =(p+vZ).dot(fLowNorm);
381 if (zinLow > halfCarTolerance) {
return kOutside; }
385 G4double zinHigh = (p-vZ).dot(fHighNorm);
386 if (zinHigh > halfCarTolerance) {
return kOutside; }
394 if ( tolRMin < 0 ) { tolRMin = 0; }
396 if (r2 < tolRMin*tolRMin || r2 > tolRMax*tolRMax) {
return kOutside; }
402 if ((tolRMin == 0) && (std::fabs(p.
x()) <= halfCarTolerance)
403 && (std::fabs(p.
y()) <= halfCarTolerance))
415 if ((phi0 >= sphi && phi0 <= ephi) ||
416 (phi1 >= sphi && phi1 <= ephi) ||
417 (phi2 >= sphi && phi2 <= ephi)) in =
kSurface;
422 if ((phi0 >= sphi && phi0 <= ephi) ||
423 (phi1 >= sphi && phi1 <= ephi) ||
424 (phi2 >= sphi && phi2 <= ephi)) in =
kInside;
430 if ((zinLow >= -halfCarTolerance) || (zinHigh >= -halfCarTolerance))
437 if (
fRMin) { tolRMin =
fRMin + halfRadTolerance; }
438 else { tolRMin = 0; }
439 tolRMax =
fRMax - halfRadTolerance;
440 if (((r2 <= tolRMin*tolRMin) || (r2 >= tolRMax*tolRMax)) &&
441 (r2 >= halfRadTolerance*halfRadTolerance))
457 G4int noSurfaces = 0;
459 G4double distZLow,distZHigh, distRMin, distRMax;
467 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y());
469 distRMin = std::fabs(rho -
fRMin);
470 distRMax = std::fabs(rho -
fRMax);
474 distZLow =std::fabs((p+vZ).dot(fLowNorm));
478 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
480 if (!fPhiFullCutTube)
482 if ( rho > halfCarTolerance )
484 pPhi = std::atan2(p.
y(),p.
x());
486 if(pPhi <
fSPhi- halfCarTolerance) { pPhi +=
twopi; }
489 distSPhi = std::fabs(pPhi -
fSPhi);
500 if ( rho > halfCarTolerance ) { nR =
G4ThreeVector(p.
x()/rho,p.
y()/rho,0); }
502 if( distRMax <= halfCarTolerance )
507 if(
fRMin && (distRMin <= halfCarTolerance) )
514 if (distSPhi <= halfAngTolerance)
519 if (distEPhi <= halfAngTolerance)
525 if (distZLow <= halfCarTolerance)
530 if (distZHigh <= halfCarTolerance)
533 sumnorm += fHighNorm;
535 if ( noSurfaces == 0 )
538 G4Exception(
"G4CutTubs::SurfaceNormal(p)",
"GeomSolids1002",
541 G4cout<<
"G4CutTubs::SN ( "<<p.
x()<<
", "<<p.
y()<<
", "<<p.
z()<<
" ); "
543 G4cout.precision(oldprc) ;
547 else if ( noSurfaces == 1 ) { norm = sumnorm; }
548 else { norm = sumnorm.
unit(); }
564 G4double distRMin, distRMax, distSPhi, distEPhi, distMin ;
567 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
569 distRMin = std::fabs(rho -
fRMin) ;
570 distRMax = std::fabs(rho -
fRMax) ;
574 distZLow =std::fabs((p+vZ).dot(fLowNorm));
578 distZHigh = std::fabs((p-vZ).dot(fHighNorm));
581 if (distRMin < distRMax)
583 if ( distZ < distRMin )
596 if ( distZ < distRMax )
607 if (!fPhiFullCutTube && rho )
609 phi = std::atan2(p.
y(),p.
x()) ;
611 if ( phi < 0 ) { phi +=
twopi; }
615 distSPhi = std::fabs(phi - (
fSPhi +
twopi))*rho ;
619 distSPhi = std::fabs(phi -
fSPhi)*rho ;
621 distEPhi = std::fabs(phi -
fSPhi -
fDPhi)*rho ;
623 if (distSPhi < distEPhi)
625 if ( distSPhi < distMin )
632 if ( distEPhi < distMin )
652 if ( distZHigh > distZLow ) { norm = fHighNorm ; }
653 else { norm = fLowNorm; }
671 "Undefined side for valid surface normal to solid.");
711 G4double Dist, sd=0, xi, yi, zi, rho2, inum, iden, cosPsi, Comp,calf ;
718 tolORMin2 = (
fRMin - halfRadTolerance)*(
fRMin - halfRadTolerance) ;
719 tolIRMin2 = (
fRMin + halfRadTolerance)*(
fRMin + halfRadTolerance) ;
726 tolORMax2 = (
fRMax + halfRadTolerance)*(
fRMax + halfRadTolerance) ;
727 tolIRMax2 = (
fRMax - halfRadTolerance)*(
fRMax - halfRadTolerance) ;
733 distZLow =(p+vZ).dot(fLowNorm);
737 distZHigh = (p-vZ).dot(fHighNorm);
739 if ( distZLow >= -halfCarTolerance )
741 calf = v.
dot(fLowNorm);
745 if(sd < 0.0) { sd = 0.0; }
747 xi = p.
x() + sd*v.
x() ;
748 yi = p.
y() + sd*v.
y() ;
749 rho2 = xi*xi + yi*yi ;
753 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
755 if (!fPhiFullCutTube && rho2)
760 iden = std::sqrt(rho2) ;
772 if ( sd<halfCarTolerance )
780 if(distZHigh >= -halfCarTolerance )
782 calf = v.
dot(fHighNorm);
785 sd = -distZHigh/calf;
787 if(sd < 0.0) { sd = 0.0; }
789 xi = p.
x() + sd*v.
x() ;
790 yi = p.
y() + sd*v.
y() ;
791 rho2 = xi*xi + yi*yi ;
795 if ((tolIRMin2 <= rho2) && (rho2 <= tolIRMax2))
797 if (!fPhiFullCutTube && rho2)
802 iden = std::sqrt(rho2) ;
814 if ( sd<halfCarTolerance )
833 t1 = 1.0 - v.
z()*v.
z() ;
834 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
835 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
841 if ((t3 >= tolORMax2) && (t2<0))
850 sd = c/(-b+std::sqrt(d));
855 G4double fTerm = sd-std::fmod(sd,dRmax);
860 zi = p.
z() + sd*v.
z() ;
861 xi = p.
x() + sd*v.
x() ;
862 yi = p.
y() + sd*v.
y() ;
863 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
864 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
866 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
867 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
877 xi = p.
x() + sd*v.
x() ;
878 yi = p.
y() + sd*v.
y() ;
891 if ((t3 > tolIRMin2) && (t2 < 0)
892 && (std::fabs(p.
z()) <= std::fabs(
GetCutZ(p))-halfCarTolerance ))
896 if (!fPhiFullCutTube)
899 iden = std::sqrt(t3) ;
920 snxt = c/(-b+std::sqrt(d));
922 if ( snxt < halfCarTolerance ) { snxt=0; }
940 c = t3 - fRMax*
fRMax;
951 snxt= c/(-b+std::sqrt(d));
953 if ( snxt < halfCarTolerance ) { snxt=0; }
974 sd =( b > 0. )? c/(-b - std::sqrt(d)) : (-b + std::sqrt(d));
975 if (sd >= -10*halfCarTolerance)
979 if (sd < 0.0) { sd = 0.0; }
982 G4double fTerm = sd-std::fmod(sd,dRmax);
985 zi = p.
z() + sd*v.
z() ;
986 xi = p.
x() + sd*v.
x() ;
987 yi = p.
y() + sd*v.
y() ;
988 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
989 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
991 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
992 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
996 if ( fPhiFullCutTube )
1027 if ( !fPhiFullCutTube )
1037 if ( Dist < halfCarTolerance )
1043 if ( sd < 0 ) { sd = 0.0; }
1044 zi = p.
z() + sd*v.
z() ;
1045 xi = p.
x() + sd*v.
x() ;
1046 yi = p.
y() + sd*v.
y() ;
1047 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
1048 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
1050 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
1051 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
1053 rho2 = xi*xi + yi*yi ;
1054 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1055 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1058 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1081 if ( Dist < halfCarTolerance )
1087 if ( sd < 0 ) { sd = 0; }
1088 zi = p.
z() + sd*v.
z() ;
1089 xi = p.
x() + sd*v.
x() ;
1090 yi = p.
y() + sd*v.
y() ;
1091 if ((-xi*fLowNorm.
x()-yi*fLowNorm.
y()
1092 -(zi+
fDz)*fLowNorm.
z())>-halfCarTolerance)
1094 if ((-xi*fHighNorm.
x()-yi*fHighNorm.
y()
1095 +(
fDz-zi)*fHighNorm.
z())>-halfCarTolerance)
1097 xi = p.
x() + sd*v.
x() ;
1098 yi = p.
y() + sd*v.
y() ;
1099 rho2 = xi*xi + yi*yi ;
1100 if ( ( (rho2 >= tolIRMin2) && (rho2 <= tolIRMax2) )
1101 || ( (rho2 > tolORMin2) && (rho2 < tolIRMin2)
1104 || ( (rho2 > tolIRMax2) && (rho2 < tolORMax2)
1122 if ( snxt<halfCarTolerance ) { snxt=0; }
1155 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho,cosPsi;
1160 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
1162 safRMin =
fRMin- rho ;
1163 safRMax = rho -
fRMax ;
1169 safZLow = (p+vZ).dot(fLowNorm);
1173 safZHigh = (p-vZ).dot(fHighNorm);
1177 if ( safRMin > safe ) { safe = safRMin; }
1178 if ( safRMax> safe ) { safe = safRMax; }
1182 if ( (!fPhiFullCutTube) && (rho) )
1188 if ( cosPsi < std::cos(
fDPhi*0.5) )
1200 if ( safePhi > safe ) { safe = safePhi; }
1203 if ( safe < 0 ) { safe = 0; }
1222 G4double distZLow,distZHigh,calfH,calfL;
1227 G4double pDistS, compS, pDistE, compE, sphi2, xi, yi, vphi, roi2 ;
1234 distZLow =(p+vZ).dot(fLowNorm);
1238 distZHigh = (p-vZ).dot(fHighNorm);
1240 calfH = v.
dot(fHighNorm);
1241 calfL = v.
dot(fLowNorm);
1245 if ( distZHigh < halfCarTolerance )
1247 snxt = -distZHigh/calfH ;
1263 if ( distZLow < halfCarTolerance )
1265 sz = -distZLow/calfL ;
1282 if((calfH<=0)&&(calfL<=0))
1298 t1 = 1.0 - v.
z()*v.
z() ;
1299 t2 = p.
x()*v.
x() + p.
y()*v.
y() ;
1300 t3 = p.
x()*p.
x() + p.
y()*p.
y() ;
1303 else { roi2 = snxt*snxt*t1 + 2*snxt*t2 + t3; }
1323 if( d2 >= 0 ) { srd = c/( -b - std::sqrt(d2)); }
1342 roMin2 = t3 - t2*t2/
t1 ;
1358 srd = c/(-b+std::sqrt(d2));
1363 if ( calcNorm ) { *validNorm =
false; }
1374 srd = -b + std::sqrt(d2) ;
1398 srd = -b + std::sqrt(d2) ;
1415 if ( !fPhiFullCutTube )
1420 vphi = std::atan2(v.
y(),v.
x()) ;
1422 if ( vphi <
fSPhi - halfAngTolerance ) { vphi +=
twopi; }
1423 else if ( vphi >
fSPhi +
fDPhi + halfAngTolerance ) { vphi -=
twopi; }
1426 if ( p.
x() || p.
y() )
1440 if( ( (
fDPhi <=
pi) && ( (pDistS <= halfCarTolerance)
1441 && (pDistE <= halfCarTolerance) ) )
1442 || ( (
fDPhi >
pi) && !((pDistS > halfCarTolerance)
1443 && (pDistE > halfCarTolerance) ) ) )
1449 sphi = pDistS/compS ;
1451 if (sphi >= -halfCarTolerance)
1453 xi = p.
x() + sphi*v.
x() ;
1454 yi = p.
y() + sphi*v.
y() ;
1463 if (((
fSPhi-halfAngTolerance)<=vphi)
1476 if ( pDistS > -halfCarTolerance )
1494 sphi2 = pDistE/compE ;
1498 if ( (sphi2 > -halfCarTolerance) && (sphi2 < sphi) )
1500 xi = p.
x() + sphi2*v.
x() ;
1501 yi = p.
y() + sphi2*v.
y() ;
1507 if( !((
fSPhi-halfAngTolerance <= vphi)
1511 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1512 else { sphi = 0.0 ; }
1522 if ( pDistE <= -halfCarTolerance ) { sphi = sphi2 ; }
1523 else { sphi = 0.0 ; }
1538 if ( (
fSPhi - halfAngTolerance <= vphi)
1539 && (vphi <=
fSPhi +
fDPhi + halfAngTolerance ) )
1569 xi = p.
x() + snxt*v.
x() ;
1570 yi = p.
y() + snxt*v.
y() ;
1576 *validNorm = false ;
1587 *validNorm = false ;
1599 *validNorm = false ;
1616 std::ostringstream message;
1617 G4int oldprc = message.precision(16);
1618 message <<
"Undefined side for valid surface normal to solid."
1620 <<
"Position:" << G4endl << G4endl
1621 <<
"p.x() = " << p.
x()/
mm <<
" mm" << G4endl
1622 <<
"p.y() = " << p.
y()/
mm <<
" mm" << G4endl
1623 <<
"p.z() = " << p.
z()/
mm <<
" mm" << G4endl << G4endl
1624 <<
"Direction:" << G4endl << G4endl
1625 <<
"v.x() = " << v.
x() << G4endl
1626 <<
"v.y() = " << v.
y() << G4endl
1627 <<
"v.z() = " << v.
z() << G4endl << G4endl
1628 <<
"Proposed distance :" << G4endl << G4endl
1629 <<
"snxt = " << snxt/
mm <<
" mm" <<
G4endl ;
1630 message.precision(oldprc) ;
1631 G4Exception(
"G4CutTubs::DistanceToOut(p,v,..)",
"GeomSolids1002",
1636 if ( snxt<halfCarTolerance ) { snxt=0 ; }
1646 G4double safRMin,safRMax,safZLow,safZHigh,safePhi,safe,rho;
1649 rho = std::sqrt(p.
x()*p.
x() + p.
y()*p.
y()) ;
1651 safRMin = rho -
fRMin ;
1652 safRMax =
fRMax - rho ;
1658 safZLow = std::fabs((p+vZ).dot(fLowNorm));
1662 safZHigh = std::fabs((p-vZ).dot(fHighNorm));
1665 if ( safRMin < safe ) { safe = safRMin; }
1666 if ( safRMax< safe ) { safe = safRMax; }
1670 if ( !fPhiFullCutTube )
1680 if (safePhi < safe) { safe = safePhi ; }
1682 if ( safe < 0 ) { safe = 0; }
1711 G4int oldprc = os.precision(16);
1712 os <<
"-----------------------------------------------------------\n"
1713 <<
" *** Dump for solid - " <<
GetName() <<
" ***\n"
1714 <<
" ===================================================\n"
1715 <<
" Solid type: G4CutTubs\n"
1716 <<
" Parameters: \n"
1717 <<
" inner radius : " <<
fRMin/
mm <<
" mm \n"
1718 <<
" outer radius : " <<
fRMax/
mm <<
" mm \n"
1719 <<
" half length Z: " <<
fDz/
mm <<
" mm \n"
1720 <<
" starting phi : " <<
fSPhi/
degree <<
" degrees \n"
1721 <<
" delta phi : " <<
fDPhi/
degree <<
" degrees \n"
1722 <<
" low Norm : " << fLowNorm <<
" \n"
1723 <<
" high Norm : " <<fHighNorm <<
" \n"
1724 <<
"-----------------------------------------------------------\n";
1725 os.precision(oldprc);
1736 G4double xRand, yRand, zRand, phi, cosphi, sinphi, chose,
1737 aOne, aTwo, aThr, aFou;
1746 cosphi = std::cos(phi);
1747 sinphi = std::sin(phi);
1755 if( (chose >=0) && (chose < aOne) )
1757 xRand = fRMax*cosphi;
1758 yRand = fRMax*sinphi;
1763 else if( (chose >= aOne) && (chose < aOne + aTwo) )
1765 xRand = fRMin*cosphi;
1766 yRand = fRMin*sinphi;
1771 else if( (chose >= aOne + aTwo) && (chose < aOne + aTwo + aThr) )
1773 xRand = rRand*cosphi;
1774 yRand = rRand*sinphi;
1778 else if( (chose >= aOne + aTwo + aThr) && (chose < aOne + aTwo + 2.*aThr) )
1780 xRand = rRand*cosphi;
1781 yRand = rRand*sinphi;
1785 else if( (chose >= aOne + aTwo + 2.*aThr)
1786 && (chose < aOne + aTwo + 2.*aThr + aFou) )
1788 xRand = rRand*std::cos(
fSPhi);
1789 yRand = rRand*std::sin(
fSPhi);
1816 typedef G4int G4int4[4];
1822 G4double3* xyz =
new G4double3[
nn];
1823 G4int4* faces =
new G4int4[nf] ;
1846 for(
G4int i=0;i<nf;i++)
1851 faces[i][k]=iNodes[k];
1853 for(
G4int k=n;k<4;k++)
1875 G4double zXLow1,zXLow2,zYLow1,zYLow2;
1876 G4double zXHigh1,zXHigh2,zYHigh1,zYHigh2;
1886 if ( (zXLow1>zXHigh1) ||(zXLow2>zXHigh2)
1887 || (zYLow1>zYHigh1) ||(zYLow2>zYHigh2)) {
return true; }
1901 if(fLowNorm.
z()!=0.)
1903 newz = -
fDz-(p.
x()*fLowNorm.
x()+p.
y()*fLowNorm.
y())/fLowNorm.
z();
1908 if(fHighNorm.
z()!=0.)
1910 newz =
fDz-(p.
x()*fHighNorm.
x()+p.
y()*fHighNorm.
y())/fHighNorm.
z();
1923 G4double phiLow = std::atan2(fLowNorm.
y(),fLowNorm.
x());
1924 G4double phiHigh= std::atan2(fHighNorm.
y(),fHighNorm.
x());
1928 G4bool in_range_low =
false;
1929 G4bool in_range_hi =
false;
1934 if (phiLow<0) { phiLow+=
twopi; }
1936 if (ddp<0) { ddp +=
twopi; }
1939 xc =
fRMin*std::cos(phiLow);
1940 yc =
fRMin*std::sin(phiLow);
1942 xc =
fRMax*std::cos(phiLow);
1943 yc =
fRMax*std::sin(phiLow);
1945 if (in_range_low) { zmin =
std::min(zmin, z1); }
1947 in_range_low =
true;
1954 if (phiHigh<0) { phiHigh+=
twopi; }
1956 if (ddp<0) { ddp +=
twopi; }
1959 xc =
fRMin*std::cos(phiHigh);
1960 yc =
fRMin*std::sin(phiHigh);
1962 xc =
fRMax*std::cos(phiHigh);
1963 yc =
fRMax*std::sin(phiHigh);
1965 if (in_range_hi) { zmax =
std::min(zmax, z1); }
1996 for (i = 1; i < 4; i++)
1998 if(z[i] < z[i-1])z1=z[i];
2010 for (i = 1; i < 4; i++)
2012 if(z[4+i] > z[4+i-1]) { z1=z[4+i]; }
2015 if (in_range_hi) { zmax =
std::max(zmax, z1); }
G4double GetCosStartPhi() const
void set(double x, double y, double z)
ThreeVector shoot(const G4int Ap, const G4int Af)
void GetFacet(G4int iFace, G4int &n, G4int *iNodes, G4int *edgeFlags=0, G4int *iFaces=0) const
static constexpr double mm
static const G4double kInfinity
CLHEP::Hep3Vector G4ThreeVector
double dot(const Hep3Vector &) const
std::vector< ExP01TrackerHit * > a
G4int createPolyhedron(G4int Nnodes, G4int Nfaces, const G4double xyz[][3], const G4int faces[][4])
G4double GetSinStartPhi() const
G4double GetRadiusInRing(G4double rmin, G4double rmax) const
G4ThreeVector GetLowNorm() const
void GetMaxMinZ(G4double &zmin, G4double &zmax) const
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
virtual void AddSolid(const G4Box &)=0
static constexpr double twopi
EInside Inside(const G4ThreeVector &p) const
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=G4bool(false), G4bool *validNorm=0, G4ThreeVector *n=0) const
G4CutTubs & operator=(const G4CutTubs &rhs)
G4OTubs & operator=(const G4OTubs &rhs)
G4GLOB_DLL std::ostream G4cout
static constexpr double degree
G4double GetRadialTolerance() const
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
G4double GetSinEndPhi() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
std::ostream & StreamInfo(std::ostream &os) const
G4bool BoundingBoxVsVoxelLimits(const EAxis pAxis, const G4VoxelLimits &pVoxelLimits, const G4Transform3D &pTransform3D, G4double &pMin, G4double &pMax) const
std::vector< G4ThreeVector > G4ThreeVectorList
G4double GetZHalfLength() const
G4Polyhedron * CreatePolyhedron() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4int GetNoVertices() const
G4ThreeVector ApproxSurfaceNormal(const G4ThreeVector &p) const
G4double GetOuterRadius() const
G4bool IsCrossingCutPlanes() const
G4GeometryType GetEntityType() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void DescribeYourselfTo(G4VGraphicsScene &scene) const
G4double GetCosEndPhi() const
G4ThreeVector GetHighNorm() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetInnerRadius() const
static constexpr double pi
void Extent(G4ThreeVector &pMin, G4ThreeVector &pMax) const
G4double GetDeltaPhiAngle() const
G4Polyhedron * CreatePolyhedron() const
static constexpr double deg
G4ThreeVector GetPointOnSurface() const
G4int GetNoFacets() const
G4double GetAngularTolerance() const
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pmin, G4double &pmax) const
static G4GeometryTolerance * GetInstance()
G4CutTubs(const G4String &pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi, G4double pDPhi, G4ThreeVector pLowNorm, G4ThreeVector pHighNorm)
G4Point3D GetVertex(G4int index) const
G4double GetCutZ(const G4ThreeVector &p) const