Virtual Geometry Model

Virtual Geometry Model (VGM) is a geometry conversion tool, actually providing conversion between Geant4 and ROOT TGeo geometry models. Its design allows inclusion of another geometry model by implementing a single sub-module instead of writing bilateral converters for all already supported models.

The reference paper: I. Hrivnacova et al 2008 J. Phys.: Conf. Ser. 119 042016 .

Introduction

The Virtual Geometry Model (VGM) has been developed as a generalization of the existing convertors roottog4, g4toxml provided within Geant4 VMC , when new directions: g4toroot, roottoxml were asked by users. Instead of adding other bilateral converters and multiplying the implementations, the abstract layer to geometry has been defined and the geometry models have been "mapped" to this generalized scheme. Once this is done, the geometry objects in different models can be handled in the same way.

In the VGM, abstract interfaces to geometry objects and an abstract factory for geometry construction, import and export are introduced. The interfaces to geometry objects were defined with the intention to be suitable for desription of "geant-like" geometries with a hierarchical volume structure.

The implementation of the VGM for a concrete geometry model represents a layer between the VGM and the particular native geometry. At present this implementation is provided for the Geant4 , and Root TGeo geometry models.

Using the VGM factory, geometry can first be defined independently from a concrete geometry model, and then built by choosing a concrete instantiation of it. Alternatively, the import function of the VGM factory makes it possible to use VGM directly with native geometries (Geant4, TGeo). The export functions provide conversion into other native geometries or the XML format.

To port a new geometry model, then providing the VGM layer for it is sufficient to obtain all the converters between this third geometry and already ported geometries (Geant4, Root, XML AGDD, GDML).

Download

The VGM is distributed at SourceForge .

To download the last tagged version (4.4):
svn co http://svn.code.sf.net/p/vgm/code/tags/v4-4 vgm.4.4
Tested with Root 5.34/36 and 6.08/04, Geant4 10.03 (with embedded CLHEP 2.3.4.3)

To download the development version:
svn co http://svn.code.sf.net/p/vgm/code/trunk/vgm vgm
Tested with Root 5.34/36 and 6.08/04, Geant4 10.03 (with embedded CLHEP 2.3.4.3)

See also a description of changes in the history file, previous version(s) are available from the SourceForge SVN page .

Tar files:

Version 4.3

vgm.4.3.tar.gz

Tested with ROOT 5.34/26 and 6.02/02,
Geant4 10.01.p02 (with embedded CLHEP 2.2.4.1

Version 4.2

vgm.4.2.tar.gz

Tested with ROOT 5.34/23 and 6.02/01,
Geant4 10.00.p03 (with embedded CLHEP 2.1.4.1)

Version 3.06

vgm.3.06.tar.gz

Tested with ROOT 5.34/03
Geant4 9.6 (with embedded CLHEP 2.1.3.1)
and 9.5.p02 (with embedded CLHEP 2.1.1.0)

Installation, Examples

Since version 4.0, only CMake build system is supported. The installation and testing procedures for this system are described in detail in vgm/doc/INSTALL.

The CMT and Autoconf build systems are removed (for maintenance reasons) and , GNUmake build system is temporarily kept as deprecated.

As the test program (being written for the purpose of testing of all features) is too complex, four simple examples demonstrating use of VGM for converting native geometries are provided in vgm/examples. The instructions how to build and run these examples are included in the README file in each example.

Geometry conversions

To convert native geometry from one geometry model to another, the geometry has to be first imported in the VGM (the native geometry objects are mapped to the VGM interfaces) using the concrete VGM factory for this geometry model, and then exported using the VGM factory for the other geometry model.

To convert Geant4 geometry in Root:

                                                  
 #include "Geant4GM/volumes/Factory.h" 
 #include "RootGM/volumes/Factory.h" 
 #include "TGeoManager.h"                               
                                                        
 // Import Geant4 geometry to VGM                       
 Geant4GM::Factory g4Factory;
 g4Factory.Import(physiWorld);                          
      // where physiWorld is of G4VPhysicalVolume* type 

 // Export VGM geometry to Root                         
 RootGM::Factory rtFactory;
 g4Factory.Export(&rtFactory);
 gGeoManager->CloseGeometry();
 return rtFactory.World();                              
      // returns Root top node, of TGeoNode* type       
 

The geometry conversions between Geant4 and Root geometry models are demonstrated in provided examples E01 and E02.

Since version 4.4, it is also to use VGM to convert a single solid from one geometry model into another one:

  XFactory xFactory;
  YFactory yFactory;
  xFactory.Import(xsolid);
  xFactory.Export(yFactory);
  YSolid* ysolid = yFactory.Solid();                    

Geometry construction via VGM

The VGM interfaces can be used to define geometry independently from a concrete geometry model.
For example, the code below builds a world box volume:

                                                    
 #include "VGM/volumes/IFactory.h"
 #include "ClhepVGM/transform.h"
 using namespace VGM;

 MyDetectorConstruction::Construct(VGM::IFactory* factory)
 {                                                    
   double wSize = 10*m;
   GISolid* worldS
     = factory->CreateBox("worldS", wSize, wSize, wSize); 
                // create the world solid                 		

   GIVolume* worldV
     = factory->CreateVolume("worldV", worldS, "Air");    
                // create the world volume                

   factory->CreatePlacement("world", 0, worldV, 0, ClhepVGM::Identity());
                // place the world volume                 
 }    
 
Choosing the concrete factory (Geant4 or Root VGM factory) will then build the geometry of the chosen model ( Geant4 or Root):
                                                    
 #include "Geant4GM/volumes/Factory.h"
 MyDetectorConstruction myDetectorConstruction;
 Geant4GM::Factory theFactory;
 myDetectorConstruction->Construct(&theFactory);          
         // Geant4 geometry will be built                 	
 
 #include "RootGM/volumes/Factory.h"
 MyDetectorConstruction myDetectorConstruction;
 RootGM::Factory theFactory;
 myDetectorConstruction->Construct(&theFactory);          
         // Root geometry will be built                   
 

XML

The VGM geometry can be exported to XML in the AGDD or GDML format. The complying with the XML schema is embedded in the VGM XML exporter code itself, no external XML parser is then needed.

                                                    
 #include "XmlVGM/AGDDExporter.h"
 XmlVGM::AGDDExporter xmlExporter1(&theFactory);
 xmlExporter1.GenerateXMLGeometry();                      
      // Export geometry to AGDD                           
                                                        
 #include "XmlVGM/GDMLExporter.h"
 XmlVGM::GDMLExporter xmlExporter2(&theFactory);
 xmlExporter2.GenerateXMLGeometry();                       
      // Export geometry to GDML                          
 
The export from native geometries (Geant4, Root) to XML is demonstrated in examples E03 and E04. The exported XML files (both AGDD and GDML) can be then viewed with the GraXML tool .

Options

Debug

Debug printing can be switched on via VGM::IFactory::SetDebug function:

                                                    
 IFactory& myFactory;                                     
 myFactory.SetDebug(n);                                   
      // where n=1 or 2; if 2 also object adresses are printed  
 

Ignore

If geometry imported in VGM includes some solid not supported in VGM (eg. a user defined solid in Geant4), then VGM prints a warning and stops. It is however possible to let VGM continue by setting the option "Ignore" to the factory importing the geometry:

                                                    
 IFactory& myFactory;                                     
 myFactory.SetIgnore(true);                               
 

Source code documentation

Source code documentation has been generated from the source code by Doxygen .

Platforms

Tested platform: Mac OSX 10.11.5: with Apple LLVM version 7.3.0


Publications

Contact:
Ivana Hrivnacova, IPN Orsay ivana@ipno.in2p3.fr

Last update: 06/02/2017