I am a beginner to ROOT, hence my experience is quite limited and I have a general question on geometry objects.
Assuming two (or even more) gdml files describing different parts of a geometry - is there a way within ROOT to merge them and write out a top-level gdml file holding all information from the single files?
Any help and information is highly appreciated!
Thanks
std::vector<std::string> listOfGDMLFiles;
// -> fill the list with files
TGeoManager *geom = new TGeoManager("gometry from many files", "");
TGeoVolume *topVolume = nullptr;
TGDMLParse parser;
for (auto file : listOfGDMLFiles) {
TGeoVolume *top = parser.GDMLReadFile(file.c_str());
if (top) topVolume = top;
}
if (topVolume) {
geom->SetTopVolume(topVolume);
geom->CloseGeometry();
}
Never tested, but there is hope that this might work. At least one of the gdml files should define the world volume, otherwise it has to be set by hand. The assumption is that the gdml files are complementary, i.e. if you would concatenate them the Import should work.
Let me know if there are issues.
Thanks a lot for the quick reply! I could actually execute the code above and read in a vector of files. However, I do not yet understand where in this code both gdml files are merged.
And when I use the gGeoManager to plot the result, like