followup session in asia-pacific geant4 workshop and training course 2009 held at epochal, tsukuba,...

47
Follow up Lectures & Working Session Go Iwai, KEK/CRC [email protected] Asia-Pacific Geant4 Workshop and Training Course 2009 7-12 December 2009 @ Tsukuba International Congress Center (Epochal), Tsukuba, Japan Day-5 : 15:00 – 17:00 @ 406 http://kds.kek.jp/sessionDisplay.py?sessionId=31&slotId=0&confId=3898#2009-12-11

Upload: go-iwai

Post on 04-Jul-2015

894 views

Category:

Education


3 download

DESCRIPTION

A couple of sillover from training course, lecture session, and working session could be followed up in this Followup Session on Friday.

TRANSCRIPT

Page 1: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Follow up Lectures & Working Session

Go Iwai, KEK/CRC

[email protected]

Asia-Pacific Geant4 Workshopand Training Course 2009

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

Day-5 : 15:00 – 17:00 @ 406

http://kds.kek.jp/sessionDisplay.py?sessionId=31&slotId=0&confId=3898#2009-12-11

Page 2: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

A little overflows at the training session

on MondayDecember 11, 2009 2Follow up Session

Page 3: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Catch up overflow

Lesson & learn from common questions

Let’s restate ourselves!December 11, 2009 3Follow up Session

Page 4: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Aims in this session

Individual Q & A

Most of your questions are common questions

Trainer

Participants

December 11, 2009 4Follow up Session

? ? ?

Page 5: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Aims in this session

Knowledge sharing

Trainer

Participants

December 11, 2009 5Follow up Session

Page 6: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Aims in this session

Participants

Your colleagues

You can be a trainer in your institute

December 11, 2009 6Follow up Session

Page 7: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Technical matters

Page 8: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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.

• Did you place kek.repo in properly?– http://repo.cc.kek.jp/SL4/kek.repo for SL4 and other RH4

clones– http://repo.cc.kek.jp/SL5/kek.repo for SL5 and other RH5

clones– We don’t have solution to resolve your distribution dynamically so far

– $ sudo yum clean all– We can resolve your architecture dynamically see a repo file

• A GDML module might be separated into the another sub package in future, e.g. geant4-gdml

December 11, 2009 8Follow up Session

Page 9: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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 ?

December 11, 2009 Follow up Session 9

Let’s see examples of solution on SL5 x86_64

Page 10: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

December 11, 2009 Follow up Session 10

$ 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 ?

Page 11: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

December 11, 2009 Follow up Session 11

$ 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!

Page 12: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

December 11, 2009 Follow up Session 12

$ 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

Page 13: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

How can we remove annoying G4XXX environment variables

• Copy & paste following shell & do it!– Only for bash users– Unset G4* & CLHEP* & CXX

December 11, 2009 13Follow up Session

envs=`env | egrep '^G4|^CLHEP' > /dev/null 2>&1`if test "x${envs+x}" = "xx"; then

for env in "$envs"; doname=`echo "$env" | cut -d'=' -f1`unset $name

doneunset name env

fiunset envsif test "x${CXX+x}" = "xx"; then

unset CXXfi

Page 14: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

• 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

December 11, 2009 Follow up Session 14

Page 15: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Why OGLIX doesn’t display detectors on SL5 ?

• It’s a bug on Mesa library for OpenGL– This can be seen both on x32 & x64 of SL5

• Solution:– VRML2FILE or DAWNFILE as visualization

driver instead of OGLIX– Use SL4 instead of SL5

December 11, 2009 15Follow up Session

# vis.mac# /vis/open OGLIX # comment out here# /vis/open DAWNFILE # you should install dawn# /vis/open VRML2FILE # you should install vrmlview

# and set G4VRMLFILE_VIEWER=vrmlview

VRML with vrmlview DAWN with gv

!?

Page 16: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

• Do you want to stay on SL4?– You should consider software lifecycle supplied by Redhat

• SL4 can be expected to terminate in 2012– We usually migrate newer release, e.g. SL5, a few year earlier

than the end of support

December 11, 2009 16Follow up Session

http://www.redhat.com/security/updates/errata/

https://www.scientificlinux.org/distributions/roadmap

Page 17: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Can we access repo.cc.kek.jp even after the workshop ?

• 24x7

• A bit delayed to official Geant4 release

December 11, 2009 17Follow up Session

Yes, we can!

Page 18: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Can we run VMs at the same time ?

December 11, 2009 Follow up Session 18

Yes, we can!

Page 19: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Can we use repo.cc.kek.jp even on Fedora ?

• You should not do this!

• Entirely different software stacks between Fedora & Redhat!

• Build from complete source tree of Geant4 if you want to work on Fedora!

December 11, 2009 19Follow up Session

No, we can’t!

Page 20: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Which versions are the best combination of Geant4 & CLHEP ?

December 11, 2009 20Follow up Session

• We should read a release note of each releases– http://www.geant4.org/geant4/support/ReleaseNotes4.9.2.html

• CLHEP 2.0.4.5 for Geant4 9.3

Page 21: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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

December 11, 2009 21Follow up Session

Page 22: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

If you hesitate wide communicationYes - I can be your 1st line support

December 11, 2009 Follow up Session 22

As goiwai on

Go Iwai, KEK/[email protected]

Yes, I can!

Page 23: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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

December 11, 2009 23Follow up Session

$ export ROOTSYS=/opt/root$ export PATH=$ROOTSYS/bin:$PATH

Page 24: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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

December 11, 2009 Follow up Session 24

Page 25: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

HELLO WORLD (C++)

December 11, 2009 Follow up Session

$ g++ -o hello.exe hello.cc # compile & link hello.cc$ ./hello.exe # execute hello.exeHELLO WORLD # result of hello.exe

Source code

CLI

#include <iostream>

int main(){std::cout << “HELLO WORLD” << std::endl;return 0;

}

hello.cc

25

Page 26: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

HELLO WORLD (CINT)

December 11, 2009 Follow up Session

root [0] .x hello.C // same with gROOT->Macro(“hello.C”) instead of .xHELLO WORLD // result of hello.Croot [1] .q // Terminate ROOT

Source code

CLI

root [0] .L hello.C // same with gROOT->LoadMacro(“hello.C”)root [1] hello(“HELLO ROOT”) // invoke hello() functionHELLO ROOT // result of hello()root [2] .q // Terminate ROOT

void hello(const char* greeting = “HELLO WORLD”){std::cout << greeting << std::endl;return;

}

$ root # execute ROOTroot [0] std::cout << “HELLO WORLD” << std::endl; // cout from CLIHELLO WORLD // resultroot [1] .q // Terminate ROOT

hello.C

26

Page 27: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Check basic functionalities provided by ROOT

December 11, 2009 Follow up Session 27

$ cp –a $ROOTSYS/share/doc/root/tutorials .$ cd tutorials/$ root

Welcome to the ROOT tutorials

Type ".x demos.C" to get a toolbar from which to execute the demos

Type ".x demoshelp.C" to see the help window

==> Many tutorials use the file hsimple.root produced by hsimple.C==> It is recommended to execute hsimple.C before any other script

root [0] .x benchmarks.C

Page 28: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

The benchmarks.C should be end with:

December 11, 2009 Follow up Session 28

---------------ROOT 5.24/00 benchmarks summary (in ROOTMARKS)-----

For comparison, a Pentium IV 2.4Ghz is benchmarked at 600 ROOTMARKShsimple = 333.85 RealMARKS, = 373.91 CpuMARKShsum = 469.08 RealMARKS, = 423.53 CpuMARKSfillrandom = 389.62 RealMARKS, = 77.42 CpuMARKSfit1 = 236.87 RealMARKS, = 112.50 CpuMARKStornado = 1148.15 RealMARKS, = 600.00 CpuMARKSna49 = 292.91 RealMARKS, = 356.41 CpuMARKSgeometry = 295.10 RealMARKS, = 308.57 CpuMARKSna49view = 311.26 RealMARKS, = 375.00 CpuMARKSntuple1 = 1126.42 RealMARKS, = 420.00 CpuMARKS

***************************************************** Your machine is estimated at 432.43 ROOTMARKS *****************************************************root [1]

Page 29: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

How can we use ROOT in Geant4 ?

A quick review of lecture slides given by Asai-san

December 11, 2009 Follow up Session 29

Page 30: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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).

December 11, 2009 Follow up Session 30

Begin of RunEvent generation(e.g. Particle injection)

Begin of Event

Pre-tracking

SteppingPost-tracking

End of EventEnd of Run

Page 31: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Review: User’s hooks

December 11, 2009 Follow up Session 31

Mandate! Others are optional hooks

Page 32: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Where should we implement ?It’s up to your design of applications

December 11, 2009 Follow up Session

1. Clear histograms1. Collect your Hit Collections2. Fill data into your histograms

1. Open a file2. Write histograms3. Close a file

32

My tips is naturally thinking about data taking models in real world

Page 33: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

December 11, 2009 Follow up Session

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.

33

Page 34: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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 classes

December 11, 2009 Follow up Session

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*)

34

Page 35: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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

December 11, 2009 Follow up Session

void MyEventAction::EndOfEventAction(const G4Event* anEvent){// Fill energy deposition into the histogramtheEdepHist->Fill(total_edep);return;

}

G4UserEventAction

MyUserEventAction

void EndOfEventAction(const G4Event*)

35

Page 36: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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();

December 11, 2009 Follow up Session

void MyRunAction::EndOfRunAction(const G4Run* aRun){TFile* f = new TFile(“mydata.root”, “RECREATE”); // Open a filetheEdepHist->Write(); // Write histogram in a filedelete f; // Close a filereturn;

}

G4UserRunAction

MyUserRunAction

void BeginOfRunAction(const G4Run*)void EndOfRunAction(const G4Run*)

36

Page 37: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

GNUmakefile

December 11, 2009 Follow up Session 37

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 makefilein Geant4

Insert just 2 lines additionally if you would like to use ROOT functions in your application

GNUmakefile

Page 38: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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 behappened

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

December 11, 2009 Follow up Session 38

Page 39: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

And offline…TBrowser may help us

December 11, 2009 39Follow up Session

Page 40: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Interactive in ROOT CLI

• You can access histogram as “edep” that is specified at the instantiation inside your Geant4 application, remember that:– theEdepHist = new TH1D(“edep”, “TITLE”, 100, 0.0,

50.0);• The canvas can be created automatically at the invocation of

Draw() method– Don’t do this – not a good manner!

• At the invocation of Print(), you can save an image file as a couple of formats, e.g. PNG, GIF, or PS, depend on ROOT version & building

December 11, 2009 Follow up Session

root [0] f = new TFile(“mydata.root”) // Open a file “mydata.root”root [1] cv = new TCanvas(“cv”, “canvas title”) // Create a canvas to show a histogramroot [2] edep->Draw() // Draw a histogramroot [3] cv->Print(“mydata.png”) // Save as an image

40

Page 41: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Using a Macro

December 11, 2009 Follow up Session

void draw(){f = new TFile("mydata.root");cv = new TCanvas("cv", "canvas title");// set title on X-axisedep->GetXaxis()->SetTitle(“Energy deposition (MeV)”);// set title on Y-axisedep->GetYaxis()->SetTitle(“# of events”);edep->Draw();cv->Print("mydata.ps");return;

}

draw.cc

41

Page 42: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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.

December 11, 2009 Follow up Session 42

Page 43: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

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

December 11, 2009 43Follow up Session

Page 44: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

My PhysicsList follows example code (N03) provided by Geant4

• If you copy & paste PhysicsList from ExN03PhysicsList.cc, you should copy & paste again and follow Geant4

• Keep up to date your PhysicsList

December 11, 2009 44Follow up Session

Page 45: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Recommended VRML viewer

• Use vrmlview

• Note: VRML is 10 years ago solution

December 11, 2009 Follow up Session 45

Page 46: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Survey on Training Course

• We don’t assume 100% of participants satisfy• The personal goal is 80% of participants satisfy

– 50% of participants can be satisfied in my self evaluation… Perhaps reflecting my bias

• To improve our course structure & materials in the rest of the 30%– We need your help!

• http://www-geant4.kek.jp/g4ws09/survey.php

December 11, 2009 46Follow up Session

Page 47: Followup Session in Asia-Pacific Geant4 Workshop and Training Course 2009 held at Epochal, Tsukuba, Japan during 7-12 Dec 2009

Any other overflows?

December 11, 2009 Follow up Session 47