Using ROOT geometry in Geant4

Dear all,

I have been trying to find this particular information, but nothing seems to be clear:

I have a geometry that was created with ROOT via the TGeoManager class and saved in a .root format. I would like to know if it is possible to use that geometry directly (.root) in Geant4? Or do I need to convert it to GDML beforehand?

I found the Virtual Monte Carlo class in ROOT as an interface to Geant4, but it looks like the latest versions of ROOT do not contain that class anymore.

_Geant4 Version: 11.0
_ROOT Version: 6.26
_Operating System: GNU/Linux Debian (conda environment)

Its better if someone else answers but it looks like you need to convert it.
https://root.cern.ch/doc/v614/group__Geometry__gdml.html

1 Like

Hello.

I agree with Jason’s answer - using GDML as the transfer format is the simplest answer, and should suffice for nearly all setups / applications.

The implementations of GDML in Root and Geant4 are well aligned, so I would expect that you will obtain the same setup in Geant4 as what you expect from ROOT.

In addition, I believe that this is the way in which tools such as DD4HEP use to export geometries created in Root to Geant4. So you would be treading a well worn path.

1 Like

You might consider in-memory conversion using the VGM tool

2 Likes

Thanks a lot for help.

It’s really not a problem in my code. It’s just that ROOT stores the geometry in a nice format (.root), where you can see the full tree of objects and such. But it’s really just a matter of changing my code from gGeoManager->Export(geom.root); to gGeoManager->Export(geom.gdml);, and I can later store the gdml file inside a ROOT file.

Thanks again.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.