Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

The LCDD geometry needs to be dumped to plain GDML to be loaded by ROOT.

Create the script GDMLROOT.py and put it in $ROOTSYS/gdml. It should contain the following code.Before using ROOT, the environment needs to be setup.

No Format
import sys
import xml.sax
import ROOT
import ROOTBinding
import GDMLContentHandler

ROOT.gSystem.Load("libGeom")

gdmlhandler = GDMLContentHandler.GDMLContentHandler(ROOTBinding.ROOTBinding())

filename = 'test.gdml'
if sys.argv.__len__() > 1:
    filename = sys.argv[1]

xml.sax.parse(filename, gdmlhandler)
geomgr = ROOT.gGeoManager

geomgr.SetTopVolume(gdmlhandler.WorldVolume())
geomgr.CloseGeometry()

geomgr.DefaultColors()

geomgr.SetExplodedView(1)
geomgr.SetBombFactors(5.0,5.0,5.0,5.0)

gdmlhandler.WorldVolume().Draw("ogl")

This command takes a GDML file as its argument. Otherwise, it uses the default of test.gdml.

...

export ROOTSYS=/my/root/dir
cd $ROOTSYS
. $ROOTSYS/bin/thisroot.sh

Assuming that there is a file called test.gdml in the current directory, a script similar to the following will load a plain GDML file into ROOT.

No Format

TGeoManager::Import("test.gdml");
gGeoManager->GetTopVolume()->Draw("ogl");

This command should display the ROOT OpenGL viewer with the geometry from the test.gdml file.

One can customize this by displaying only a particular volume, specified by name, using the following command:

No Format

gGeoManager->GetVolume("VolumeName")->Draw("ogl");

Note that in the gdml file the volume name has a hexadecimal number appended to it. This should be disregarded when specifying the volume name.