Problem when accesing volume daughters through specific TGeoNode

I have the following geometry architecture
the code is pretty complex , I am trying to simplify it here

Level 0: TGeoVolume* topVolume
.TGeoNode* topToMiddle_0, TGeoNode* topToMiddle_1
Level 1: TGeoVolume* middleVolume
TGeoNode* middleToBottom_0
Level 2: TGeoVolume* bottomVolume

  • I am adding daughters to bottomVolume

-Later in the code I can see and access these daughters from bottomVolume, when going through TGeoNode* topToMiddle_0,

however, when going through TGeoNode topToMiddle_1,
then bottomVolume shows that it has no daughters.

Any ideas how is this possible? I am absolutely lost…

Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

Thanks for reaching out. Sorry to read you encountered this difficulty. I am adding in the loop @agheata who could have concrete suggestions.

Best,
Danilo

Thanks,

a short update

  • I get as input a root file from MC simulation

  • then when I read it (blackbox script), I should get the geometry structure described in my first post

  • this I am modifying by adding daughters to bottomVolume

  • I found out, that when having MC simulation file with Geant3 everything works as it should work.

  • The described behavior occurs, when running MC simulation with Geant4 - and I just found out, that it is because bottomVolume is now not unique. For some reason I now get two bottomVolume’s instead of a single one.

Summary:

  • for Geant3 TGeoManager::fUniqueVolumes and TGeoManager::fVolumes have both 1 member named bottomVolume
  • for Geant4 TGeoManager::fUniqueVolumes has 1 member named bottomVolume, and TGeoManager::fVolumes has now 2 members named bottomVolume

Any idea why this can happen?

Volumes get copied if misalignment is used. All volumes in the alignable physical node path are cloned to be moved independently. Please check if any misalignment is involved. On the other hand, if you add daughters in a closed geometry, do not expect navigation to work out of the box, without some operations done when closing a geometry.

Thanks for the reply @agheata,

I redesigned my program a bit to better isolate the problem, now I have:

Level 0: TGeoVolume* topVolume

branch 0
TGeoNode* topToMiddle_0
Level 1: TGeoVolume* middleVolume_0
TGeoNode* middleToBottom_0
Level 2: TGeoVolume* bottomVolume_0

branch 1
TGeoNode* topToMiddle_1
Level 1: TGeoVolume* middleVolume_1
TGeoNode* middleToBottom_1
Level 2: TGeoVolume* bottomVolume_1

I do:

TGeoVolume *currVol = gGeoManager->GetVolume(“bottomVolume_0”)
currVol->AddNode(…);
TGeoVolume *currVol = gGeoManager->GetVolume(“bottomVolume_1”)
currVol->AddNode(…);

std::cout << "Nodes_0: " << gGeoManager->GetVolume(“bottomVolume_0”)->GetNdaughters() << std::endl;
std::cout << "Nodes_1: " << gGeoManager->GetVolume(“bottomVolume_1”)->GetNdaughters() << std::endl;

This prints 1 and 1 (works ok for Geant3 and Geant 4)

Now, when I do:
TGeoVolume * tVolume = gGeoManager->GetTopVolume();
TObjArray* nodes = tVolume->GetNodes();
int nodesNumber = nodes->GetEntriesFast();
for (int i=0; i<nodesNumber; ++i)
{
TGeoNode* middleNode = (TGeoNode* )(nodes->UncheckedAt(i));
TGeoNode* bottomNode = middleNode->GetDaughter(0);
std::cout << “Nodes_” << i << ": " << bottomNode->GetNdaughters() << std::endl;
}

This prints 1 and 0 for Geant4.

For Geant3 everything works fine.

What am I missing here?

EDIT: I kinda fixed this behavior by
middleToBottom_1->SetVolume(gGeoManager->GetVolume(“bottomVolume_1_Name”));

…but I still have no idea why it occurs, the primary suspect is Geant4 and its handling of geometry…

The top volume may change during some operations, like volume->Draw. The original top volume defined can be accessed with GetMasterVolume. Also, getting a volume by name only returns just the first volume with that name. Why don’t you print also the pointers of the volumes to see if they are unique/those you expect. Better, send the geometries and a script reproducing the problem.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.