Wim,
I tried out your suggestions, but I can’t get it to work. Here is a minimal working example illustrating my problem:
import sys
import ROOT
ROOT.gSystem.Load('libGeom')
# first ROOT geometry
mgr1 = ROOT.TGeoManager("geom1", "Sphere in Box")
xx_mat = ROOT.TGeoMaterial("MAT2",
mgr1.GetElementTable().GetElement(0),
1)
med1 = ROOT.TGeoMedium("FALLTHROUGH", 1, xx_mat)
med2 = ROOT.TGeoMedium("FALLTHROUGH", 1, xx_mat)
box = mgr1.MakeBox("Box", med1, 4, 4, 4)
sphere = mgr1.MakeSphere("Sphere", med2, 0, 2)
box.AddNode(sphere, 1)
mgr1.SetTopVolume(box)
mgr1.CloseGeometry("")
mgr1.SetTopVisible()
ROOT.gGeoManager = ROOT.MakeNullPointer(ROOT.TGeoManager)
print('gGeoManager={}'.format(ROOT.gGeoManager)); sys.stdout.flush()
print('mgr1={}'.format(mgr1)); sys.stdout.flush()
# second ROOT geometry
mgr2 = ROOT.TGeoManager("geom2", "Box in Box")
xx_mat = ROOT.TGeoMaterial("MAT2",
mgr2.GetElementTable().GetElement(0),
1)
med1 = ROOT.TGeoMedium("Water", 1, xx_mat)
med2 = ROOT.TGeoMedium("FALLTHROUGH", 1, xx_mat)
box = mgr2.MakeBox("BoxOutside", med1, 5, 5, 5)
box2 = mgr2.MakeBox("BoxInside", med2, 3, 3, 3)
box.AddNode(box2, 1)
mgr2.SetTopVolume(box)
mgr2.CloseGeometry("")
mgr2.SetTopVisible()
ROOT.gGeoManager = ROOT.MakeNullPointer(ROOT.TGeoManager)
print('gGeoManager={}'.format(ROOT.gGeoManager)); sys.stdout.flush()
print('mgrs={}, {}'.format(mgr1, mgr2)); sys.stdout.flush()
And here is the output on my machine (Python 3.4.3, ROOT 5.34.30):
Info in <TGeoManager::TGeoManager>: Geometry geom1, Sphere in Box created
Info in <TGeoManager::SetTopVolume>: Top volume is Box. Master volume is Box
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 1, max placements = 1
Info in <TGeoManager::CloseGeometry>: 2 nodes/ 2 volume UID's in Sphere in Box
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
gGeoManager=<ROOT.TGeoManager object at 0x(nil)>
mgr1=<ROOT.TGeoManager object ("geom1") at 0x2511a00>
TGeoManager::Init:0: RuntimeWarning: Deleting previous geometry: geom1/Sphere in Box
Info in <TGeoManager::TGeoManager>: Geometry geom2, Box in Box created
Info in <TGeoManager::SetTopVolume>: Top volume is BoxOutside. Master volume is BoxOutside
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 1, max placements = 1
Info in <TGeoManager::CloseGeometry>: 2 nodes/ 2 volume UID's in Box in Box
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------
gGeoManager=<ROOT.TGeoManager object at 0x(nil)>
mgrs=None, <ROOT.TGeoManager object ("geom2") at 0x27e6640>
As you can see, there is a warning about the first geometry being deleted, and mgr1=None on the last line.
Regards,
Davide