Define the placement of a volume

Hello,

Is there a simple way to define the placement of a volume with respect to global reference frame? The manual (TGeoMatrix’s class description) says that it is handled by the manager class, but I do not understand how to do it. Let’s consider this simple piece of code (see attachment, it shows the simplest cace without rotations)

I would like to define a placement of vol2 with respect to totl. I see the only way to do it:

  1. Define a placement of vol1 with respect to totl using translation tr1.
  2. Define the placement of vol2 with respect to vol1 using transltion tr2

But the geometry I’m working with has a deep hierarchy of objects (volumes-inside- volume-inside-volume-etc), and I would like to define a placement of any volume with respect to totl in one step (without care of current volume’s nesting level). How do I do it?
test.C (941 Bytes)

Sorry, but I don’t understand:

totl->AddNode(vol1, 1, tr_x);

??? why placement of vol2 with respect to vol1 ??? why not simple define a placement of vol2 with respect to totl using translation tr2 ?

totl->AddNode(vol2, 1, tr_y);

Jan

[quote=“musinsky”]Sorry, but I don’t understand:
??? why placement of vol2 with respect to vol1 ??? why not simple define a placement of vol2 with respect to totl using translation tr2 ?

totl->AddNode(vol2, 1, tr_y);

[/quote]
Because tr_y is given to me with respect to vol1 but not totl and I have no idea how to get translation of vol1 with respect to totl using the same way as show in the script.

did yuo mean vol2 with respect to totl …

append this lines at end of your test.C:

gGeoManager->cd("/Totl_1/Box_1/Sphere_1");
Double_t *tr21 = gGeoManager->GetCurrentMatrix()->GetTranslation();
cout << "sphere in totl: " << tr21[0] << ' ' << tr21[1] << ' ' << tr21[2] << endl;

tr21 is translation of vol2 with respect to totl: