Geant4 Geometry Objects Persistency

Simulation Framework

General Information

The aim of this activity is to provide object persistency for Geant4 geometry using ROOT/Core. The approach is to use lcgdict tool to create Reflex dictionnary for the Geant4 classes. Using Cintex tool, that dictionary can then be loaded into ROOT (CINT) and the corresponding objects can be persistified (saved in the .root file).

Technical aspects

There are certain technical requirements and limitation concerning the objects we want to provide persistency for. We will discuss them one by one. You can also have a look at the list of my diffs.

Building the application

In order to be able to save G4 objects one needs to create the Reflex dictionary for them. To do so, the selection file is required. It is basically a list of all the classes we want to create the dictionary for. The additional role of the selection file is to specify whether we want to leave any members of some classes transient. This can be, for instance, the case for the pointer to the field manager in G4LogicalVolume class. The actual generation of the dictionary is, in our case, performed automaticaly by the makefile (see the target with 'lcgdict' comand).

Running the application

The file geoWriter.C contains an example application which saves the Geant4 geometry in a ROOT file. It first loads the G4 geometry into memory using GDML->G4 converter (it reads geo.gdml file). Once the G4 geometry tree is in memory, ROOT I/O is called to save it into a .root file. It is worth pointing out here, that a simple 'wrapper' class GeoTree has been introduced just to force saving the static element and material tables.
This example has been implemented in the form of CINT script. It would be equally trivial, however, to write it in C++ as a simple plugin for any G4 simulation application.

To read the .root file, there has been DetConstrReader implemented. It is just a standard G4VUserDetectorConstruction-derived class, with the actuall 'construction' part replaced by a call to ROOT I/O reading the file. The 'main' G4 application (g4rootrun.cpp) uses this detector construction in a 'transparent' way, i.e. without realizing that the geometry is read from a file.

Code Repository


Contact: Witek Pokorski