Introduction to the Drawing package

+-------------+                                               +----------##
| Geant 3.16  |               GEANT User's Guide              | DRAW001  ##
+-------------+                                               +----------##
                                   

Author(s) : P.Zanarini, S.Giani Submitted: 07.03.92 Origin : R.Brun, P.Zanarini Revised: 11.12.92

The drawing package

The drawing package has been designed mainly to visualise:

  1. detector components;
  2. the logical tree of detector components;
  3. the geometrical dimensions;
  4. particle trajectories
  5. the hits recorded in the sensitive elements of the detector.

Graphics in GEANT

The set of routines in the drawing package allows the visualization of the volumes of the detector. These routines can be called from the user program or interactively via the command interface. The output can be directed onto the screen or to a file. The graphics of GEANT is based on the HIGZ [bib-HIGZ] package. HIGZ is a high-level interface between the user program (in this case GEANT), ZEBRA and a basic graphics library. At the moment of writing, HIGZ can use various flavours of the GKS [bib-gks2d], [bib-gks3d], [bib-GKS1] graphics system or the X11 [bib-X11] system. A version based on the PHIGS [bib-phigs] system is now being developed at CERN.

Graphics functionality of GEANT

The graphics capabilities of GEANT have been greatly enhanced in the last few revisions of the program. It is now possible to display volumes with hidden lines removed from the drawing. This improves the understanding of complicated objects. It is also possible to cut the displayed volumes with various shapes (boxes, cones, tubes and spheres) in order to visualise the internals of a detector element. The surfaces of the volumes drawn can be filled with colour, either solid or shaded according to a scan-line based lighting algorithm. A more sophisticated surface rendering algorithm is now being developed but it will be available only in the next version of the program.

Almost all drawing commands can be executed either by calling a routine from the user application or by issuing a command when running GEANT with the standard interactive interface. Several interactive tools (ZOOM, LENS) have been developed to analyse in detail the various parts of the detectors. The interactive MOVE facility allows the rotation, translation and zooming in real time for simple components of the detectors. Some of these commands are only available in the interactive interface. These are described briefly in [DRAW500] and more extensively in the [XINT] section.

Various graphical options can be set via the GSATT and GDOPT routines.

Every detector component can be visualised either in orthonormal projection or in perspective (routines GDRAW and GDRVOL). Sections of the volumes and of their descendents can be visualised as well (routines GDRAWX and GDRAWC).

The hierarchical relations of the various volumes which compose the detector can be visualised via the GDTREE routine. In the interactive interface the user can select one of the volumes which are nodes of the tree with the mouse, and display the characteristics of the volume and walk up and down the logical tree.

Tracks and hits can be drawn either alone or superimposed on the detector (routines GDCHIT, GDHITS, GDAHIT, GDXYZ). It is also possible to draw the tracks while tracking is performed via the routine GDCXYZ.

The drawing may be done with hidden-line removal and with shading effects according to the value of the options HIDE and SHAD (see next section).

Drawing complicated detectors can be a lengthy process even on a fast machine. In particular, when graphics options like hidden line removal or surface shading are requested and many volumes are involved, the complete drawing can take several minutes on the most powerful workstations. To alleviate this problem drawings can be stored in memory in so called view banks. The routines involved are GDOPEN, GDCLOS, GDSHOW and GDELET, and the corresponding interactive commands (DOPEN, DCLOSE, DSHOW, DELETE). These banks can then be redisplayed quickly. They can also be written on disk and read back.

Attributes like colour (GDCOL) and line width (GDLW) can be globally set for all 2D drawings (i.e. text, vectors, man, etc.); such attributes do not affect the volume attributes that can be set by the GSATT routine with COLO or LWID option.

The user can control some drawing options (GDOPT), by selecting, for instance, to have either parallel or perspective projection, either Y-Z or R-Z projection, etc.

The geometrical dimensions of an existing volume can be changed via the routine GEDITV.

Various service routines allow the drawing of the profile of a human figure, the axis, the scale of the dimension of the drawing and so on. These are described in [DRAW400].

The shading algorithm

In GEANT 3.16 a new shading algorithm has been introduced which is 10 to 100 times faster than the algorithm which was implemented in GEANT 3.15. In the new algorithm the search for the visible portions of all the faces of every volume is performed in the following steps:

  1. the vertices of each face are transformed from the MARS to the screen reference system. In this way the dimensions of the face are of the order of magnitude of centimeters.
  2. in the screen reference system the face is filled with horizontal lines scan-lines according to the desired resolution.
  3. These lines are then transformed back in the MARS, where the hidden line removal technique is used to find their visible portions.
  4. The colour luminosity is chosen as a function of the angle between the normal to the surface and the line of view which is considered to be also the line of illumination.
  5. The visible portions of the lines are finally transformed into the screen reference system and drawn with the calculated luminosity so that they fill only the visible part of each face.

    The resulting picture can be saved into GEANT view banks or HIGZ picture files.

    Summary

    The best way to initialise the drawing package is to call the HPLOT initialisation routine HPLINT. This will work independently of the basic graphic package used. The reader should consult the HPLOT documentation for more information on this routine. The drawing package is initialized by:

    HPLINT
    to initialize the basic graphics package and the HPLOT package;
    GDINIT
    to initialize the GEANT drawing package.

    The main drawing routines are:

    GDRAW
    to draw a projection view of the detector -- Case 1
    GDRVOL
    to draw a projection view of the detector -- Case 2
    GDRAWC
    to draw a cut view of the detector (along one axis)
    GDRAWX
    to draw a cut view of the detector (from any point)
    GDXYZ
    to draw tracks at the end of the event
    GDCXYZ
    to draw tracks at tracking time
    GDPART
    to draw particle names and track numbers at end of tracks
    GDAHIT
    to draw one single hit
    GDHITS
    to draw hits for trajectory type detectors
    GDCHIT
    to draw hits for calorimeter type detectors

    Routines that show how the detector has been modelled are:

    GDTREE
    to draw a picture with the geometrical tree
    GDSPEC
    to draw a picture with volume specifications
    GDFSPC
    to draw several GDSPEC pictures

    Routines that perform control operations on view banks are:

    GDOPEN
    to open a given view bank, identified by a view number; in this way we enter in bank mode
    GDCLOS
    to close the current view bank, i.e. the last one opened, and restore screen mode
    GDSHOW
    to show all graphics information contained in a given view bank
    GDLENS
    to scan interactively the drawing contained in the view bank
    GDELET
    to delete a given view bank from memory

    Routines that allow the visualization of the detector with hidden line removal are:

    GDCGOB
    to create CG objects
    GDCGSL
    to create clipping objects
    GDCGCL
    to perform boolean operations
    GDCGHI
    to insert CG objects in HIDE and WIRE structures of faces
    GDSHIF
    to shift in the space a CG object
    GDBOMB
    to make the detector explode

    Other routines are:

    GDOPT
    to set drawing options
    GDZOOM
    to set the zoom parameters
    GDAXIS
    to draw the axes of the MARS, oriented according to the current view parameters
    GDSCAL
    to draw the current scale
    GDMAN
    to draw a profile of a man within the current scale
    GDRAWT
    to draw text, with software characters
    GDRAWV
    to draw polylines in 2D user coordinates
    GDHEAD
    to draw a frame header
    GDCOL
    to set colour code
    GDLW
    to set line width
    GDCURS
    to have an input from the graphics cursor
    GDFR3D
    to convert from 3D coordinates (either in MARS or DRS) to 2D user coordinates
    GD3D3D
    to convert from 3D MARS coordinates to 3D Projection Reference System coordinates.