follow up by requests fri 10 th dec 2010 10:20 – 10:50 (30’)
Post on 19-Dec-2015
218 views
TRANSCRIPT
G4VM-10.11 (i386)
• emacs が入っておりません
2010/12/10 Follow up by requests 2
$ sudo yum install emacs emacs-el
もしくはほかのエディタを使用する
$ gedit <filename>$ vi <filename>
G4VM-10.11 (i386)
• DAWN のデフォルト PS ビュワー gv が入っていません
2010/12/10 Follow up by requests 3
$ sudo yum install gv
もしくはほかのビュワーを指定する
$ export G4DAWNFILE_PS_VIEWER=evince
G4VM-10.11 (i386 && x86_64)
• OpenScientist のパス指定が間違っています
2010/12/10 Follow up by requests 4
$ vi $HOME/.bashrc# .bashrc
# Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcFi... snip
#export PATH=$PATH:/cern/pro/bin:/opt/root/pro/bin:/opt/osc_batch/16.9/binexport PATH=$PATH:/cern/pro/bin:/opt/root/pro/bin:/opt/osc_batch/16.11.2/bin
なぜか DAWN が起動しない
2010/12/10 Follow up by requests 6
Idle> /control/execute vis.macIdle> /vis/open DAWNFILEIdle> /vis/viewer/flush
AddElement の引数
2010/12/10 Follow up by requests 7
G4Element* Cs = new G4Element("Cesium", symbol="Cs", z=55., a=132.9*g/mole);G4Element* I = new G4Element("Iodine", symbol="I", z=53., a=126.9*g/mole);G4Material* CsI = new G4Material("CsI", density=4.51*g/cm3, ncomponents=2);
// CsI->AddElement(I, 0.5);// CsI->AddElement(Cs, 0.5);
CsI->AddElement(I, 1);CsI->AddElement(Cs, 1);
Getting started Geant4 on your own NOT-virtual-machine!
• Geant4 Official Installation Guide– http://
www.geant4.org/geant4/support/gettingstarted.shtml
• Joseph’s installation Note– http://geant4.slac.stanford.edu/installation/
2010/12/10 Follow up by requests 8
Installation Notebased on Joseph’s work
Thank Joseph!
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.
2010/12/10 Follow up by requests 10
Getting and Installing CLHEP
• Go to the CLHEP source download page:• http://proj-clhep.web.cern.ch/proj-clhep/DIST
RIBUTION/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/DIST
RIBUTION/distributions/clhep-2.0.4.2.tgz
2010/12/10 Follow up by requests 11
2010/12/10 Follow up by requests 12
$ 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
2010/12/10 Follow up by requests 13
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/
2010/12/10 Follow up by requests 14
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:
2010/12/10 Follow up by requests 15
$ 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.gz2010/12/10 Follow up by requests 16
2010/12/10 Follow up by requests 17
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
2010/12/10 Follow up by requests 18
2010/12/10 Follow up by requests 19
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.
2010/12/10 Follow up by requests 20
Basic Environment Variables for sh family including bash
2010/12/10 Follow up by requests 21
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# export XERCESCROOT=/usr
2010/12/10 Follow up by requests 22
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)
2010/12/10 Follow up by requests 23
2010/12/10 Follow up by requests 24
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
2010/12/10 Follow up by requests 25
$ 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 G4INSTALL G4INSTALL = ../../..endif
.PHONY: allall: lib bin
include $(G4INSTALL)/config/binmake.gmk
2010/12/10 Follow up by requests 26
$ make…$ ./bin/Linux-g++/exampleN01
************************************************************* Geant4 version Name: geant4-09-02-patch-01 (13-March-2009) Copyright : Geant4 Collaboration Reference : 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 Summary Number of events processed : 3 User=0s Real=0.01s Sys=0sG4 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!
2010/12/10 Follow up by requests 27
Catch up overflow
Lesson & learn from common questions
Let’s restate ourselves!2010/12/10 28Follow up by requests
orz… Dependency error at the RPM installation
• By default setting on both SL4 & SL5, the DAG repository is set as enabled=0 that means never look up DAG. Since a GDML in Geant4 depends on software in DAG, you should revise it just enabled=1 in /etc/yum.repos.d/dag.repo.
2010/12/10 29Follow up by requests
Failure to link a xerces-c while compiling our own application code
• We should check 2 points– What is “make utility” doing ?– Have you installed libxerces-c.so ?
2010/12/10 Follow up by requests 30
Let’s see examples of solution on SL5 x86_64
2010/12/10 Follow up by requests 31
$ make -ntouch tmp/Linux-g++/exampleN03/exe/obj.lastecho "Using global libraries ..."if [ ! -d ./bin/Linux-g++ ] ; then mkdir ./bin/Linux-g++ ;fiecho Linking exampleN03g++ -W -Wall -ansi -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverload d-virtual -pipe -O2 -DG4OPTIMISE -Iinclude -I/opt/clhep/include -DG4LIB_USE_GDML -I/usr/include -DG4VERBOSE -DG4_STORE_TRAJECTORY -DG4UI_USE_TCSH -DG4UI_USE_GAG -DG4UI_USE -DG4VIS_USE_DAWNFILE -DG4VIS_USE_HEPREPFILE DG4VIS_USE_RAYTRACER -DG4VIS_USE_VRMLFILE -DG4VIS_USE_ASCIITREE -DG4VIS_USE_GAGTREE -DG4VIS_USE_DAWN -DG4VIS USE_OPENGLX -DG4VIS_USE_OPENGLXM -DG4VIS_USE_OPENGL -DG4VIS_USE_RAYTRACERX -DG4VIS_USE_VRML -DG4VIS_USE -I/i clude -I/usr/X11R6/include -I/usr/include/X11/extensions -I/usr/include/X11 -I/opt/geant4/include \ -o ./bin/Linux-g++/exampleN03 ./tmp/Linux-g++/exampleN03/exe/exampleN03.o -L/opt/clhep/lib64 - /opt/geant4/lib64/Linux-g++ -L./tmp/Linux-g++/exampleN03 -Wl,-rpath ./tmp/Linux-g++/exampleN03 \ -lexampleN03 -lG4FR -lG4visHepRep -lG4RayTracer -lG4VRML -lG4Tree -lG4OpenGL -lG4vis_management lG4modeling -lG4interfaces -lG4persistency -lG4error_propagation -lG4readout -lG4physicslists -lG4run -lG4ev nt -lG4tracking -lG4parmodels -lG4processes -lG4digits_hits -lG4track -lG4particles -lG4geometry -
lG4materia s -lG4graphics_reps -lG4intercoms -lG4global -L/usr/lib64 -lxerces-c -L/lib64 -lGLU -lGL -lXm -lXpm -L/usr/ 11R6/lib64 -lXmu -lXt -lXext -lX11 -lXi -lSM -lICE -lCLHEP -lmif [ \( -f ./bin/Linux-g++/exampleN03 \) ]; then \ echo "... Done!"; fi
Do you have libxerces-c.so in /usr/lib64 ?
2010/12/10 Follow up by requests 32
$ unset G4LIB_USE_GDML$ unset G4LIB_BUILD_GDML$ make –ntouch tmp/Linux-g++/exampleN03/exe/obj.lastecho "Using global libraries ..."if [ ! -d ./bin/Linux-g++ ] ; then mkdir ./bin/Linux-g++ ;fiecho Linking exampleN03g++ -W -Wall -ansi -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -pipe -O2 -DG4OPTIMISE -Iinclude -I/opt/clhep/include -DG4VERBOSE -DG4_STORE_TRAJECTORY -DG4UI_USE_TCSH -DG4UI_USE_GAG -DG4UI_USE -DG4VIS_USE_DAWNFILE -DG4VIS_USE_HEPREPFILE -DG4VIS_USE_RAYTRACER -DG4VIS_USE_VRMLFILE -DG4VIS_USE_ASCIITREE -DG4VIS_USE_GAGTREE -DG4VIS_USE_DAWN -DG4VIS_USE_OPENGLX -DG4VIS_USE_OPENGLXM -DG4VIS_USE_OPENGL -DG4VIS_USE_RAYTRACERX -DG4VIS_USE_VRML -DG4VIS_USE -I/include -I/usr/X11R6/include -I/usr/include/X11/extensions -I/usr/include/X11 -I/opt/geant4/include \ -o ./bin/Linux-g++/exampleN03 ./tmp/Linux-g++/exampleN03/exe/exampleN03.o -L/opt/clhep/lib64 -L/opt/geant4/lib64/Linux-g++ -L./tmp/Linux-g++/exampleN03 -Wl,-rpath ./tmp/Linux-g++/exampleN03 \ -lexampleN03 -lG4FR -lG4visHepRep -lG4RayTracer -lG4VRML -lG4Tree -lG4OpenGL -lG4vis_management -lG4modeling -lG4interfaces -lG4persistency -lG4error_propagation -lG4readout -lG4physicslists -lG4run -lG4event -lG4tracking -lG4parmodels -lG4processes -lG4digits_hits -lG4track -lG4particles -lG4geometry -lG4materials -lG4graphics_reps -lG4intercoms -lG4global -L/lib64 -lGLU -lGL -lXm -lXpm -L/usr/X11R6/lib64 -lXmu -lXt -lXext -lX11 -lXi -lSM -lICE -lCLHEP -lmif [ \( -f ./bin/Linux-g++/exampleN03 \) ]; then \ echo "... Done!"; fi
Unset G4LIB_*_GDML if you don’t want to link xerces-c!
2010/12/10 Follow up by requests 33
$ rpm -qa | grep xerces-cxerces-c-devel-2.7.0-1.el5.rf.x86_64xerces-c-2.7.0-1.el5.rf.x86_64
$ rpm -ql xerces-c-devel | grep libxerces/usr/lib64/libxerces-c.so/usr/lib64/libxerces-depdom.so
$ rpm -ql xerces-c | grep libxerces/usr/lib64/libxerces-c.so.27/usr/lib64/libxerces-c.so.27.0/usr/lib64/libxerces-depdom.so.27/usr/lib64/libxerces-depdom.so.27.0
Step by step to check xerces-c library
Installed package list on SL5
2010/12/10 Follow up by requests 34
$ sudo yum groupinstall 'Development Libraries' \'X Software Development' \'Legacy Software Development' \'Development Tools'
$ sudo yum install openmotif-devel \xerces-c-devel \libXpm-devel \mesa-libGL-devel \mesa-libGLU-devel \xerces-c-devel \python-devel \libXft-devel \xorg-x11-proto-devel \xorg-x11-xtrans-devel
How can we remove annoying G4XXX environment variables
• Copy & paste following shell & do it!– Only for bash users– Unset G4* & CLHEP* & CXX
2010/12/10 35Follow up by requests
envs=`env | egrep '^G4|^CLHEP' > /dev/null 2>&1`if test "x${envs+x}" = "xx"; then for env in "$envs"; do name=`echo "$env" | cut -d'=' -f1` unset $name done unset name envfiunset envsif test "x${CXX+x}" = "xx"; then unset CXXfi
• Check your init file: $HOME/.bashrc and $HOME/.bash_profile– Also check many init files are placed in the /etc/profile.d
• It could be good idea to recreate as a clean user if you have root privileges – $ sudo useradd tempuser
2010/12/10 Follow up by requests 36
Which versions are the best combination of Geant4 & CLHEP ?
2010/12/10 38Follow up by requests
• We should read a release note of each releases– http://geant4.web.cern.ch/geant4/support/ReleaseNotes4.9.3.html
• CLHEP 2.0.4.5 for Geant4 9.3
Where can we post questions ?
• Geant4 HyperNews– http://hypernews.slac.stanford.edu/HyperNews/geant4/cindex
• Problem Tracker (Bugzilla)– http://bugzilla-geant4.kek.jp/
• Geant4 Japanese Users Mail List– http://www-geant4.kek.jp/mailman/listinfo/geant4-users
2010/12/10 39Follow up by requests
Follow up by requests 40
If you hesitate wide communicationYes - I can be your 1st line support
2010/12/10
As goiwai on
Go Iwai, KEK/[email protected]
How can we use a ROOT: external analysis software with Geant4 ?
• Very natural requirement • First of all, you should download & build &
install ROOT– http://root.cern.ch/
• You must set two kind of environment valuables below at least
2010/12/10 41Follow up by requests
$ export ROOTSYS=/opt/root$ export PATH=$ROOTSYS/bin:$PATH
What’s ROOT ?
• Popular analysis software in HENP– ROOT Killed PAW
• Written in C++– Very good compatibility with Geant4– Python/Ruby interface
• What can we do ?– Create & Display histograms
• By using C++ like macro• From CLI & execution file
2010/12/10 Follow up by requests 42
Begin of Run
Event Generati
on
Begin of Event Pre-track Stepping Post-
trackEnd of event
End of run
Review: How Geant4 processes a RunTechnical Terminology in Geant4
• A Track consists of one or more Step(s).• A Event consists of one or more Track(s).• A Run consists of one or more Event(s).
2010/12/10 Follow up by requests 44
Begin of RunEvent generation(e.g. Particle injection)
Begin of Event
Pre-tracking
SteppingPost-tracking
End of EventEnd of Run
Review: User’s hooks
2010/12/10 Follow up by requests
G4VUserP
rimaryGe
neratorA
ction::G
enerateP
rimaries
(G4Event
* anEven
t)
G4UserRu
nAction:
:BeginOf
RunActio
n(const
G4Run* a
Run)
G4UserEv
entActio
n::Begin
OfEventA
ction(co
nst G4Ev
ent* anE
vent)
G4UserTr
ackingAc
tion::Pr
eUserTra
ckingAct
ion(cons
t G4Trac
k* aTrac
k)
G4UserRu
nAction:
:EndOfRu
nAction(
const G4
Run* aRu
n)
G4UserEv
entActio
n::EndOf
EventAct
ion(cons
t G4Even
t* anEve
nt)
G4UserTr
ackingAc
tion::Po
stUserTr
ackingAc
tion(con
st G4Tra
ck* aTra
ck)
G4UserSt
eppingAc
tion::Us
erSteppi
ngAction
(const G
4Step* a
Step)
45
Mandate! Others are optional hooks
Where should we implement ?It’s up to your design of applications
2010/12/10 Follow up by requests
1. Clear histograms1. Collect your Hit Collections2. Fill data into your histograms
1. Open a file2. Write histograms3. Close a file
46
My tips is naturally thinking about data taking models in real world
G4UserRu
nAction:
:
BeginOfR
unAction
(const G
4Run* aR
un)
G4UserEv
entActio
n::
EndOfEve
ntAction
(const G
4Event*
anEvent)
G4UserRu
nAction:
:
EndOfRun
Action(c
onst G4R
un* aRun
)
2010/12/10 Follow up by requests
G4RunManager
G4UserRunAction* userRunActionG4UserEventAction* userEventAction
void SetUserAction(G4UserRunAction*)void SetUserAction(G4UserEventAction*)
G4UserRunAction
G4Run* GenerateRun()void BeginOfRunAction(const G4Run*)void EndOfRunAction(const G4Run*)
G4UserEventAction
void BeginOfEventAction(const G4Event*)void EndOfEventAction(const G4Event*)
MyUserRunAction
G4Run* GenerateRun()
void BeginOfRunAction(const G4Run*)void EndOfRunAction(const G4Run*)
MyUserEventAction
void BeginOfEventAction(const G4Event*)
void EndOfEventAction(const G4Event*)
User defined classes
Related classes provided by Geant4
You should register your Action classes into G4RunManager!
You can override hook functions in your inherited classes.If we don’t override? Answer is that Geant4 doesn’t anything.
47
Examples of ImplementationAt the BeginOfRunAction
• Just one time instantiation of a histogram in the constructor– Of course, you can create/delete a histogram object in every Run
• It’s up to your design which class has a histogram object• Note: You should implement a Get interface to histograms if
you would like to access from other classes2010/12/10 Follow up by requests
void MyRunAction::MyRunAction(){ theEdepHist = new TH1D(“edep”, “TITLE”, 100, 0.0, 50.0); // “edep” is an unique ID to identify a histogram // TITLE is a title shown on the canvas // last 3 arguments in TH1D: // 100: number of bins // 0.0: x minimum // 50.0: x maximum}
void MyRunAction::BeginOfRunAction(const G4Run* aRun){ // clear the content of histogram theEdepHist->Reset(); return;}
G4UserRunAction
MyUserRunAction
void BeginOfRunAction(const G4Run*)void EndOfRunAction(const G4Run*)
48
Examples of ImplementationAt the EndOfEventAction
• Collect your hit collections (omitted in this examples)
• Get physical quantities you have interest• Fill them in the histogram
• You should get a histogram object via MyRunAction– G4RunManager::GetRunManager()-
>GetUserRunAction()– You may need to cast to the type “MyRunAction” if
you use specific functions in MyRunAction
2010/12/10 Follow up by requests
void MyEventAction::EndOfEventAction(const G4Event* anEvent){ // Fill energy deposition into the histogram theEdepHist->Fill(total_edep); return;}
G4UserEventAction
MyUserEventAction
void EndOfEventAction(const G4Event*)
49
Examples of ImplementationAt the EndOfRunAction
• If you would like to create a data file in every run
• If you have two or more histograms, you should call Write() method each– Histo1->Write();– Histo2->Write();– HistoX->Write();
2010/12/10 Follow up by requests
void MyRunAction::EndOfRunAction(const G4Run* aRun){ TFile* f = new TFile(“mydata.root”, “RECREATE”); // Open a file theEdepHist->Write(); // Write histogram in a file delete f; // Close a file return;}
G4UserRunAction
MyUserRunAction
void BeginOfRunAction(const G4Run*)void EndOfRunAction(const G4Run*)
50
Follow up by requests
GNUmakefile
2010/12/10 51
name := exampleXXG4TARGET := $(name)G4EXLIB := true
G4WORKDIR = .
.PHONY: allall: lib bin
include $(G4INSTALL)/config/binmake.gmk
CPPFLAGS += $(shell $(ROOTSYS)/bin/root-config --cflags)LDFLAGS += $(shell $(ROOTSYS)/bin/root-config --libs)
Typical makefile in Geant4
Insert just 2 lines additionally if you would like to use ROOT functions in your application
GNUmakefile
Tips for make utility(can be applied GNU version, not for make nor nmake)
Usage Explanation
make -n Print the commands that would be executed, but do not execute them. Helpful if you would like to know what/how is going to be happened
make –k Continue as much as possible after an error.
make –f filename
Use filename as a makefile.
make –p Print the data base (rules and variable values) that results from reading the makefiles. Helpful because too many macro values are encapsulated by Geant4.
make -jN Specifies the number of jobs to run simultaneously. If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously. Just 10 minutes to complete Geant4 installation with a -j8 on my desktop !! Thanks for multi core technologies
2010/12/10 Follow up by requests 52
Summary of using ROOT in Geant4• On the CLI (CINT)
– To execute a macro: .x macro.C– To load a macro: .L macro.C
• Implementation in Hooks– Clear a histogram at BeginOfRunAction()– Save a file at EndOfRunAction()– Fill contents in a histograms at EndOfEventAction()
• GNUmakefile should be slightly modified– Just insert 2 lines CPPFLAGS & LDFLAGS
• For offline analysis– Open a file: f = new TFile(“filename.root”)– Specify an unique identifier, e.g. edep, vtx, etc, call Draw() method
• This very basic scheme can be applied even if you would like to other analysis software, e.g. GNU plot, PAW, Excel, etc.
2010/12/10 Follow up by requests 53
Why compiler shows messages we have never seen before ?
• More generic question• A couple of reasons are expected:
– You may use different version of compiler, check it• In general, newer compiler is implemented strictly to
be compliant with standard specification
– You should check it is Error or Warning• Sometimes, we don’t understand well
– Copy & paste messages and ask Google– Google is a rather better teacher than me
2010/12/10 54Follow up by requests
Recommended VRML viewer
• Use vrmlview• Note: VRML is 10 years ago solution
2010/12/10 Follow up by requests 55