Short Course NSS2008
Demo 1: compile and run a brachytherapy simulation locally
The objective is to understand the basics of a Geant 4 simulation application.
$ cd G4Brachy
$ source setup.sh
$ gmake
$ ./workdir/bin/Linux-g++/Brachy macros/default.mac 1
$ show_hist brachytherapy.xml 20 30
Exercise 1: Running a Geant4 application: particle beam
Perform the following steps:
- Compile the Geant4 particle beam example application. Solution:
$ cd G4ParticleBeam
$ source setup.sh
$ gmake
- Execute the particle beam example using the macro file electronbeam.mac. The application simulates 5.5 MeV electrons impinging on a water box and computes the longitudinal energy deposition profile inside the box. By default 100 events are simulated. Solution:
./workdir/bin/Linux-g++/ParticleBeam macros/electronbeam.mac 1
- The simulation program created an xml file (simoutput.xml) containing a histogram "energydeposit". Visualize the computed energy deposition profile by executing
show_hist simoutput.xml energydeposit
- Rerun the application with an increased number of events (3000) and visualize the output. Solution: Change in the macro file the following command:
\run\beamOn 3000
and execute again
$ ./workdir/bin/Linux-g++/ParticleBeam macros/electronbeam.mac 1
$ show_hist simoutput.xml energydeposit
- As a next step change the incident angle of the beam to 60 deg and rerun the application. Visualize the results. Solution: Change in the macro file the following command:
/source/incidentAngle 60.0 deg
Demo 2.1: Ganga Primer
The objective here is learn how Ganga works using very basic commands.
Create a small executable file (using editor or shell cat command):
$ cat > say_hello
#!/usr/bin/env bash
echo Hello $*
^D
$ chmod u+x say_hello
$ ./say_hello XXX
Hello XXX
Submit jobs using ganga (interactively):
$ ganga
j = Job()
j.application.exe=File('say_hello')
j.application.args = ['DRESDEN']
j.name='Hello Dresden!'
print j
j.submit()
j2 = j.copy()
j2.application.args = ['GRID','AUS', 'DRESDEN!!!']
j2.name='Hello Grid!'
j2.backend=LCG()
j2.submit()
Useful commands and options in the interactive shell:
# optionally select the CE, one of:
j.backend.CE=
jobs
jobs[-1]
jobs.select(status='submitted')
!ls -l $j.outputdir
j.peek()
j.peek('stdout','cat')
j.peek('stderr','cat')
j2.peek('stdout.gz','zcat')
j2.peek('stderr.gz','zcat')
Demo 2.1: Geant4 with Ganga
First create a small wrapper file which will source the environment and run the application. Use editor or cat command. The wrapper command assumes that both executable and setup.sh are in the current working directory. This is where ganga puts them when the job starts.
$cd G4Brachy
$cat > run_brachy
#!/usr/bin/env bash
source setup.sh
./Brachy $*
^D
$ chmod u+x run_brachy
$ ganga
j = Job()
j.inputsandbox=[File('./workdir/bin/Linux-g++/Brachy'), File('./setup.sh')]
j.outputsandbox=['brachytherapy.xml']
j.name='G4Brachy'
j.application.exe=File('./run_brachy')
j.application.args=[File('macros/default.mac'), '1']
j.submit()
j2 = j.copy()
j2.backend=LCG()
j2.submit()
if j.status == 'completed':
!show_hist $j.outputdir/brachytherapy.xml 20 30
Exercise 2.1: Particle Beam
To be defined.
Demo 2.2: Geant4 with Ganga (split jobs)
Objective: simulate more events using a fixed number of processors
Now the code gets more complex, so we will save it in a file and let ganga execute in one go.
$ cd G4Brachy
$ cat > submit_brachy
j = Job()
j.inputsandbox=[File('./workdir/bin/Linux-g++/Brachy'), File('./setup.sh'), File('macros/default.mac')]
j.outputsandbox=['brachytherapy.xml']
j.name='G4Brachy'
j.application.exe=File('./run_brachy')
j.backend=LCG()
j.splitter = ArgSplitter()
for i in range(10):
j.splitter.args.append(['default.mac', str(i)])
j.submit()
^D
Now you may run all the commands in one go:
$ ganga submit_brachy
Start ganga in the interactive mode and have a look at the job - it should contain 10 subjobs:
$ ganga
j = jobs[-1]
print j
Exercise 2.2: Particle Beam
increase the statistics
Demo 3.0: Geant4 with Ganga + DIANE on the Grid
Objective: simulate more events using variable number of processors (up to specified number) and splitting job into many more smaller pieces.
The easiest way to understand what's going on is to start two windows.
Window 1: master
diane-run G4Brachy/macros/iodiumsource-diane.run
Take note of the run directory.
Window 2: submission of jobs and visualisation
ganga LCGSubmitter.py --diane-worker-number=10 # 10 jobs on the Grid
ganga Local.py --diane-worker-number=1 # one job locally
show_hist rundir/merged1D_brachytherapy.xml
Exercise 3.0: Particle Beam
IMPORTANT: modify port number in the run file!
TBD.
--
JakubMoscicki - 17 Oct 2008