Installation on private machines


G4LBNE officially depends on:

  • Geant4 4.9.6p02
  • ROOT 5.34.18
  • DK2Nu 1.1.0

and their dependencies.

Manual installation of g4lbne and dependencies

The following is guidance on manually building and installing G4LBNE using cmake on machines running Scientific Linux 6. This includes installation of sufficient dependencies to use the OpenGL, QT, and OpenInventor visualization driver. It may working with other operating systems with minor modifications. If you are interested in trying an automated worch-based installation of g4lbne, see the next section of this page.


Redhat Enterprise Linux (SL-6 or later) with "sudo" privileges

We recommend that you create a working directory where all the softwares will be downloaded, built and installed. This folder is called "/home/<$USER>/mother" in the instructions below.

Prerequisites, tips for non-experts in such software installs:

Laura Fields and Brett Viren have done an excellent hob at creating and maintaining this page. However, the present contributor (Paul L.), can get confused, sometimes. Life in the 21th century, particularly for those born before the pion was discovered, can be a bit more complicated then advertised in the movie "Angels and the Bad Man" (1947), featuring John Wayne and Gail Russel. So, here are some informal advices. As usual with software, correctness is not guaranteed. Striving not to be worse than the bad man. But not as good either. Honestly.

**Root Privilege. The "sudo" privilege are indeed welcome, although, if one decides to install everything from source, in principle are not required. However, they come really handy. If a package, such Xerces, or OpenInventor, is clearly 3rd party, not HEP specific, it is very likely that a Centos rpm (or equivalent for Ubuntu system)
exists, and a "yum install" can be easier than rebuilding the package from source.

**Regarding root and Geant3, indeed, install from source, as you might want to learn from browsing the source code, or even debug these packages. But as, you do so, remember to finish the installation cleanly (do the make install), as the "setup" scripts and the cmake FindXXX.cmake, and USE_XXX files can be written out during the install phase, not during the build phase.

**cmake: The recommended way to build g4lbne, for upcoming version. Not that many of us (me included) are currently not using cmake for g4lbne work on lbnegpvm0x (x=3,4,5,6). This is just "past history", the Makefile generated by cmake is much better, with faster compile and link, than we inherited a while ago. As mentioned above, cmake can also be installed with one yum install. Note that cmake delivered by default on Scientific Linux 6.x is cmake 2.6, which might not work with Geant4 v4.9.6 installs. One needs cmake v2.8, available on epel or slf yum repository. Look for it. To avoid loosing the old version, powers at be have decided to install it as "/usrbin/cmake28", not "/usr/bin/cmake". Depending on your of cmake for other projects, either remove the old cmake, or make symbolic links, or simply, run the "usr/bin/cmake28". This latter options seems to have worked for me.

Note cmake prides itself for being really efficient, so it remembers what it did previously. This means, that, if you made a mistake in adjusting the CMakeList.txt file for your specific settings, it is best to "rm ./CMakeCache.txt", and "rm - f - r ./CMakeFiles/*" , fix the suspected mistake, and try again. Otherwise, cmake might - quite proudly - declared that you have made a mistake.

The cmake "find_package" macros is quite interesting. It has the bad habits of finding versions of the a given package that you don't want. It is best to tell where things are, if need be. Spend a few minutes reading the lengthy documentation about this puzzling functionality of cmake.

Installation of cmake
  • Can be downloaded from [[]]; be sure you get the files that are developed for Unix/Linux ("has \n line feeds")
  • Instructions for building and installing can be found in the README file
  • As of this writing, the most recent version is 3.0.2, which is what was used in this example
Installation of Xerces C Installation of Root Installation of Coin2
Using OpenInventor requires coin2, which is a bit of a chore to install. One possible path is to do:
  • Obtain the source rpm from
  • If not already installed, you should first run : sudo install libGLU-devel and sudo yum install bzip2-devel
  • sudo rpmbuild --rebuild Coin2-2.5.0-14.fc16.src.rpm
  • sudo rpm -Uvh /root/rpmbuild/RPMS/x86_64/Coin2-2.5.0-14.el6.x86_64.rpm
  • sudo rpm -Uvh /root/rpmbuild/RPMS/x86_64/Coin2-devel-2.5.0-14.el6.x86_64.rpm
  • sudo rpm -Uvh /root/rpmbuild/RPMS/x86_64/Coin2-debuginfo-2.5.0-14.el6.x86_64.rpm
Installation of SoXt
Again, required for OpenInventor Installation of Geant4:
  • Download version 4.9.6.p03 (a minor update from the official G4LBNE version) from More information on installation can be found at
  • If you don't already have them installed, do sudo yum install expat-devel.x86_64' and 'sudo yum install qt-devel.x86_64'
  • export INVENTOR_INCLUDE_DIR=/home/ljf26/g4lbne/geant4/geant4.9.6.p03/source/visualization/OpenInventor
  • Assuming, you are in the “mother” directory.
    $mkdir geant4_build
    Geant4.9.p03    geant4_build
    $cd /path/to/geant4_build
  • Here, the “DCMAKE_INSTALL_PREFIX” will set the installation directory which here is geant4.9.9.p03-install and build the GEANT4 on geant4_build directory with the ability to read gdml files and use the QT, OpenGL and OpenInventor visualization drivers. The log file myCmakeCmd.log will be in the current directory. At the end of the file, you should see something like:
    --Generating done
    --Build files have been written to: /path/to/geant4_build
  • Next, you should build and install geant4 with the following commands. This will take quite a while.
    $make –j1
    $make install
  • (To uninstall geant4, simply do “make uninstall in the build directory which in this case is “geant4_build”.)

Installation of Dk2Nu

  • More info about dk2nu can be found on its redmine page:
  • First, run . bin/ in your root installation so that dk2nu knows where to find root
    $ mkdir $MOTHER/dk2nu
    $ cd dk2nu
    $ svn co my-dk2nu-svn-checkout 
    $ export DK2NU=$PWD/my-dk2nu-install
    $ mkdir -p $DK2NU
    $ mkdir -p my-dk2nu-build
    $ cd my-dk2nu-build
    $ cmake -DWITH_GENIE=OFF -DCMAKE_INSTALL_PREFIX:PATH=$DK2NU ../my-dk2nu-svn-checkout/dk2nu/
    $ gmake install all 

Now, we have all the pre-requisites needed for the development of G4LBNE.

Installation of G4LBNE:
  • To get started, chose a name to identify your g4lbne working area. This could be a particular version of g4lbne, or could be the name of a feature or change you are going to make to g4lbne.
    $ mkdir -p $MOTHER/g4lbne
    $ cd $MOTHER/g4lbne
    $ mkdir -p <version_name>
    $ git clone ssh:// <version_name>
    $ cd <version_name>
  • In the g4lbne working directory, create a cmake file and name it “CMakeLists.txt”.
    Copy and Paste the following in the text file:

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)


SET(CMAKE_MODULE_PATH $ENV{ROOTSYS}/etc/cmake/ $ENV{G4SYS}/lib64/Geant4-9.6.3/ $ENV{G4SYS})

option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
find_package(ROOT REQUIRED)   

   find_package(Geant4 REQUIRED ui_all vis_all)
   find_package(Geant4 REQUIRED)

link_directories("${GEANT4_LIBRARY_DIR}" "${DK2NU_LIBRARY_DIR}" "${ROOT_LIBRARY_DIR}")
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
ROOT_GENERATE_DICTIONARY(g4lbneCint ${PROJECT_SOURCE_DIR}/src/ TrackPoint_t.hh LBNEDataNtp_t.hh LINKDEF Linkdef.h OPTIONS -p)

add_executable(g4lbne ${sources} ${headers})
target_link_libraries(g4lbne ${Geant4_LIBRARIES})
target_link_libraries(g4lbne ${ROOT_LIBRARIES})
target_link_libraries(g4lbne $ENV{DK2NU_DIR}/dk2nu/lib/

Now, in the g4lbne working directory, you will see a “setups” subdirectory. Go to the directory and create a “*.sh” file. For the sake of convenience, I will call that file “”. This file will setup all the required environment to run the g4lbne in the local computer. Hence,

source /path/to/
export ROOTSYS = /path/to/root-directory/
source /path/to/
export G4SYS = /path/to/geant4-install directory/
export DK2NU_DIR =/path/to/dk2nu directory/
export D2KNU_LIBDIR =/path/to/dk2nu/dk2nu/lib/
export DK2NU_INC_DIR=/path/to/dk2nu_install/

The first line “source /path/to/ is basically the bath to the .sh file “”. In the root directory (where you have installed ROOT), this file is typically in the bin directory (source …../root/bin/
ROOTSYS is the environment that sets the path to the root directory or the director in which you have installed root cern.
The third line is the path to file which if you have installed the geant4 following the above instruction, will look like this “source ……/geant4.9.6.p03-install/bin/”.
The fourth line sets the path to the geant4-install directory (geant4.9.6.p03-install according to my example).
DK2NU_DIR is the path to the r487 subdirectory in the dk2nu directory.
DK2NU_LIBDIR is the path to lib subdirectory in the dk2nu directory.


In the file, you can see something like:
#<include> “…dk2nu/tree/calcLocationWeigths.h”
Change the path to its actual path in your local machine. Do the same for the LBNEAnalysis.hh file located in "include" directory.


Delete all the GNUMake files that are previously generated. They are located in the working directory.
Finally, we have setup all the prerequisites and environment to setup the g4lbne in the local computer.
Go to the working directory of g4lbne (the same directory where you have CMakeLists.txt). Then do:
$source setups/

$ccmake .

It will start making the g4lbne and finally, we will have an executive file “g4lbne” in the working directory.

This will open the g4lbne visualization in Qt mode.

Note: Once you "cmake" two files "" and "g4lbneCint.hh" are supposed to be generated by ROOTcint in the "src" directory.

Automated Release Installation with worch

Warning: the latest worch configuration may specify different versions. To find out what it currently defaults to you can check the corresponding section in the packages.cfg configuration file. If you wish to install different versions you may edit the copy of this file that is cloned in the instructions below. Changing versions, particularly to older ones may lead to build problems.

Worch is a tool that is used to build releases of all LBNE software suites. To use it you get some configuration files and the worch tool itself like so:

$ mkdir -p /path/to/build
$ cd /path/to/build
$ git clone
## at this point you may customize the configuration if desired
$ git clone
$ cd worch/
$ alias waf=`pwd`/waf
$ waf --version
$ waf --prefix=/path/to/install --orch-config=../lbne-beamsim-worch/config/suite-g4lbne.cfg configure
$ waf
  • If you edit the worch configuration under lbne-beamsim-worch/config/ you need to repeat the waf ... configure command followed by just waf. You can combine the two commands into one by adding "build" as in waf ... configure build.
  • If this does not work for you, see Known Installation Issues.
  • The authenticated URL for the worch configuration is:

Using this installation

For now, worch provides user environment management via Environment Modules (EM). To use them some minimal one time setup is required.

$ source /path/to/install/Modules/3.2.10/init/bash
$ export MODULEPATH=/path/to/install/modules/
$ module load g4lbne
$ g4lbne ....


  • Placing the first two lines into your setup script is fast and only minimally changes your environment
  • There is a tcsh init script as well, adjust to taste
  • The need to set MODULEPATH will go away in the next release of worch.



  • The above is for building and installing released versions of the G4LBNE software suite
  • It is not meant to provide a development environment.
  • This section gives on possible way to leverage a release for development
  • This is just an outline and still needs testing and maybe some scripting to hide the details.
  • It should better to have git-flow patterns ingrained.

To get started, first pick a name for what feature you want to add or bug fix you want to make. Below the name FEATURE is used.

First set up directories to hold source repository, build area and installation location.

$ mkdir -p /path/to/dev/g4lbne/FEATURE/build
$ cd /path/to/dev/g4lbne/FEATURE
$ git clone ssh:// repo
$ cd repo
$ git checkout -t -b FEATURE master

Now, copy the EM file for the released g4lbne package and modify it to match the location of your development area.

$ cd /path/to/dev/g4lbne/FEATURE
$ cp /path/to/install/modules/g4lbne/HEAD/modulefile .
$ emacs modulefile

You'll need to modify the setting of PATH to be:


Now, set up your environment to add the development EM area to the one provided by the base release

# if you haven't already done this from above, set up the base release
$ source /path/to/install/Modules/3.2.10/init/bash
$ export MODULEPATH=/path/to/install/modules/
# now add your development release
$ module avail

You should see (at least) two instances of g4lbne. Set up your copy by appending /FEATURE:

$ module load g4lbne/FEATURE

You should now be able to build and install from your source

$ cd /path/to/dev/g4lbne/FEATURE/build
$ cmake -DCMAKE_INSTALL_PREFIX=.. ../repo
$ make
$ make install
$ which g4lbne