Geant4 Visualization Tutorial using the HepRApp HepRep Browser
This tutorial is designed for anyone who wants to learn
HepRApp Visualization for Geant4.
The tutorial can be used on its own, but gives the most comprehensive introduction to
Geant4 visualization when used as part of the following full set of documents:
When you run Geant4 visualization using
/vis/open HepRepFile
Your output comes in a graphics file in a format
called HepRep
(for High Energy Physics REPresentables).
This visualization tutorial will show you how to use the HepRApp HepRep Browser
to view that HepRep file
(or an equivalent file included with this tutorial - see details later).
HepRApp is written as 100 percent pure Java to provide a true "runs anywhere" capability.
It is currently being used on all versions of Windows (from Windows 95
to XP and Vista), Linux, Unix and Mac OSX.
HepRApp, and the HepRep graphics protocol, are general purpose tools
that can read data from many sources (such as the BaBar collaboration's
offline and live data servers and the GLAST collaboration's Gaudi services).
Complete instructions on installation and operation of the HepRApp HepRep Browser,
along with many additional references, can be found at the
HepRApp Users Home Page.
But this present document should have enough instructions to get you going.
HepRApp's input is something called a .heprep file.
The .heprep file is a plain text file format that contains a full 3D description of what is to
be drawn (geometry, trajectories, hits, markers - depending on what you chose to add from Geant4)
plus visualization attributes (such as color and linestyle) and an extensible set of additional
physics attributes (such as momentum, particle name and energy).
You don't really need to understand the details of the .heprep file format to use HepRApp, but in
case you are interested:
-
The .heprep file is an XML format, which means that it is self-describing in a way that lets
many common tools (most web browser) display it with helpful indenting and color coding.
-
HepRep is a hierarchical format: Geant4 volumes have sub-volumes, etc.
HepRep browsers such as HepRApp let you control visibility and other attributes based on this
hierarchy (so that you can, for example, interactively turn on and off whole parts of the detector).
-
HepRep was not developed specifically for Geant4 but is intended as a generic interface between
data sources and display clients.
-
Because the HepRep file format was not created specifically for Geant4, it does not have exactly the
same set of graphics primitives as Geant4. Geant4 solves this by decomposing some of the more complex
Geant4 shapes into simpler polygons before they are written out to HepRep.
-
HepRep is further described at:
The HepRep Home Page
The .heprep file format is fairly easy to understand just by looking at it.
Here are some lines from one example:
<heprep xmlns="http://www.freehep.org/HepRep"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="HepRep.xsd">
<layerorder="Detector, Event, CalHit, Trajectory, TrajectoryPoint, Hit"/>
<typetree name="G4GeometryTypes" version="1.0">
<type name="Detector">
<attvalue name="Layer" showLabel="NONE" type="String" value="Detector"/>
<attdef category="Physics" desc="Logical Volume" extra="" name="LVol"/>
<attdef category="Physics" desc="Material Name" extra="" name="Material"/>
<type name="Detector/World">
<type name="Detector/World/Calorimeter">
<type name="Detector/World/Calorimeter/Layer">
<type name="Detector/World/Calorimeter/Layer/Lead">
</type>
</type>
</type>
</type>
</type>
</typetree>
<typetree name="G4EventTypes" version="1.0">
<type name="Event">
<attvalue name="Layer" showLabel="NONE" type="String" value="Event"/>
<type name="Event/Trajectory">
If you have not yet produced your own HepRep file, this might be a good time to do so.
You can also skip running Geant4 for now and instead find a copy of Geant4 example A01's HepRep file
here (this version differs from the one you would have
created yourself only in that this version has been compressed using gzip - this saves
a factor of about 20 in space and can still be read directly by WIRED3, no need to unzip).
The commands to generate a .heprep file from a typical example such as example A01 are:
$G4BIN/A01app
/vis/open HepRepFile
/vis/drawVolume
/vis/viewer/flush
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1
At the first "/vis/viewer/flush", a .heprep file is produced that contains only detector geometry.
At the "/run/beamOn 1", a second .heprep file is produced that contains geometry plus trajectories and hits.
This file is produced because the "/run/beamOn" automatically does a "/vis/viewer/flush".
Other commands that might be useful are discussed in this document's section called
Further Resources.
Ignore any commands related to setting camera views, lighting or surface style.
Those commands are only relevant to an immediate visualization driver such as OpenGL.
When you work with a driver such as HepRepFile that has a 3D file format, you set these
things later, from the visualization application, HepRApp.
The installation instructions are taken from the
HepRApp Users Home Page in April 2007.
If significant time has passed since that date, or if you just want more detailed
information, please check back with that original source.
Nothing could be simpler than installing HepRApp.
The application comes as one simple file, HepRApp.jar.
If you are on Mac or Windows
(or some other systems that have automatic association of jar files with Java),
just click on this file to start the application.
-
If your system doesn't know what to do with a jar file,
try associating jar files with the command "java -jar"
-
If that doesn't work, run the application from the command line by typing: java -jar HepRApp.jar
-
If none of that works, you probably don't have an appropriate Java version.
See Checking Your Java Version or Installing a new Java.
The first time you run HepRApp, it will immediately open the "Select Group" menu.
This is where you can specify whether HepRApp should run with any special settings
for known groups (currently the BaBar and GLAST experimental collaborations).
As a Geant4 users, you should just select the option called "Standard".
You can also revisit this setting at any time from the Options menu.
The setting you make here, along with many other settings you make as you work in HepRApp,
will be stored in a file called "user.properties" that will be created in the directory
from which you ran HepRApp.
If all is well at this point, procede to the HepRApp Tour for Geant4 Users.
If the application did not start correctly, there is probably a problem with your version of Java.
Read the next section right here.
HepRApp requires Java version 1.4.1 or greater,
and your Java MUST NOT Be one called libgcj.
You can check the version number by typing the following from a terminal window
(or on Windows, a command or cygwin window):
java -version
If the response includes the words "libgcj", watch out, this is not a real Java version.
Rather, it is a minimal version that some Linux distributions include as a place-holder for a real Java.
While it may be sufficient to run some simple web applets, it is not sufficient to run serious
Java applications such as HepRApp.
If you don't already have the appropriate Java:
-
You can obtain Windows,
Sun or Linux versions of Java free from
Sun at
http://java.sun.com/javase/downloads/index.jsp
-
If you just want to run Java programs, the minimum package you should take is the one called
"Java Runtime Environment (JRE)".
-
If you also want to be able to make your own Java programs (not something you need to do for HepRApp),
you may want to take the development kit, "JDK". You do not also need the JRE since JDK includes the JRE.
Additional notes for Linux users:
Use the Open Data button to select some data.
You should see a new window as follows:
-
Select "Open HepRep File..."
and navigate to the directory where you wrote your .heprep file.
This should be something like geant4/examples/extended/analysis/A01/G4Data1.heprep.
-
If you have not run the G4 tutorial example yourself, you can find the same .heprep file
here
-
You can even just have HepRApp read that file over the web by using "Open HepRep URL..."
rather than "Open HepRep File..."
and specifying
http://www.slac.stanford.edu/~perl/heprep1xml/G4Data1.heprep.gz
You can also use the "-file" startup to have HepRApp start right off with
a particular heprep file (either from local disk or from the web).
You do this either by:
- Specifying a file property in your user.properties file, by including a line such as:
file=c:\jp\slac\geant4\G4VisTutorial\G4WIREDTutorial\G4Data1.heprep
or
file=http://www.slac.stanford.edu/~perl/heprep1xml/G4Data1.heprep.gz
- Or running HepRApp from the command line with the file property specified right there:
java -jar HepRApp.jar -file c:\jp\slac\geant4\G4VisTutorial\G4WIREDTutorial\G4Data1.heprep
or
java -jar HepRApp.jar -file http://www.slac.stanford.edu/~perl/heprep1xml/G4Data1.heprep.gz
Use the reload button to reread data that may have changed.
If you are reading files from disk (rather than a URL),
you can always quickly go to the next file produced by Geant4 by hitting the
right arrow button at the top of the window.
This "next event" button always gets the next .heprep or .heprep.gz file
alphabetically in the current file's directory.
Since each new picture produced from Geant4 has a sequential heprep file name, this button
gets you the next Geant4 picture.
Note that it will be the next or previous file of the exact same file extension.
Thus if there is a mix of .heprep and .heprep.gz files, it will skip some of those files.
You may notice that the web accessible files have the suffix
".heprep.gz" whereas the version you make directly from Geant has just
".heprep". This is because HepRApp can accept gzipped HepRep files
as easily as unzipped HepRep files. Unzipped HepRep is an easy format
for people to read and, if necessary, edit (it is an XML format),
but the files can get very large. GZipping solves this problem,
compressing the files to about five percent of their original size.
Regardless of how you open the file, you should end up with an image as follows :
The other options on the File Chooser are not relevant to this G4 tutorial
but are discussed in detail in the
HepRApp Users Home Page.
Orientation Toolbar
The bottom of the view window contains the Orientation Toolbar.
These buttons control zoom, rotate and translation functions
(later you will learn how to also control these with various mouse drag
operations).
-
Fit in Window adjusts scaling to make the entire image fit the window.
Try this right away to make the entire G4 example fit the current window.
You should then see the following:
the rest of the orientation toolbar
-
Reset restores all options to their default values.
-
Fit To Window adjusts scaling to make the entire image fit the window.
Try this right away to make the entire example fit the current window.
You should then see the following:
-
Zoom In and Zoom Out.
-
Center the image.
-
Rotate the image around the axis perpendicular to the screen.
-
Translate the image left or right.
-
Rotate the image around the screen's vertical axis.
You can either click on the little arrows on either side of the slider
or you can click and drag the slider.
-
Additional tools along the right side of the window allow translation
up or down and rotation around the screen's horizontal axis.
-
Orientation can also be controlled by the mouse, which controls various
parameters depending on what mouse function you have specified from the
View Popup menu discussed below.
The following shows a rotation around the screen's horizontal axis.
Orientation Actions in the Popup View Menu
To select from among some standard views, place the cursor into the window
that contains the event display and hit the right mouse button
(Macintosh users, hit control and mouse button).
You should see a new window as follows:
Then select "Orientation Actions", which will give the following submenu:
Use these options to select standard views or reset to the initial view.
"Top View", for example, will give you the following:
which will make a little more sense if you then hit the "Fit to Window" button:
So you then see the following:
The rest of the popup view menu will be discussed later.
Data Visibility Tree
use the Data Visibility Tree to toggle on and off visibility of data
and detector elements.
A tree will appear at the right side of the main window.
Widen the main window a little by dragging on the window's right side.
You should then see the following:
- Click on the signs next to the first line of text to expand the tree.
Depending on your operating system and selected Java look and feel, the sign
will be either a little right arrow, or a circle with a line coming out of it, or a plus sign.
In any case, it is the symbol to expand the tree.
-
If you expand the first level, you should then see separate items for
"Detector Geometry" and "Event Data".
- Click on the check marks to toggle items visible or invisible.
Try turning off first the Event Data and then the Detector Geometry.
Turn the Detector Geometry data back on.
- Expand the tree further.
Each check mark controls visibility of everything from that level of the
tree downward.
- If you see no change when you turn an item on, expand that part of the
tree and turn on the items deeper within the tree.
- To see a popup menu with more tree manipulation options,
position the cursor over a part of the tree and hit the right mouse button
(Macintosh users, hit control and mouse button).
The popup menu includes options to expand or turn on an entire tree structure
with a single action.
- Point at the line "Detector Geometry", right click, and select
"Expand Tree Below".
You will then see the entire detector geometry tree.
- Close the part of the tree called "firstArmPhysical".
- Point at "secondArmPhysical", hit the right mouse button and select
"Show All Below".
The Hadronic Calorimeter, depicted as the blue rectangle at the lower right,
will then have so much detail that it appears as a solid filled area
(actually a very complex set of individual calorimeter cell outlines).
Interaction Between View Window and Data Visibility Tree
Picking on objects in the view window can cause them to highlight in the
Data Visibility Tree, and the opposite is also true.
-
To try this, return now to the View Popup Menu by pointing at the view
window and hitting the right mouse button.
- Expand the "Mouse Function" submenu and select "Pick Rectangle".
- Now click and drag with the left mouse button to select some objects
from the view. Try picking on the top part of the white circular structure at the center of the view.
- A window will pop up that tells some attributes of the picked object (it was a magnet),
the picked object will now stand out (all other objects will be dimmed)
and the corresponding object will highlight in the Data Visibility Tree.
- To undo the highlighting, pick on any empty part of the view.
- To see the inverse of this effect, again expand the Detector Geometry part of the
Data Visibility Tree, point at its item named
"secondArmPhys", hit the right mouse button, and select "Toggle Highlighting".
The entire secondArmPhys should now be highlighted in the view window
(all other objects will be dimmed).
- Picking on trajectories will give you information about the selected particle.
Try picking on the trajectory that disappears off the lower right corner of the view.
You will find that this was a gamma.
Expand the popup attribute window a little (by clicking and dragging on a corner)
to read the entire momentum string.
IMag gives the magnitude of the momentum.
IMom-X, Y and Z give the three separate components of the momentum.
- The attributes you see here were filled in Geant4's class
source/tracking/src/G4Trajectory.cc.
HepRApp simply displays whatever attributes were set in that Geant4 class.
You could easily add additional attributes by setting them in your own copy
of G4Trajectory. The relevant lines have the form:
G4String Ch("Ch");
(*store)[Ch] = G4AttDef(Ch,"Charge","Physics","","G4double");
and
s.seekp(std::ios::beg);
s << PDGCharge << std::ends;
values->push_back(G4AttValue("Ch",c,""));
- If you didn't see any attributes when you picked on the trajectory, it may be that your
particular Geant4 example is using some special verison of G4Trajectory that doesn't fill
any attributes. Try the standard version of G4Trajectory, or copy that version's
attribute-filling logic into your special G4Trajectory.
HepRApp can label any object with any of its HepRep attributes.
For example, the label could appear as follows:
Labelling follows the flexible scheme envisioned in the
HepRep standard.
For example, if there is a Track that has a Transverse Momentum of 3.143 GeV, you can choose
to
- have no label
- have the label "P_T 3.143 Gev"
- have the label "Transverse Momentum 3.143 GeV"
- or even just "3.143".
Labels are anchored to whatever point of the object appears closest to a screen edge.
This has the desireable affect that when you zoom in on a track, while the end of the track may
fall off the screen, the label will slide along the track, remaining on the screen, unless the
track falls completely off the screen.
You can reposition labels by hand if you need to.
- From the View Popup Menu, Select "Mouse Function..."
- Select "Pick to Offset Label"
- Click and drag over a label to select which label to move.
- The selected label will highlight. Everything else will be grayed out.
- Click and drag a second time to actually move the selected label.
- Note that you are actually storing an offset, such that if you then zoom or rotate the image,
the label will move. It is the new offset you created that will remain constant.
- If you subsequently "Export Graphics", the new offset will still be used.
- Note that if you turn the data type off and then back on (from the Data Visibility Tree),
your new offset will be lost and the label will return to the automatically computed initial position.
Labels can be controlled from a Label Control Dialog or from startup options.
-
To get to the Label Control Dialog:
-
Select "Label Control..." from the Options Menu.
-
Or, to see a version of the label control dialog that is focused on just
a particular data type, pick on an object in the main view window
(while the View Popup Menu's
"Mouse Function"..."Show Attributes" option is on).
Then, from the resulting attribute popup, select "Label Control..."
The label control dialog will appear.
-
Or, right click on an object in the
Data Visibility Tree,
and from the resulting menu, select "Label Control..."
Either way, the Label Control Dialog will appear.
-
To control labels from a startup option:
java -jar HepRApp.jar -label "KalmanTrk:nSvt:13;KalmanTrk:nDch:13;" -group babar -server kan18mc
where the syntax is "TypeName:AttributeName:Flag;"
and the flag is an integer bitmap composed by adding up:
- 1 for the short name (such as P_T)
- 2 for the long name (such as Transverse Momentum)
- 4 for the value
- 8 for the units (such as GeV)
So, for example:
- 13 would give "P_T 3.124 GeV"
- 14 would give "Transverse Momentum 3.124 GeV"
- 4 would give "3.124"
You can always override this initial label setting by the interactive label control.
-
Some servers or HepRep xml data can already contain flags to control labelling.
You can always override this server default by specifying a startup option
or by the interactive label control.
HepRApp can hide objects based on cuts that you provide.
For example, you could cut out all calorimeter clusters that have less than
some specified energy. Cuts can be based on any HepRep attribute.
Cuts can be controlled from a Cut Control Dialog or from startup options.
-
To get to the Cut Control Dialog:
-
Select "Cut Control..." from the Options Menu.
-
Or, to see a version of the cut control dialog that is focused on just
a particular data type, pick on an object in the main view window
(while the View Popup Menu's
"Mouse Function"..."Show Attributes" option is on).
Then, from the resulting attribute popup, select "Cut Control..."
-
Or, right click on an object in the
Data Visibility Tree,
and from the resulting menu, select "Cut Control..."
Either way, the Cut Control Dialog will appear.
-
Type in a cut value in either the "equals" area or the "min" or "max" area,
-
Then, while the cursor is still in that area, hit the "enter" key.
-
To remove a cut, remove the value and again hit the "enter" key.
-
For example, here is some data before a cut. Notice the many low momentum delta rays
that appear as red trajectories:
-
Apply a 25 MeV cut on Trajectories:
-
Only two trajectories remain (we've turned on the trajectory momentum label here as well):
-
To set cuts from a startup option:
java -jar HepRApp.jar -cut "EmcCluster:E>0.5;"
where the syntax is one of either:
- "TypeName:AttributeName>MinValue;"
- "TypeName:AttributeName<MaxValue;"
- "MinValue<TypeName:AttributeName<MaxValue;"
- "TypeName:AttributeName=Value;"
You can always override this initial cut by the interactive cut control.
The type of value tested can be either integer, float or string as long
as it matches the type of value of the relevant HepRep attribute
(which can be seen from the attribute popup or by using the
labelling feature.
Whenever cuts are in force, the cut will be listed in the lower right
corner of the view window, and this list will be included in any
exported graphics.
Specialized Projections
The HepRApp HepRep Browser can perform many specialized projections that
distort the visualized space in useful ways.
Because some of these projections assume a cylindrical detector design,
read in a more appropriate detector geometry file before proceeding
with the tutorial.
-
Use the file BaBar_Example1.heprep.gz which you can find
here
-
You can even just have HepRApp read that file over the web by using "Open HepRep URL..."
rather than "Open HepRep File..."
and specifying
http://www.slac.stanford.edu/~perl/heprep1xml/BaBar_Example1.heprep.gz
When the image appears, reset to standard scale and rotation by using
the Reset button at the lower left corner of the view window.
Also, undo any left over picking information by picking on an empty area of the image.
You should end up with an image as follows:
The image shows a simplified rendition of the BaBar detector
with real data from the collision of an electron with a positron
at the PEPII accelerator at SLAC.
- The green dots at the center are hits in a Silicon Vertex Tracker.
- The red, blue and green dots outside of that area are hits in a
Drift Chamber (different colors represent different "stereo angles",
a drift chamber design detail we won't go into here).
- The green squares outside of that area are hits in an Electromagnetic
Calorimeter.
A good example of a specialized projection is the "FishEye Projection".
From the Popup View menu, select "Projection"..."FishEye".
You should then see the following:
The FishEye has distorted the space such that the inner parts of the
detector are exanded while the outer parts of the detector are compressed.
This can be superior to a standard zoom since, while it allows a close
inspection of the inner area, it still allows one to correlate inner
detector data with outer detector data.
With the specialized projection comes a specialized mouse function.
Try clicking the mouse near the center of the image and then dragging
outward. The FishEye quality will be enhanced (you have altered the
FishEye's "alpha" parameter), such as in the following:
Two more examples of projections are:
-
Z-FishEye
a projection in which you can control what percentage
of screen space is given to low Z versus high Z parts of the detector
(no effect will be visible from the beam view,
select side or top views instead).
The mouse will default to control this new variable, known as "alpha",
and the Mouse Function menu will now show more options, such that the mouse can
control either this new "alpha" variable or can control any of the
standard variables (scaling, translation, rotation).
-
Rho-Z
the detector is cut along a plane of constant phi angle.
All elements above this plane are collapsed together on the top half of
the display, all elements below this plane are collapsed together on the
bottom half of the display.
The mouse will default to control this new variable, known as "phi0",
and the Mouse Function menu will now show more options, such that the mouse can
control either this new "phi0" variable,
or a degree of FishEye projection, or any of the
standard variables (scaling, translation, rotation).
Return to the Parallel Projection before continuing with the tutorial.
Multiple View Windows
To open additional view windows, click the "New View" button.
You will then see two views as follows:
You can then control the views separately.
The following example shows four views:
- At top left is a Parallel Projection beam view.
- At top right is a FishEye Projection beam view.
- At bottom left is a Parallel Projection side view, slightly zoomed in, with detector geometry
turned off.
- At bottom right is a Parallel Projection top view, slightly zoomed in, with detector goemetry
turned off.
Each view has its own Data Visibility Tree.
The visibility tree that is shown at the right always corresponds to the
currently selected view.
Printing
To print the selected view directly to a printer (as a bitmapped image),
click on the File Menu's "Print..." option.
Your regular system printer selection dialog will then take over.
For many higher quality print options, including vector PostScript,
select the File Menu's "Export Graphics...".
-
For each format, once you have selected the format you should then click the
"Options..." button to the right of the format name. This brings up a panel of
options appropriate for that graphics format (letting you adjust options such as
background colors, transparency, whether to include a preview image, etc.).
-
This impressive selection of output formats and detailed options is made possible by the
FreeHEP VectorGraphics Package.
-
Preferred formats for publication quality images are the vector formats.
Additional Mouse Functions
You have already seen the mouse used for picking objects to see their
attributes, and for adjusting the FishEye projection's alpha parameter.
The Popup View Menu's "Mouse Function" menu lets you also configure the
mouse in other ways:
-
PickWedge, PickCircle and PickPolygon are similar to PickRectangle,
but they let you define the pick area in other ways.
Give them a try.
-
To pick more than one object at a time (for example to highlight
two different tracks), pick the first one normally, then hold down the
control key while you pick the second one.
-
Pick To Measure toggles on a feature that lets you measure the distance
between two points.
Click at the first point and then drag to the second point.
(Remember that, as the mouse knows nothing about the coordinate into or
out of the screen, the measurement you are getting is just the component
in the screen plane.)
-
Pick To Offset Label lets you adjust the position of labels.
See details in the
HepRApp Users Home Page.
-
Show Attributes lets you disable the pop-up table that shows the
attributes of picked objects.
-
Highlight in Data Visibility Tree lets you stop the data visibility
tree from showing what you have picked.
-
Transform View and Show Daughters are not relevant for Geant4 data.
See details in the
HepRApp Users Home Page.
-
The remaining items vary depending on the current projection.
For the default, Parallel Projection, these functions include zoom,
translate and rotate.
An interesting feature of HepRApp is that projections are "daisy-chained".
The results of the Fish Eye Projection, for example, are subsequently
piped through a Parallel Projection. This means that after you have
adjusted the fish eye's alpha parameter, you can also perform a standard
spatial rotation around the detector, such as:
Additional Buttons on the Top Button Bar
The up and down buttons are not relevant to data from HepRep files.
They are only used when navigating events from a HepEventServer.
See details in the
HepRApp Users Home Page.
The Auto Update button causes HepRApp to automatically cycle through HepRep files
in the current directory. It is equivalent to repeatedly pressing the next event button.
You can adjust the update rate from the Options Menu.
Additional Items in the Popup View Menu
-
Orientation Toolbar
turns off and on the orientation toolbar that was described above.
-
Drawing Options...Show Shadows
lets you control whether objects have drop shadows.
Such shadows make it easier to see objects when they fall on top of
another object of similar color, but they slow down the system
and can appear unattractive in some hard copies (due to the different
background color used in a hard copy).
-
Drawing Options...AntiAlias
lets you control whether lines are anti-aliased, a rendering technique that improves
the smoothness of lines at some cost to interactive performance.
Try drawing with and without this option to find what is best for your graphics card and screen.
-
Drawing Options...Always Use Fast Mode
speeds up performance by using fast drawing options.
Lines are always rendered a single pixel wide.
Area fills are ignored.
By default this option is turned off and fast mode is only used during mouse drag events.
So when, for example, you click to zoom, drawing is done in fast mode only until you complete
the drag motion.
-
Drawing Options...Show Status
lets you control whether a status box is drawn in the top right corner
of the view window. This status gives parameters of the view.
-
By default, the Geant4 HepRepFile driver will write a file called G4Data0.heprep to the current directory.
Each subsequent file will have a file name like G4Data1.heprep, G4Data2.heprep, etc.
-
You can specify a different directory for the heprep output files by setting the environment variable
G4HEPREPFILE_DIR, as in:
export G4HEPREPFILE_DIR=someOtherDir/someOtherSubDir
-
You can specify a different file name (the part before the number) by setting the environment variable
G4HEPREPFILE_NAME, as in:
export G4HEPREPFILE_NAME=myFileName
which will produce files named myFileName0.heprep, myFileName1.heprep, etc.
-
You can specify that each file should overwrite the previous file (always rewriting to the same file name)
by setting the environment variable
G4HEPREPFILE_OVERWRITE, as in:
export G4HEPREPFILE_OVERWRITE=1
This may be useful in some automated applications where you always want to see the latest output file
in the same location.
-
Geant4 visualization supports a concept called "culling", by which certain parts of the detector can be
made invisible.
By default, Geant4 Trajectories are drawn as polylines with no specific symbols for step points.
But you can specify additional commands to make trajectories include dots for step points
and you can adjust the size and color of these dots.
Sample commands are:
/vis/modeling/trajectories/create/generic
/vis/modeling/trajectories/generic-0/default/setLineColour blue
/vis/modeling/trajectories/generic-0/default/setDrawLine false
/vis/modeling/trajectories/generic-0/default/setDrawAuxPts true
/vis/modeling/trajectories/generic-0/default/setDrawStepPts true
/vis/modeling/trajectories/generic-0/default/setStepPtsSize 5
/vis/modeling/trajectories/generic-0/default/setAuxPtsSize 5
/vis/modeling/trajectories/generic-0/default/setAuxPtsColour yellow
/vis/modeling/trajectories/generic-0/default/setStepPtsColour red
/vis/modeling/trajectories/generic-0/default/setStepPtsColour red
/vis/modeling/trajectories/generic-0/default/setStepPtsType circles
By default, these step points will not have any HepRep attributes.
Picking on these points in HepRApp will not give you any specific information about those points.
But with a slightly different form of the command
/vis/scene/add/trajectories
you can tell Geant4 to generate points that contain a wealth of additional HepRep information.
Just use:
/vis/scene/add/trajectories rich
The cost is that the HepRep file will now be larger (and Geant4 will run slightly more slowly, since it has to
write this additional information). But now each step point will have extra information that will be displayed
when you pick on the point in HepRApp:
-
Total energy deposited at this point
-
Position (x,y,z)
-
Why was this point generated
-
Interaction
-
Decay
-
Boundary Crossing
-
Step
For more details on use of Rich Trajectories, and the other /vis/modeling and /vis/filtering commands,
see Geant4 Advanced Visualization
(ppt,
pdf)
If you need to quickly repeat the commands to generate the .heprep file, it may be
helpful to cut and paste a set of commands from this list:
$G4BIN/A01app
/vis/open HepRepFile
/vis/drawVolume
/vis/viewer/flush
/vis/scene/add/trajectories
/vis/scene/add/hits
/run/beamOn 1
Documents in this Visualization Tutorial Set:
Other Resources:
Joseph Perl
1 June 2007