Muons, Inc.

G4beamline

VERSION

http://g4beamline.muonsinc.com
G4beamline
Introduction
Using the Program
Visualizing the System
HistoRoot - program to Create Histograms
References
Appendix: Using the OpenInventor Viewer
Appendix: Using the Wired Viewer
Appendix: G4beamline Commands
Appendix: List of Particles (QGSP)

G4beamline is a particle-at-a-time simulation program based on Geant4 [1] and optimized for the simulation of beamlines. See the G4beamline User's Guide at the above URL for a description of the program (it is also installed with this distribution).

This brief description only discusses how to use the program, it does not describe how to construct a simulation's input file; for that see the G4beamline User's Guide.

Using the Program

NOTE:Before G4beamline can run, it requires that various Geant4 data-sets be downloaded and unpacked; which specific data-sets are required depends on the physics list used in your input.file. When first run, G4beamline prompts the user to download them. If you find you need to download more data-sets, click here.

Select the input file using the "Browse" button above. The directory containing it will become the current directory, and the output file named above will receive the program output, as will this TextArea. Any additional Parameters used by the input file can be entered above. Pushing the "Run" button above will run the program, replacing this text with its output. While the program is running, the "Run" button above will change to "Abort" to permit you to stop the program immediately. Closing this window will also abort g4beamline. After running the simulation (with viewer=none), the simulation usually creates one or more Root files containing the NTuples. You can use the HistoRoot program to generate histograms from these files.

IMPORTANT NOTE: With a viewer selected, NTuple output files are not written. This includes both .root files and ASCII files from vitualdetector-s, zntuple-s, etc.

Several examples are provided in the distribution. They are located in the "examples" directory under the install directory. In Linux the install directory is usually in your HOME directory; in Mac OS X it is usually in /Applications; in Windows a Copy of "G4beamline examples" is placed into "My Documents" (Windows Xp) or "Documents" (Windows Vista).

Visualizing the system

viewer=none will run the simulation and write the NTuple files; any other choice will run the simulation and viewer without writing NTuple files. Each image in the viewer is a single run with the selected number of events.

viewer=best will visualize the system using OpenInventor; use its File/Escape to go to the next image (run). The OpenInventor viewer is part of the G4beamline program. For usage hints, see this Appendix.

The "Other" selection can be used to run any other viewer supported by G4beamline and installed on your system (if necessary). See the output from a G4beamline run with viewer=best to see the list of supported viewers.

viewer=Other:Wired will visualize the system using the Wired3 viewer [2]. The "Run" button will run the selected number of runs, each generating a .heprep file. When that is complete, the Wired viewer will be opened on the first file; it considers them "events". For usage hints in Wired, see this Appendix.

Using HistoRoot to Create Histograms

The HistoRoot program makes it easy to generate plots and histograms from the Root files containing NTuples. A macro version of HistoRoot is included in the G4beamline distribution; it requires a recent version of Root to be installed. NOTE: the macro version of HistoRoot runs about 100 times slower than the compiled version, so should only be used for small files. The compiled version of HistoRoot is available at http://historoot.muonsinc.com; it requires the spedific version of Root from that webpage. G4beamline can create .root files without Root being installed, and you can install Root and/or HistoRootafter generating them, if necessary. HistoRoot has its own Help to assist you in using it.

References

 [1] http://geant4.cern.ch
 [2] http://www.slac.stanford.edu/BFROOT/www/Computing/Graphics/Wired/
 [3] http://root.cern.ch

Using the OpenInventor Viewer

Because the OpenInventor driver (OIX) is so much more useful than the other drivers, it is the driver of choice (linked to the name "best" whenever possible). This driver will permit you do to almost everything that any other driver can do. It is run synchronously from the G4beamline program, so at the end of a run the veiwer is opened. To go to the next run (image), select File/Escape -- this exits the OpenInventor viewer, and G4beamline will simulate the next run, displaying its image at the end.

Like other X-windows programs, the OpenInventor driver of G4Beamline can operate in either local or remote (networked) mode. Both the X display client and server must have the 3-D display capabilities of OpenGL installed. Operation over a network can be slow, and a good network connection (>1 megabit/sec) is required for useful results.

The Rotx and Roty wheels at the lower left rotate the image relative to the viewer, and the Dolly wheel (Z) at the lower right moves in and out with a corresponding change of scale. The buttons along the right edge do the following:
ArrowSelect pick mode and cursor
HandSelect move mode and cursor (default)
?Help (not implemented)
HouseRestore display to Home position
House with arrowSet Home position to be the current display
EyeZoom so everything is visible
GunsightNot implemented
Perspective box outlineSelect isometric or projected display

When the Hand cursor is active the mouse behaves like this:
Left ButtonClick and drag to rotate the display. It acts as if there were an invisible sphere surrounding the image, and the mouse movements rotate that sphere in any direction. This is quite different from the Rotx and Roty wheels, and takes some getting used to.
Middle ButtonClick and drag to pan the display -- this moves the visible objects around without changing perspective.
Right ButtonBrings up a menu with various functions, Draw Styles, and other items. The most useful is DrawStyles/StillDrawStyle/Wireframe which will draw in the wireframe mode rather than as solid surfaces. This permits you to look inside objects, and is considerably faster drawing. NOTE: daughters are not necessarily visible in wireframe mode -- see the Etc. menu item that makes them visible.

The File menu has several useful items:
PS (gl2ps)Save the current image in PostScript (drawing)
PS (pixmap)Save the current image as PostScript (pixel map)
IVSave the current image as an OpenInventor file
EscapeExit the OpenInventor Viewer. This causes the program to simulate the next run and display the result.

The Etc. menu has several useful items:
Set SolidSet the G4 mode to Solid (default)
Set (G4) reduced wire frameSet the G4 mode to wireframe, real edges only
Set (G4) full wire frameSet the G4 mode to wireframe, including triangles to fill surfaces
Visible mothers + invisible daughtersDaughter volumes are invisible (default)
Visible mothers + visible daughtersMake all objects visible
Note that daughter volumes are by default invisible, so to look inside a solid object you usually need to select wireframe mode and also Etc/VisibleMothers+VisibleDaughters.

The key to understanding how objects are displayed is to know that Geant4 has a solid/wireframe choice, and OpenInventor has a solid/wireframe choice, and they are different:
G4 mode
(Etc menu)
OI mode
(Right click menu)
Description
SolidSolid (as is)Draw solid surfaces
SolidWireframeDraw wireframes with triangles filling visible surfaces
Reduced WireframeEitherDraw reduced wireframes, showing only real edges
Full WireframeEitherDraw wireframes with triangles filling visible surfaces
For instance, in G4 reduced wireframe mode a sphere is invisible as it has no real edges; in G4 full wireframe mode it has triangles filling its visible surface (in such a way you can tell it is a sphere).

The OpenInventor driver has many more features, but this should get you started. It will also do animation: with the hand cursor left click and drag the image, letting go of the button while moving -- the image will continue to rotate until you left click on it (works best locally).

Using the Wired Viewer

The Wired event viewer is a reasonably flexible viewer, and can do most of what users typically need to do. Compared to OpenInventor, it has only the "reduced Wireframe" mode of drawing, and it is somewhat less intuitive how to manipulate the image to look from different perspectives.

On Windows, the Wired viewer is installed with G4beamline, and is used as the "best" viewer. On Linux and Mac OS, you must install it manually [2] and then make a symbolic link from its install directory to [g4beamline install directory]/Wired -- then you can set Other to Wired and use it.

When the Wired viewer comes up, it displays a few centimeters near the point x=0,y=0,z=0. It may happen that your system has no visible objects there and the display may look blank. On the lower left is a set of icons, and a click on the second one (a "plus sign" with 4 arrowheads) will zoom so that your entire system will be in the display.

The Wired viewer is started with the first image file loaded. At the top of the window is a toolbar with icons for "open", "reload", "previous event", "next event", "up (inactive)", "down (inactive)", "Toggle Automatic Updating (looks like a clock)", "Create New Window", and "Show/Hide Data Tree". On the right side of the window is a data visibility tree that permits you to select individual elements of the simulation and toggle their visibility.

At the bottom of the viewer subwindow are 8 icons and 2 sliders. The icons are:
RReset View
+ with arrowheadsFit in Window
+Zoom In
-Zoom Out
+ arrows pointing inReset Translation
CCW arrowRotate Counter Clockwise
CW arrowRotate Clockwise
CircleReset Rotation
The left bottom slider translates the image, and the right bottom slider rotates it. The translate slider does not immediately react to reversals of direction. The rotate slider may look like it goes forward and backwards while sliding in one direction -- this is really due to the fact that you are looking completely through the system, and a right rotation makes components behind the center move to the left (etc).

Along the right edge of the viewer are two sliders. The upper one translates the image and the lower one rotates it. The same remarks apply to these.

A right-click on the viewer window brings up a context menu with several useful choices:
Orientation ActionsPerform the above icon actions, plus more. Includes OrientationActions such as TopView, SideView, CenterInWindow, etc.
Orientation ToolbarTurn the bottom icons on or off
ProjectionSelect projection (Parallel is the default)
Mouse FunctionSelect what mouse actions do
Drawing OptionsVarious drawing options
By selecting MouseFunction/Rotation you can drag the viewer window to rotate it, as in OpenInventor (i.e. the mouse is rotating an invisible sphere containing the system). Similarly, MouseFunction/Translate lets you pan the image using the left mouse buton, as OpenInventor does with the center mouse button.