Chapter 8.  Visualization

8.1.  Introduction to Visualization

The Geant4 visualization system was developed in response to a diverse set of requirements:

  1. Quick response to study geometries, trajectories and hits

  2. High-quality output for publications

  3. Flexible camera control to debug complex geometries

  4. Tools to show volume overlap errors in detector geometries

  5. Interactive picking to get more information on visualized objects

No one graphics system is ideal for all of these requirements, and many of the large software frameworks into which Geant4 has been incorporated already have their own visualization systems, so Geant4 visualization was designed around an abstract interface that supports a diverse family of graphics systems. Some of these graphics systems use a graphics library compiled with Geant4, such as OpenGL, while others involve a separate application, such as WIRED or DAWN.

8.1.1.  What Can be Visualized

Simulation data can be visualized:

  • Detector components

    • A hierarchical structure of physical volumes

    • A piece of physical volume, logical volume, and solid

  • Particle trajectories and tracking steps

  • Hits of particles in detector components

Other user defined objects can be visualized:

  • Polylines, such as coordinate axes

  • 3D Markers, such as eye guides

  • Text, descriptive character strings, comments or titles

  • Scales

  • Logos

8.1.2.  You have a Choice of Visualization Drivers

The many graphics systems that Geant4 supports are complementary to each other.

  • OpenGL

    • View directly from Geant4

    • Uses GL libraries that are already included on most Linux systems (plus some Windows availability)

    • Rendered, photorealistic image with some interactive features

    • zoom, rotate, translate

    • Fast response (can usually exploit full potential of graphics hardware)

    • Limited printing ability (pixel graphics, not vector graphics)

  • OpenInventor

    • View directly from Geant4

    • Requires addition of OpenInventor libraries (freely available for most Linux systems).

    • Rendered, photorealistic image

    • Many interactive features

    • zoom, rotate, translate

    • click to "see inside" opaque volumes

    • Fast response (can usually exploit full potential of graphics hardware)

    • Expanded printing ability (vector and pixel graphics)

  • HepRep/WIRED

    • Create a file to view in the WIRED3 HepRep Browser or the WIRED4 JAS Plugin

    • Requires WIRED browser (a Java application easily to install on all operating systems)

    • Wireframe or simple area fills (not photorealistic)

    • Many interactive features

    • zoom, rotate, translate

    • click to show attributes (momentum, etc.)

    • special projections (FishEye, etc.)

    • control visibility from hierarchical (tree) view of data

    • Hierarchical view of the geometry

    • Export to many vector graphic formats (PostScript, PDF, etc.)

  • DAWN

    • Create a file to view in the DAWN Renderer

    • Requires DAWN, available for all Linux and Windows systems.

    • Rendered, photorealistic image

    • No interactive features

    • Highest quality technical rendering - output to vector PostScript

  • VRML

    • Create a file to view in any VRML browser (some as web browser plug-ins).

    • Requires VRML browser (many different choices for different operating systems).

    • Rendered, photorealistic image with some interactive features

    • zoom, rotate, translate

    • Limited printing ability (pixel graphics, not vector graphics)

  • RayTracer

    • Create a jpeg file

    • Forms image by using Geant4's own tracking to follow photons through the detector

    • Can show geometry but not trajectories

    • Can render any geometry that Geant4 can handle (such as Boolean solids)

    • Supports shadows, transparency and mirrored surfaces

  • ASCIITree

    • Text dump of the geometry hierarchy

    • Not graphical

    • Control over level of detail to be dumped

    • Can calculate mass and volume of any hierarchy of volumes

  • Qt

    • View directly from Geant4

    • Uses GL libraries that are already included on most Linux systems (plus some Windows availability)

    • Rendered, photorealistic image with some interactive features

    • zoom, rotate, translate

    • Fast response (can usually exploit full potential of graphics hardware)

    • Expanded printing ability (vector and pixel graphics)

    • Could make movies

8.1.3.  Choose the Driver that Meets Your Needs

  • If you want very responsive photorealistic graphics (and have the OpenGL libraries installed)

    • OpenGL is a good solution (if you have the Motif extensions, this also gives GUI control)

  • If you want very responsive photorealistic graphics plus more interactivity (and have the Qt and OpenGL libraries installed)

    • Qt is a good solution and will also give you the GUI control

  • If you want very responsive photorealistic graphics plus more interactivity (and have the OpenInventor libraries installed)

    • OpenInventor is a good solution

  • If you want GUI control, want to be able to pick on items to inquire about them (identity, momentum, etc.), perhaps want to render to vector formats, and a wireframe look will do

    • HepRep/WIRED will meet your needs

  • If you want to render highest quality photorealistic images for use in a poster or a technical design report, and you can live without quick rotate and zoom

    • DAWN is the way to go

  • If you want to render to a 3D format that others can view in a variety of commodity browsers (including some web browser plug-ins)

    • VRML is the way to go

  • If you want to visualize a geometry that the other visualization drivers can't handle, or you need transparency or mirrors, and you don't need to visualize trajectories

    • RayTracer will do it

  • If you just want to quickly check the geometry hierarchy, or if you want to calculate the volume or mass of any geometry hierarchy

    • ASCIITree will meet your needs

  • You can also add your own visualization driver.

    • Geant4's visualization system is modular. By creating just three new classes, you can direct Geant4 information to your own visualization system.

8.1.4.  Controlling Visualization

Your Geant4 code stays basically the same no matter which driver you use.

Visualization is performed either with commands or from C++ code.

  • Some visualization drivers work directly from Geant4

    • OpenGL

    • Qt

    • OpenInventor

    • RayTracer

    • ASCIITree

  • For other visualization drivers, you first have Geant4 produce a file, and then you have that file rendered by another application (which may have GUI control)

    • HepRep/WIRED

    • DAWN

    • VRML

8.1.5.  Visualization Details

The following sections of this guide cover the details of Geant4 visualization:

Other useful references for Geant4 visualization outside of this user guide:

  • Introduction to Geant4 Visualization ( pdf, ppt )

  • Status of Geant4 Visualization (giving current status and a summary of what has been improved over the last few releases) ( pdf, ppt )

  • Macro files distributed in Geant4 source in examples/novice/N03/visTutor/.