ROOT OO model to render multi-level 3-D geometrical objects via an
OpenGL

Rene Brun^1^, Valeri Fine^2,3^, Fons Rademakers^1^

^1^CERN - European Organization for Nuclear Research - CH-1211 Geneva
23, Switzerland

^2^Brookhaven National Laboratory, P.O. Box 5000, Upton, NY 11973

^3^Joint Institute for Nuclear Research, Dubna, Russia

**Abstract.** This paper presents a set of C++ low-level classes to
render 3D objects within ROOT-based frameworks. This allows developing a
set of viewers with different properties the user can choose from to
render one and the same 3D objects.

# Introduction {#introduction .INTRODUCTION}

Modern accelerators like the Relativistic Heavy Ion Collider (RHIC) at
the Brookhaven National Laboratory and the coming Large Hadron Collider
(LHC) at CERN enable physicists to study the fundamental constituents of
matter more closely than ever before. They accelerate beams of gold
nuclei or protons to nearly the speed of light before smashing them
together and creating hundreds of new particles.

Because of the sheer size and complexity of the new detectors, and the
huge amounts of data modern detectors are expected to produce, 3D
visualization is becoming a major component of any High Energy Physics
Framework.

# ROOT 3D class library

The ROOT package \[1\] provides two sets of classes. One of them is the
\"end-user\" set. It is to give the user a tool to define his / her 3D
object model. It is optimized for two kinds of geometry, namely for
so-called \"detector geometry\" and \"event geometry\". The \"detector
geometry\" is to describe HEP detectors. It assumes the detector
definition is provided in terms of GEANT3 shapes. \"Event geometry\" is
a collection of 3D markers and 3D polylines. ROOT end-user applications
and end-user 3D OO models must not depend on the 3D rendering package
and hardware / software platforms.

A 3-D OO ROOT model allows a user to create and render rather
complicated 3-D objects with the various 3-D viewer classes. At present
the ROOT user can use TBrowser, TVirtualX, X3D and OpenGL layers to draw
ROOT 3D objects like TNode, TShape, TVolumeView, TVolume, TPolyLine3D,
TPolymarker3D etc. These ROOT classes allow the creation of hierarchical
3D objects. Such an organization allows creating an effective OpenGL
model to render the original object by a limited number of user-defined
geometry levels. By default the system renders three levels of the
hierarchy. This allows rendering very complicated objects (for example
the ATLAS detector \[2\] OO model contains about 30x10^6^ nodes) but
still can be drawn and manipulated in a reasonable time with a simple
PC.

## ROOT low-level 3D classes 

To achieve the \"ROOT\" goal -- the ROOT end-user application and the
end-user 3D OO model must not depend on the 3D rendering package and
hardware / software platforms -- ROOT 3D viewer\'s classes are not
designed to render the generic OpenGL \"pictures\". It is optimized to
render 3D models based on ROOT classes mentioned above. However the
\"Open Inventor\" viewer does allow mixing the ROOT 3D class and those
from Open Inventor meta-files. Figure 1 shows a UML class diagram of
ROOT low-level 3D rendering classes.

![](media/image1.wmf)

At present ROOT provides four different viewers to represent its
classes. Depending on current needs the user may choose any or all of
them to represent his / her 3D object model.

### Representing ROOT 3D objects with TBrowser class

The TBrowser class is used to represent complex models with multilevel
hierarchical organization, such as HEP detector geometries. It provides
an interface to select some subset of the detector before it can be
drawn with other types of viewers. Figure 2 shows part of the STAR
detector geometry \[3\] via TBrowser class.

*Representing 3D objects with TVirtualPad class*

TVirtualPad is another generic class one can employ to represent any
object of a class derived from the ROOT TObject base class via
TObject::Draw method. It gives just a simple wire frame view of 3D
objects. However, it works with any kind of local and remote video
terminals and does provide a facility to directly "pick" objects and
access any class method of the picked C++ object interactively. One can
write the whole picture out with postscript, gif or ROOT file formats.
Figure 3 shows a typical \"TPad\" view of a simulated event within the
STAR \"forward TPC\" used to debug the reconstruction algorithm.

![](media/image2.png){width="2.890277777777778in" height="3.8in"}

### ![](media/image3.png)

**FIGURE 3**. \"TPad\" view of the STAR simulated event

### Special ROOT classes to render 3D objects 

The ROOT package provides an abstract interface TPadView3D. That can be
used to get the high-quality graphics for ROOT 3D objects available via
third party software packages. These classes can be used only if the
particular hardware /software conditions are satisfied.

UNIX users with X-terminal connections can use X3D view. The X3D class
provides very fast rendering via TCP/IP connections but for the UNIX
platform only, and it lacks many features one expects from solid 3D
rendering packages. It is not available for the Windows platform.

![](media/image4.png){width="3.032638888888889in" height="3.9in"}The
TGLViewerImp class provides an abstract interface to OpenGL rendering
packages. At the moment ROOT provides two kinds of implementation of
that interface. One of them is \"plain\" OpenGL; another one provides
the advanced \"Open Inventor\" view whenever \"Open Inventor\" is
available. The plain OpenGL can render ROOT 3D objects and provide
primitive interaction tools. The \"Open Inventor\" viewer allows using
the \"Open Inventor \"Scene Viewers\" classes \[4\] and merging the
views of the ROOT object with those provided from the Open Inventor
file. Figure 4 presents the well known NA49 detector drawn with the Open
Inventor viewer and merged with the Text3 class object from the external
root.iv file.

# References

1\. Brun, R., Buncic, N., Fine, V., Rademakers, F., "ROOT: An
Object-Oriented Framework" in AIHENP\'96 Workshop Proceedings, Lausanne:
1996.

2\. Fine, V., Nevski P., "OO model of STAR detector for simulation,
visualization and reconstruction" in *Computing in High Energy Physics -
CHEP\'2000*, edited by M.Mazzucato, CHEP\'2000 Conference Proceedings
181, Chicago: 2000, pp. 143-146

3\. Fine, V., Fisyak Y., Perevoztchikov V., Wenaus T., "The STAR offline
framework" in *Computing in High Energy Physics - CHEP\'2000*, edited by
M.Mazzucato, CHEP\'2000 Conference Proceedings 181, Chicago: 2000, pp.
196-200.

4\. Wernecke J., *The Inventor Mentor*, Addison-Wesley, 1998.