Getting Started with Geant4 on LCC & MCC Clusters

Getting Started with Geant4 on LCC & MCC Clusters

This guide explains how to build and run Geant4 examples on the Morgan Compute Cluster (MCC) and Lipscomb Compute Cluster (LCC) using the provided Singularity container. It covers both batch jobs and interactive visualization through Open OnDemand (OOD).


1. Accessing the Clusters via Open OnDemand

  1. Log in to Open OnDemand using your LinkBlue credentials.

    1. https://ood.ccs.uky.edu (LCC)

    2. https://mcc-ood.ccs.uky.edu (MCC)

  2. From the Interactive Apps menu, select Lipscomb Compute Cluster (LCC) or Morgan Compute Cluster (MCC).

  3. Request a node with:

    • Walltime: e.g., 2:00:00

    • Cores/Memory: e.g., 4 cores, 8 GB RAM

  4. Launch the Remote Desktop session.

When the desktop loads, open a terminal window — all the following steps assume you are inside that remote desktop session.


2. Geant4 on CCS

  • Geant4 is available via Singularity containers; you don’t need to build or import the full library.

  • The container includes:

    • Geant4 libraries and datasets

    • Qt visualization drivers

    • ROOT (if needed)

    • The official Geant4 examples (via the geant4-examples package)

Examples are located inside the container under:

Path to Geant4 examples directory in the container
$CONDA_PREFIX/share/Geant4/examples/

Subdirectories include:

  • basic/ – starter examples (e.g., B1)

  • extended/ – visualization, physics, medical, etc.

  • advanced/ – larger applications


3. Building an Example (B1)

Step A. Copy to Workspace

LCC:

Commands to copy B1 example to workspace on LCC
mkdir -p ~/geant4 && cd ~/geant4 module load ccs/singularity-3.8.2 singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/lcc-conda-14-rocky9.sinf bash -c 'cp -r $CONDA_PREFIX/share/Geant4/examples/basic/B1 ./B1' cd B1 mkdir build && cd build

MCC:

Commands to copy B1 example to workspace on MCC
mkdir -p ~/geant4 && cd ~/geant4 singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/amd-conda26-rocky9.sinf bash -c 'cp -r $CONDA_PREFIX/share/Geant4/examples/basic/B1 ./B1' cd B1 mkdir build && cd build

Step B. Configure & Compile

LCC:

CMake configure and make commands for LCC
singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/lcc-conda-14-rocky9.sinf cmake .. -DGeant4_DIR=$CONDA_PREFIX/lib/Geant4-11.3.2/cmake singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/lcc-conda-14-rocky9.sinf make -j

MCC:

CMake configure and make commands for MCC
singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/amd-conda26-rocky9.sinf cmake .. -DGeant4_DIR=$CONDA_PREFIX/lib/Geant4-11.3.2/cmake singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/amd-conda26-rocky9.sinf make -j

This produces the exampleB1 executable.


4. Running Example B1

A. Batch Mode (no GUI)

Batch macros are best for production runs:

LCC:

Command to run B1 example in batch mode on LCC
singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/lcc-conda-14-rocky9.sinf ./exampleB1 run.mac

MCC:

Command to run B1 example in batch mode on MCC
singularity run --app geant41132root6344 /share/singularity/images/ccs/conda/amd-conda26-rocky9.sinf ./exampleB1 run.mac

All output is written to the terminal/log.


4B. Visualization (Interactive Mode)

By default, the Geant4 B1 example is compiled with support for the Qt + OpenGL viewer (OGLSQt). When run interactively, it attempts to open this viewer unless overridden. On MCC/LCC, you may encounter different display environments depending on whether you are using Open OnDemand remote desktop or a forwarded X11 session.

To handle this, we recommend setting a few environment variables before launching the program:

LCC & MCC:

Environment variable setup for Qt and X11 visualization
# Ensure runtime dir is available for Qt export XDG_RUNTIME_DIR=/tmp/$UID mkdir -p $XDG_RUNTIME_DIR chmod 700 $XDG_RUNTIME_DIR # X11/Qt settings export QT_X11_NO_MITSHM=1 && export LIBGL_ALWAYS_INDIRECT=1 && export LIBGL_DRI3_DISABLE=1 export G4VIS_DEFAULT_DRIVER=TSGQtZB #LCC ONLY

Launching the Example

From your build directory:

LCC:

Singularity command to launch B1 with visualization on LCC
singularity run \ -B /tmp/.X11-unix:/tmp/.X11-unix \ --env DISPLAY=$DISPLAY,XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR,QT_X11_NO_MITSHM=$QT_X11_NO_MITSHM,LIBGL_ALWAYS_INDIRECT=$LIBGL_ALWAYS_INDIRECT,LIBGL_DRI3_DISABLE=$LIBGL_DRI3_DISABLE \ --app geant41132root6344 /share/singularity/images/ccs/conda/lcc-conda-14-rocky9.sinf \ ./exampleB1

MCC:

Singularity command to launch B1 with visualization on MCC
singularity run \ -B /tmp/.X11-unix:/tmp/.X11-unix \ --env DISPLAY=$DISPLAY,XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR,QT_X11_NO_MITSHM=$QT_X11_NO_MITSHM,LIBGL_ALWAYS_INDIRECT=$LIBGL_ALWAYS_INDIRECT,LIBGL_DRI3_DISABLE=$LIBGL_DRI3_DISABLE \ --app geant41132root6344 /share/singularity/images/ccs/conda/amd-conda26-rocky9.sinf \ ./exampleB1

This will run exampleB1 in interactive mode. By default, it executes its own vis.mac, which includes /vis/open with no arguments. This causes Geant4 to select the OpenGL Qt driver (OGLSQt) automatically.

Geant4 visualization window displaying 3D geometric shapes including a sphere (Shape1), rectangular volumes (Shape2), and a large dark blue box, with dimension labels and C4 text overlay.

Figure: Geant4 visualization window displaying 3D geometric shapes including a sphere (Shape1), rectangular volumes (Shape2), and a large dark blue box, with dimension labels and C4 text overlay.

 

5. Remote Access Options

  • Open OnDemand Remote Desktop (recommended): Full-featured, supports both software and OpenGL Qt visualization.

  • SSH with X11 Forwarding:

    SSH command with X11 forwarding to connect to MCC

    ssh -X username@mcc.uky.edu

    This can forward Qt windows but may be slow, and OpenGL often fails unless indirect GLX is enabled. For simplicity, we recommend MobaXTerm to handle X11 sessions.
    If you want visualization, use OOD Remote Desktop. SSH/X11 is only for quick checks.

  • Production Jobs: Use batch macros (no GUI) in SLURM scripts. Save analysis outputs (ROOT files, histograms, etc.) instead of graphics.


6. Best Practices

  • Use batch mode for large production physics jobs.

  • Use visualization mode only for debugging geometry or educational runs.

  • Do not copy or rebuild the entire Geant4 distribution. Build only your examples or your own application codes against the provided container.

  • Start small (e.g., Example B1) to test visualization before moving to more complex extended/advanced examples.


✅ With this workflow, you can:

  • Build and run the official Geant4 examples on both MCC and LCC.

  • Choose between batch or interactive visualization.

  • Leverage Open OnDemand for a full GUI experience on the clusters.

Center for Computational Sciences