Back to Agenda
In this first hands on you will learn:
$ cd <tutorial> #change <tutorial> to your working directory |
Follow the instructions of Hands On
1 to configure with cmake
the example and build
it.
Hint: Remember the cmake comamnd line option:
-DGeant4_DIR=
to specify where the Geant4
lib/Geant4-10.0.1
directory is located. The last argument
of cmake is the location of the source code, in our case: <tutorial>/HandsOn2
.
Try out the application:
$ cd <tutorial> #If needed, do NOT do the next in HandsOn2 directory (Where the code of the exercise is. |
[Debug|Releaase|RelWithDebInfo]
).The following should appear:
Familiarize with the application GUI (if enabled). In particular note
the menu with different actions. It is possible to execute UI commands
directly form the menu.
The default behavior of the application when started without command
line arguments is to start the GUI (if enabled) and execute the macro
init_vis.mac
(init.mac
if no support for
visualization has been enabled in G4).
If visualization is enabled and the UI session is graphical the
additional macro gui.mac
is also executed.
You can start the application withotu graphics and execute directly
a macro file, passing to SlacTut
a macro name, for
example: ./SlacTut run1.mac
gui.mac
macro? Check the syntax of
the commands in the application GUI (help panel), or type:
help <command>
|
Modify the run1.mac
macro file.
Modify some parameters of the simulation: number of events, the particle type.
DetectorConstruction::ConstructMaterials()
where all materials
that are used in the application are built. Such method is not
mandatory, but it may help to organize your code. Throughout this
tutorial the exercises are clearly marked in the code itself: search
the commented lines:
//============================ |
Create a CsI (Cesium Iodide) material starting from the elements.
Some properties:
The materials defined are :
. At the end of
the method DetectorConstruction::ConstructMaterials()
there is a line that prints on screen the complete list of materials
defined. Note the paragraph relative to CsI and its properties./material/g4/printMaterial [name|all]
can
be issued at run time to print the material table.
DetectorConstruction.cc File: |
G4Element* el_i = new G4Element("Iodine","I", 53,126.9*g/mole);
|
Use NIST database to create Lead material.
Hint: You can use UI command
/material/nist/listMaterials
to dump on screen the list
of all known Geant4-NIST
compounds. Search for the name relative to lead.
Build again the application and run it again. Note that now the list
of materials includes lead with all naturally abundant isotopes.
DetectorConstruction.cc File: |
nistManager->FindOrBuildMaterial("G4_Pb");
|
In this example we will create a very simple geometry. The goal of this exercise is to show how to define a shape, a logical volume and a simple placement.
Add a box of to the setup.
The box has full dimensions (X times Y times Z): 300x60x100 cm,
select CsI as material. Place the box inside the logical volume
second arm. It should be placed at the very back of the mother
volume. At the end of the tutorials this simple box will become a
calorimeter.
Re-compile and check that you obtain the correct behavior:
DetectorConstruction.cc File: |
G4Material* material = G4Material::GetMaterial("CsI");
|
Change material of the box and observe effect on physics simulation.
Modify the material of the box: instead of CsI, use the
scintillator. Simulate a single electron. Note how the material
affects the shower dimensions:
In this exercise we will collect simulation information using command line scoring. A scoring mesh will be defined on top of the volume created in Exercise 2.a, different quantities will be recorded, and we will show how to display and store the scored quantities.
Enable command line scoring.
Instantiate a scoring manager in the main()
function.
tutorial.cc File: |
// Activate UI-command base scorer
|
Score some quantities: energy deposit, number of steps of gammas and use some filters.
Using UI commands create a box mesh that is placed on top of the box you created. The mesh should have the same dimension as the box and it has (X times Y times Z) 30x6x10 voxels. Score the following quantities:
Hint: use the help
command to understand the
format of command line scoring UI commands.
The macro scoring.mac
shows all the UI commands needed
in this exercise.be used directly to create
the output file:
$ ./SlacTut scorer.mac
|
scoring.mac File: |
/run/initialize
|
Visualize scored quantities.
Using UI commands draw on the screen different scored
quantities. For example the energy deposit looks like:
The macro file draw.mac
shows how to draw scored
quantities, in also shows how to draw slices using loops in UI
commands.
This macro should be executed after
scoring.mac
:
$ ./SlacTut
|
draw.mac File: |
########################################
|