# Visualization Tutorial: How to check Geant4 Geometry Description

Complete:

## Basic concepts

A detector geometry in Geant4 is made of a number of volumes. The largest volume is called the World volume. It must contain, with some margin, all other volumes in the CMS detector geometry. The other volumes are created and placed inside previous volumes, included in the World volume.

Each volume is created by describing its shape and its physical characteristics, and then placing it inside a containing volume.

When a volume is placed within another volume, Geant4 calls the former volume the daughter volume and the latter the mother volume. The coordinate system used to specify where the daughter volume is placed, is the coordinate system of the mother volume.

To describe a volume's shape, Geant4 uses the concept of a solid. A solid is a geometrical object that has a shape and specific values for each of that shape's dimensions. A cube with a side of 10 centimeters and a cylinder of radius 30 cm and length 75 cm are examples of solids.

To describe a volume's full properties, Geant4 uses a logical volume. It includes the geometrical properties of the solid, and adds physical characteristics: the material of the volume; whether it contains any sensitive detector elements; the magnetic field; etc.

To position the volume in Geant4 you create a physical volume, which places a copy of the logical volume inside a larger, containing, volume.

## Getting started

This is a recipe which works with CMSSW_2_0_0 release. It will work with any major release, but is not guaranteed if you use any nightly build.

```> scram p CMSSW CMSSW_2_0_0
> cd CMSSW_2_0_0/src
> project CMSSW
> cvs co -r CMSSW_2_0_0 VisDocumentation/VisTutorial
> eval `scram ru -csh`
> cd VisDocumentation/VisTutorial
> iguana -p cmssw-geom.cfg
```

If you use CMSSW_3_X_X releases, you need to checkout the corresponding version and use the python file.

```> cd CMSSW_3_X_X/src
> eval `scram runtime -csh`
> cvs co -r \$CMSSW_VERSION VisDocumentation/VisTutorial
> cd VisDocumentation/VisTutorial
> iguana -p cmssw-geom_cfg.py
```

When IGUANA pops up a GUI, choose "CMSSW Simulation":

Then ask for an event (geometry is produced on the first event):

Note that the OCMS branch appears in the tree browser under the Detector branch. The OCMS is the World volume in Geant4 terminology.

The picture on the left shows the tree browser before asking for an event and the picture on the right - the same tree browser after the event has been requested.

## How to expand and collapse geometry tree

To expand the volume hierarchy either click on + (on left from the volume name) or double mouse click on the volume name. When the hierarchy expands, the + changes to - and you will see the daughters. To collapse the volume hierarchy either click on - or double mouse click on the volume name. The following picture shows the result of expanding the CMSE volume hierarchy:

Since we build the Geant4 geometry on user request, you may see that some of the volume names are grayed out - the volumes for which IGUANA has not build the geometry yet. It means, that you cannot visualize these volumes untill you request IGUANA to build their geometry. How? Enable them! To enable the daughters of the mother volume right mouse click on the mother volume name (CMSE) to retrieve the object menu and click on "Enable Children". The following picture shows the object menu of the CMSE volume.

## How to switch between logical and physical volumes

By default IGUANA shows a logical volume hierarchy. You can switch it to a physical hierarchy for all or some of the volumes.

Use the object menu to switch between physical and logical volumes. This can be done at any level (if applicable). To pop up the menu right mouse click on the volume name. The picture on the left shows the logical children of the CMSE mother volume. The middle picture shows the object menu. The picture on the right shows the physical children of the CMSE mother volume.

## How to look up a volume properties

Select the name of a volume in the tree browser. A list of volume properties appears in the text browser: a volume name, a copy number, whether it is replicated, volume position, rotation, material, density, sensitivity, etc.

The picture below shows the list of properties displayed for a BEAM volume.

## How to calculate a logical volume mass

Right mouse click on the volume name in the tree browser to pop up an object menu and choose "Get Mass". This will envoke `G4LogicalVolume::GetMass` which returns the mass of the logical volume tree computed from the estimated geometrical volume of each solid and material associated to the logical volume and (by default) to its daughters.

NOTE: the computation may require a considerable amount of time, depending from the complexity of the geometry tree.

The result will be shown in a dialog box.

## How to visualize volumes

When you have expanded and enabled the volume hierarchy, tick the visibility box on. If the volume does not appear, bring it into the view by clicking on "View All" tool bar button.

You can also use an object menu: clicking on "Show This" displays selected volume.

"Show Only This" displays selected volume and hides all other already visible volumes.

"Show By Level" allows you to expand the volumes hierarchy and display the volumes by selected level down to the leaves.

"Show By Category" allows you to display the volumes by their sensitivity.

"Show By Material" will pop up a selector dialog window with all available materials to choose from. Only the volumes made of the selected material will be displayed.

## Review status

Reviewer/Editor and Date (copy from screen) Comments
IannaOsborne - 23 April 2007 (Ianna Osborne) page content author
JennyWilliams - 27 Apr 2007 moved material here from visualization page
JinzhongZhang - 22 Sep 2009 add the starting codes for CMSSW_3_X_X releases

Responsible: IannaOsborne
Last reviewed by: Reviewer

Topic revision: r8 - 2010-03-11 - KatiLassilaPerini

 Cern Search TWiki Search Google Search CMSPublic All webs
Copyright &© 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback