geant4 novice training course in asia-pacific geant4 workshop and training course 2009 held at...

85
One Day Training Course Go Iwai, KEK/CRC [email protected] Asia-Pacific Geant4 Workshop and Training Course 2009 All materials in this training course are designed for non native English speakers & Geant4 novice users so that slides are described as verbose as possible. Consequently, participants can study by themselves even after this course. http://www-geant4.kek.jp/g4ws09/training.php 7-12 December 2009 @ Tsukuba International Congress Center (Epochal), Tsukuba, Japan “Slides as a Textbook”

Upload: go-iwai

Post on 05-Dec-2014

3.818 views

Category:

Education


2 download

DESCRIPTION

As a basic concept of this slide "Slides as a Textbook", all materials in this training course are designed for non native English speakers & Geant4 novice users so that slides are described as verbose as possible. Consequently, participants can study by themselves even after this training course. Visit: http://www-geant4.kek.jp/g4ws09/training.php

TRANSCRIPT

One Day Training Course

Go Iwai, KEK/CRC

[email protected]

Asia-Pacific Geant4 Workshopand Training Course 2009

All materials in this training course are designed for non native English speakers & Geant4 novice users so that slides are described as verbose as possible. Consequently, participants can study by themselves even after this course.

http://www-geant4.kek.jp/g4ws09/training.php

7-12 December 2009 @ Tsukuba International Congress Center (Epochal), Tsukuba, Japan

“Slides as a Textbook”

Safety First!

• Emergency exits and assembly point

• Check your evacuation route

• Don’t use the lift in an emergency

December 7, 2009 APG4WS2009 2

We are here Lv4

Welcome to Earthquake Country

• Be aware of exits in your building• Fire or other emergency evacuation

– Follow building residents out of building to the assembly area• Earthquake

– Remain in building: Duck, cover, and hold position until shaking stops– Evacuate building to assembly area outside (follow others)– Stay away from windows, downed power lines

• In the event of an emergency– Dial 110 for PD, or – Dial 119 for Fires and Ambulance– Provide address

• Congress Centre (Epochal): 2-20-3,Takezono,Tsukuba• OKURA FRONTIER HOTELTSUKUBA EPOCHAL: 2-20-1,Takezono, Tsukuba• Daiwa Roynet Hotel: 1-5-7 Azuma, Tsukuba

December 7, 2009 APG4WS2009 3

Networking

• WiFi– IEEE 802.11b or 802.11g compliant adaptors should

be accepted– SSID: tsukuba04– WEP: Open (Not excypted)

• Wired connection– Limited number of sockets: ~16– Supplied only in front area of this room– If you need wired connection, please let us know

• Let us know if you have any difficulties or questions

December 7, 2009 APG4WS2009 4

Plan for the week

• Talks and practical– Geant4 installation (this course)

– Others are shown in next a few slides

• Discussion– Before and after each module

December 7, 2009 APG4WS20095

Tuesday• Introduction to Geant4• History of Geant4• Upcoming release Geant4 version 9.3

• Don’t miss the reception party at Incarose 6:30-8:30PM!

December 7, 2009 APG4WS2009 6

Wednesday• Basic Introduction & structure of Geant4 (in Lecture 1)• Introduction to Hadronic & EM Physics (in Lecture 1)• More Physics (in Lecture II-1)• Still more Physics mainly focused on Medicals (in Lecture II-2)

• Working session feedback report from users

December 7, 2009 APG4WS2009 7

Thursday

• Geometry Placement, Physics and Primary Particles (Lecture III)

• User Interface, Materials and Scoring (Lecture IV)• Working session feedback report from users

December 7, 2009 APG4WS2009 8

Friday

• Visualization, Advanced geometry placement, and Detector sensitivity (Lecture V)

• Documentation and discussion with your insights we can improve… (Lecture VI)

• Follow up for this course (150min)

December 7, 2009 APG4WS2009 9

We can follow up on Friday afternoon if anything spill out of this course

Agenda Today

Time Duration Contents

13:30 - 14:30 60min Introduction

14:30 - 14:45 15min Break

14:45 - 15:45 60min Hands-on work

15:45 - 16:00 15min Break

16:00 - 16:30 30min Installation & Tips

16:30 – 18:00 90min QA & comments

December 7, 2009 APG4WS2009 10

Aims in this session

• EVERY participants can get started in Geant4

• EVERY participants can install Geant4 by themselves

• EVERY participants can proceed next step– i.e. application development!

December 7, 2009 APG4WS2009 11

Not aims in this session

• I don’t aim…• Advanced technical matter

– How to create materials and geometries in Geant4– How to inject particles– How to define own physics process– And so on…

• But question is welcome of course!• I try to profile your questions or difficulties (we

have!) and then, allocate appropriate persons to them

December 7, 2009 APG4WS2009 12

Starting Point of the Workshop

• Tips to make our workshop successfull– To make ourselves comfortable

– To be relax during the workshop

• Tsukuba is designed as science city…

• We don’t have so many choices

• A few personal recommendation can be shown in next a few slides

December 7, 2009 APG4WS2009 13

Lunch

December 7, 2009 APG4WS2009 14

http://www-geant4.kek.jp/g4ws09/access.phpGoogle map may help you

CASA Tsukuba Epochal~1,000JPYDirect access through concourse

We are here

Lunch

December 7, 2009 APG4WS2009 15

http://www-geant4.kek.jp/g4ws09/access.phpGoogle map may help you

Ton-Q~2,000JPY600m away 15 min by walk

We are here

KFC~600JPY500m away 12 min by walk

Dinner

December 7, 2009 APG4WS2009 16

OKURA FRONTIER HOTEL TSUKUBA EPOCHAL

J-Pub: Tairyo-Maru~5,000JPY (depend on quantity & quality of your drink!)

Reception Party at Incarose18:30-20:30 on Tue

BBQ: Shu-Yen~5,000JPY

Sushi: Yagura~6,000JPY

Sushi: Kintaro~5,000JPY

200m

We are here

Many restaurant should be found basement of DaysTown Tsukuba

http://www-geant4.kek.jp/g4ws09/access.phpGoogle map may help you

Shopping

December 7, 2009 APG4WS2009 17

http://www-geant4.kek.jp/g4ws09/access.phpGoogle map may help you

Seibu Shopping Center

Q’t Shopping Center

OKURA FRONTIER HOTEL TSUKUBA EPOCHAL

Daiwa Roynet Hotel

500m

Shopping

December 7, 2009 APG4WS2009 18

Kenkyu-GakuenStation next to Tsukuba Sta.

IIAS Tsukuba: Shopping moll

2min next station

~50m walking distance

http://www-geant4.kek.jp/g4ws09/access.phpGoogle map may help you

Who am I?

My name Go Iwai

Where I am working Computing Research CenterKEK, Tsukuba

My experience in Geant4

10 years! since beta-release when I was a MC students!I am not wizard… Actually, same with most of you.

Platform today Scientific Linux 5.4 x86_64 on VMwareWindows Vista x64 as host machine

Platform in usual work OpenSUSE on physical box as desktop machineMost of development are on remote resources

What I aim in this course

It’s clear: I am hoping that EVERY participants can get started in Geant4, can install Geant4 by themselves, can proceed next step, i.e. application development!

What community I am involved in

My original background was HEP, nowadays I am getting involved in distributed computing science, e.g. LCG.

Goal in my research My main responsibility is to design/coordinate/implement national computing resources for a general purpose infrastructure and to show my community people how to utilize this with their legacy resources.December 7, 2009 APG4WS2009 19

Who’s here!?

• Name• Where you work• Your experience in Geant4

– Enough for rough estimation, e.g. 1day? 1week? 1year?• Platform

– Today?– In usual work?

• What you aim in this course• What community/experiment you are involved in

– And role in your community/experiment• Goal in your research or work

December 7, 2009 APG4WS2009 20

Please give us your…

Break before Hands-on works?

If you are not yet ready to start hands-on works, please let us know!

I have not yet connected the Internet!I have not yet downloaded VM images!I have not yet installed VMware!I have not yet….I can not…

Seat Arrangement

Team

A

Each Group consists of ~4 membersWe organize based on international collaboration!Build up Team

December 7, 2009 APG4WS2009 23

Front of Room

Entrance door

Entrance door

Team

C

Team

E

Team

G

Team

B

Team

D

Team

F

Team

H

Hands-on

60-90 min

Introduction

• As the admin on Grid computing at KEK– Keep up-to-date with the latest software on WNs as well as local

cluster machines• A few software is locally packaged out RPM

– Including Geant4-related software.– Great improvement on daily duties.

• RPMed Geant4 is useful for– Administrators– Application developers– Lectures in tutorial courses

• Scope of presentation– Sharing experiences among those who have relevant activities– Help for users who have a difficulty of its long installation time or

keeping up-to-date

December 7, 2009 APG4WS2009 25

Technology Choice of Package ManagementAPT vs. YUM

Pros Cons

APT Wider support across distributions (since its a Debian tool) Not a base part of the FC package set.Perhaps a slightly higher learning curve to use effectively.

Many users may be more familiar with APT rather than YUM

Harder to roll my own repository

EGEE developer team will stop providing apt repository in future

YUM Compatible with many update tools, e.g. up2date, apt and Yast

Few graphical update/management tool.

EGEE developer team will possibly support only YUM on SL4 in future

Comes with Fedora by default, widely supported by many RPM repositories.

Fairly easy to roll my own repository

Simple and powerful user interface

• Neither found significant advantage nor disadvantage in APT/YUM• It seems using YUM is better way

– As the administrator on Grid

December 7, 2009 APG4WS2009 26

* Perhaps reflecting my bias

Quicker Installation

• Just 1min ready to go Geant4– If network

performance is reasonable

• Easy to keep up-to-date– No more waste time

for installation

December 7, 2009 APG4WS2009 27

http://repo.cc.kek.jp/

Contents of PackagesPackage Content/Comment

geant4 Dynamic librariese.g.: libG4FR.so, libG4OpenGL.so, libG4RayTracer.so, ...

geant4-devel Static libraries , header files and gmk filese.g.: libG4FR.a, libG4OpenGL.a, libG4RayTracer.a, ..., G4RunManager.hh, G4RunManagerKernel.hh, ..., common.gmk, binmake.gmk, ...

geant4-source Source treei.e.: All files placed in $G4INSTALL/source

clhep Dynamic librariese.g.: libCLHEP-Random-2.0.4.0.so, libCLHEP.so, ...

clhep-devel Static libraries and header filese.g.: libCLHEP-Random-2.0.4.0.so, libCLHEP.so, ..., JamesRandom.h, ThreeVector.h, ...

geant4-demo Executable examplese.g.: exampleN01, exampleN02, ..., desktop icon, ...

geant4-data Pseudo package, just dependencies are held

data_G4NDLdata_G4EMLOWdata_G4ABLAdata_Photon...data_Radio...

ASCII data filesAll packages depend on geant4-data pseudo package.

December 7, 2009 APG4WS2009 28

Stack of geant4Stack of geant4-data

Supported Distros and ArchitectureAs of Dec. 2009

• New: ready for Scientific Linux 5!

• Redhat Enterprise Linux clones (SL, CentOS, and SLC) both version 4 and 5– Both architectures i386 and x86_64

December 7, 2009 APG4WS2009 29

December 7, 2009 APG4WS2009 30

It's really easy, 10 seconds to setup to look up repository here.If your platform is SL5, URL should be addressed:http://repo.cc.kek.jp/SL5/kek.repo

December 7, 2009 APG4WS2009 31

Contents of a repo file “kek.repo”Enabled for two stacks geant4 and geant4-data by default

December 7, 2009 APG4WS2009 32

After placing a repo file in /etc/yum.repos.d, just execute “yum install geant4-demo” to install geant4-demo package

December 7, 2009 APG4WS2009 33

All dependencies for a geant4-demo package are resolved by yum before staring to install geant4-demo.clhep, geant4 and geant4-data packages are installed in this example.

December 7, 2009 APG4WS2009 34

Tips: “yum -y install demo” to skip here.

To make sure to set up your environment valuable, logout

here and login again

December 7, 2009 APG4WS2009 35

December 7, 2009 APG4WS2009 36

After installing geant4-demo, you should find short cut for a demo application in application menu list.

December 7, 2009 APG4WS2009 37

You can find an icon on your desktop also

December 7, 2009 APG4WS2009 38

Open up terminal window and control window by double clicking the desktop icon.

December 7, 2009 APG4WS2009 39

Selectable tab N01-N07

December 7, 2009 APG4WS2009 40

Click “Quit” to terminate a demo

December 7, 2009 APG4WS2009 41

$ rpm --query --list geant4geant4 package provides only shared libraries, it’s enough to work applications.

December 7, 2009 APG4WS2009 42

$ rpm --query --list clhepclhep package also provides only shared libraries.

Setup

• It's really easy, 10 seconds to setup to look up this repository here.

December 7, 2009 APG4WS2009 43

# cd /etc/yum.repos.d# wget http://repo.cc.kek.jp/SL4/kek.repo

# cd /etc/yum.repos.d# wget http://repo.cc.kek.jp/SL5/kek.repo

If you are working on SL5:

Geant4 InstallationEnd-Level Users

• This “geant4” package provides only shared libraries.– Basically it’s sufficient to run an application.– Neither header files nor static libraries are inclusive.

(install geant4-devel package if necessary)– Useful for cloning too many nodes.

• A package “geant4-data” is ascii data set of Geant4– Pseudo package, provides only dependencies for actual

data files.• i.e. data_G4ABLA, data_G4EMLOW, data_G4NDL,

data_PhotonEvaporation and data_RadioactiveDecay

December 7, 2009 APG4WS2009 44

# yum install geant4# yum install geant4-data

Novice example N01• Fixed geometry

– Ar gas mother volume with Al cylinder and Pbblock with Al slices

• Incident particle is a geantino– no physics interactions – only the transportation process is enabled

• Hard coded batch job and verbosity

Novice Example N03• Sampling calorimeter with layers of Pb absorber and

liquid Ar detection gaps (replicas)

• Exhaustive material definitions

• Command interface

• Randomization of incident beam

• All EM processes + decay, with separate production cuts for γ, e+, e-

• Detector response: E deposit, track length in absorber and gap

• Visualization tutorial

• Random number seed handling

Novie Example N02• Pb target, Xe gas chambers (parameterized

volumes)

• All EM processes + decay including charged leptons and charged hadrons

• Detector response– Trajectories and chamber hit collections may

be stored

• Visualization of detector and event

• Command interface introduced– Can change target, chamber materials,

magnetic field, incident particle type, momentum, etc. at run time

Novie Example N04• Simplified collider detector

– all kinds of volume definitions

• Magnetic field

• PYTHIA primary event generator– Higgs decay by Z0, lepton pairs

• Packaged physics list (QGSP)

• Event filtering by using stacking mechanism

Novice Example N05

• Fast simulation with parameterized showers– EM showers (derived from G4VFastSimulationModel)– Pion showers (for illustration only – not used)

• EM physics only– Use of G4FastSimulationManagerProcess

• Simplified collider detector geometry– Drift chamber – EM, hadronic calorimeter– Ghost volume

Novice Example N06• Water Cerenkov detector with air

“bubble”

• Materials– Specification of optical properties– Specification of scintillation spectra

• Physics– Optical processes– Generation of Cerenkov radiation, energy

loss collected to produce scintillation

Novice Example N07• 3 simplified sandwich calorimeters (Pb, Al,

Ar)

• Cylindrical ghost volume for scoring

• Run-based (as opposed to event-based) hit accumulation

• Changing geometries without rebuilding world

• Setting different secondary production cuts for each calorimeter using G4Region

Make Your Application!

December 7, 2009 APG4WS2009 52

Geant4 InstallationApplication Developers

• A package “geant4-devel” is necessary if you as the application developer, want header files or static libraries.

• The “geant4-source” may be useful as references or debugging.

December 7, 2009 APG4WS2009 53

# yum install geant4-devel

External Tools for Visualization

• A package “dawn” and “vrmlview” is necessary if you would like to visualize your simulation results graphically.

December 7, 2009 APG4WS2009 54

# yum install vrmlview dawn

Build & Run

55

$ wget http://www-geant4.kek.jp/g4users/g4tut07/download/exercise-2.tar.gz$ tar zxvf exercise-2.tar.gz$ cd exercise-2$ lsGNUmakefile ex02.cc gun.mac include/ src/ vis.mac vrml.mac

$ make...

$ ./bin/Linux-g++/ex02...

ex02(Idle)[/]:/control/execute vis.mac

Advanced Hands-on

Try this if you could finish everything earlier and getting boring

December 7, 2009 APG4WS2009 56

Rotate Tube

• Edit DetectorConstruction class– src/DetectorDescription.cc

December 7, 2009 APG4WS2009 57

G4RotationMatrix* rotM= new G4RotationMatrix;rotM-> rotateY(-90.*deg);new G4PVPlacement(rotM, G4ThreeVector(),

tubeLV, "tube", boxLV, false, 0);

Volume Placement

• Place 6 volumes 45 degree rotated about an z-axis

• Edit DetectorConstruction class

December 7, 2009 APG4WS2009 58

const G4double dphi= 45.*deg;

for(G4int i=0; i<6; i++) { // check rotation directioon!!G4ThreeVector armVec= G4ThreeVector(30.*cm, 0., 0.);G4RotationMatrix armRot= G4RotationMatrix();

armVec.rotateZ(dphi*i);armRot.rotateZ(dphi*i);

new G4PVPlacement(G4Transform3D(armRot, armVec), boxLV, "box", worldLV,false, i); // copy# should be unique.

}

Beam On!

December 7, 2009 APG4WS2009 59

$ ./bin/Linux-g++/ex02...

ex02(Idle)[/]:/control/execute gun.macex02(Idle)[/]:/control/execute vis.macex02(Idle)[/]:/run/beamOn

Let’s have a break!

Geant4 Installation Guide

If you can understand a SPEC file in SRPM…

• It is the best practical example to install Geant4– http://repo.cc.kek.jp/SL4/geant4/SRPMS/

– http://repo.cc.kek.jp/SL5/geant4/SRPMS/

December 7, 2009 APG4WS2009 62

BuildRequires: mesa-libGL-devel, mesa-libGLU-develBuildRequires: xorg-x11-proto-devel, openmotif-develBuildRequires: xerces-c-devel

To understand dependency in “BuildRequires”

Everything in a SPEC file!

December 7, 2009 APG4WS2009 63

#...snipexport G4SYSTEM=%{g4system}export G4INSTALL=%{_builddir}/%{name}.%{version}export CLHEP_BASE_DIR=/opt/clhepexport G4LIB_BUILD_GDML=1export XERCESCROOT=/usrexport G4VIS_BUILD_DAWN_DRIVER=1export G4VIS_BUILD_VRML_DRIVER=1export G4VIS_BUILD_RAYTRACERX_DRIVER=1export G4VIS_BUILD_OPENGLX_DRIVER=1export G4VIS_BUILD_OPENGLXM_DRIVER=1cd $G4INSTALL/source%{__make} %{?_smp_mflags}

export G4LIB_BUILD_SHARED=1export G4LIB=$G4INSTALL/slibexport G4TMP=$G4INSTALL/tmp-slibcd $G4INSTALL/source%{__make} %{?_smp_mflags}%{__make} global%{__make} includes

To understand build procedure in “%build” section

But some magic words might discourage us

Joseph’s Installation Note

Thank Joseph!

December 7, 2009 APG4WS2009 64

http://geant4.slac.stanford.edu/tutorial/installation/Geant4.9.2.p02/Linux/Geant4_9_2_p02_Linux_Installation.htm

Mac and Windows also available, find here:http://geant4.slac.stanford.edu/SLACTutorial09/Agenda.html

Note that we assume to install everything into your $HOME/geant4 in your home directory. This means that you don’t need any special privilege.

What are the two pieces of software required for building Geant4?

• gcc 3.4.6 (for SLC4 or RedHat 4) or gcc 4.2.1 (for SLC5 or RedHat 5):gcc is the compiler that is recommended for Geant4 on Linux. Users have also had success with some other gcc versions, but there is no guarantee. To check your version, type: gcc –v.

• CLHEP: CLHEP is a set of base libraries that have long provided great functionality for the particle physics community. They provide things like matrix manipulations, four-vector tools and lists of particle properties. The Geant4 collaboration has chosen to use these libraries rather than re-invent these wheels. Please note that while CLHEP and Geant4 both come out of the particle physics communities, they are separate products - the Geant4 collaboration is not responsible for maintenance, distribution or documentation of CLHEP.

December 7, 2009 APG4WS2009 65

Getting and Installing CLHEP

• Go to the CLHEP source download page:• http://proj-clhep.web.cern.ch/proj-

clhep/DISTRIBUTION/clhep.html• From the "Source" section near the bottom of

the page, select "clhep-2.0.4.2.tgz“• which corresponds to:• http://proj-clhep.web.cern.ch/proj-

clhep/DISTRIBUTION/distributions/clhep-2.0.4.2.tgz

December 7, 2009 APG4WS2009 66

December 7, 2009 APG4WS2009 67

$ cd /tmp$ wget http://proj-clhep.web.cern.ch/proj-clhep/DISTRIBUTION/distributions/clhep-2.0.4.2.tgz

And then,

$ tar -zxvf clhep-2.0.4.2.tgz

The unpacking process will begin, starting with:

2.0.4.2/2.0.4.2/CLHEP/2.0.4.2/CLHEP/CVS/2.0.4.2/CLHEP/CVS/Root2.0.4.2/CLHEP/CVS/Repository

And ending with:2.0.4.2/CLHEP/Vector/configure2.0.4.2/CLHEP/config.guess2.0.4.2/CLHEP/config.sub2.0.4.2/CLHEP/Makefile.in2.0.4.2/CLHEP/configure

December 7, 2009 APG4WS2009 68

Now navigate into the unpacked directory and begin the configuration process.$ cd /tmp/2.0.4.2/CLHEP$ ./configure --prefix $HOME/geant4/clhep

You should get a response that starts with:checking build system type... i686-pc-linux-gnuchecking host system type... i686-pc-linux-gnuchecking target system type... i686-pc-linux-gnuchecking for a BSD-compatible install... /usr/bin/install –cchecking whether build environment is sane... Yes

And ends with:config.status: creating test/exctest4.shconfig.status: creating test/exctestNothrow.shconfig.status: creating test/excDblThrow.shconfig.status: creating Exceptions/defs.hconfig.status: executing depfiles commands$ cd $HOME/CLHEP/

December 7, 2009 APG4WS2009 69

For the following, be sure to type make rather than gmake. It can be very hard to remember which of these to type. One some Linux systems, they may even do the exact same thing, but not always. So for your CLHEP and Geant4 work, don't use gmake.

Run the build process:

$ make

You should get a response that starts with:Making all in Unitsmake[1]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.0.4.2/CLHEP/Units‘Making all in Unitsmake[2]: Entering directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.0.4.2/CLHEP/Units/Units‘make all-am

And ends with:rm -f libCLHEP-2.0.4.2.soliblist=`./getObjectList -shared Units Vector Evaluator GenericFunctions Geometry Random Matrix RandomObjects RefCount Cast Exceptions`; ¥g++ -O -ansi -pedantic -Wall -D_GNU_SOURCE -g -O2 -o libCLHEP-2.0.4.2.so -shared -Wl,-soname,libCLHEP-2.0.4.2.so $liblist –o libCLHEP-2.0.4.2.so./build-headermake[1]: Leaving directory `/afs/slac.stanford.edu/u/ey/perl/CLHEP/2.0.4.2/CLHEP'Now navigate into the unpacked directory and begin the configuration process.

$ make install

Dynamic or Static?• After completing to install CLHEP, you can find libCLHEP-2.0.4.2.so and libCLHEP-2.0.4.2.a in

$HOME/clhep/lib directory.• By default, liker try to link dynamic library, i.e. libCLHEP-2.0.4.2.so

– In this case, you should set LD_LIBRARY_PATH as $HOME/clhep/lib– Personally, I don’t recommend this

• If you want to use a static library, i.e. libCLHEP-2.0.4.2.a, follow this instruction to remove dynamic library here:

December 7, 2009 APG4WS2009 70

$ cd $HOME/geant4/clhep/lib$ lslibCLHEP-2.0.4.2.a libCLHEP-Matrix-2.0.4.2.alibCLHEP-2.0.4.2.so* libCLHEP-Matrix-2.0.4.2.so*libCLHEP-Cast-2.0.4.2.a libCLHEP-Random-2.0.4.2.alibCLHEP-Cast-2.0.4.2.so* libCLHEP-Random-2.0.4.2.so*libCLHEP-Evaluator-2.0.4.2.a libCLHEP-RandomObjects-2.0.4.2.alibCLHEP-Evaluator-2.0.4.2.so* libCLHEP-RandomObjects-2.0.4.2.so*libCLHEP-Exceptions-2.0.4.2.a libCLHEP-RefCount-2.0.4.2.alibCLHEP-Exceptions-2.0.4.2.so* libCLHEP-RefCount-2.0.4.2.so*libCLHEP-GenericFunctions-2.0.4.2.a libCLHEP-Vector-2.0.4.2.alibCLHEP-GenericFunctions-2.0.4.2.so* libCLHEP-Vector-2.0.4.2.so*libCLHEP-Geometry-2.0.4.2.a [email protected]* libCLHEP.so@$ rm libCLHEP.so

Getting Geant4

• From the top of the Geant4 home page:– http://geant4.web.cern.ch/geant4/

• Select "Download" from near the top right corner of the page.

• Select "Unix tar format, compressed using gzip"

• which corresponds to:– http://geant4.web.cern.ch/geant4/support/source

/geant4.9.2.p02.tar.gz

December 7, 2009 APG4WS2009 71

December 7, 2009 APG4WS2009 72

Navigate to this directory and unpack the file:

$ cd $HOME/geant4$ wget http://geant4.web.cern.ch/geant4/support/source/geant4.9.2.p02.tar.gz$ tar zxvf geant4.9.2.p02.tar.gz

The unpacking process will begin, starting with:geant4.9.2.p02/geant4.9.2.p02/ReleaseNotes/geant4.9.2.p02/ReleaseNotes/Beta4.9.2-1.txtgeant4.9.2.p02/ReleaseNotes/Patch4.4.0-1.txtgeant4.9.2.p02/ReleaseNotes/Patch4.4.0-2.txt

And ending with:geant4.9.2.p02/source/visualization/modeling/src/G4VModel.ccgeant4.9.2.p02/source/visualization/modeling/src/G4VTrajectoryModel.ccgeant4.9.2.p02/source/visualization/modeling/src/G4VisTrajContext.ccgeant4.9.2.p02/source/GNUmakefile

Getting Data Files

• Depending on the physics of your particular application, you may need to install additional data files. These data files can be downloaded separately from the Geant4 source distribution page (the same place where you got Geant4 itself).

• Create a new folder within ~/geant4 to hold any of these required data files. ~/geant4/data

December 7, 2009 APG4WS2009 73

December 7, 2009 APG4WS2009 74

For now, pick up the "data files for low energy electromagnetic processes":

$ mkdir –p $HOME/geant4/data$ cd $HOME/geant4/data$ wget http://geant4.web.cern.ch/geant4/support/source/G4EMLOW.6.2.tar.gz$ tar zxvf G4EMLOW.6.2.tar.gz

The unpacking process will begin, starting with:G4EMLOW6.2/G4EMLOW6.2/auger/G4EMLOW6.2/auger/au-tr-pr-10.datG4EMLOW6.2/auger/au-tr-pr-100.datG4EMLOW6.2/auger/au-tr-pr-11.dat

And ending with:G4EMLOW6.2/tripdata/pp-trip-cs-95.datG4EMLOW6.2/tripdata/pp-trip-cs-96.datG4EMLOW6.2/tripdata/pp-trip-cs-97.datG4EMLOW6.2/tripdata/pp-trip-cs-98.datG4EMLOW6.2/tripdata/pp-trip-cs-99.dat

Doing the Initial Build• TAKE YOUR TIME AT THIS STAGE, DON'T RUSH IT.• Mistakes made at this stage can be very time-consuming to correct. Slow

down.• Maybe get a cup of coffee (or a glass of wine) before you

proceed. Breathe.• Finally, unless you're absolutely sure you are starting from a nice clean

system, make sure you don't have any pre-existing Geant4 environment variables. You can use the "printenv" or “env” command to show all variables, and filter this with a "grep" for the string G4 as follows:

• From a Terminal or xterm window:• printenv | grep G4• If any variables show up, find out what is setting them and remove

them. They might be coming from your .login or .cshrc file or from some other script that you invoke upon login for some other project. Take the time now to find the cause and resolve it.

December 7, 2009 APG4WS2009 75

Basic Environment Variables for sh family including bash

December 7, 2009 APG4WS2009 76

export G4SYSTEM=Linux-g++export G4INSTALL=$HOME/geant4/geant4.9.2.p02export CLHEP_BASE_DIR=$HOME/geant4/clhepexport G4VIS_BUILD_DAWN_DRIVER=1export G4VIS_BUILD_VRML_DRIVER=1export G4VIS_BUILD_RAYTRACERX_DRIVER=1export G4VIS_BUILD_OPENGLX_DRIVER=1export G4VIS_BUILD_OPENGLXM_DRIVER=1# export G4LIB_BUILD_GDML=1 # if you want to build GDML# export XERCESCROOT=/usr # if you want to build GDML

December 7, 2009 APG4WS2009 77

After setup environment varuables, move to geant4 source directory and start to make it:$ cd $G4INSTALL/source # correspond to $HOME/geant4/geant4.9.2.p02/source

$ export LANG=POSIX$ make 2>&1 | tee make.log...

$ make incudes...

Check Your Installation

• It should be noted that environment valuables at building Geant4 main libraries and your applications are different! (not always)

December 7, 2009 APG4WS2009 78

December 7, 2009 APG4WS2009 79

export G4SYSTEM=Linux-g++export G4INSTALL=$HOME/geant4/geant4.9.2.p02export CLHEP_BASE_DIR=$HOME/geant4/clhep# export G4LIB_USE_GDML=1 # if you want to use GDML# export XERCESCROOT=/usr # if you want to use GDMLexport G4VIS_USE_DAWN=1export G4VIS_USE_VRML=1export G4VIS_USE_RAYTRACERX=1export G4VIS_USE_OPENGLX=1export G4VIS_USE_OPENGLXM=1export G4UI_USE_TCSH=1export G4UI_USE_GAG=1

export G4NEUTRONHPDATA=$HOME/geant4/data/G4NDL3.13export G4LEDATA==$HOME/geant4/data/G4EMLOW6.2export G4LEVELGAMMADATA==$HOME/geant4/data/PhotonEvaporation2.0export G4RADIOACTIVEDATA==$HOME/geant4/data/RadioactiveDecay3.2export G4ABLADATA==$HOME/geant4/data/G4ABLA3.0

# if you want to link dynamic library libeCLHEP.so, not libCLHEP.a# export LD_LIBRARY_PATH=$CLHEP_BASE_DIR/lib

December 7, 2009 APG4WS2009 80

$ cd /tmp$ cp –a $G4INSTALL/examples/novice/N01 .$ cd N01

Important & Convenient Tips!Just insert one line G4WORKDIR = . In your GNUmakefileThis variable specifies your working directory, i.e. everything are build in this directory.Otherwise your application will be placed under $G4INSTALL

name := exampleN01G4TARGET := $(name)G4EXLIB := true

G4WORKDIR = .

ifndef G4INSTALLG4INSTALL = ../../..

endif

.PHONY: allall: lib bin

include $(G4INSTALL)/config/binmake.gmk

December 7, 2009 APG4WS2009 81

$ make…$ ./bin/Linux-g++/exampleN01

*************************************************************Geant4 version Name: geant4-09-02-patch-01 (13-March-2009)

Copyright : Geant4 CollaborationReference : NIM A 506 (2003), 250-303

WWW : http://cern.ch/geant4*************************************************************

...snip

Track (trackID 1, parentID 0) is processed with stopping code 2### pop requested out of 0 stacked tracks.### 0 waiting tracks are re-classified to

0 urgent tracks and 0 waiting tracks.NULL returned from G4StackManager.Terminate current event processing.Run terminated.Run SummaryNumber of events processed : 3User=0s Real=0.01s Sys=0s

G4 kernel has come to Quit state.

How to keep up to date

• Major/Minor release: one time a year (end of Year usually)

• Beta release: 6 months prior to major/minor release (June usually)

• Patch release: a few times a year (irregular)

• If find the latest version, download and rebuild it– It is subject for Geant4 users to keep up-to-date!

December 7, 2009 APG4WS2009 82

Shall we have a break?

QA and Comments

Note that we should lock this room and return a key to administration office so we would like to close this session by

~5:45PM

Acknowledgement

December 7, 2009 APG4WS2009 85

http://www-geant4.kek.jp/g4ws09/training.php

As goiwai on

Go Iwai, KEK/[email protected]

Many of slides are copied and pasted from SLAC Geant4 Tutorial Course 2009Thanks to Joseph Perl and SLAC Geant4 Team

Communication channel to me

http://www-public.slac.stanford.edu/geant4/Tutorial2009.asp