View on GitHub

Geant4 Zero to Hero

The Definitive Guide for End Users

Home Visualization Docker image

HepRepFile

The HepRepFile visualization driver is available in any Geant4 installation. It can be used to generate G4Data*.heprep files, which can be viewed using an external program called HepRApp Data Browser in wireframe mode, that is, no surface, only outlines, which sounds primitive, but is one of the best ways to troubleshoot a complicated geometry.

Unfortunately, HepRApp only runs on a very old java version, 1.8 (or 8 in short). To use it, you may need to install two versions of java, one new and one old, and switch to the old one to use HepRApp. This can be done, but the detailed procedure changes with the OS. In case of Windows, simply download java 8 from https://www.java.com/en/download. In case of modern MacOS or Linux distributions, there is no tested working procedure. A Docker image https://hub.docker.com/r/physino/heprapp is create to solve this problem. It can be used in the following way:

  1. download and run Docker Desktop
  2. for Mac and Windows users: run an X11 server (XQuartz for Mac, MobaXterm for Windows)
  3. for Mac and Linux users: run xhost + in a terminal
  4. save compose.yml in a folder that contains the G4Data*.heprep file that you want to view, in that folder, run
docker compose run --rm heprapp

The HepRApp Data Browser should pop up on your desktop.

Preparing Geometry for HepRApp Browser

The following code snippet shows how to prepare your detector geometry written in simple text for the HepRApp browser.

:volu hall BOX 1*m 1*m 1*m G4_AIR
// without specifying color, HepRepFile won't show the volume, but Qt will
:color hall 0.8 0.9 0.1
// use the following to disable visualization in all drivers, w/o color
:vis hall OFF

The following Geant4 [macro][../../run/macro] command can be used to add a 3D coordinate system in your HepRApp browser.

# This command add x,y,z axes (right-handed system) in HepRepFile
# HepRApp Data Browser shows an axis as a hexagonal stick + a tetrahedra
# By default, x is shown in red, y in green, z in blue
/vis/scene/add/axes

Views in HepRApp Data Browser

You can select a few different views to display your geometry through right click on your HepRApp browser:

Note: all /vis/viewer/set commands have NO effort in HepRApp Data Browser but they do work in Qt.

/vis/viewer/set/upVector 0 1 0 # y points up
/vis/viewer/set/viewpointVector 0 0 1 # view against z (beam view)
/vis/viewer/set/background 0 0.17 0.21 # solarized color: base03