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, Qt, while others involve a separate application, such as HepRApp or DAWN.

Most examples include a vis.mac to perform typical visualization for that example. The macro includes optional code which you can uncomment to activate additional visualization features.

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
  • Scoring data

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
    • Requires addition of GL libraries that are freely avialable for all operating systems (and pre-installed on many)
    • Rendered, photorealistic image with some interactive features
    • zoom, rotate, translate
    • Fast response (can usually exploit full potential of graphics hardware)
    • Print to EPS (vector and pixel graphics)
  • Qt
    • View directly from Geant4
    • Requires addition of Qt and GL libraries that are freely available on most operating systems
    • Rendered, photorealistic image
    • Many interactive features
    • zoom, rotate, translate
    • Fast response (can usually exploit full potential of graphics hardware)
    • Expanded printing ability (vector and pixel graphics)
    • Easy interface to make movies
  • 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
    • Create a file to view in a HepRep browser such as HepRApp, FRED or WIRED4
    • Requires a HepRep browser (above options work on any operating system)
    • 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
  • gMocren
    • Create a gMocren file suiable for viewing in the gMocren volume data visualization application
    • Represents three dimensional volume data such as radiation therapy dose
    • Can also include geometry and trajectory information
  • 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
  • Wt (WARNING: this driver is experimental and should be used with caution)
    • View directly from Geant4 across a Web browser.
    • Requires addition of Wt librarie that is freely available on most operating systems.
    • Require a Web browser with WebGL enable.
    • Rendered, photorealistic image
    • Many interactive features
    • zoom, rotate, translate
    • Fast response (can usually exploit full potential of graphics hardware)

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 to have the User Interface and all Visualization windows in the same window

    • Only Qt can do that

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

    • OpenInventor or Qt are good solutions

  • If you want GUI control, very responsive photorealistic graphics plus more interactivity (and have the Qt libraries installed).

    • Qt 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 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 want to visualization volume data, such as radiation therapy dose distributions

    • gMocren will meet your needs

  • 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

  • If you to interact with your application with a Web Broswser

    • Wt will do it. WARNING: this driver is experimental and should be used with caution

  • 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
    • Wt (WARNING: this driver is experimental and should be used with caution)

  • 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
    • DAWN
    • VRML
    • gMocren

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: