library: libGeom
#include "TGeoTube.h"

TGeoTube


class description - header file - source file - inheritance tree (.pdf)

class TGeoTube : public TGeoBBox

Inheritance Chart:
TObject
<-
TNamed
<-
TGeoShape
<-
TGeoBBox
<-
TGeoTube
<-
TGeoEltu
TGeoHype
TGeoTubeSeg
<-
TGeoCtub

    public:
TGeoTube() TGeoTube(Double_t rmin, Double_t rmax, Double_t dz) TGeoTube(const char* name, Double_t rmin, Double_t rmax, Double_t dz) TGeoTube(Double_t* params) TGeoTube(const TGeoTube&) virtual ~TGeoTube() virtual Double_t Capacity() const static Double_t Capacity(Double_t rmin, Double_t rmax, Double_t dz) static TClass* Class() virtual void ComputeBBox() virtual void ComputeNormal(Double_t* point, Double_t* dir, Double_t* norm) static void ComputeNormalS(Double_t* point, Double_t* dir, Double_t* norm, Double_t rmin, Double_t rmax, Double_t dz) virtual Bool_t Contains(Double_t* point) const virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) virtual Double_t DistFromInside(Double_t* point, Double_t* dir, Int_t iact = 1, Double_t step = TGeoShape::Big(), Double_t* safe = 0) const static Double_t DistFromInsideS(Double_t* point, Double_t* dir, Double_t rmin, Double_t rmax, Double_t dz) virtual Double_t DistFromOutside(Double_t* point, Double_t* dir, Int_t iact = 1, Double_t step = TGeoShape::Big(), Double_t* safe = 0) const static Double_t DistFromOutsideS(Double_t* point, Double_t* dir, Double_t rmin, Double_t rmax, Double_t dz) static void DistToTube(Double_t rsq, Double_t nsq, Double_t rdotn, Double_t radius, Double_t& b, Double_t& delta) virtual TGeoVolume* Divide(TGeoVolume* voldiv, const char* divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step) virtual const char* GetAxisName(Int_t iaxis) const virtual Double_t GetAxisRange(Int_t iaxis, Double_t& xlo, Double_t& xhi) const virtual void GetBoundingCylinder(Double_t* param) const virtual const TBuffer3D& GetBuffer3D(Int_t reqSections, Bool_t localFrame) const virtual Int_t GetByteCount() const virtual Double_t GetDz() const virtual TGeoShape* GetMakeRuntimeShape(TGeoShape* mother, TGeoMatrix* mat) const virtual Int_t GetNmeshVertices() const virtual Double_t GetRmax() const virtual Double_t GetRmin() const Bool_t HasRmin() const virtual void InspectShape() const virtual TClass* IsA() const virtual Bool_t IsCylType() const virtual TBuffer3D* MakeBuffer3D() const TGeoTube& operator=(const TGeoTube&) virtual Double_t Safety(Double_t* point, Bool_t in = kTRUE) const static Double_t SafetyS(Double_t* point, Bool_t in, Double_t rmin, Double_t rmax, Double_t dz, Int_t skipz = 0) virtual void SavePrimitive(ostream& out, Option_t* option = "") virtual void SetDimensions(Double_t* param) virtual void SetPoints(Double_t* points) const virtual void SetPoints(Float_t* points) const virtual void SetSegsAndPols(TBuffer3D& buff) const void SetTubeDimensions(Double_t rmin, Double_t rmax, Double_t dz) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Sizeof3D() const virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members


    protected:
Double_t fRmin inner radius Double_t fRmax outer radius Double_t fDz half length

Class Description

_____________________________________________________________________________
 TGeoTube - cylindrical tube class. It takes 3 parameters :
            inner radius, outer radius and half-length dz.

_____________________________________________________________________________
























_____________________________________________________________________________
 TGeoTubeSeg - a phi segment of a tube. Has 5 parameters :
            - the same 3 as a tube;
            - first phi limit (in degrees)
            - second phi limit

_____________________________________________________________________________












_____________________________________________________________________________
 TGeoCtub - a tube segment cut with 2 planes. Has 11 parameters :
            - the same 5 as a tube segment;
            - x, y, z components of the normal to the -dZ cut plane in
              point (0, 0, -dZ);
            - x, y, z components of the normal to the +dZ cut plane in
              point (0, 0, dZ);

_____________________________________________________________________________
TGeoTube()
 Default constructor
TGeoTube(Double_t rmin, Double_t rmax, Double_t dz)
 Default constructor specifying minimum and maximum radius
TGeoTube(const char *name, Double_t rmin, Double_t rmax, Double_t dz)
 Default constructor specifying minimum and maximum radius
TGeoTube(Double_t *param)
 Default constructor specifying minimum and maximum radius
 param[0] = Rmin
 param[1] = Rmax
 param[2] = dz
~TGeoTube()
 destructor
Double_t Capacity()
 Computes capacity of the shape in [length^3]
Double_t Capacity(Double_t rmin, Double_t rmax, Double_t dz)
 Computes capacity of the shape in [length^3]
void ComputeBBox()
 compute bounding box of the tube
void ComputeNormal(Double_t *point, Double_t *dir, Double_t *norm)
 Compute normal to closest surface from POINT.
void ComputeNormalS(Double_t *point, Double_t *dir, Double_t *norm, Double_t /*rmin*/, Double_t /*rmax*/, Double_t /*dz*/)
{
 Compute normal to closest surface from POINT.
norm[2] = 0;
Double_t phi = TMath::ATan2(point[1], point[0]);
norm[0] = TMath::Cos(phi);
norm[1] = TMath::Sin(phi);
if (norm[0]*dir[0]+norm[1]*dir[1]<0) {
norm[0] = -norm[0];
norm[1] = -norm[1];
}
}

_____________________________________________________________________________
Bool_t TGeoTube::Contains(Double_t *point) const
{
 test if point is inside this tube
if (TMath::Abs(point[2]) > fDz) return kFALSE;
Double_t r2 = point[0]*point[0]+point[1]*point[1];
if ((r2<fRmin*fRmin) || (r2>fRmax*fRmax)) return kFALSE;
return kTRUE;
}

_____________________________________________________________________________
Int_t TGeoTube::DistancetoPrimitive(Int_t px, Int_t py)
{
 compute closest distance from point px,py to each corner
Int_t n = gGeoManager->GetNsegments();
Int_t numPoints = 4*n;
if (!HasRmin()) numPoints = 2*(n+1);
return ShapeDistancetoPrimitive(numPoints, px, py);
}

_____________________________________________________________________________
Double_t TGeoTube::DistFromInsideS(Double_t *point, Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
{
 Compute distance from inside point to surface of the tube (static)
 Boundary safe algorithm.
 compute distance to surface
 Do Z
Double_t sz = TGeoShape::Big();
if (dir[2]) {
sz = (TMath::Sign(dz, dir[2])-point[2])/dir[2];
if (sz<=0) return 0.0;
}
 Do R
Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
if (TMath::Abs(nsq)<TGeoShape::Tolerance()) return sz;
Double_t rsq=point[0]*point[0]+point[1]*point[1];
Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
Double_t b,d;
Double_t sr = TGeoShape::Big();
 inner cylinder
if (rmin>0) {
 Protection in case point is actually outside the tube
if (rsq <= rmin*rmin+TGeoShape::Tolerance()) {
if (rdotn<0) return 0.0;
} else {
if (rdotn<0) {
DistToTube(rsq,nsq,rdotn,rmin,b,d);
if (d>0) {
sr=-b-d;
if (sr>0) return TMath::Min(sz,sr);
}
}
}
}
 outer cylinder
if (rsq >= rmax*rmax-TGeoShape::Tolerance()) {
if (rdotn>=0) return 0.0;
}
DistToTube(rsq,nsq,rdotn,rmax,b,d);
if (d>0) {
sr=-b+d;
if (sr>0) return TMath::Min(sz,sr);
}
return 0.;
}

_____________________________________________________________________________
Double_t TGeoTube::DistFromInside(Double_t *point, Double_t *dir, Int_t iact, Double_t step, Double_t *safe) const
{
 Compute distance from inside point to surface of the tube
 Boundary safe algorithm.
if (iact<3 && safe) {
*safe = Safety(point, kTRUE);
if (iact==0) return TGeoShape::Big();
if ((iact==1) && (*safe>step)) return TGeoShape::Big();
}
 compute distance to surface
return DistFromInsideS(point, dir, fRmin, fRmax, fDz);
}

_____________________________________________________________________________
Double_t TGeoTube::DistFromOutsideS(Double_t *point, Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
{
 Static method to compute distance from outside point to a tube with given parameters
 Boundary safe algorithm.
 check Z planes
Double_t xi,yi,zi;
Double_t rmaxsq = rmax*rmax;
Double_t rminsq = rmin*rmin;
zi = dz - TMath::Abs(point[2]);
Double_t s = TGeoShape::Big();
Bool_t in = kFALSE;
Bool_t inz = (zi<0)?kFALSE:kTRUE;
if (!inz) {
if (point[2]*dir[2]>=0) return TGeoShape::Big();
s  = -zi/TMath::Abs(dir[2]);
xi = point[0]+s*dir[0];
yi = point[1]+s*dir[1];
Double_t r2=xi*xi+yi*yi;
if ((rminsq<=r2) && (r2<=rmaxsq)) return s;
}

Double_t rsq = point[0]*point[0]+point[1]*point[1];
 check outer cyl. surface
Double_t nsq=dir[0]*dir[0]+dir[1]*dir[1];
Double_t rdotn=point[0]*dir[0]+point[1]*dir[1];
Double_t b,d;
Bool_t inrmax = kFALSE;
Bool_t inrmin = kFALSE;
if (rsq<=rmaxsq+TGeoShape::Tolerance()) inrmax = kTRUE;
if (rsq>=rminsq-TGeoShape::Tolerance()) inrmin = kTRUE;
in = inz & inrmin & inrmax;
 If inside, we are most likely on a boundary within machine precision.
if (in) {
Bool_t checkout = kFALSE;
Double_t r = TMath::Sqrt(rsq);
if (zi<rmax-r) {
if ((rmin==0) || (zi<r-rmin)) {
if (point[2]*dir[2]<0) return 0.0;
return TGeoShape::Big();
}
}
if ((rmaxsq-rsq) < (rsq-rminsq)) checkout = kTRUE;
if (checkout) {
if (rdotn>=0) return TGeoShape::Big();
return 0.0;
}
if (rmin==0) return 0.0;
if (rdotn>=0) return 0.0;
 Ray exiting rmin -> check (+) solution for inner tube
if (TMath::Abs(nsq)<TGeoShape::Tolerance()) return TGeoShape::Big();
DistToTube(rsq, nsq, rdotn, rmin, b, d);
if (d>0) {
s=-b+d;
if (s>0) {
zi=point[2]+s*dir[2];
if (TMath::Abs(zi)<=dz) return s;
}
}
return TGeoShape::Big();
}
 Check outer cylinder (only r>rmax has to be considered)
if (TMath::Abs(nsq)<TGeoShape::Tolerance()) return TGeoShape::Big();
if (!inrmax) {
DistToTube(rsq, nsq, rdotn, rmax, b, d);
if (d>0) {
s=-b-d;
if (s>0) {
zi=point[2]+s*dir[2];
if (TMath::Abs(zi)<=dz) return s;
}
}
}
 check inner cylinder
if (rmin>0) {
DistToTube(rsq, nsq, rdotn, rmin, b, d);
if (d>0) {
s=-b+d;
if (s>0) {
zi=point[2]+s*dir[2];
if (TMath::Abs(zi)<=dz) return s;
}
}
}
return TGeoShape::Big();
}

_____________________________________________________________________________
Double_t TGeoTube::DistFromOutside(Double_t *point, Double_t *dir, Int_t iact, Double_t step, Double_t *safe) const
{
 Compute distance from outside point to surface of the tube and safe distance
 Boundary safe algorithm.
 fist localize point w.r.t tube
if (iact<3 && safe) {
*safe = Safety(point, kFALSE);
if (iact==0) return TGeoShape::Big();
if ((iact==1) && (step<=*safe)) return TGeoShape::Big();
}
 find distance to shape
return DistFromOutsideS(point, dir, fRmin, fRmax, fDz);
}

_____________________________________________________________________________
void TGeoTube::DistToTube(Double_t rsq, Double_t nsq, Double_t rdotn, Double_t radius, Double_t &b, Double_t &delta)
{
 Static method computing the distance to a tube with given radius, starting from
 POINT along DIR director cosines. The distance is computed as :
    RSQ   = point[0]*point[0]+point[1]*point[1]
    NSQ   = dir[0]*dir[0]+dir[1]*dir[1]  ---> should NOT be 0 !!!
    RDOTN = point[0]*dir[0]+point[1]*dir[1]
 The distance can be computed as :
    D = -B +/- DELTA
 where DELTA.GT.0 and D.GT.0

Double_t t1 = 1./nsq;
Double_t t3=rsq-(radius*radius);
b          = t1*rdotn;
Double_t c =t1*t3;
delta = b*b-c;
if (delta>0) {
delta=TMath::Sqrt(delta);
} else {
delta = -1;
}
}

_____________________________________________________________________________
TGeoVolume *TGeoTube::Divide(TGeoVolume *voldiv, const char *divname, Int_t iaxis, Int_t ndiv,
Double_t start, Double_t step)
{
--- Divide this tube shape belonging to volume "voldiv" into ndiv volumes
 called divname, from start position with the given step. Returns pointer
 to created division cell volume in case of Z divisions. For radial division
 creates all volumes with different shapes and returns pointer to volume that
 was divided. In case a wrong division axis is supplied, returns pointer to
 volume that was divided.
const char * GetAxisName(Int_t iaxis)
 Returns name of axis IAXIS.
Double_t GetAxisRange(Int_t iaxis, Double_t &xlo, Double_t &xhi)
 Get range of shape for a given axis.
void GetBoundingCylinder(Double_t *param)
--- Fill vector param[4] with the bounding cylinder parameters. The order
 is the following : Rmin, Rmax, Phi1, Phi2, dZ
void InspectShape()
 print shape parameters
TBuffer3D * MakeBuffer3D()
 Creates a TBuffer3D describing *this* shape.
 Coordinates are in local reference frame.
void SetSegsAndPols(TBuffer3D &buffer)
 Fill TBuffer3D structure for segments and polygons.
Double_t Safety(Double_t *point, Bool_t in)
 computes the closest distance from given point to this shape, according
 to option. The matching point on the shape is stored in spoint.
Double_t SafetyS(Double_t *point, Bool_t in, Double_t rmin, Double_t rmax, Double_t dz, Int_t skipz)
 computes the closest distance from given point to this shape, according
 to option. The matching point on the shape is stored in spoint.
void SavePrimitive(ostream &out, Option_t * /*option*/ /*= ""*/)
 Save a primitive as a C++ statement(s) on output stream "out".
void SetTubeDimensions(Double_t rmin, Double_t rmax, Double_t dz)
 Set tube dimensions.
void SetDimensions(Double_t *param)
 Set tube dimensions starting from a list.
void SetPoints(Double_t *points)
 create tube mesh points
void SetPoints(Float_t *points)
 create tube mesh points
Int_t GetNmeshVertices()
 Return number of vertices of the mesh representation
void Sizeof3D()
/// fill size of this 3-D object
/    TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
/    if (!painter) return;
/    Int_t n = gGeoManager->GetNsegments();
/    Int_t numPoints = n*4;
/    Int_t numSegs   = n*8;
/    Int_t numPolys  = n*4;
/    painter->AddSize3D(numPoints, numSegs, numPolys);
const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame)
 Fills a static 3D buffer and returns a reference.
TGeoTube()
 constructors
Bool_t Contains(Double_t *point)
Double_t DistFromInsideS(Double_t *point, Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
Double_t DistFromInside(Double_t *point, Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0)
Double_t DistFromOutsideS(Double_t *point, Double_t *dir, Double_t rmin, Double_t rmax, Double_t dz)
Double_t DistFromOutside(Double_t *point, Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=0)
void DistToTube(Double_t rsq, Double_t nsq, Double_t rdotn, Double_t radius, Double_t &b, Double_t &delta)
Int_t DistancetoPrimitive(Int_t px, Int_t py)
Int_t GetByteCount()
Double_t GetRmin()
Double_t GetRmax()
Double_t GetDz()
Bool_t HasRmin()
Bool_t IsCylType()

Author: Andrei Gheata 24/10/01
Last update: root/geom:$Name: $:$Id: TGeoTube.cxx,v 1.68 2006/07/03 16:10:44 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Class Hierarchy - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.