How to get shape parameters of TGeoSomething?

I write, for instance:

TGeoVolume *box = gGeoManager->MakeBox(...)
TGeoSphere *sphere = gGeoManager->MakeSphere(...)

How do I get the shape parameters (dx, dy and dz for box; rmin, rmax and angles for sphere) of these objects?

See root.cern.ch/root/htmldoc/TGeoSphere.html

Hello.

[quote]I write, for instance:

TGeoVolume *box = gGeoManager->MakeBox(...)
TGeoSphere *sphere = gGeoManager->MakeSphere(...)

How do I get the shape parameters (dx, dy and dz for box; rmin, rmax and angles for sphere) of these objects?[/quote]

I guess, you mean

TGeoVolume *vol = gGeoManager->MakeSphere(...)

You can get shape by

TGeoSphere *sphere = (TGeoSphere*)vol->GetShape();

Now :

sphere->GetRmin() etc.

Thank Valeri, thanks tpochep. Actually, I did not formulare my problem properly in my first post. The point is that I have a geometry which contains many TGeoVolume obects. I’d like to loop over these objects and guess the shape of each volume. As for now, I’ve solved it by means of TGeoShape::TestShapeBit method:

[code]TIter nextv(gGeoManager->GetListOfVolumes());

while (TGeoVolume vol = (TGeoVolume)nextv()) {
TIter nextn(vol->GetNodes());
while (TGeoNode node = (TGeoNode)nextn()) {
TGeoVolume vol1 = node->GetVolume();
if (vol1->GetShape()->TestShapeBit(TGeoShape::kGeoSph) == kTRUE)
{ /
this is a shpere /}
else if (vol1->GetShape()->TestShapeBit(TGeoShape::kGeoBox) == kTRUE))
{/
this is a box */}
}
}[/code]
This code seems to work fine now. Anyway, thank you…

[quote=“kbat”]Thank Valeri, thanks tpochep. Actually, I did not formulare my problem properly in my first post. The point is that I have a geometry which contains many TGeoVolume obects. I’d like to loop over these objects and guess the shape of each volume and its parameters. As for now, I’ve solved it by means of TGeoShape::TestShapeBit method:

[code]TIter nextv(gGeoManager->GetListOfVolumes());

while (TGeoVolume vol = (TGeoVolume)nextv()) {
TIter nextn(vol->GetNodes());
while (TGeoNode node = (TGeoNode)nextn()) {
TGeoVolume vol1 = node->GetVolume();
if (vol1->GetShape()->TestShapeBit(TGeoShape::kGeoSph) == kTRUE)
{ /
this is a shpere, get its parameters /}
else if (vol1->GetShape()->TestShapeBit(TGeoShape::kGeoBox) == kTRUE))
{/
this is a box, get its parameters */}
}
}[/code]
This code seems to work fine now. Anyway, thank you…[/quote]

You can use the method TObject::ClassName()
root.cern.ch/root/htmldoc/TObjec … :ClassName

See the code below (from qtgl package).

[code]#define GEOSHAPE(shapeCode)
( shape->IsA() == (NAME2(T,shapeCode)::Class() ) ) { t=MakeShape(*(NAME2(T,shapeCode *))shape,rgba); }

TObject3DView *TObject3DViewFactory::MakeShape(const TGeoShape *shape,const Float_t *rgba) {
TObject3DView *t = 0;
if (shape) {

       if GEOSHAPE(GeoPara)
  else if GEOSHAPE(GeoBBox)
  else if GEOSHAPE(GeoParaboloid)
  else if GEOSHAPE(GeoTorus)
  else if GEOSHAPE(GeoHype)
  else if GEOSHAPE(GeoXtru)
  else if GEOSHAPE(GeoSphere)
  else if GEOSHAPE(GeoTube)
  else if GEOSHAPE(GeoTubeSeg)
  else if GEOSHAPE(GeoCone)
  else if GEOSHAPE(GeoConeSeg)
  else if GEOSHAPE(GeoPcon)
  else if GEOSHAPE(GeoPgon)
  else if GEOSHAPE(GeoArb8)
  else if GEOSHAPE(GeoEltu)
  else if GEOSHAPE(GeoTrap)
  else if GEOSHAPE(GeoCtub)
  else if GEOSHAPE(GeoTrd1)
  else if GEOSHAPE(GeoTrd2)
  else if GEOSHAPE(GeoGtra);

}
return t;
}[/code]

Where the TObject3DViewFactory.h header file contains the interfaces as follows

[code] //________________________________________________________________
//
// Make the TGeoShape
//________________________________________________________________
TObject3DView *MakeShape(const TGeoBBox &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoPara &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTube &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTubeSeg &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoCone &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoConeSeg &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoPcon &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoPgon &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoEltu &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTrap &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoCtub &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTrd1 &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTrd2 &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoSphere &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoGtra &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoArb8 &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoTorus &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoHype &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoXtru &shp, const Float_t *rgba);
TObject3DView *MakeShape(const TGeoParaboloid &shp, const Float_t *rgba);

TObject3DView *MakeShape(const TGeoShape *shape, const Float_t *rgba);[/code]