Installing and Running Examples

The following instructions apply to the installation since the version 3.00. Since this 3.00, VMC examples are installed with CMake.

The VMC examples libraries require ROOT installation and the VMC core package if using ROOT built without vmc enabled. The VMC examples programs can be built against Geant3 with VMC or Geant4 VMC libraries. Only the examples with the multiple engine mode (at present only E03c) can be built with both Geant3 and Geant4 VMC libraries. The VMC_WITH_Multi CMake option has to be set, too, in this special case.

By default, the VMC examples libraries and the VMC examples programs are built against Geant4 VMC libraries together with Geant4 VMC installation. Below we provide the instructions how to build VMC examples altogether outside Geant4 VMC. The analogous instructions can be used to build each example individually or to build a user application.

To install all examples

  1. First get the Geant4 VMC source from the Download page, as the examples are provided within this package. We will assume that the Geant4 VMC package sits in a subdirectory

    /mypath/geant4_vmc

  2. Create build directory alongside our source directory for installation with Geant4:

    $ cd /mypath
    $ mkdir examples_build_g4
    $ ls
    geant4_vmc examples_build_g4    
    and/or for installation with Geant3:
    $ cd /mypath
    $ mkdir examples_build_g3
    $ ls
    geant4_vmc examples_build_g3    
    and/or for the installation without specific MC (only libraries will be installed in this case):
    $ cd /mypath
    $ mkdir examples_build
    $ ls
    geant4_vmc examples_build    

  3. To configure the build, change into the build directory and run CMake with either -DVMC_WITH_Geant4

    $ cd /mypath/example_build_g4
    $ cmake -DCMAKE_INSTALL_PREFIX=/mypath/examples_install_g4 \
        -DVMC_WITH_Geant4=ON \
        -DGeant4VMC_DIR=/mypath/geant4_vmc_install/lib[64]/Geant4VMC-3.0.0 \
        /mypath/geant4_vmc/examples
    or -DVMC_WITH_Geant3,
    $ cd /mypath/example_build_g3
    $ cmake -DCMAKE_INSTALL_PREFIX=/mypath/examples_install_g3 \
        -DVMC_WITH_Geant3=ON \
        -DGeant3_DIR=/mypath/geant3_install/lib[64]/Geant3-2.0.0 \
        -DPythia6_LIB_DIR=/my_path_to_pythia6_library \
        /mypath/geant4_vmc/examples
    or with VMC_WITH_Multi,
    $ cd /mypath/example_build_multi
    $ cmake -DCMAKE_INSTALL_PREFIX=/mypath/examples_install_multi \
        -DVMC_WITH_Geant3=ON \
        -DVMC_WITH_Geant4=ON \
        -DVMC_WITH_Multi=ON \
        -DGeant3_DIR=/mypath/geant3_install/lib[64]/Geant3-2.0.0 \
        -DGeant4VMC_DIR=/mypath/geant4_vmc_install/lib[64]/Geant4VMC-3.0.0 \
        -DPythia6_LIB_DIR=/my_path_to_pythia6_library \
        /mypath/geant4_vmc/examples
    or no specific MC:
    $ cd /mypath/example_build_g3
    $ cmake -DCMAKE_INSTALL_PREFIX=/mypath/examples_install \
        -DCMAKE_MODULE_PATH=/mypath/geant4_vmc_install/lib[64]/Geant4VMC-3.0.0/Modules \  
        /mypath/geant4_vmc/examples

    • Note that in the last case, you still have to define the path to CMake configuration files used in examples which are provided with both Geant4 VMC and Geant3 CMake installations. Only examples libraries are built and installed in this case.

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

  • Since ROOT 6.18, building the VMC library is optional. When using ROOT built with the vmc option enabled, then Geant4 VMC will automatically use the VMC library from ROOT, otherwise the VMC stand-alone library has to be provided using -DVMC_DIR cmake option.
  1. After the configuration has run, CMake will have generated Unix Makefiles for building examples. 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
  1. Once the build has completed, you can install examples to the directory you specified earlier in CMAKE_INSTALL_PREFIX by running
    $ make install

This will install examples libraries in lib[64] and executables in bin directory in CMAKE_INSTALL_PREFIX directory.

For the old instructions see: