Day 1 - Exercises on Visualisation


Run a Geant4 example and visualize the setup.

Run the same example with the advanced Qt dirver.


For this task we will use the exampleN03 that comes with Geant4.

Example can be found under:

Copy the example code to your working directory:
        % cd ~/g4course2011
	% cp -r $G4INSTALL/examples/novice/N03 .
        % cd N03
        % less README
To compile the code enter the N03 directory and run
        % gmake -j2
Test that everything works by executing:
        % $G4WORKDIR/bin/$G4SYSTEM/exampleN03

Type exit at G4 prompt to exit application:

        Idle> # type your commands. example:
        Idle> /run/beamOn 1
        Idle> exit


For background information see User's Guide for Application Developers

Exercise 1.5: Check which visualization drivers are available

Check which visualization drivers have been compiled in Geant4. Run exampleN03 and pay attention to the output:
         Current available graphics systems are:
	   ASCIITree (ATree)
You can always retrieve this list with the command:
       Idle> /vis/list
at Geant4 prompt.

Check that OpenGL dirver is available. Check that OpenGL with Qt extensions has been build.

What are the corresponding driver names (short string between parenthesis)?

Which drivers are available in your application?

To use a specific driver, one can issue the command:

       Idle> /vis/open DRIVERNAME
at Geant4 prompt.

Look at vis.mac macro file, what is the driver that you are using?

Exercise 1.6: Check which User Interfaces (UI) are available

User Interfaces define how you will interact with the application.

UIs are controlled through environment variables: G4UI_BUILD_UIname_SESSION variables tell which UI have been built in Geant4, G4UI_USE_UIname tells you which UI your application will use.

Which UIs are available in your setup?

Hint: to see all environment variables related to Geant4 you can issue the shell command:

       % env | grep G4

Exercise 1.7: Run the example with the default UI and driver

When the example is executed without arguments it automatically uses the vis.mac macro (line 121 of file This file automatically opens a graphic window.

Which UI to use is decided at compilation time via the G4UI_USE_UIname variables; to change the UI you need to recompile your code.

Only one UI can be used each time. If more than one G4UI_USE_UIname is set the UI that is actually used is chosen as follows: G4UI_USE_TCSH has the highest preference, then G4UI_USE_XM followed by G4UI_USE_QT (if none is set a very basic text based UI will be used).

Which is the UI that you are using?

Exercise 1.8: Change zoom and move camera with default driver and UI

Launch the application and move the camera 5 cm to the left and increase zoom by 30%:

       % $G4WORKDIR/bin/$G4SYSTEM/exampleN03
       Idle> /vis/viewer/pan -5 0 cm
       Idle> /vis/viewer/zoom 1.3

What is the difference between pan/zoom and panTo/zoomTo commands?

Hint: at G4 prompt try:

       Idle> ls /vis/viewer
       Idle> help /vis/viewer/PutHereTheCommandName

Exercise 1.9: Use OpenGL Qt driver

Repeat exercise 4 with the OpenGL Qt driver.

Do you notice any difference?

Hint: if you use /vis/open OGL in your vis.mac file, this will issue /vis/open OGLIX or /vis/open OGLIQt depending on the used UI.

Exercise 1.10: Use Qt User Interface

Now we want to change the TCSH UI back to the Qt one.

Set the G4UI_USE_QT variable (if unset in Exercise 1.1). Hint: use shell command:

        % export G4UI_USE_QT=1
Rememeber that now you need to recompile your code! Acutally only the code containing the main function has to be recompiled:
        % touch
        % gmake

Re-run example. Try the Help, Cout, and History tabs.

Interact with the detector window: you can use the mouse to zoom, rotate pan etc (Hint: use right click for more options).

Get familiar with the new interface.

Hint: We will use Qt driver and UI for the rest of the tutorial. If your OpenGL window seems not to be updated try

or interact with the window using the mouse.

Generated on Tue May 10 17:25:54 2011