Visualisation of Geometries


With ROOT you can visualize complex geometries, for example the ones of the LHC experiments or the one of a space station. In this notebook we will read a geometry from a ROOT file and display it. The possibility to save and resume geometries persisted on disk is a powerful feature as it avoids all the complex calculations behind the construction of a geometry from scratch, e.g. from a CAD or XML file.

In [1]:
%%python
inputFileName = 'spaceStation.root'
import os
if not os.path.exists(inputFileName):
    import urllib2
    response = urllib2.urlopen('https://raw.githubusercontent.com/dpiparo/swanExamples/master/notebooks/spaceStation.root')
    filecontent = response.read()   
    with open(inputFileName,"w") as f_out:
        f_out.write(filecontent)
In [2]:
TGeoManager::Import("spaceStation.root");
Info in <TGeoManager::Import>: Reading geometry from file: spaceStation.root
Info in <TGeoManager::CloseGeometry>: Geometry loaded from file...
Info in <TGeoManager::SetTopVolume>: Top volume is top. Master volume is top
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CountLevels>: max level = 1, max placements = 645
Info in <TGeoManager::CloseGeometry>: 0 nodes/ 645 volume UID's in Space Station
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------

We now get the top volume of the geometry to which all volumes are attached and draw it. The visualisation is interactive Rotate and zoom it with your mouse!

In [3]:
auto topVolume = gGeoManager->GetTopVolume();
topVolume->Draw();
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1