Node at arbitrary point

I am developing a simulation package for the calorimeter. The geometry of the ECAL is not fixed at the moment. I need to determine is the beginning of the given track (not current!) lies inside the calorimeter volume. In TGeoManager there is a method FindNode(Double_t x, Double_t y, Double_t z) which returns the deepest node contains given point. In my case (“shashlik” calorimeter) found node will not be the top calorimeter node. I can’t check is found node is one of daughters of top calorimeter node: to many daughters.
Of course, I can organize names of nodes/volumes in a way, which allows me easy check. But are there more elegant solution?


Typically you have to store the volume id number (for your calorimeter envelope or whatever) when defining it:

Then during tracking, use:

// Check current branch from current node upwards
Bool_t found = kFALSE;
TGeoNode *node = 0;
Int_t imother = 0;
while (!found && (node=gGeoManager->GetMother(imother++))) {
   if (node->GetVolume()->GetNumber()==fCaloId) found=kTRUE;

Alternatively you have to define which are the sensitive volumes inside your calorimeter. These you can also recognize via id or pointer (if using replication) during tracking and generally stay at a constant depth in your calorimeter. Use again GetMother(depth) to identify the parent module.

Hope it helps,

Not much. Problem that I have to determine is track born inside the calorimeter volume not for current track, but for its mother, or mother of mother of current track…

At the end I have decided to use proper names. In any case: this is much faster than tree scaning.