106 :
TGeoTube(param[1],param[3],param[0])
143 Error(
"ComputeBBox",
"Shape %s hyperbolic surfaces are malformed: rin=%g, stin=%g, rout=%g, stout=%g",
158 Double_t rsq = point[0]*point[0]+point[1]*point[1];
166 if (i==0 || r<1.
E-10) {
167 norm[0] = norm[1] = 0.;
182 if (norm[0]*dir[0]+norm[1]*dir[1]+norm[2]*dir[2]<0) {
195 Double_t r2 = point[0]*point[0]+point[1]*point[1];
197 if (r2>routsq)
return kFALSE;
200 if (r2<rinsq)
return kFALSE;
218 if (iact<3 && safe) {
227 sz = (
fDz-point[2])/dir[2];
228 if (sz<=0.)
return 0.;
231 sz = -(
fDz+point[2])/dir[2];
232 if (sz<=0.)
return 0.;
245 if (npos) srin = s[0];
247 if (npos) srout = s[0];
258 if (iact<3 && safe) {
272 if ((point[2]*dir[2]) < 0) {
276 xi = point[0]+sz*dir[0];
277 yi = point[1]+sz*dir[1];
282 if (r2 <= rmax2)
return sz;
293 zi = point[2] + s[0]*dir[2];
296 zi = point[2] + s[1]*dir[2];
302 zi = point[2] + s[0]*dir[2];
305 zi = point[2] + s[1]*dir[2];
327 Double_t a = dir[0]*dir[0] + dir[1]*dir[1] - t0*dir[2]*dir[2];
328 Double_t b = t0*point[2]*dir[2] - point[0]*dir[0] - point[1]*dir[1];
329 Double_t c = point[0]*point[0] + point[1]*point[1] - t0*point[2]*point[2] - r0*r0;
334 if (snext < 0.)
return 0;
342 if (delta < 0.)
return 0;
347 snext = (b + i*sone*delta)*ainv;
349 if (snext<0)
continue;
356 if (inner) ndotd *= -1;
358 if (ndotd<0) s[npos++] =
snext;
359 }
else s[npos++] =
snext;
370 Error(
"Divide",
"Hyperboloids cannot be divided. Division volume %s not created", divname);
409 param[0] *= param[0];
411 param[1] *= param[1];
428 if (zmax<0)
return 0;
431 Error(
"GetMakeRuntimeShape",
"Shape %s does not have negative Z range",
GetName());
450 printf(
" Bounding box:\n");
462 Int_t nbPnts = (hasRmin)?(2*n*n):(n*n+2);
463 Int_t nbSegs = (hasRmin)?(4*n*n):(n*(2*n+1));
464 Int_t nbPols = (hasRmin)?(2*n*n):(n*(n+1));
467 nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols);
487 Int_t irout = (hasRmin)?(n*n):2;
520 Int_t isgenin = (hasRmin)?(isin+n*n):0;
521 Int_t isout = (hasRmin)?(isgenin+n*(n-1)):0;
522 Int_t isgenout = isout+n*
n;
523 Int_t islo = isgenout+n*(n-1);
529 for (i=0; i<
n; i++) {
530 for (j=0; j<
n; j++) {
531 npt = 3*(isin+n*i+j);
533 buff.
fSegs[npt+1] = irin+n*i+j;
534 buff.
fSegs[npt+2] = irin+n*i+((j+1)%n);
538 for (i=0; i<n-1; i++) {
539 for (j=0; j<
n; j++) {
540 npt = 3*(isgenin+n*i+j);
542 buff.
fSegs[npt+1] = irin+n*i+j;
543 buff.
fSegs[npt+2] = irin+n*(i+1)+j;
548 for (i=0; i<
n; i++) {
549 for (j=0; j<
n; j++) {
550 npt = 3*(isout + n*i+j);
552 buff.
fSegs[npt+1] = irout+n*i+j;
553 buff.
fSegs[npt+2] = irout+n*i+((j+1)%n);
557 for (i=0; i<n-1; i++) {
558 for (j=0; j<
n; j++) {
559 npt = 3*(isgenout+n*i+j);
561 buff.
fSegs[npt+1] = irout+n*i+j;
562 buff.
fSegs[npt+2] = irout+n*(i+1)+j;
566 for (j=0; j<
n; j++) {
569 buff.
fSegs[npt+1] = irin;
570 if (hasRmin) buff.
fSegs[npt+1] += j;
571 buff.
fSegs[npt+2] = irout + j;
574 for (j=0; j<
n; j++) {
577 buff.
fSegs[npt+1] = irin+1;
578 if (hasRmin) buff.
fSegs[npt+1] += n*(n-1)+j-1;
579 buff.
fSegs[npt+2] = irout + n*(n-1)+j;
605 Int_t ipout = (hasRmin)?(ipin+n*(n-1)):0;
606 Int_t iplo = ipout+n*(n-1);
610 for (i=0; i<n-1; i++) {
611 for (j=0; j<
n; j++) {
612 npt = 6*(ipin+n*i+j);
614 buff.
fPols[npt+1] = 4;
615 buff.
fPols[npt+2] = isin+n*i+j;
616 buff.
fPols[npt+3] = isgenin+i*n+((j+1)%n);
617 buff.
fPols[npt+4] = isin+n*(i+1)+j;
618 buff.
fPols[npt+5] = isgenin+i*n+j;
623 for (i=0; i<n-1; i++) {
624 for (j=0; j<
n; j++) {
625 npt = 6*(ipout+n*i+j);
627 buff.
fPols[npt+1] = 4;
628 buff.
fPols[npt+2] = isout+n*i+j;
629 buff.
fPols[npt+3] = isgenout+i*n+j;
630 buff.
fPols[npt+4] = isout+n*(i+1)+j;
631 buff.
fPols[npt+5] = isgenout+i*n+((j+1)%n);
636 for (j=0; j<
n; j++) {
638 buff.
fPols[npt] = c+1;
639 buff.
fPols[npt+1] = 4;
640 buff.
fPols[npt+2] = isin+j;
641 buff.
fPols[npt+3] = islo+j;
642 buff.
fPols[npt+4] = isout+j;
643 buff.
fPols[npt+5] = islo+((j+1)%n);
645 for (j=0; j<
n; j++) {
647 buff.
fPols[npt] = c+2;
648 buff.
fPols[npt+1] = 4;
649 buff.
fPols[npt+2] = isin+n*(n-1)+j;
650 buff.
fPols[npt+3] = ishi+((j+1)%n);
651 buff.
fPols[npt+4] = isout+n*(n-1)+j;
652 buff.
fPols[npt+5] = ishi+j;
655 for (j=0; j<
n; j++) {
657 buff.
fPols[npt] = c+1;
658 buff.
fPols[npt+1] = 3;
659 buff.
fPols[npt+2] = isout+j;
660 buff.
fPols[npt+3] = islo+((j+1)%n);
661 buff.
fPols[npt+4] = islo+j;
663 for (j=0; j<
n; j++) {
664 npt = 6*iplo+5*(n+j);
665 buff.
fPols[npt] = c+2;
666 buff.
fPols[npt+1] = 3;
667 buff.
fPols[npt+2] = isout+n*(n-1)+j;
668 buff.
fPols[npt+3] = ishi+j;
669 buff.
fPols[npt+4] = ishi+((j+1)%n);
687 return (r0*r0+tsq*z*z);
704 return ((r*r-r0*r0)/tsq);
717 if (safrmin < safe) safe = safrmin;
719 if (safrmax < safe) safe = safrmax;
723 if (safrmin > safe) safe = safrmin;
725 if (safrmax > safe) safe = safrmax;
738 rsq = point[0]*point[0]+point[1]*point[1];
774 out <<
" rin = " <<
fRmin <<
";" << std::endl;
775 out <<
" stin = " <<
fStIn <<
";" << std::endl;
776 out <<
" rout = " <<
fRmax <<
";" << std::endl;
777 out <<
" stout = " <<
fStOut <<
";" << std::endl;
778 out <<
" dz = " <<
fDz <<
";" << std::endl;
779 out <<
" TGeoShape *" <<
GetPointerName() <<
" = new TGeoHype(\"" <<
GetName() <<
"\",rin,stin,rout,stout,dz);" << std::endl;
836 for (i=0; i<
n; i++) {
839 for (j=0; j<
n; j++) {
849 points[indx++] = -
fDz;
852 points[indx++] =
fDz;
855 for (i=0; i<
n; i++) {
858 for (j=0; j<
n; j++) {
884 for (i=0; i<
n; i++) {
887 for (j=0; j<
n; j++) {
897 points[indx++] = -
fDz;
900 points[indx++] =
fDz;
903 for (i=0; i<
n; i++) {
906 for (j=0; j<
n; j++) {
922 nvert = (hasRmin)?(2*n*n):(n*n+2);
923 nsegs = (hasRmin)?(4*n*n):(n*(2*n+1));
924 npols = (hasRmin)?(2*n*n):(n*(n+1));
963 Int_t nbPnts = (hasRmin)?(2*n*n):(n*n+2);
964 Int_t nbSegs = (hasRmin)?(4*n*n):(n*(2*n+1));
965 Int_t nbPols = (hasRmin)?(2*n*n):(n*(n+1));
966 if (buffer.
SetRawSizes(nbPnts, 3*nbPnts, nbSegs, 3*nbSegs, nbPols, 6*nbPols)) {
990 for (
Int_t i=0; i<vecsize; i++) inside[i] =
Contains(&points[3*i]);
1000 for (
Int_t i=0; i<vecsize; i++)
ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
1008 for (
Int_t i=0; i<vecsize; i++) dists[i] =
DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
1016 for (
Int_t i=0; i<vecsize; i++) dists[i] =
DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
1026 for (
Int_t i=0; i<vecsize; i++) safe[i] =
Safety(&points[3*i], inside[i]);
virtual ~TGeoHype()
destructor
virtual Double_t Capacity() const
Computes capacity of the shape in [length^3].
#define snext(osub1, osub2)
Int_t GetNsegments() const
Get number of segments approximating circles.
virtual TBuffer3D * MakeBuffer3D() const
Creates a TBuffer3D describing this shape.
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const
Get range of shape for a given axis.
ClassImp(TGeoHype) TGeoHype
Default constructor.
Int_t GetBasicColor() const
Get the basic color (0-7).
virtual void SetPoints(Double_t *points) const
create tube mesh points
Short_t Min(Short_t a, Short_t b)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Double_t SafetyToHype(const Double_t *point, Bool_t inner, Bool_t in) const
Compute an underestimate of the closest distance from a point to inner or outer infinite hyperbolas...
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from outside point to surface of the box.
virtual Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape, according to option.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual TGeoShape * GetMakeRuntimeShape(TGeoShape *mother, TGeoMatrix *mat) const
in case shape has some negative parameters, these has to be computed in order to fit the mother ...
static Double_t Tolerance()
virtual Bool_t Contains(const Double_t *point) const
test if point is inside this tube
virtual void ComputeBBox()
Compute bounding box of the hyperboloid.
void SetHypeDimensions(Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Set dimensions of the hyperboloid.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
compute closest distance from point px,py to each corner
Double_t ATan2(Double_t, Double_t)
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
compute distance from outside point to surface of the hyperboloid.
virtual TGeoVolume * Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step)
Cannot divide hyperboloids.
void SetSectionsValid(UInt_t mask)
void TransformPoints(Double_t *points, UInt_t NbPoints) const
Tranform a set of points (LocalToMaster)
Double_t ZHypeSq(Double_t r, Bool_t inner) const
Compute z^2 at a given r^2, for either inner or outer hyperbolas.
virtual void DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specisied by dirs. Store output in dist...
virtual void SetDimensions(Double_t *param)
Set dimensions of the hyperboloid starting from an array.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void InspectShape() const
print shape parameters
Bool_t TestBit(UInt_t f) const
#define isin(address, start, length)
virtual void GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
Returns numbers of vertices, segments and polygons composing the shape mesh.
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Fills a static 3D buffer and returns a reference.
Generic 3D primitive description class.
virtual void Sizeof3D() const
virtual const char * GetName() const
Get the shape name.
virtual void SetSegsAndPols(TBuffer3D &buff) const
Fill TBuffer3D structure for segments and polygons.
virtual Int_t GetNmeshVertices() const
Return number of vertices of the mesh representation.
virtual void InspectShape() const
Prints shape parameters.
R__EXTERN TGeoManager * gGeoManager
virtual void FillBuffer3D(TBuffer3D &buffer, Int_t reqSections, Bool_t localFrame) const
Fills the supplied buffer, with sections in desired frame See TBuffer3D.h for explanation of sections...
Int_t DistToHype(const Double_t *point, const Double_t *dir, Double_t *s, Bool_t inner, Bool_t in) const
Compute distance from an arbitrary point to inner/outer surface of hyperboloid.
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
Compute normal to closest surface from POINT.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
Int_t ShapeDistancetoPrimitive(Int_t numpoints, Int_t px, Int_t py) const
Returns distance to shape primitive mesh.
const char * GetPointerName() const
Provide a pointer name containing uid.
void SetShapeBit(UInt_t f, Bool_t set)
Equivalent of TObject::SetBit.
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0) const
Compute distance from inside point to surface of the hyperboloid.
Bool_t TestShapeBit(UInt_t f) const
virtual Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi) const =0
virtual void GetBoundingCylinder(Double_t *param) const
— Fill vector param[4] with the bounding cylinder parameters.
virtual void ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
Compute the normal for an array o points so that norm.dot.dir is positive Input: Arrays of point coor...
Double_t Sqrt(Double_t x)
Long64_t LocMin(Long64_t n, const T *a)
virtual void DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t *step) const
Compute distance from array of input points having directions specisied by dirs. Store output in dist...
double norm(double *x, double *p)
Double_t RadiusHypeSq(Double_t z, Bool_t inner) const
Compute r^2 = x^2 + y^2 at a given z coordinate, for either inner or outer hyperbolas.
unsigned int r2[N_CITIES]
virtual void Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
Compute safe distance from each of the points in the input array.
Bool_t SectionsValid(UInt_t mask) const
virtual void Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
Check the inside status for each of the points in the array.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.