Problem with reading more than one .gdml file

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version: 11.2.0
Operating System: WSL with Ubuntu 22.04.4 LTS
Compiler/Version: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
CMake Version: cmake version 3.30.0-rc3

Dear community!

I have strange behavior in the program when constructing detector components from a .gdml file.

In the first function, I read the first file, and everything works fine. (This part of the code seems significant for describing the issue.)


This function outputs the names of the daughter volumes from the magnetFull.gdml file.

Then, I call another function, which contains the same lines, but opens secondMagnetYoke.gdml file.

As a result of running this function, I get the message that the secondMagnetYoke.gdml file was read (so far, everything is correct). However, the list of daughter volumes is the same as the one from the previous file.

Meanwhile, if I run only the second function, I get data from the secondMagnetYoke.gdml file.

Can you suggest what might be the problem and how it can be fixed?

I’ve tried to use different names of parser and other objects but it doesn’t case (obviousely)

P.S. Unfortunately, using a single file for both magnets in my case is very inconvenient.