TGeoNode from TGeoVolume

Hello (Andrei),
Thanks for the patience that you have shown with my many queries
recently. I am approaching the end of my present task, and had one
more question.
After constructing a TGeoVolume, adding it to a complete geometry
and closing it, is there a way to obtain the TGeoNode associated with
the volume, or a way to obtain the mother volume? Or is it up to the
user to have knowledge of the path to the volume?


Hi Gora,

You need to have in mind that a TGeoNode represents a positioned TGeoVolume. Therefore, for a given volume you might have several TGeoNodes that are not necessary positioned in the same mother volume. Due to this, there is no way to go from a volume to its associated TGeoNode, nor to its mother volume. A TGeoVolume is a logical hierarchy structure that cannot store the information about its position - otherwise it would not be replicable any more.

In the same way, a TGeoNode does not give you full information of the way the associated object is positioned in the geometry, but only with respect to its mother. In other words, having a TGeoNode pointer does not mean : “OK, I can put my hand on this object” - there might be several of them since their container can be replicated in the geometry. The full information is available only when you specify the path to a given node, e.g.: TOP_1/A_2/B_5
You can do this either by enforcing it explicitly:


or by performing the “Where am I ?” query for a given point:


Only after that you can ask for instance which is the mother of the current volume:

TGeoNode *TGeoManager::GetMother(Int_t nlevel_up=1)

For performance reasons there is no class representing the current “touchable” object - in a real detector geometry you might have up to 1 billion such objects that obviously cannot fit to memory and creating/destroying them on the flight would be a disaster during navigation.

On the other hand, when you navigate a geometry all this information can be retreived. For instance, if you need to know the exact position of the current “touchable” node, after a “where am I?” for instance, you just have to do:

   TGeoHMatrix *current_global_matrix = gGeoManager->GetCurrentMatrix();

or if you want to convert a point from MARS to the local frame directly:

gGeoManager->MasterToLocal(Double_t *master_point, Double_t *local_point);

Sorry for these quite long explanations that in some sense are beyond what you have asked for. The short answer to your question is :yes, it is the task of the user to provide additional information related to the object (e.g. path) if this path is not automatically computed by navigation queries.

Hope this helps,