Building ldmx-sw Without Containers

This method is highly discouraged.

The collaboration has standardized on using the container and so developing and running outside of the standardized container will not be supported.

Building ldmx-sw will require the installation of several dependencies. The following guide will walk you through the installation of those dependencies as well as ldmx-sw.

This is your final warning.

These instructions are not being maintained because we standardized on the container build. You are on your own.

Supported Platforms

  • Linux
    • Tested on: RedHat6 and CentOS7 with devtoolset-6/8, OpenSuse > 42.1, Ubuntu > 18.0)
  • Building on MacOS outside the container is not supported.
  • Building on Windows outside the container is not even close to supported.

Required Tools

  • Git

    • Used for version control
    • Download: https://git-scm.com/download or simply use your package manager
    • Notes: Make sure git is added to your PATH environment variable before running CMake
  • CMake > v3.0

    • Used to generate a build configuration for your build system
    • Download: https://cmake.org/download
    • Installation: https://cmake.org/install/
  • GCC > 7.0

    • Need a modern compiler that supports the C++17 standard.
    • Download: https://gcc.gnu.org/git.html or use your package manager
    • Installation: https://gcc.gnu.org/install/ or use your package manager

Required dependencies

  • Boost > 1.60

    • Used for logging and provides additional C++ tools
    • Download: https://www.boost.org/users/history/
    • Installation: https://www.boost.org/doc/libs/1_61_0/more/getting_started/unix-variants.html or use your package manager.
  • Xerces C++ > 3.2

    • Framework is required for GDML support in Geant4 so it must be installed first.
    • Download: http://xerces.apache.org/xerces-c/download.cgi
    • Building on Linux:
      wget http://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.0.tar.gz
      tar -zxvf xerces-c-3.2.0.tar.gz
      cd xerces-c-3.2.0
      mkdir build; mkdir install; cd build;
      cmake -DCMAKE_INSTALL_PREFIX=../install ..
      make -j16 install
      cd ../install
      export XercesC_DIR=$PWD 
      
    • Notes: The XercesC_DIR environment variable is optional and for convenience. The option -j16 after the make command is used to specify the number of cores the build should use and should be set to a value appropriate to your system.
  • Geant4 > 10.2.p03

    • Geant4 is the simulation engine used by LDMX. LDMX uses a custom version of Geant4 10.02.p03 that includes modifications to the Bertini Cascade model and fixes to the calculation of the Gamma to mu+mu- matrix element.
    • Building on Linux:
      git clone -b LDMX.10.2.3_v0.4 --single-branch https://github.com/LDMXAnalysis/geant4.git 
      cd geant4
      mkdir build; cd build
      cmake -DGEANT4_USE_GDML=ON -DGEANT4_INSTALL_DATA=ON -DXERCESC_ROOT_DIR=$XercesC_DIR \
            -DGEANT4_USE_OPENGL_X11=ON -DCMAKE_INSTALL_PREFIX=../install ..
      cmake --build . --target install
      cd ../install
      source bin/geant4.sh
      export G4DIR=$PWD
      
    • Notes: Installing on Ubuntu variants can require a couple of dependencies to fix the errors: EXPAT error, Could not find X11, Could not find X11 headers, Could not find OpenGL. Add -DGEANT4_USE_SYSTEM_EXPAT=OFF' to the CMake argument, before the last .., and install these dependencies before the CMake step: After it is installed, you can source geant4.sh in the bin directory. This script defines the environment variable G4DIR which points to the installation.
  • ROOT > 6.0

    • The ROOT data structure is used for persistency of simulated and reconstructed objects and for creation of histograms.
    • Download: https://root.cern.ch/downloading-root
    • Building on Linux:
      wget https://root.cern.ch/download/root_v6.16.00.source.tar.gz
      tar -zxvf root_v6.16.00.source.tar.gz
      mkdir root-6.16.00-build
      cd root-6.16.00-build
      cmake -DCMAKE_INSTALL_PREFIX=../root-6.16.00-install -Dgdml=ON -Dcxx17=ON -DPYTHON_EXECUTABLE=$(which python3) ..
      make -j16 install
      cd ../root-6.16.00-install
      source bin/thisroot.sh
      
    • Notes: ROOT has many installation options and optional dependencies, and the building ROOT documentation covers this in full detail. When you source thisroot.sh, it defines the bash environment variable ROOTSYS to be the locations of the install.

Optional Dependencies

  • ONNXRuntime > 1.2
    • Scoring engine for machine learning models. Used to load BDT and DNN models into ECal veto processors.
    • Download: https://github.com/microsoft/onnxruntime/releases/tag/v1.2.0
    • Notes: Building from source requires a modern CMake version (> 3.14) and Python 3.0 and is not recommended. Use the binaries if possible.

Building ldmx-sw

Start by cloning the ldmx-sw repository and make a build directory.

git clone https://github.com/LDMX-Software/ldmx-sw.git
cd ldmx-sw; mkdir build; cd build;

Configuring the build via CMake can be done as follows

cmake -DGeant4_DIR=$G4DIR -DROOT_DIR=$ROOTDIR -DXercesC_DIR=$XercesC_DIR -DCMAKE_INSTALL_PREFIX=../install ..  

In some instances, a non-system installation of python will be needed. In this case, the environmental variable $PYTHONHOME needs to be set to point to your python build. The above cmake command should then be modified as follows:

 -DPYTHON_EXECUTABLE=`which python` -DPYTHON_INCLUDE_DIR=$PYTHONHOME/include/python2.7 -DPYTHON_LIBRARY=$PYTHONHOME/lib/libpython2.7.so 

After the cmake step exits without any errors, you can build and install ldmx-sw with the following command

cmake --build . --target install -- -j16

Now you have an installation of ldmx-sw in the ../install directory. Note: The number after the -j should be changed to reflect the number of processors you want to allow the build to use.

Setting Up the Environment

Now you need to tell your computer where the ldmx-sw install is. This can be done by running the following lines (it might make things easier if you put these lines in your .bash_profile so that they are automatically run when you open a new terminal).

export LDMX_INSTALL_PREFIX=/full/path/to/ldmx/install #need to change this line
source <path-to-root-install>/bin/thisroot.sh #need to change this line
source <path-to-geant4-install>/bin/geant4.sh #need to change this line
export LD_LIBRARY_PATH=$LDMX_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH
export PATH=$LDMX_INSTALL_PREFIX/bin:$PATH
export PYTHONPATH=$LDMX_INSTALL_PREFIX/lib/python:$PYTHONPATH

Once you have executed the above commands in your shell, you should be able to execute programs like ldmx-app without any additional setup.