You are here

Installing geant4_vmc

The following instructions apply to the installation since the version 3.0 built against Geant4 10.00.p03. For the installation of the previous versions see Installing geant4_vmc - Old Versions.

Geant4 VMC

Geant4 VMC requires ROOT and Geant4 installed, and optionally, it can be built with VGM. See below tips for configuration and installation of these packages.

Since version 3.00, Geant4 VMC is installed with CMake. To install geant4_vmc:

  1. First get the Geant4 VMC source from the Download page. We will assume that the Geant4 VMC package sits in a subdirectory
  2. Create build directory alongside our source directory
    $ cd /mypath
    $ mkdir geant4_vmc_build
    $ ls
     geant4_vmc geant4_vmc_build    
  3. To configure the build, change into the build directory and run CMake:
    $ cd /mypath/geant4_vmc_build 
    $ cmake -DCMAKE_INSTALL_PREFIX=/mypath/geant4_vmc_install /mypath/geant4_vmc

    If ROOT and Geant4 environment was defined using thisroot.[c]sh and geant4.[c]sh scripts, there is no need to provide path to their installations. Otherwise, they can be provided using -DROOT_DIR and -DGeant4_DIR cmake options.

  4. After the configuration has run, CMake will have generated Unix Makefiles for building Geant4 VMC. To run the build, simply execute make in the build directory:
    $ make -jN
    where N is the number of parallel jobs you require (e.g. if your machine has a dual core processor, you could set N to 2).

    If you need more output to help resolve issues or simply for information, run make as

    $ make -jN VERBOSE=1
  5. Once the build has completed, you can install Geant4 VMC to the directory you specified earlier in CMAKE_INSTALL_PREFIX by running
    $ make install
This will build geant4_vmc, g4root and mtroot packages. For VMC examples see VMC examples installation page .

Geant4 VMC Build Options

Geant4 VMC includes G4Root and MTRoot packages, which are independent from Geant4 VMC and can be build and used stand-alone. Use of G4Root, VGM, Geant4 G3toG4, UI and VIS packages in Geant4 VMC library is optional and can be switched on/off during CMake build.

Overview of available options and their default values:

Geant4VMC_BUILD_G4Root       Build G4Root        ON
Geant4VMC_BUILD_MTRoot       Build MTRoot        ON
Geant4VMC_BUILD_Geant4VMC    Build Geant4VMC     ON
Geant4VMC_BUILD_EXAMPLES     Build VMC examples  ON
Geant4VMC_USE_G4Root         Build with G4Root                ON
Geant4VMC_USE_VGM            Build with VGM                   OFF
Geant4VMC_USE_GEANT4_UI      Build with Geant4 UI drivers     ON
Geant4VMC_USE_GEANT4_VIS     Build with Geant4 Vis drivers    ON
Geant4VMC_USE_GEANT4_G3TOG4  Build with Geant4 G3toG4 library OFF
Geant4VMC_INSTALL_EXAMPLES   Install examples    ON

Required and Optional packages

Geant4 VMC requires ROOT and Geant4 installed, and optionally, it can be built with VGM. See below tips for configuration and installation of these packages.

The path to required and optional packages installations can be defined in these complementary ways:
a) Via path to the CMake configuration file

Geant4_DIR      ... path to Geant4Config.cmake
ROOT_DIR        ... path to ROOTConfig.cmake
VGM_DIR         ... path to VGMConfig.cmake
b) With their configuration script available in your PATH (Geant4 and Root):
geant4-config   ... Geant4 configuration script
root-config     ... Root configuration script
c) With the environment variable ROOTSYS (Root only)
ROOTSYS         ... path to Root
To make the packages configuration scripts available in your PATH, you should source the relevant script from the packages installations (CMAKE_INSTALL_PREFIX or ROOTSYS):
$ . bin/          ... Geant4 - on bourne shells (eg. bash)
$ . bin/        ... Root    
$ source bin/geant4.csh    ... Geant4 - on C shells  
$ source bin/thisroot.csh  ... Root


Geant4 VMC, as well as ROOT and Geant4, have moved to the C++11 standard. The latest versions of all three packages use C++11 by default: Geant4 VMC 3.3, Geant4 10.2 and ROOT 6.

When mixing other versions of Geant4 and ROOT together, the same standard must be used for both packages. See below how the override the default setting when needed.


To install ROOT - follow the Root Installation Page .
  • C++11
    Geant4 VMC 3.3 built against ROOT 5.x requires ROOT built with C++11 (not default for this ROOT version), set via:
    option, when ROOT is built using CMake, or
    option, when ROOT is built using configure script.


To install Geant4 - download the source from Geant4 Download page and follow the Geant4 Installation Guide together with the tips relevant to using it with VMC described below.
  • C++11
    Geant4 VMC 3.0 - 3.2 built against Geant4 10.0.x or 10.1.x and ROOT 6x requires Geant4 built with C++11 (not default for these Geant4 versions), set via:

  • G3toG4 tool
    The G3toG4 package is used in geant4_vmc to support geometry definition via VMC with Geant4 native navigation. The build of G3toG4 package can be activated when building Geant4 with the following CMake options:
    Since Geant4 VMC 3.0 the use of this package is optional.

  • OpenGL visualization
    It is recommended to build Geant4 X11 OpenGL visualization driver used in the VMC examples. It is handled in Geant4 CMake build via the CMake option:

  • Multi-threading
    Geant4 VMC can be built against Geant4 installation in multi-threading mode which is handled in Geant4 CMake build via the CMake option:
    Dynamic loading of Geant4 libraries, as used in VMC, requires to change the Geant4 default TLS model, initial-exec, with global-dynamic via the CMake option:

    Geant4 VMC 3.00.x version is migrated to Geant4 multi-threading and can be built against both Geant4 sequential and Geant4 multi-threading installations. The global-dynamic model is required for running VMC applications from Root session (in a "traditional" way with dynamic loading of libraries). When the VMC application main program is linked with all libraries, Geant4 built with the default TLS model can be used.

    The VMC application will run automatically in MT mode when Geant4 VMC is built against Geant4 MT. See the page on Multi-threaded processing how this default behaviour can be changed in the configuration of the application.

VGM (optional)

VGM is used in Geant4 VMC for a geometry in memory conversion from Root TGeo objects to the Geant4 native geometry. This conversion is performed when users geometry is defined via the Root geometry package and Geant4 native geometry navigation is selected.

To install VGM - follow the installation instructions on the VGM Web site . To build Geant4 VMC with VGM, you have to select the option: