12.07.2015 Views

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

Geant4 User's Guide for Application Developers - Geant4 - CERN

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix# a target box is placedglobal targettarget= G4EzVolume("Target")au= G4Material.GetMaterial("G4_Au")target.CreateTubeVolume(au, 0., 1.*cm, 1.*mm)target.PlaceIt(G4ThreeVector(0.,0.,-10.*cm))8.3.2. NISTmaterials moduleThe NISTmaterials module provides an instant use of <strong>Geant4</strong> NIST materials. An example code <strong>for</strong> creating NISTmaterials:from <strong>Geant4</strong> import *import g4py.NISTmaterialsg4py.NISTmaterials.Construct()print <strong>Geant4</strong>.gMaterialTable8.3.3. ParticleGun moduleThe ParticleGun module provides a primary generator action with G4ParticleGun. An example code is shownhere:import g4py.ParticleGun# normal way <strong>for</strong> constructing user primary generator action#pgPGA= g4py.ParticleGun.ParticleGunAction()#gRunManager.SetUserAction(pgPGA)#pg= pgPGA.GetParticleGun()# 2nd way, short-cut waypg= g4py.ParticleGun.Construct()# set parameters of particle gunpg.SetParticleByName("e-")pg.SetParticleEnergy(300.*MeV)primary_position= G4ThreeVector(0.,0., -14.9*cm)primary_direction= G4ThreeVector(0.2, 0., 1.)pg.SetParticlePosition(primary_position)pg.SetParticleMomentumDirection(primary_direction)8.4. ExamplesThere are some examples of <strong>Geant4</strong>Py in the directories "tests/" and "examples/".In the "tests/" directory,gtest01 : exposes a user applicationgtest02 : test <strong>for</strong> using site-module packagesgtest03 : test <strong>for</strong> ezgeom packagegtest04 : test <strong>for</strong> getting command tree and command in<strong>for</strong>mationgtest05 : test <strong>for</strong> constructing CSG geometries in Pythongtest06 : test <strong>for</strong> constructing/visualizing boolean geoemtriesgtest07 : test <strong>for</strong> checking overlapped geometriesThe "examples/" directory contains a set of examples of <strong>Geant4</strong>Py.demos/water_phantomAn example of "water phantom dosimetry". This demo program shows that a <strong>Geant4</strong> application well coworkswith Root on Python front end. VisManager, PrimaryGeneratorAction, UserAction-s, histogramming withRoot are implemented in Python;• dose calculation in a water phantom• Python overloading of user actions• on-line histogramming with Root• visualization306

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!