81 SetTorusDimensions(
r, rmin, rmax, phi1, dphi);
82 if ((fRmin < 0) || (fRmax < 0))
83 SetShapeBit(kGeoRunTimeShape);
94 SetTorusDimensions(
r, rmin, rmax, phi1, dphi);
95 if ((fRmin < 0) || (fRmax < 0))
96 SetShapeBit(kGeoRunTimeShape);
111 SetDimensions(param);
112 if (fRmin < 0 || fRmax < 0)
113 SetShapeBit(kGeoRunTimeShape);
199 if ((
fRmax - daxis) > 1E-5) {
211 for (
Int_t i = 0; i < 3; i++) {
212 norm[i] = point[i] - r0[i];
213 normsq += norm[i] * norm[i];
220 if (dir[0] * norm[0] + dir[1] * norm[1] + dir[2] * norm[2] < 0) {
245 Double_t radsq = (rxy -
fR) * (rxy -
fR) + point[2] * point[2];
262 else if (
fDphi < 360)
273 for (
Int_t i = 0; i < 3; i++)
274 p[i] =
pt[i] + t * dir[i];
285 for (
Int_t i = 0; i < 3; i++)
286 p[i] =
pt[i] + t * dir[i];
289 return ((p[2] * dir[2] -
fR *
TMath::Sqrt(dir[0] * dir[0] + dir[1] * dir[1])) /
294 Double_t dd = (p[0] * dir[0] + p[1] * dir[1] + p[2] * dir[2] - (p[0] * dir[0] + p[1] * dir[1]) *
fR / rxy) /
d;
304 for (
Int_t i = 0; i < 3; i++)
305 p[i] =
pt[i] + t * dir[i];
313 (p[0] * dir[0] + p[1] * dir[1] + p[2] * dir[2] - (p[0] * dir[0] + p[1] * dir[1]) *
fR / rxy) / daxis;
314 Double_t dddaxis = 1 - ddaxis * ddaxis - (1 - dir[2] * dir[2]) *
fR / rxy +
315 fR * (p[0] * dir[0] + p[1] * dir[1]) * (p[0] * dir[0] + p[1] * dir[1]) / (rxy * rxy * rxy);
326 if (iact < 3 && safe) {
330 if ((iact == 1) && (step <= *safe))
355 TGeoTubeSeg::DistFromInsideS(point, dir,
fR -
fRmax,
fR +
fRmax,
fRmax,
c1,
s1,
c2, s2, cm, sm, cdfi);
357 if (daxis >=
fRmin + 1.E-8 && daxis <=
fRmax - 1.E-8)
369 if (iact < 3 && safe) {
373 if ((iact == 1) && (step <= *safe))
383 Double_t c1 = 0,
s1 = 0,
c2 = 0, s2 = 0, cm = 0, sm = 0, cdfi = 0;
409 fio = 0.5 * (phi1 + phi2);
417 rxy2 = point[0] * point[0] + point[1] * point[1];
419 if (!hasphi || inphi)
442 daxis =
Daxis(point, dir, snext);
446 for (i = 0; i < 3; i++)
447 pt[i] = point[i] + snext * dir[i];
453 if (daxis <
fRmin + 1.E-8) {
458 for (i = 0; i < 3; i++)
459 pt[i] += 0.1 * eps * dir[i];
466 dring =
TGeoTubeSeg::DistFromInsideS(
pt, dir,
fR -
fRmin,
fR +
fRmin,
fRmin,
c1,
s1,
c2, s2, cm, sm, cdfi);
472 snext += dring + eps;
473 for (i = 0; i < 3; i++)
474 pt[i] = point[i] + snext * dir[i];
483 for (i = 0; i < 3; i++)
484 pt[i] += 0.1 * eps * dir[i];
490 s1,
c2, s2, cm, sm, cdfi);
498 snext += dring + eps;
499 for (i = 0; i < 3; i++)
500 pt[i] = point[i] + snext * dir[i];
522 case 2:
return "PHI";
524 default:
return "UNDEFINED";
547 case 3: dx = 0;
return dx;
571 Error(
"GetMakeRuntimeShape",
"parametrized toruses not supported");
580 printf(
"*** Shape %s: TGeoTorus ***\n",
GetName());
581 printf(
" R = %11.5f\n",
fR);
582 printf(
" Rmin = %11.5f\n",
fRmin);
583 printf(
" Rmax = %11.5f\n",
fRmax);
584 printf(
" Phi1 = %11.5f\n",
fPhi1);
585 printf(
" Dphi = %11.5f\n",
fDphi);
586 printf(
" Bounding box:\n");
605 Int_t nbSegs = (2 *
n - 1) * (
n - 1);
606 Int_t nbPols = (
n - 1) * (
n - 1);
608 nbSegs += (2 *
n - 1) * (
n - 1);
609 nbPols += (
n - 1) * (
n - 1);
612 nbSegs += 2 * (
n - 1);
613 nbPols += 2 * (
n - 1);
634 Int_t indx, indp, startcap = 0;
647 for (i = 0; i <
n; i++) {
648 for (j = 0; j <
n - 1; j++) {
649 buff.
fSegs[indx + (i * (
n - 1) + j) * 3] =
c;
650 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 1] = i * (
n - 1) + j;
651 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 2] = i * (
n - 1) + ((j + 1) % (
n - 1));
654 indx += 3 *
n * (
n - 1);
657 for (i = 0; i <
n - 1; i++) {
658 for (j = 0; j <
n - 1; j++) {
659 buff.
fSegs[indx + (i * (
n - 1) + j) * 3] =
c;
660 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 1] = i * (
n - 1) + j;
661 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 2] = (i + 1) * (
n - 1) + j;
664 indx += 3 * (
n - 1) * (
n - 1);
665 startcap = (2 *
n - 1) * (
n - 1);
670 for (i = 0; i <
n; i++) {
671 for (j = 0; j <
n - 1; j++) {
672 buff.
fSegs[indx + (i * (
n - 1) + j) * 3] =
c;
673 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 1] = indp + i * (
n - 1) + j;
674 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 2] = indp + i * (
n - 1) + ((j + 1) % (
n - 1));
677 indx += 3 *
n * (
n - 1);
680 for (i = 0; i <
n - 1; i++) {
681 for (j = 0; j <
n - 1; j++) {
682 buff.
fSegs[indx + (i * (
n - 1) + j) * 3] =
c;
683 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 1] = indp + i * (
n - 1) + j;
684 buff.
fSegs[indx + (i * (
n - 1) + j) * 3 + 2] = indp + (i + 1) * (
n - 1) + j;
687 indx += 3 * (
n - 1) * (
n - 1);
688 startcap = (4 *
n - 2) * (
n - 1);
695 for (j = 0; j <
n - 1; j++) {
696 buff.
fSegs[indx + j * 3] =
c + 1;
697 buff.
fSegs[indx + j * 3 + 1] = (
n - 1) * i + j;
698 buff.
fSegs[indx + j * 3 + 2] = indp + (
n - 1) * i + j;
702 for (j = 0; j <
n - 1; j++) {
703 buff.
fSegs[indx + j * 3] =
c + 1;
704 buff.
fSegs[indx + j * 3 + 1] = (
n - 1) * i + j;
705 buff.
fSegs[indx + j * 3 + 2] = indp + (
n - 1) * i + j;
710 for (j = 0; j <
n - 1; j++) {
711 buff.
fSegs[indx + j * 3] =
c + 1;
712 buff.
fSegs[indx + j * 3 + 1] = (
n - 1) * i + j;
713 buff.
fSegs[indx + j * 3 + 2] =
n * (
n - 1);
717 for (j = 0; j <
n - 1; j++) {
718 buff.
fSegs[indx + j * 3] =
c + 1;
719 buff.
fSegs[indx + j * 3 + 1] = (
n - 1) * i + j;
720 buff.
fSegs[indx + j * 3 + 2] =
n * (
n - 1) + 1;
731 for (i = 0; i <
n - 1; i++) {
732 for (j = 0; j <
n - 1; j++) {
734 buff.
fPols[indx++] = 4;
735 buff.
fPols[indx++] =
n * (
n - 1) + (
n - 1) * i + ((j + 1) % (
n - 1));
736 buff.
fPols[indx++] = (
n - 1) * (i + 1) + j;
737 buff.
fPols[indx++] =
n * (
n - 1) + (
n - 1) * i + j;
738 buff.
fPols[indx++] = (
n - 1) * i + j;
742 indp = (2 *
n - 1) * (
n - 1);
745 for (i = 0; i <
n - 1; i++) {
746 for (j = 0; j <
n - 1; j++) {
748 buff.
fPols[indx++] = 4;
749 buff.
fPols[indx++] = indp +
n * (
n - 1) + (
n - 1) * i + j;
750 buff.
fPols[indx++] = indp + (
n - 1) * (i + 1) + j;
751 buff.
fPols[indx++] = indp +
n * (
n - 1) + (
n - 1) * i + ((j + 1) % (
n - 1));
752 buff.
fPols[indx++] = indp + (
n - 1) * i + j;
759 Int_t np = (hasrmin) ? 4 : 3;
760 for (j = 0; j <
n - 1; j++) {
761 buff.
fPols[indx++] =
c + 1;
762 buff.
fPols[indx++] = np;
763 buff.
fPols[indx++] = j;
764 buff.
fPols[indx++] = startcap + j;
766 buff.
fPols[indx++] = indp + j;
767 buff.
fPols[indx++] = startcap + ((j + 1) % (
n - 1));
771 for (j = 0; j <
n - 1; j++) {
772 buff.
fPols[indx++] =
c + 1;
773 buff.
fPols[indx++] = np;
774 buff.
fPols[indx++] = (
n - 1) * i + j;
775 buff.
fPols[indx++] = startcap + (
n - 1) + ((j + 1) % (
n - 1));
777 buff.
fPols[indx++] = indp + (
n - 1) * i + j;
778 buff.
fPols[indx++] = startcap + (
n - 1) + j;
793 saf[0] = rad -
fRmin;
794 saf[1] =
fRmax - rad;
798 for (i = 0; i < 2; i++)
808 for (i = 0; i < 2; i++)
822 out <<
" r = " <<
fR <<
";" << std::endl;
823 out <<
" rmin = " <<
fRmin <<
";" << std::endl;
824 out <<
" rmax = " <<
fRmax <<
";" << std::endl;
825 out <<
" phi1 = " <<
fPhi1 <<
";" << std::endl;
826 out <<
" dphi = " <<
fDphi <<
";" << std::endl;
827 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoTorus(\"" <<
GetName() <<
"\",r,rmin,rmax,phi1,dphi);"
870 for (i = 0; i <
n; i++) {
874 for (j = 0; j <
n - 1; j++) {
886 for (i = 0; i <
n; i++) {
890 for (j = 0; j <
n - 1; j++) {
929 for (i = 0; i <
n; i++) {
933 for (j = 0; j <
n - 1; j++) {
946 for (i = 0; i <
n; i++) {
950 for (j = 0; j <
n - 1; j++) {
983 else if (
fDphi < 360.)
1011 t = (-3 *
q * sq3 + delta) / (6 * sq3);
1012 u = (3 *
q * sq3 + delta) / (6 * sq3);
1018 u = delta / (6 * sq3);
1023 t =
x[0] *
x[0] +
a *
x[0] +
b;
1025 delta = u * u - 4. * t;
1029 x[1] = 0.5 * (-u - delta);
1030 x[2] = 0.5 * (-u + delta);
1053 delta =
e *
e - 4. *
g;
1057 h = 0.5 * (-
e - delta);
1060 x[ireal++] = -
h - 0.25 *
a;
1061 x[ireal++] =
h - 0.25 *
a;
1063 h = 0.5 * (-
e + delta);
1066 x[ireal++] = -
h - 0.25 *
a;
1067 x[ireal++] =
h - 0.25 *
a;
1071 for (i = 0; i < ireal; i++)
1073 memcpy(
x, xx, ireal *
sizeof(
Double_t));
1079 x[ireal++] = -0.25 *
a;
1081 for (i = 0; i < ind[0]; i++)
1082 x[ireal++] = xx[i] - 0.25 *
a;
1085 for (i = 0; i < ireal; i++)
1087 memcpy(
x, xx, ireal *
sizeof(
Double_t));
1099 for (i = 0; i < 3; i++) {
1110 delta =
h *
h - 4. * j;
1113 x[ireal++] = 0.5 * (-
h - delta) - 0.25 *
a;
1114 x[ireal++] = 0.5 * (-
h + delta) - 0.25 *
a;
1116 delta =
h *
h - 4. *
g / j;
1119 x[ireal++] = 0.5 * (
h - delta) - 0.25 *
a;
1120 x[ireal++] = 0.5 * (
h + delta) - 0.25 *
a;
1124 for (i = 0; i < ireal; i++)
1126 memcpy(
x, xx, ireal *
sizeof(
Double_t));
1141 Double_t rdotn =
pt[0] * dir[0] +
pt[1] * dir[1] +
pt[2] * dir[2];
1144 Double_t b = 2. * (r0sq + 2. * rdotn * rdotn - rsumsq + 2. *
fR *
fR * dir[2] * dir[2]);
1145 Double_t c = 4. * (r0sq * rdotn - rsumsq * rdotn + 2. *
fR *
fR *
pt[2] * dir[2]);
1153 Double_t b0 = (
pt[0] * dir[0] +
pt[1] * dir[1]) / (dir[0] * dir[0] + dir[1] * dir[1]);
1154 Double_t c0 = (
pt[0] *
pt[0] + (
pt[1] - r0) * (
pt[1] + r0)) / (dir[0] * dir[0] + dir[1] * dir[1]);
1165 c0 = (
pt[0] *
pt[0] + (
pt[1] - r0) * (
pt[1] + r0)) / (dir[0] * dir[0] + dir[1] * dir[1]);
1166 delta = b0 * b0 - c0;
1179 for (
Int_t j = 0; j < nsol; j++)
1191 for (
Int_t i = 0; i < nsol; i++) {
1198 for (
Int_t ipt = 0; ipt < 3; ipt++)
1199 norm[ipt] =
pt[ipt] +
x[i] * dir[ipt] - r0[ipt];
1200 ndotd = norm[0] * dir[0] + norm[1] * dir[1] + norm[2] * dir[2];
1210 Double_t delta = s * s * s * s +
a * s * s * s +
b * s * s +
c * s +
d;
1211 Double_t eps0 = -delta / (4. * s * s * s + 3. *
a * s * s + 2. *
b * s +
c);
1218 delta = s * s * s * s +
a * s * s * s +
b * s * s +
c * s +
d;
1219 eps = -delta / (4. * s * s * s + 3. *
a * s * s + 2. *
b * s +
c);
1237 nvert =
n * (
n - 1);
1244 nsegs = (2 *
n - 1) * (
n - 1);
1245 npols = (
n - 1) * (
n - 1);
1247 nsegs += (2 *
n - 1) * (
n - 1);
1248 npols += (
n - 1) * (
n - 1);
1251 nsegs += 2 * (
n - 1);
1252 npols += 2 * (
n - 1);
1275 Int_t nbSegs = (2 *
n - 1) * (
n - 1);
1276 Int_t nbPols = (
n - 1) * (
n - 1);
1278 nbSegs += (2 *
n - 1) * (
n - 1);
1279 nbPols += (
n - 1) * (
n - 1);
1282 nbSegs += 2 * (
n - 1);
1283 nbPols += 2 * (
n - 1);
1286 if (buffer.SetRawSizes(nbPnts, 3 * nbPnts, nbSegs, 3 * nbSegs, nbPols, 6 * nbPols)) {
1294 if (!buffer.fLocalFrame) {
1312 for (
Int_t i = 0; i < vecsize; i++)
1323 for (
Int_t i = 0; i < vecsize; i++)
1333 for (
Int_t i = 0; i < vecsize; i++)
1343 for (
Int_t i = 0; i < vecsize; i++)
1354 for (
Int_t i = 0; i < vecsize; i++)
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
externTGeoManager * gGeoManager
Generic 3D primitive description class.
void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const override
Fill the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections,...
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
void InspectShape() const override
Geometrical transformation package.
Base abstract class for all shapes.
Int_t GetBasicColor() const
Get the basic color (0-7).
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster).
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
static Double_t SafetyPhi(const Double_t *point, Bool_t in, Double_t phi1, Double_t phi2)
Static method to compute safety w.r.t a phi corner defined by cosines/sines of the angles phi1,...
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
const char * GetPointerName() const
Provide a pointer name containing uid.
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
static void NormalPhi(const Double_t *point, const Double_t *dir, Double_t *norm, Double_t c1, Double_t s1, Double_t c2, Double_t s2)
Static method to compute normal to phi planes.
const char * GetName() const override
Get the shape name.
static Double_t Tolerance()
Bool_t TestShapeBit(UInt_t f) const
Int_t SolveQuartic(Double_t a, Double_t b, Double_t c, Double_t d, Double_t *x) const
void Sizeof3D() const override
Double_t ToBoundary(const Double_t *pt, const Double_t *dir, Double_t r, Bool_t in) const
Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const override
Double_t DDDaxis(const Double_t *pt, const Double_t *dir, Double_t t) const
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
const char * GetAxisName(Int_t iaxis) const override
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
Double_t Daxis(const Double_t *pt, const Double_t *dir, Double_t t) const
void SetTorusDimensions(Double_t r, Double_t rmin, Double_t rmax, Double_t phi1, Double_t dphi)
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
TBuffer3D * MakeBuffer3D() const override
void SetPoints(Double_t *points) const override
Int_t GetNmeshVertices() const override
void SetSegsAndPols(TBuffer3D &buff) const override
void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const override
TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const override
void GetBoundingCylinder(Double_t *param) const override
void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const override
Double_t DDaxis(const Double_t *pt, const Double_t *dir, Double_t t) const
Bool_t Contains(const Double_t *point) const override
void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const override
void InspectShape() const override
TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step) override
const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const override
Stub implementation to avoid forcing implementation at this stage.
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const override
void SetDimensions(Double_t *param) override
void ComputeBBox() override
void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize) override
Int_t SolveCubic(Double_t a, Double_t b, Double_t c, Double_t *x) const
void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const override
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
Double_t Capacity() const override
static Double_t DistFromInsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz, Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
static Double_t DistFromOutsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz, Double_t c1, Double_t s1, Double_t c2, Double_t s2, Double_t cm, Double_t sm, Double_t cdfi)
static Double_t DistFromInsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
static Double_t DistFromOutsideS(const Double_t *point, const Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Long64_t LocMin(Long64_t n, const T *a)
Returns index of array with the minimum element.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
T1 Sign(T1 a, T2 b)
Returns a value with the magnitude of a and the sign of b.
Double_t ATan2(Double_t y, Double_t x)
Returns the principal value of the arc tangent of y/x, expressed in radians.
Long64_t LocMax(Long64_t n, const T *a)
Returns index of array with the maximum element.
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort the n elements of the array a of generic templated type Element.
constexpr Double_t RadToDeg()
Conversion from radian to degree: .
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.