Geant4-S.incerti - Indico

Download Report

Transcript Geant4-S.incerti - Indico

http://cern.ch/geant4
Do-Son school on Advanced Computing and
GRID Technologies for Research
Institute of Information Technology, VAST,
Hanoi, Vietnam
5-16 November 2007
The Geant4 Monte Carlo toolkit
On behalf of the Geant4 collaboration
Sébastien Incerti
IN2P3/CNRS
Centre d’Etudes Nucléaires de Bordeaux Gradignan
France
[email protected]
1
Thank you !

Do-Son school organizers

IN2P3
– Vincent Breton (IN2P3)
– François Le Diberder (IN2P3)

Geant4
– Makoto Asai (SLAC)
– Michel Maire (IN2P3)
– The whole Geant4 collaboration
2
Outline of the course
1.
2.
3.
4.
Introduction
Basic structure
Definition of materials
Geometry construction
15 minutes
25 minutes
10 minutes
30+40 minutes
5.
6.
Electromagnetic Physics : standard version
Electromagnetic Physics : low energy version
20 minutes
35 minutes
7.
8.
9.
10.
Hadronic Physics
Physics lists
Primary particles generation
Particles and processes
25 minutes
15 minutes
10 minutes
40 minutes
11.
12.
13.
14.
15.
User interface
Documentation, examples, forum
Linux
Write your own application
Hands on
15 minutes
10 minutes
10 minutes
5 minutes
rest of day
3
The Geant4 toolkit :
1/15 - Introduction
15 minutes
4
Color code
In red : what is very important
 In violet : new definitions
 In yellow : important
 In yellow and courier : code


: attention !
5
The role of simulation
Simulation plays a fundamental role in various domains
and phases of an experimental physics project






design of the experimental set-up
evaluation and definition of the potential physics
output of the project
evaluation of potential risks to the project
assessment of the performance of the experiment
development, test and optimization of reconstruction
and physics analysis software
contribution to the calculation and validation of
physics results
6
Detector simulation - general

General characteristics of a detector simulation system
– You specify the geometry of a particle detector
– Then the software system automatically transports
the particle you shoot into the detector by
simulating the particle interactions in matter based
on the Monte Carlo method

The heart of the simulation: the Monte Carlo method
– a method to search for solutions to a mathematical
problem using a statistical sampling with random
numbers
7
Basic requirements for a simulation system










Modeling the experimental set-up
Tracking particles through matter
Interaction of particles with matter
Modeling the detector response
Run and event control
Accessory utilities
(random number generators, PDG particle information etc.)
Interface to event generators
Visualization of the set-up, tracks and hits
User interface
Persistency
8
GEometry ANd Tracking
What is Geant4 ?
OO Toolkit for the simulation of next
generation HEP detectors
… of the current generation too
... not only of HEP detectors
… also…
Distributed software production
and management
Application of rigorous software engineering
methodologies and Object Oriented
technology to the HEP environment
Born from the requirements
of large scale HEP
experiments
Geant3
• Fortran
• CERN product
Inadequate for LHC experiments
R&D phase : RD44, 1994 - 1998
1st release: December 1998
2 new releases/year
9
Born from the
requirements
of large scale
HEP
experiments
All
interactions
9 orders of magnitude !
ATLAS
Higgs
LHCb
10
Geant4 collaboration
CERN, ESA, KEK, SLAC, TRIUMF,
TJNL, INFN, IN2P3, PPARC
Barcelona Univ., Budker Inst., Frankfurt
Univ., Karolinska Inst., Helsinki Univ.,
Lebedev Inst., LIP, Northeastern Univ. etc.
11
The zoo
EGS4, EGS5, EGSnrc
Geant3, Geant4
MARS
MCNP, MCNPX, A3MCNP, MCNP-DSP, MCNP4B
MVP, MVP-BURN
Penelope
Peregrine
Tripoli-3, Tripoli-3 A, Tripoli-4
Many codes are not publicly distributed
Much activity around MC !
DPM
EA-MC
FLUKA
GEM
HERMES
LAHET
MCBEND
MCU
MF3D
NMTC
MONK
MORSE
RTS&T-2000
SCALE
TRAX
VMC++
12
What can Geant4 do for you ?
 Transports a particle step-by-step by taking into account the
interactions with materials and external electromagnetic
fields until the particle
- loses its kinetic energy to zero,
- disappears by an interaction,
- comes to the end of the simulation volume
 Provides a way for the user to access the transportation
process and grab the simulation results
- at the beginning and end of transportation,
- at the end of each stepping in transportation,
- at the time when the particle is going into the sensitive volume of
the detector
- etc.
These are called User Actions
13
What you have to do for Geant4
 Three essential information you have to provide :
- Geometrical information of the detector
- Choice of physics processes
- Kinematical information of particles going into the detector
 Auxiliary you have to prepare :
- Magnetic and electric field
- Actions you want to take when you access the particle
transportation
- Actions you want to take when a particle goes into a sensitive
volume of the detector
- etc.
14
Minimum software knowledge to use Geant4

C++
– Geant4 is implemented in C++, therefore a basic knowledge of C++ is
mandatory
– C++ is a complex language, but you are not required to be a C++ expert to use
Geant4

Object Oriented Technology
– basic concepts
– in-depth knowledge needed only for the development of complex applications

Unix/Linux
Unix/Linux is a standard working environment for Geant4, therefore a minimum
knowledge/experience is required
– How to use basic Unix command
– How to compile a C++ code

Windows
• You can use Visual C++
• Though still you need some knowledge of Unix (cygwin) for installation
15
Tools for input preparation
Geant4 provides standard tools to help you to prepare input information
 Multiple choices to describe the detector geometry
 Combining basic geometry elements (box, cylinder, trapezoid, etc)
 Representation by surface planes
 Representation by Boolean operation, etc.
 Standard way to define materials in the detector
 A large collection of examples to define various materials
 A set of wide variety of particles
 Standard elementary particles (electron, muon, proton,….)
 Unstable particles (resonances, quarks, …)
 Ions
 Exotic particles (geantino, charged geantino,… yours !)
16
Choices of Physics processes
Geant4 provides a wide variety of physics models of particle
interactions with matter you can select
 Category of physics processes
 Standard electromagnetic processes
 Low energy electromagnetic processes
 Hadronic processes
 How to use physics processes
 A rich samples of Physics List provided with example applications
 Recommended Physics List (educated guess) for hadronic physics
17
Geant4 training and user support

This course is part of the training programme offered by the Geant4
Collaboration
– an international collaboration of scientists, developing and maintaining the
Geant4 Simulation Toolkit

This course is a brief introduction to the architecture, modeling
capabilities, physics, functionality and applications of the Geant4 Toolkit
– it does not replace the study of Geant4 User Documentation

More extensive courses, with hands-on exercises, are organized by the
Geant4 Collaboration
– information available from Geant4 web site http://cern.ch/geant4
18
Other tutorial material
Documentation
and tutorials available at :
http://cern.ch/geant4
19
The Geant4 toolkit :
2/15 - Basic structure
25 minutes
20
The Geant4 kernel
 Handles runs, events, tracks, steps, hits, trajectories
 Implements Geant4 as a state machine
 provides a framework for
− physics processes
− visualization drivers
− GUIs
− persistency
− histogramming/analysis
− user code
21
Run

A run is a collection of events which are produced under identical conditions

Within a run, user cannot change:
–
–
Detector or apparatus geometry
Physics process settings

By analogy to high energy physics, a Geant4 run begins with the command
“beamOn”. Detector is inaccessible once beam is on

At beginning of run:
–
–
–

Geometry is optimized for navigation
Cross sections are calculated according to materials in setup
Low-energy cutoff values are defined
The class G4Run defines a run object
22
Event

At beginning of processing, an event contains primary particles (from
generator, particle gun, ...), which are pushed onto a stack

During processing, each particle is popped from the stack and tracked

When the stack is empty, processing of the event is over

The class G4Event defines an event object

At the end of processing it has the following objects:
–
–
–
–
List of primary vertices and particles (the input)
Hits collections
Trajectory collections (optional)
Digitizations collections (optional)
23
Track

A track is a snapshot of a particle within its environment
–
–
–

as the particle moves, the quantities in the snapshot change
at any particular instance, a track has position, physical quantities
it is not a collection of steps
Track object lifetime
–
–
created by a generator or physics process (e.g. decay)
deleted when it:
•
•
•
•
leaves world volume
disappears (particle decays or is absorbed)
goes to zero energy and no “at rest” process is defined
user kills it

No track object survives the end of an event (not persistent).
User must take action to store track record in trajectory

The G4Track class defines a track object
24
Step

The step is the basic unit of simulation
– Associated class is G4Step
– Has two points (pre-step, post-step)
– Contains the incremental particle information
(energy loss, elapsed time, etc.)
– Each point contains volume and material information
– If step is limited by a boundary, the end point stands exactly on the
boundary, but is logically part of next volume
– Hence boundary processes such as refraction and transition radiation
can be simulated
25
A Geant4 simulation as a HEP experiment
Incident particles :
e.g. beam of protons
Target
Detectors
Secondary particles
TRACK
= a snapshot of a particle
RUN
= all the beam
protons
EVENT
= a proton
STEP
= the elementary
interation step
26
Geant4 categories

Geant4 consists of 17
categories
D
– Each is independently
developed and maintained
by a working group

Categories designed to
minimize dependence
– Geant4 kernel consists of
categories in red
27
Tracking

Geant4 tracking is general
– It is independent of
• the particle type
• the physics processes assigned to the particle
– It enables all processes to
• contribute to the determination of the step length
• contribute to any possible changes in physical quantities of
the track
• generate secondary particles
• suggest changes in the state of the track
28
(e.g. to suspend, postpone or kill)
Processes

All the work of particle decays and interactions is done by
processes
– Particle transportation is also a process; the particle can interact with
geometrical boundaries and any kind of field
– There is also a shower parameterization process which can take over
from transportation

Each particle has its own list of applicable processes. At the
beginning of each step, all of these processes are queried for a
proposed physical interaction length

The process with the shortest proposed length (in space-time) is the
one that occurs
– The chosen process also limits the step size
29
Cuts

A “cut” in Geant4 is really a production threshold
– Only applies to physics processes which have infrared divergence
– It is not a tracking cut

An energy threshold must be determined at which discrete energy
loss is replaced by continuous energy loss
• Specify range (which is converted to energy for each material) at
which continuous energy loss begins, track primary down to zero
range
• above specified range create secondaries,
• below range add to continuous energy loss of primary
30
User classes

Use these classes to build your application on top of the Geant4 toolkit
(class names in purple are mandatory)

Initialization classes
–
–

Action classes
–
–
–
–
–
–

G4VUserDetectorConstruction
G4VUserPhysicsList
G4VUserPrimaryGeneratorAction
G4UserRunAction
G4UserEventAction
G4UserStackingAction
G4UserTrackingAction
G4UserSteppingAction
Main() - not provided by Geant4
31
Manager classes

Managers classes broker transactions between objects within a category
and communicate with other managers

They are singletons

The user will have the most contact with G4RunManager
–

Must register detector geometry, physics list, particle generator to it
Other manager classes:
– G4EventManager – handles event processing, user actions
– G4TrackingManager – handles tracks, trajectory storage, user actions
– G4SteppingManager – handles steps, physics processes, hit scoring, user
actions
– G4VisManager – handles visualization drivers
32
Build your simulation in 7 steps
33
1 - Describe your detector

Derive your own concrete class from the abstract base class
G4VUserDetectorConstruction

In the virtual method Construct()
– assemble all necessary materials
– build the volumes of your detector geometry

Optionally you may define:
– sensitive detector classes and assign them to the detector
volumes
– regions for any part of your detector (for production ranges)
– visualization attributes of detector elements
– magnetic (or other) fields
34
2 – Select physics processes

Geant4 does not have any default particles or processes
–

even particle transporation must be explicitly defined by user
Derive your own concrete class from G4VUserPhysicsList
abstract base class
–
–
–
define all necessary particles
define all necessary processes and assign them to the proper particles
define production threshold (cutoff) ranges and assign them to world
volume and each region

Geant4 provides many utility classes/methods to assist in the above
tasks

Example (educated guess) physics lists exist for electromagnetic
and hadronic physics
35
3 – Generate primary event

For each event, user must define all details of initial particle

Derive concrete class from G4VUserPrimaryGeneratorAction
abstract base class

Geant4 provides several ways to do this:
– derive your own generator from G4VPrimaryGenerator
– use provided generators:
• G4ParticleGun (user provides number, energy, direction, type)
• G4HEPEvtInterface, G4HepMCInterface (interfaces to high
energy generator programs)
• G4GeneralParticleSource (mostly for radioactivity)
36
4 – User action classes

G4UserRunAction
– BeginOfRunAction (define
histograms)
– EndOfRunAction (fill
histograms)

G4UserEventAction
– BeginOfEventAction
(event selection)
– EndOfEventAction
(analyze event)

G4UserTrackingAction
– PreUserTrackingAction
(create user defined
trajectory)
– PostUserTrackingAction

G4UserSteppingAction
– UserSteppingAction (kill,
suspend, postpone track)

G4UserStackingAction
– PrepareNewEvent (reset
priority control)
– ClassifyNewTrack
• invoked when new track is
pushed
• can set track as urgent,
waiting, postpone or kill
– NewStage
• invoked when urgent stack
is empty
• event filtering
37
5 - The main() program

Geant4 does not provide a main()
–

In main(), you must:
–
–

However, many examples are provided in the Application Developers
Guide
Construct G4RunManager (or a class derived from it)
Provide to G4RunManager pointers to mandatory user classes:
• G4VUserDetectorConstruction
• G4VUserPhysicsList
• G4VUserPrimaryGeneratorAction
Other classes which can be defined in main()
– G4VisManager
–
–
(G)UI session
Optional user classes
38
6 – Setting up a user interface session

Geant4 provides several G4UISession concrete classes
– Select the one that is appropriate for your computing
envirnoment
– In main(), construct one of them
– Invoke its sessionStart() method

UI sessions provided:
– G4UIterminal – C- and TC-shell like character terminal
– G4GAG – Tcl/Tk of Java PVM based GUI
– G4JAG – interface to JAS (Java Analysis Studio)
– G4UIBatch – batch job with macro file
39
7 - Visualization

Geant4 provides interfaces to several graphics drivers:
–
–
–
–
–
–
DAWN – Fukui renderer
WIRED – event display
RayTracer – ray tracing by Geant4 tracking
OpenGL
OpenInventor
VRML
40
Application files : example

In the directory simulation
–
–

–
–
main()
Instructions for gmake
–
–
–
–
–
–
–
Materials and geometries
Particles and Physics processes
Primary particles
User action class (run)
User action class(event)
User action class(track)
User action class(step)
In simulation/src
–
–
–
–
–
–
–

Simulation.cc
GNUMakefile
DetectorConstruction.cc
PhysicsList.cc
PrimaryGeneratorAction.cc
UserRunAction.cc
UserEventAction.cc
UserTrackingAction.cc
UserSteppingAction.cc
In simulation/include
–
–
–
–
–
–
–
DetectorConstruction.hh
PhysicsList.hh
PrimaryGeneratorAction.hh
UserRunAction.hh
UserEventAction.hh
UserTrackingAction.hh
UserSteppingAction.hh
In purple : mandatory files
In white : optional files
41
The G4 prefix

For portability “G4” is prepended to raw C++ type names
– G4int, G4double, ...
– This way Geant4 implements correct type for a given architecture

G4cout and G4cerr are ostream objects defined by Geant4
– G4endl is also provided

Some GUIs are buffer output streams so that they display print-outs
on another window or provide storing/editing functionality
– The user should not use std::cout, etc.

Users should not use std::cin for input. Instead use the userdefined commands provided by the intercoms category
– e.g. G4UIcmdWithADouble
42
System of units

Geant4 has no default unit. To give a number, unit
must be “multiplied” to the number.
– for example :
G4double width = 12.5*m;
G4double density = 2.7*g/cm3;
– If no unit is specified, the internal G4 unit will be used, but this
is discouraged !
– Almost all commonly used units are available.
– The user can define new units.
– Refer to CLHEP: SystemOfUnits.h

Divide a variable by a unit you want to get.
G4cout << dE / MeV << “ (MeV)” << G4endl;
43
System of units

System of units are defined in CLHEP, based on:
–
millimetre (mm), nanosecond (ns), Mega eV (MeV), positron charge (eplus) degree Kelvin (kelvin),
the amount of substance (mole), luminous intensity (candela), radian (radian), steradian
(steradian)

All other units are computed from the basic ones.

In output, Geant4 can choose the most appropriate unit to use. Just specify the
category for the data (Length, Time, Energy, etc…):
G4cout << G4BestUnit(StepSize, “Length”);

StepSize will be printed in km, m, mm or … fermi, depending on its value

New units can be defined
44
Summary

The Geant4 toolkit consists of 17 categories, each designed for minimal
dependence on the others

The largest unit of a simulation application is the run, which consists in
turn of events, tracks, and steps
–
a track is a snapshot of a dynamic particle, not a trajectory

Tracking and physics are carried out by processes

Production thresholds and stacking allow for efficient simulation
–

Geant4 tracks particles down to zero energy
User classes allow the simulation to be customized
–
–
user must build the apparatus, select the physics
commands allow user to communicate with simulation
45
More
46
Geant4 as a state machine
Geant4 has six application states






G4State_PreInit: initialization, definition
of geometry, material, particles and physics
G4State_Idle: may start run or modify
geometry/physics for next run
G4State_GeomClosed: geometry is
optimized, cross section tables updated,
ready to process event
G4State_EventProc: an event is being
processed
G4State_Quit: normal termination
G4State_Abort: fatal exception and
program is aborting
D
47
Definition of new units

New units can be defined directly as constants, or (suggested way)
via G4UnitDefinition.
G4UnitDefinition ( name, symbol, category, value )

Example (mass thickness):
G4UnitDefinition (“grammpercm2”, “g/cm2”, “MassThickness”, g/cm2);
– The new category “MassThickness” will be registered in the kernel in
G4UnitsTable

To print the list of units:
– From the code
G4UnitDefinition::PrintUnitsTable();
– At run-time, as UI command:
Idle> /units/list
48
Environment variables

To compile, link and run a Geant4-based simulation, the following
environment variables must be set:
–
–
–
–

Variables for physics processes (if those processes are used):
–
–
–
–

$G4SYSTEM – operating system (e.g. Linux-g++)
$G4INSTALL – base directory of Geant4 (where the compiled libraries are)
$G4WORKDIR – where you run your application
$CLHEP_BASE_DIR – location of the compiled CLHEP libraries
$G4LEVELGAMMADATA – location of photon evaporation data
$G4LEDATA -- location of cross sections for low energy EM module
$G4RADIOACTIVEDATA – for radioactive decay processes
$NeutronHPCrossSections – location of high precision neutron db
Additional variables for GUI, Visualization, Analysis
49
Commands & intercoms

In Geant4, user can define commands and macros to run
applications

The Intercoms category handles the framework mechanism of
defining and delivering commands
–
–
–
It is exportable to any other application
It is independent of other Geant4 categories
Uses strong type and range checking
•
–
–

C++ syntax : aCmd -> SetRange(“x>0. && y>0.”);
Dynamic command definition / activation
Commands can be hard coded or issued by (G)UI
Macro files are enabled
–
Loop, foreach, alias, ...
50
Track stacking


G4Track is a class object -> easy
to suspend or postpone tracks
Example:
–
–


Suspend tracks at entrance to
calorimeter, i.e. simulate all tracks
in tracking region before
generating showers
Suspend “looper” tracks or abort
or postpone them to next event
Stacking allows prioritized
tracking without a perfomance
penalty
Well thought-out prioritization or
abortion of tracks/events make
simulation more efficient
51
Initialization
m a in
Ru n m a n a g e r
1 : in i t i al iz e
user d et ect o r
co n s t r u c t i o n
u s e r p h y si cs
l is t
2 : c o n st r u c t
3 : m at e ri al c o n st r u ct i o n
Describe your
experimental set-up
4 : g e o m e t r y c o n st r u c t io n
5 : w o r ld v o l u m e
6 : c o n st r u c t
7 : p h y si cs p r o c e ss co n s t r u c t i o n
Activate physics
processes appropriate to
your experiment
8 : se t cu t s
52
Beam On
m ain
Run Manag er
1 : Be am On
Geo m et r y
m an ag er
Ev en t
g en erat or
Eve nt
Man age r
2 : c lo se
3 : g en erat e one e ve nt
Generate primary
events according to
distributions relevant
to your experiment
4 : pr oc ess o ne ev e nt
5 : o p en
53
Event computation
Event
manager
St acking
manager
Tracking
manager
Stepping
manager
User sensitive
det ect or
1: pop
2: process one t rack
5: secondaries
6: push
3: Stepping
4: generat e hit s
Record the physics
quantities generated by
the simulation, that are
relevant to your
experiment
54
Step computation
55
The Geant4 toolkit :
3/15 - Definition of materials
DetectorConstruction.hh (.cc)
10 minutes
56
Definition of materials

Different kinds of materials can be defined:
–
–
–
–

isotopes
<>
elements
<>
molecules
<>
compounds and mixtures <>
G4Isotope
G4Element
G4Material
G4Material
Attributes associated:
– temperature, pressure, state, density
57
Isotopes, elements and materials

G4Isotope and G4Element describe the
properties of the atoms:
– Atomic number, number of nucleons, mass of a
mole, shell energies
– Cross-sections per atoms, etc…

G4Material describes the macroscopic
properties of the matter:
– temperature, pressure, state, density
– Radiation length, absorption length, etc…
58
Elements & isotopes
Isotopes can be assembled into elements
G4Isotope (const G4String&
G4int
G4int
G4double
name,
z,
// number of atoms
n,
// number of nucleons
a ); // mass of mole
… building elements as follows:
G4Element (const G4String& name,
const G4String& symbol, // element symbol
G4int
nIso ); // # of isotopes
G4Element::AddIsotope(G4Isotope* iso,
// isotope
G4double relAbund); // fraction of atoms
// per volume
59
Material of one element (lAr)
G4double density = 1.390*g/cm3;
G4double a = 39.95*g/mole;
G4Material* lAr =
new G4Material("liquidArgon",z=18.,a,density);
60
Material : molecule (water)
A molecule is made of several elements
(composition by number of atoms):
a = 1.01*g/mole;
G4Element* elH =
new G4Element("Hydrogen",symbol="H",z=1.,a);
a = 16.00*g/mole;
G4Element* elO =
new G4Element("Oxygen",symbol="O",z=8.,a);
density = 1.000*g/cm3;
G4Material* H2O =
new G4Material("Water",density,ncomp=2);
H2O->AddElement(elH, natoms=2);
H2O->AddElement(elO, natoms=1);
61
Material : compound (air)

Compound: composition by fraction of mass
a = 14.01*g/mole;
G4Element* elN =
new G4Element(name="Nitrogen",symbol="N",z= 7.,a);
a = 16.00*g/mole;
G4Element* elO =
new G4Element(name="Oxygen",symbol="O",z= 8.,a);
density = 1.290*mg/cm3;
G4Material* Air =
new G4Material(name="Air",density,ncomponents=2);
Air->AddElement(elN, 70.0*perCent);
Air->AddElement(elO, 30.0*perCent);
62
Material : mixture (aerogel)

Composition of compound materials
G4Element* elC = …;
G4Material* SiO2 = …;
G4Material* H2O = …;
// define “carbon” element
// define “quartz” material
// define “water” material
density = 0.200*g/cm3;
G4Material* Aerog =
new G4Material("Aerogel",density,ncomponents=3);
Aerog->AddMaterial(SiO2,fractionmass=62.5*perCent);
Aerog->AddMaterial(H2O ,fractionmass=37.4*perCent);
Aerog->AddElement (elC ,fractionmass= 0.1*perCent);
63
Exemple : gas (CO2)

It may be necessary to specify temperature
and pressure
– (dE/dx computation affected)
G4double density = 27.*mg/cm3;
G4double temperature = 325.*kelvin;
G4double pressure = 50.*atmosphere;
G4Material* CO2 =
new G4Material(“CarbonicGas", density, ncomponents=2
kStateGas, temperature, pressure);
CO2->AddElement(C,natoms = 1);
CO2->AddElement(O,natoms = 2);
64
Exemple : vacuum

Absolute vacuum does not exist. It is a gas at
very low density !
– Cannot define materials composed of multiple elements
through Z or A, or with r = 0
G4double atomicNumber = 1.;
G4double massOfMole = 1.008*g/mole;
G4double density = 1.e-25*g/cm3;
G4double temperature = 2.73*kelvin;
G4double pressure = 3.e-18*pascal;
G4Material* Vacuum =
new G4Material(“interGalactic", atomicNumber,
massOfMole, density, kStateGas,
temperature, pressure);
65
Material NIST database
====================================
### Elementary Materials from the NIST Data Base
==================================
Z Name ChFormula
density(g/cm^3) I(eV)
====================================
1 G4_H H_2
8.3748e-05
19.2
2 G4_He
0.000166322
41.8
3 G4_Li
0.534
40
4 G4_Be
1.848
63.7
5 G4_B
2.37
76
6 G4_C
2
81
7 G4_N N_2
0.0011652
82
8 G4_O O_2
0.00133151
95
9 G4_F
0.00158029
115
10 G4_Ne
0.000838505 137
11 G4_Na
0.971
149
12 G4_Mg
1.74
156
13 G4_Al
2.6989
166
14 G4_Si
2.33
173

Elements
 Compounds
 Nuclear applications
 Space applications
===================================
### Compound Materials from the NIST Data Base
===================================
N Name ChFormula
density(g/cm^3) I(eV)
===================================
13 G4_Adipose_Tissue
0.92
63.2
1 0.119477
6 0.63724
7 0.00797
8 0.232333
11 0.0005
12 2e-05
15 0.00016
16 0.00073
17 0.00119
19 0.00032
20 2e-05
26 2e-05
30 2e-05
4 G4_Air
0.00120479 85.7
6 0.000124
7 0.755268
8 0.231781
18 0.012827
2 G4_CsI
4.51
553.1
53 0.47692
55 0.52308
66
How to use it ?

No need to predefine elements and materials

Dedicated user interfaces
G4NistManager* manager = G4NistManager::GetPointer();
G4Element* elm = manager->FindOrBuildElement(“symb”, G4bool iso);
G4Element* elm = manager->FindOrBuildElement(G4int Z, G4bool iso);
G4Material* mat = manager->FindOrBuildMaterial(“name”, G4bool iso);
G4Material* mat = manager->ConstructNewMaterial(“name”,
const std::vector<G4int>& Z,
const std::vector<G4double>& weight,
G4double density, G4bool iso);
G4double isotopeMass = manager->GetMass(G4int Z, G4int N);
67
The Geant4 toolkit :
4/15 - Geometry construction
DetectorConstruction.hh (.cc)
70 minutes
68
Outline
1.
2.
3.
4.
5.
6.
7.
8.
9.
The basics
Logical and physical volumes
Solids
Touchables
Sensitive detector, digitizer
Magnetic field
Visualization
Advanced features
Geometry examples
69
Geometry :
1 – the basics
70
Describe your detector

Derive your own concrete class from
G4VUserDetectorConstruction abstract base class

Implementing the method Construct()
Modularize it according to each detector component or subdetector :
• Construct all necessary materials
• Define shapes/solids required to describe the geometry
• Construct and place volumes of your detector geometry
 Options
− Define sensitive detectors and identify detector volumes
which to associate them
− Associate magnetic field to detector regions
− Define visualization attributes for the detector elements
71
Creating a detector volume

Start with its Shape & Size
– Box 3x5x7 cm, sphere R=8m

Add properties:
– material, B/E field
– (make it sensitive)

• Solid
• Logical
Place it within another volume
– in one place
– repeatedly using a function
• Physical
72
Define detector geometry

Three conceptual layers
– G4VSolid : shape, size
– G4LogicalVolume : daughter physical volumes, material,
sensitivity, user limits, etc.
– G4VPhysicalVolume : position, rotation
G4VSolid
G4LogicalVolume
G4Material
G4Box
G4Tubs
G4VisAttributes
G4VSensitiveDetector
G4VPhysicalVolume
G4PVPlacement
G4PVParameterised
73
Geometry

Logical volume :
Solid
: shape and
+ material,
sensitivity,
etc.size
Basic strategy
G4VSolid* pBoxSolid =
new G4Box(“aBoxSolid”,
1.*m, 2.*m, 3.*m);
G4LogicalVolume* pBoxLog =
Physical volume :
+ rotation and position
new G4LogicalVolume( pBoxSolid,
pBoxMaterial, “aBoxLog”, 0, 0, 0);
G4VPhysicalVolume* aBoxPhys =
new G4PVPlacement( pRotation,
G4ThreeVector(posX, posY, posZ),
pBoxLog, “aBoxPhys”, pMotherLog,
0, copyNo);
 A volume is placed in its mother volume.
 Position and rotation of the daughter volume is described with respect to the
local coordinate system of the mother volume.
 The origin of mother volume’s local coordinate system is at the center of the mother volume.
74
 Daughter volume cannot protrude from mother volume
Geometrical hierarchy

One logical volume can be placed more than once.
One or more volumes can be placed to a mother
volume.

Note that the mother-daughter relationship is an
information of G4LogicalVolume.
–

If the mother volume is placed more than once, all
daughters are by definition appear in all of mother
physical volumes.
The world volume must be a unique physical
volume which fully contains all the other volumes.
–
The world volume defines the global coordinate
system. The origin of the global coordinate system is
at the center of the world volume.
–
Position of a track is given with respect to the global
coordinate system.
75
Geometry :
2 – logical and physical volumes
76
1) G4LogicalVolume
G4LogicalVolume(G4VSolid* pSolid, G4Material* pMaterial,
const G4String& name, G4FieldManager* pFieldMgr=0,
G4VSensitiveDetector* pSDetector=0,
G4UserLimits* pULimits=0,
G4bool optimise=true);
– Contains all information of volume except position:
•
•
•
•
•
–
–
–
–
Shape and dimension (G4VSolid)
Material, sensitivity, visualization attributes
Position of daughter volumes
Magnetic field, User limits
Shower parameterisation
Physical volumes of same type can share a logical volume.
The pointers to solid and material must be NOT null
Once created it is automatically entered in the LV store
It is not meant to act as a base class
77
2) G4VPhysicalVolume
– G4PVPlacement
1 Placement = ONE volume
• A volume instance positioned once in a mother volume
– G4PVParameterised
1 Parameterised = MANY Volumes
• Parameterised by the copy number
– Shape, size, material, position and rotation can be parameterised, by
implementing a concrete class of G4VPVParameterisation.
• Reduction of memory consumption
– Currently: parameterisation can be used only for volumes that either
– have no further daughters
– are identical in size & shape
– G4PVReplica
1 Replica = MANY Volumes
• Slicing a volume into smaller pieces (if it has a symmetry)
78
2) G4VPhysicalVolume - next

Placement : it is one positioned volume

Repeated : a volume placed many times
– can represent any number of volumes
– reduces use of memory
– Replica
• simple repetition, similar to G3 divisions
– Parameterised
placement
 A mother volume can contain either
– many placement volumes OR
– one repeated volume
repeated
79
G4VPhysicalVolume
G4PVPlacement
G4PVParameterised
G4PVReplica
G4PVDivision
80
G4PVPlacement
G4PVPlacement(G4RotationMatrix* pRot,
const G4ThreeVector& tlate,
G4LogicalVolume* pCurrentLogical,
const G4String& pName,
G4LogicalVolume* pMotherLogical,
G4bool pMany,
G4int pCopyNo);

Single volume positioned relatively to the mother volume
– In a frame rotated and translated relative to the coordinate system of the
mother volume

Three additional constructors
– A simple variation: specifying the mother volume as a pointer to its physical
volume instead of its logical volume.
– Using G4Transform3D to represent the direct rotation and translation of the
solid instead of the frame
– The combination of the two variants above
81
G4PVPlacement
G4PVPlacement(G4RotationMatrix* pRot,
// rotation of mother frame
const G4ThreeVector &tlate, // position in rotated frame
G4LogicalVolume *pDaughterLogical,
const G4String &pName,
G4LogicalVolume *pMotherLogical,
G4bool pMany, // ‘true’ not implemented yet…
G4int pCopyNo, // unique arbitrary integer
G4bool pSurfChk=false); // optional : boundary check
Mother volume
rotation
82
Alternative G4PVPlacement
G4PVPlacement(
G4Transform3D(G4RotationMatrix &pRot, // rotation du réf. fille
const G4ThreeVector &tlate), // position dans le ref. mère
G4LogicalVolume *pDaughterLogical,
const G4String &pName,
G4LogicalVolume *pMotherLogical,
G4bool pMany,
G4int pCopyNo,
G4bool pSurfChk=false);
Mother volume
rotation
83
G4VPhysicalVolume
G4PVPlacement
G4PVParameterised
G4PVReplica
G4PVDivision
84
Parameterised physical volumes

User written functions define:
–
the size of the solid (dimensions)
•
–
where it is positioned (transformation)
•

the type of the solid
•
–
function ComputeSolid(…)
the material
•
function ComputeMaterial(…)
Limitations:
–
–

function ComputeTransformations(…)
Optional:
–

function ComputeDimensions(…)
Applies to simple CSG solids only
Daughter volumes allowed only for special cases
Very powerful:
–
Consider parameterised volumes as “leaf” volumes
85
Use of parameterised volumes
Complex detectors
– with large repetition of
volumes
• regular or irregular
Medical applications
– the material in animal
tissue is measured
• cubes with varying material
86
G4PVParameterised
G4PVParameterised(const G4String& pName,
G4LogicalVolume* pCurrentLogical,
G4LogicalVolume* pMotherLogical,
const EAxis pAxis,
const G4int nReplicas,
G4VPVParameterisation* pParam);
 Replicates the volume nReplicas times using the parameterisation pParam, within
the mother volume
 The positioning of the replicas is dominant along the specified Cartesian axis
– If kUndefined is specified as axis, 3D voxelisation for optimisation of the
geometry is adopted
 Represents many touchable detector elements differing in their positioning and
dimensions. Both are calculated by means of a G4VPVParameterisation object
 Alternative constructor using pointer to physical volume for the mother
87
G4VPhysicalVolume
G4PVPlacement
G4PVParameterised
G4PVReplica
G4PVDivision
88
Replicated physical volumes
 The mother volume is sliced into replicas, all of the
same size and dimensions.
 Represents many touchable detector elements differing
only in their positioning.
 Replication may occur along:
– Cartesian axes (X, Y, Z) – slices are considered
perpendicular to the axis of replication
• Coordinate system at the center of each replica
– Radial axis (Rho) – cons/tubs sections centered on the
origin and un-rotated
• Coordinate system same as the mother
– Phi axis (Phi) – phi sections or wedges, of cons/tubs form
• Coordinate system rotated such as that the X axis
bisects the angle made by each wedge
repeated
89
G4PVReplica
G4PVReplica(const G4String& pName,
G4LogicalVolume* pCurrentLogical,
G4LogicalVolume* pMotherLogical,
const EAxis pAxis,
const G4int nReplicas,
const G4double width,
const G4double offset=0);
A daughter volume
to be replicated
mother volume
 Alternative constructor: using pointer to physical volume for the mother
 An offset can only be associated to a mother offset along the axis of
replication
 Features and restrictions:
– Replicas can be placed inside other replicas
– Normal placement volumes can be placed inside replicas, assuming no
intersection/overlaps with the mother volume or with other replicas
– No volume can be placed inside a radial replication
– Parameterised volumes cannot be placed inside a replica
90
Replica – axis, width, offset

Cartesian axes - kXaxis,kYaxis,kZaxis
– offset shall not be used
– Center of n-th daughter is given as
width
-width*(nReplicas-1)*0.5+n*width
width

Radial axis - kRaxis
– Center of n-th daughter is given as
width*(n+0.5)+offset

offset
Phi axis - kPhi
– Center of n-th daughter is given as
width*(n+0.5)+offset
width
offset
91
G4VPhysicalVolume
G4PVPlacement
G4PVParameterised
G4PVReplica
G4PVDivision
92
G4PVDivision
 Implemented as “special” kind of parameterised volumes
– Applies to CSG-like solids only (box, tubs, cons, para, trd, polycone, polyhedra)
– Divides a volume in identical copies along one of its axis (copies are not strictly
identical)
• e.g. - a tube divided along its radial axis
• Offsets can be specified
 The possible axes of division vary according to the supported solid type
 Represents many touchable detector elements differing only in their
positioning
 G4PVDivision is the class defining the division
– The parameterisation is calculated automatically using the values provided in
input
93
Geometry :
3 - solids
94
G4VSolid

Abstract class

All solids in Geant4 derive from it
– Defines but does not implement
all functions required to:
•
•
•
•

compute distances to/from the shape
check whether a point is inside the
shape
compute the extent of the shape
compute the surface normal to the
shape at a given point
Once constructed, each solid is
automatically registered in a
specific solid store
95
Solids
Solids defined in Geant4
– CSG (Constructed Solid Geometry) solids
• G4Box, G4Tubs, G4Cons, G4Trd, …
• Analogous to simple Geant3 CSG solids
– Specific solids (CSG like)
• G4Polycone, G4Polyhedra, G4Hype, …
• G4TwistedTubs, G4TwistedTrap, …
– BREP (Boundary REPresented) solids
• G4BREPSolidPolycone, G4BSplineSurface, …
• Any order surface
– Boolean solids
• G4UnionSolid, G4SubtractionSolid, …
96
CSG: G4Tubs, G4Cons
G4Tubs(const G4String&
G4double
G4double
G4double
G4double
G4double
pname,
pRmin,
pRmax,
pDz,
pSphi,
pDphi);
// name
G4Cons(const G4String&
G4double
G4double
G4double
G4double
G4double
G4double
G4double
pname,
pRmin1,
pRmax1,
pRmin2,
pRmax2,
pDz,
pSphi,
pDphi);
// name
// inner radius
// outer radius
// Z half length
// starting Phi
// segment angle
// inner radius -pDz
//
//
//
//
//
//
outer radius -pDz
inner radius +pDz
outer radius +pDz
Z half length
starting Phi
segment angle
97
CSG: G4Box, G4Tubs
G4Box(const G4String &pname,
// name
G4double half_x,
// X half size
G4double half_y,
// Y half size
G4double half_z);
// Z half size
G4Tubs(const G4String &pname,
// name
G4double
pRmin,
// inner radius
G4double
pRmax,
// outer radius
G4double
pDz,
// Z half length
G4double
pSphi,
// starting Phi
G4double
pDphi); // segment angle
98
Other CSG solids
G4Trap
G4Cons
G4Para
(parallelepiped)
G4Trd
G4Torus
G4Sphere
G4Orb
(full sphere)
Consult Geant4 Application
Developers Guide for all available
shapes.
99
Specific CSG Solids: G4Polycone
G4Polycone(const G4String& pName,
G4double phiStart,
G4double phiTotal,
G4int numRZ,
const G4double r[],
const G4double z[]);
● numRZ : numbers of corners in the r,z space
● r, z : coordinates of corners
● Additional constructor
100
Other Specific CSG solids
G4Polyhedra
G4EllipticalTube
G4Tet
(tetrahedra)
G4Hype
G4Ellipsoid
G4TwistedBox
G4EllipticalCone
G4TwistedTubs
G4TwistedTrap
G4TwistedTrd
Consult Geant4 Application
Developers Guide for all available
101
shapes.
BREP solids
 BREP = Boundary REPresented Solid
 Listing all its surfaces specifies a solid
– e.g. 6 squares for a cube
 Surfaces can be
– planar, 2nd or higher order
•
elementary BREPS
– Splines, B-Splines,
NURBS (Non-Uniform B-Splines)
•

advanced BREPS
Few elementary BREPS pre-defined
– box, cons, tubs, sphere, torus, polycone, polyhedra
 Advanced BREPS built through CAD systems
102
BREPS:
G4BREPSolidPolyhedra
G4BREPSolidPolyhedra(const G4String& pName,
G4double phiStart,
G4double phiTotal,
G4int sides,
G4int nZplanes,
G4double zStart,
const G4double zval[],
const G4double rmin[],
const G4double rmax[]);




sides - numbers of sides of each polygon in the x-y plane
nZplanes - numbers of planes perpendicular to the z axis
zval[] - z coordinates of each plane
rmin[], rmax[] - radii of inner and outer polygon at each plane
103
Boolean solids

Solids can be combined using boolean operations:
–
G4UnionSolid, G4SubtractionSolid, G4IntersectionSolid
–
Requires: 2 solids, 1 boolean operation, and an (optional) transformation for the 2nd solid
–
2nd solid is positioned relative to the coordinate system of the 1st solid
–
Result of boolean operation becomes a solid. Thus the third solid can be combined to the
resulting solid of first operation.

Solids to be combined can be either CSG or other Boolean solids.

Note: tracking cost for the navigation in a complex Boolean solid is proportional to the number of
constituent CSG solids
G4UnionSolid
G4SubtractionSolid
G4IntersectionSolid
104
Boolean solids
105
Boolean Solids - example
G4VSolid* box = new G4Box(“Box",50*cm,60*cm,40*cm);
G4VSolid* cylinder
= new G4Tubs(“Cylinder”,0.,50.*cm,50.*cm,0.,2*M_PI*rad);
G4VSolid* union
= new G4UnionSolid("Box+Cylinder", box, cylinder);
G4VSolid* subtract
= new G4SubtractionSolid("Box-Cylinder", box, cylinder,
0, G4ThreeVector(30.*cm,0.,0.));
G4RotationMatrix* rm = new G4RotationMatrix();
rm->RotateX(30.*deg);
G4VSolid* intersect
= new G4IntersectionSolid("Box&&Cylinder",
box, cylinder, rm, G4ThreeVector(0.,0.,0.));

The origin and the coordinates of the combined solid are the same as those
106
of the first solid.
Geometry :
4 - touchables
107
Touchables

Suppose a geometry is made of 4x5
voxels and it is implemented by two
levels of replica.

In reality, there is only one physical
volume object for each level. Its
position is parameterized by its copy
number. To get the copy number of
each level , use touchable to get the
copy number of each level

0
1 CopyNo
2 =0 3
4
0
1 CopyNo
2 =1 3
4
0
1 CopyNo
2 =2 3
4
0
1 CopyNo
2 =3 3
4
G4VTouchable has a method
GetCopyNumber(G4int nLevel=0)
– nLevel = 0 : returns the copy number of the bottom level
– nLevel = 1 : returns the copy number of the mother volume
– nLevel = 2 : returns the copy number of the grandmother volume, etc.
108
Geometry :
5 – sensitive detector and digitizer
109
Detector sensitivity

A logical volume becomes sensitive if it has a pointer
to a concrete class derived from
G4VSensitiveDetector

A sensitive detector either
– constructs one or more hit objects or
– accumulates values to existing hits
using information given in a G4Step object
NOTE: you must get the volume information from the
“PreStepPoint”
110
Sensitive detector and hit

Each “Logical Volume” can have a pointer to a sensitive
detector

Hit is a snapshot of the physical interaction of a track or an
accumulation of interactions of tracks in the sensitive
region of your detector

A sensitive detector creates hit(s) using the information
given in G4Step object. The user has to provide his/her own
implementation of the detector response

Hit objects, which still are the user’s class objects, are
collected in a G4Event object at the end of an event.
– The UserSteppingAction class should NOT do this
111
Hit class – 1

Hit is a user-defined class derived from G4VHit

You can store various types information by
implementing your own concrete Hit class

For example:
–
–
–
–
–
Position and time of the step
Momentum and energy of the track
Energy deposition of the step
Geometrical information
or any combination of above
112
Hit class - 2

Hit objects of a concrete hit class must be stored in a
dedicated collection which is instantiated from
G4THitsCollection template class

The collection will be associated to a G4Event object
via G4HCofThisEvent

Hits collections are accessible
– through G4Event at the end of event,
– through G4SDManager during processing an event
• Used for Event filtering
113
Readout geometry

Readout geometry is a virtual and artificial geometry which can
be defined in parallel to the real detector geometry

A readout geometry is optional

Each one is associated to a sensitive detector
114
Digitization

Digit represents a detector output (e.g. ADC/TDC count,
trigger signal)

Digit is created with one or more hits and/or other
digits by a concrete implementation derived from
G4VDigitizerModule

In contradiction to the Hit which is generated at
tracking time automatically, the digitize() method of
each G4VDigitizerModule must be explicitly invoked
by the user’s code (e.g. EventAction)
115
Defining a sensitive detector

Basic strategy
G4LogicalVolume* myLogCalor = ……;
G4VSensitiveDetector* pSensitivePart =
new MyCalorimeterSD(“/mydet/calorimeter”);
G4SDManager* SDMan = G4SDManager::GetSDMpointer();
SDMan->AddNewDetector(pSensitivePart);
myLogCalor->SetSensitiveDetector(pSensitivePart);
116
Geometry :
6 – magnetic field
117
Magnetic field

Create your magnetic field class
–
Uniform field : use a G4UniformMagField class object
G4MagneticField* magField =
new G4UniformMagField(G4ThreeVector(1.*Tesla,0.,0.);
–
Non uniform field : create a concrete class derived from G4MagneticField
and implement the GetFieldValue method
void MyField::GetFieldValue(
const double Point[4], double *field) const

•
Point[0..2] are the positions in the GLOBAL reference frame
•
Point[3] is time
•
field[0..2] returns magnetic field coordinates
Also, possibility to define any kind of field !
118
Field integration

In order to propagate a particle inside a field (e.g. magnetic, electric or both), we
solve the equation of motion of the particle in the field.

We use a Runge-Kutta method for the integration of the ordinary differential
equations of motion.
–


Several Runge-Kutta ‘steppers’ are available.
In specific cases other solvers can also be used:
–
In a uniform field, using the analytical solution.
–
In a smooth but varying field, with RK+helix.
Using the method to calculate the track's motion in a field, Geant4 breaks up this
curved path into linear chord segments.
–
We determine the chord segments so that they closely approximate the curved path.
Tracking Step
Real trajectory
Chords
119
Tracking in field

We use the chords to interrogate the G4Navigator, to see whether the track has
crossed a volume boundary.

One physics/tracking step can create several chords.
–

In some cases, one step consists of several helix turns.
User can set the accuracy of the volume intersection,
–
By setting a parameter called the “miss distance”
• It is a measure of the error in whether the approximate track intersects a volume.
• It is quite expensive in CPU performance to set too small “miss distance”.
Tracking step
Chords
Real trajectory
"miss distance"
120
Example

Tell Geant4 to use your field
1.
Find the global Field Manager
G4FieldManager* globalFieldMgr =
G4TransportationManager::GetTransportationManager()
-> GetFieldManager();
2.
Set the field for this FieldManager,
globalFieldMgr-> SetDetectorField(magField);
3.
and create a Chord Finder.
globalFieldMgr-> CreateChordFinder(magField);

$G4INSTALL/example/novice/N04/ExN04 is a good starting point
121
Geometry :
7 - visualization
122
Visualization of detector

Each logical volume can have associated a
G4VisAttributes object
– Visibility, visibility of daughter volumes
– Color, line style, line width
– Force flag to wire-frame or solid-style mode

For parameterised volumes, attributes can be
dynamically assigned to the logical volume

Lifetime of visualization attributes must be at least
as long as the objects they’re assigned to
123
Visualization of hits and trajectories

Each G4VHit concrete class must have an
implementation of Draw() method.
– Colored marker
– Colored solid
– Change the color of detector element

G4Trajectory class has a Draw() method.
– Blue : positive
– Green : neutral
– Red : negative
– You can implement alternatives by yourself
124
Geometry :
8 – advanced fonctions
125
Cuts by region

Geant4 has had a unique production threshold (‘cut’) expressed in length
(i.e. minimum range of secondary)
– For all volumes
– Possibly different for each particle.

Yet appropriate length scales can vary greatly between different
areas of a large detector
– E.g. a vertex detector (5 mm) and a muon detector (2.5 cm)
– Having a unique (low) cut can create a performance penalty

Geant4 allows for several cuts
– Globally or per particle
– Enabling the tuning of production thresholds at the level of a subdetector, i.e. region
– Cuts are applied only for gamma, electron and positron and only for
126
processes which have infrared divergence
Detector region

Concept of region
– Set of geometry volumes,
typically of a sub-system
Default
Region
Region B
• barrel + end-caps of the
calorimeter;
• “Deep” areas of support
structures can be a region.
– Or any group of volumes

A set of cuts in range is
associated to a region
– a different range cut for each
particle among gamma, e-, e+
is allowed in a region
Region
B
Region A
Region
B
C
C
Region B
127
Region and cut
World Volume - Default Region
Root logical - Region A

Each region has its unique set of cuts.

World volume is recognized as the
default region. The default cuts defined
in Physics list are used for it.
–

User is not allowed to define a region to the
world volume or a cut to the default region
A logical volume becomes a root
logical volume once it is assigned to a
region.
–

Root logical
- Region B
All daughter volumes belonging to the root
logical volume share the same region (and
cut), unless a daughter volume itself
becomes to another root
Important restriction :
No logical volume can be shared by more than
one regions, regardless of root volume or not
128
GGE (Graphical Geometry Editor)

Implemented in JAVA, GGE is a graphical
geometry editor compliant to Geant4. It allows to :
– Describe a detector geometry including:
• materials, solids, logical volumes, placements
– Graphically visualize the detector geometry using a
Geant4 supported visualization system, e.g. DAWN
– Store persistently the detector description
– Generate the C++ code according to the Geant4
specifications

GGE can be downloaded from Web as a separate
tool :
http://erpc1.naruto-u.ac.jp/~geant4/
129
Computing volumes and masses

Geometrical volume of a generic solid or
boolean composition can be computed from
the solid
G4double GetCubicVolume();

Overall mass of a geometry setup
(subdetector) can be computed from the logical
volume
G4double GetMass(G4Bool forced=false,
G4Material* parameterisedMaterial=0);
130
Debugging geometries

An overlapping volume is a contained volume which actually protrudes from its
mother volume
–
Volumes are also often positioned in a same volume with the intent of not provoking
intersections between themselves. When volumes in a common mother actually intersect
themselves are defined as overlapping

Geant4 does not allow for malformed geometries

The problem of detecting overlaps between volumes is bounded by the complexity
of the solid models description

Utilities are provided for detecting wrong positioning
–
–
Graphical tools (DAVID, OLAP)
Kernel run-time commands
131
Moving objects

In some applications, it is essential to simulate the movement of
some volumes.
–

E.g. particle therapy simulation
Geant4 can deal with moving volume
–
In case speed of the moving volume is slow enough compared to
speed of elementary particles, so that you can assume the position of
moving volume is still within one event.

Two tips to simulate moving objects :
1.
Use parameterized volume to represent the moving volume.
2.
Do not optimize (voxelize) the mother volume of the moving
volume(s).
132
Geometry
9 - examples
133
LHCb detector at CERN
Courtesy of the LHCb Collaboration
Vertex localizer
134
CMS detector at CERN
Courtesy of the CMS Collaboration
SUSY events
ATLAS detector at CERN
Courtesy of the ATLAS Collaboration
Anti-neutrino detector – Kamioka liquid scintillator
137
Courtesy of H.Ikeda (Tohoku)
Courtesy T. Ersmark, KTH Stockholm
International Space Station
138
More
139
Parameterization : example
G4VSolid* solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
G4LogicalVolume* logicChamber =
new G4LogicalVolume(solidChamber, ChamberMater, "Chamber", 0, 0, 0);
G4double firstPosition = -trackerSize + 0.5*ChamberWidth;
G4double firstLength = fTrackerLength/10;
G4double lastLength
= fTrackerLength;
G4VPVParameterisation* chamberParam =
new ChamberParameterisation( NbOfChambers, firstPosition,
ChamberSpacing, ChamberWidth,
firstLength, lastLength);
G4VPhysicalVolume* physChamber =
new G4PVParameterised( "Chamber", logicChamber, logicTracker,
kZAxis, NbOfChambers, chamberParam);
Use kUndefined to activate voxelization 3D for optimization140
Parameterization : example - next
class ChamberParameterisation : public G4VPVParameterisation
{
public:
ChamberParameterisation( G4int NoChambers, G4double startZ,
G4double spacing, G4double widthChamber,
G4double lenInitial, G4double lenFinal );
~ChamberParameterisation();
void ComputeTransformation (const G4int copyNo,
G4VPhysicalVolume* physVol) const;
void ComputeDimensions (G4Box& trackerLayer, const G4int copyNo,
const G4VPhysicalVolume* physVol) const;
}
141
Parameterization : example - end
void ChamberParameterisation::ComputeTransformation
(const G4int copyNo, G4VPhysicalVolume* physVol) const
{
G4double Zposition= fStartZ + (copyNo+1) * fSpacing;
G4ThreeVector origin(0, 0, Zposition);
physVol->SetTranslation(origin);
physVol->SetRotation(0);
}
void ChamberParameterisation::ComputeDimensions
(G4Box& trackerChamber, const G4int copyNo,
const G4VPhysicalVolume* physVol) const
{
G4double
halfLength= fHalfLengthFirst + copyNo * fHalfLengthIncr;
trackerChamber.SetXHalfLength(halfLength);
trackerChamber.SetYHalfLength(halfLength);
trackerChamber.SetZHalfLength(fHalfWidth);
}
142
Replica : examples
G4double tube_dPhi = 2.* M_PI;
G4VSolid* tube =
new G4Tubs("tube", 20*cm, 50*cm, 30*cm, 0., tube_dPhi*rad);
G4LogicalVolume * tube_log =
new G4LogicalVolume(tube, Ar, "tubeL", 0, 0, 0);
G4VPhysicalVolume* tube_phys =
new G4PVPlacement(0,G4ThreeVector(-200.*cm, 0., 0.*cm),
"tubeP", tube_log, world_phys, false, 0);
G4double divided_tube_dPhi = tube_dPhi/6.;
G4VSolid* divided_tube =
new G4Tubs("divided_tube", 20*cm, 50*cm, 30*cm,
-divided_tube_dPhi/2.*rad, divided_tube_dPhi*rad);
G4LogicalVolume* divided_tube_log =
new G4LogicalVolume(divided_tube, Ar, "div_tubeL", 0, 0, 0);
G4VPhysicalVolume* divided_tube_phys =
new G4PVReplica("divided_tube_phys", divided_tube_log, tube_log,
kPhi, 6, divided_tube_dPhi);
143
The Geant4 toolkit :
5/15 - Electromagnetic Physics (QED)
STANDARD version
PhysicsList.hh (.cc)
20 minutes
144
Content



Available EM Physics processes
How to use them ?
Important processes
– Compton scattering
– ionization
– Multiple scattering
145
Available packages

Standard
–
–
–
–

Muons
–

Interactions of optical photons
High energy
–
–

Processes for X ray and optical photons production
Optical
–

Up to 1 PeV
Rayons X
–

from 1 keV
gammas, e+- up to 100 TeV
Hadronsup to 100 TeV
ions up to 100 TeV
High energy processes (E>10GeV)
Exotic particles physics
Polarization
–
Polarized beams
146
Photons and electrons

Photons
–
–
–
–
Conversion into e+eCompton scattering
Photoelectric effect
Rayleigh scattering
in low energy package
– Photo-nuclear interactions in the
– Hadronic sub-package CHIPS

Electrons and positrons
–
–
–
–
Ionization
Coulomb scattering
Bremsstrahlung
Nuclear interactions in the hadronic
sub-package CHIPS
– Positron annihilation
Calorimeter
Medical linac
147
Muons

Ionization
 Bremsstrahlung
 e+e- pair production
 Muon-nucleus interactions in hadronic packages
148
Hadrons and ions


Coulomb scattering
Ionization
– Corrected Bethe-Bloch formula for E>2 MeV
– Parametrizations of Bragg peak for E< 2 MeV
(from ICRU’49 & NIST databases)
149
X rays and optical photons

Standard package
–
–
–
–

Cherenkov radiation
Synchrotron radiation
Transition radiation
Scintillation
Low energy package
– Atomic relaxation (fluorescence & Auger transitions)

Optical
–
–
–
–
Reflexion
Refraction
Absorption
Rayleigh scattering
150
How to use EM processes ?
151
Physics list

For each particle type,
theProcessManager maintains a list of
applicable processes

Three types of processes
– Action at rest : AtRest
– Action along step : AlongStep
– Action after step : PostStep

Declared in the UserPhysicsList class
152
Example of Physics list (1)
AtRestDoIt
AlongStepDoIt
PostStepDoIt
The -1 parameter indicates inactive153DoIt
Example de Physics list (2)
154
Example of Physics list (3)
… is a shortcut of …
Order has no importance for
processes with PostStepAction only
155
Examples of processes
156
Compton scattering

Describes photon scattering by quasi-free atomic electrons
g + e  g + e

Each electron behaves as an independent target : it is an
incoherent scattering
Cross section per atom =
Z x Cross section per electron

The differential cross section in scattered energy is
described by the Klein-Nishina formula, corrected by a
factor taking into account the binding energy of the atomic
electron

Linked to annihilitation (e+,e-) by crossing symmetry
157
Example of Compton scattering
10 MeV g in 10 cm Al
158
Ionization

The base mechanism is an inelastic collision of
the moving charged particle with the material
atomic electrons, ejecting an atomic electron
m + atom  m + atom+ + e
During each individual collision, the energy
transferred to the electron is small. But the total
number of collisions is large and one can define a
mean energy loss per macroscopic unit of range
159
Generation of secondary electrons
(delta rays)

In Geant4, one may choose to simulate or not
ejected electrons (delta electrons) and their
interactions with energies above a threshold Tcut
– Below this threshold, electrons are taken into account in
the continuous energy loss of the ionizing particle and
they are not explicitly simulated
– above, they are explicitly generated. They are excluded
from the continuous energy loss of the ionizing particle.

The continuous energy loss is computed from the
troncated Bethe Bloch formula (dE/dx for T<Tcut)
160
Example of delta ray production
e-, p, a of 200 MeV in 1 cm Al
161
Energy loss fluctuations
(straggling)

The Bethe Bloch formula only
gives the mean energy loss per
ionization. There are fluctuations
(straggling). The distribution of
the energy loss DE within a
thickness Dx can be very
dissymmetric (Landau
distribution)

Large fluctuations are caused by
rare collisions having large
energy transfers
162
Straggling example
16 MeV e- in 10 cm water
105 MeV p in 10 cm water
Fluctuations on DE  fluctuations on range
163
Multiple Coulomb scattering

Charged particles travelling through a finite
thickness of matter undergo multiple elastic
Coulomb scattering.

The cumulated effect of these small angle
scatterings lead to a global deviation of the
particle’s direction of propagation.

Theory by Lewis
164
Multiple scattering example
165
The Geant4 toolkit :
6/15 - Electromagnetic Physics (QED)
LOW ENERGY version
PhysicsList.hh (.cc)
35 minutes
166
Content

Introduction

Processes based on the Livermore
database

Processes based on the Monte Carlo code
Penelope

How to use this package ?
167
The low energy package

A package in the Geant4 electromagnetic package
 in $G4INSTALL/source/processes/electromagnetic/lowenergy/

A set of processes extending the coverage of electromagnetic interactions in Geant4
down to “low” energy
–
–
–
–
250 eV (in principle even below this limit) / 100 eV for electrons and photons
down to approximately the ionization potential of the interacting material for hadrons and ions
up to 100 GeV (unless specified)
based on theoretical models and evaluated data sets ; they involve two distinct phases :
•
•

calculation and use of total cross sections
generation of the final state
Models are detailed
–
–
shell structure of the atom
precise angular distributions

Complementary to the “standard” electromagnetic package

Driven by requirements which come from medicine and space research
and from users in HEP instrumentation
168
Overview of Physics
Photons
• Compton Scattering
• Compton Scattering by Linearly Polarized Gamma Rays
• Rayleigh Scattering
• Gamma Conversion
• Photoelectric effect
Electrons
• Bremsstrahlung
• Ionisation
Come in two “flavours” of models:
• based on the Livermore Library
• à la Penelope (+ positron annihil.)
Hadrons and ion ionisation
• Energy loss of slow & fast hadrons
• Energy loss in compounds
• Delta-ray production
• Effective charge of ions
• Barkas and Bloch effects (hadron sign + relativistic)
• Nuclear stopping power
• PIXE
Atomic relaxation
• Fluorescence
• Auger process
169
A set of LowE processes
are based on the
Livermore Library
170
Photons and electrons

Based on evaluated data librairies from LLNL :
– EADL
(Evaluated Atomic Data Library)
– EEDL
(Evaluated Electrons Data Library)
– EPDL97 (Evaluated Photons Data Library)

Validity range : 250 eV - 100 GeV
– The processes can be used down to 100 eV, with degraded accuracy
– In principle the validity range of the data libraries extends down to ~10 eV

Elements Z=1 to Z=100
– Atomic relaxation : Z > 5 (transition data available in EADL)
171
Calculation of cross sections
 Interpolation from the data libraries
log 1  logE2 / E   log 2  logE / E1 
log E  
logE2 / E1 
E1 and E2 are the lower and higher energy
for which data (1 and 2) are available
 Mean free path for a
process, at energy E :

1
  i  E   ni
i
ni = atomic density of the ith element
contributing to the material composition 172
Photons
173
174
Compton scattering (incoherent)
Klein-Nishina cross section (E’/E) × Scattering Function (q)
q = E sin2 (/2) momentum transfer

Energy distribution of the scattered photon according to the KleinNishina formula, multiplied by scattering function F(q) (Hubbel’s
atomic factor) from EPDL97 data library

The effect of scattering function becomes
low energies in suppressing forward scattering

Angular distribution of the scattered photon and
the recoil electron also based on EPDL97
significant
175
at
Rayleigh scattering (coherent)

Depends on charge distribution of atom

Angular distribution
F(E,)=[1+cos2()]sinF2(q)
Rayleigh formula times F(q), the energy dependent Hubbel’s
form factor obtained from EPDL97 (forward peak at high
energies)

Only available in the lowenergy package
176
Photoelectric effect
 Cross section
– Integrated cross section (over the shells)
from EPDL + interpolation
– Shell from which the electron is emitted selected according to
the detailed cross sections of the EPDL library
 Final state generation
– Various angular distribution generators
(“naïve”, Sauter-Gavrila, Gavrila)
 De-excitation via the atomic relaxation sub-process
– Initial vacancy + following chain of vacancies created
177
Gamma conversion

The secondary e- and e+ energies are sampled using BetheHeitler cross sections with Coulomb correction (screening)

e- and e+ assumed to have symmetric angular distribution

Energy and polar angle sampled w.r.t. the incoming photon
using Tsai differential cross section

Azimuthal angle generated isotropically

Choice of which particle in the pair is e- or e+ is made randomly
178
Illustration :
mass attenuation coefficient
Comparison with NIST data
photons in Fe
N/N0 = exp [-(m /r rx]
LE EPDL
LE Penelope
All simulation results lie
with  3 w.r.t. the
corresponding
NIST
data (National Institute
of
Standards
and
Technologies)
STD
data
179
Electrons
180
Bremsstrahlung
Paramétrisation of EEDL data
Delta electrons in Si from 100 keV e-
– 16 parameters for each
atom
– At high energy the
parameterization
reproduces the Bethe-Heitler
formula
Gamma in Si from 100 keV e-
– Precision is ~ 1.5 %
– Three LowE generators
available : G4ModifiedTsai
(HE), G4Generator2BS and
G4Generator2BN (<500 keV)
181
Ionisation

Parameterisation based
on 5 parameters for
each shell

Precision of
parameterization is
better than 5% for 50 %
of shells, less accurate
for the remaining shells
182
Illustration :
range
Comparaison avec données NIST
électrons in Uranium
LE EEDL
● Compared to NIST database
● All simulation results lie
within  3 w.r.t. the
corresponding NIST data
LE Penelope
STD
data
The stopping power can be used to calculate the distance it takes to slow an electron down to a given energy. This
distance is called the continuous slowing down approximation range, or CSDA range, because the calculation
assumes that the electron slows down continuously from the initial energy E to the final energy.
183
Hadrons
184
185
Hadrons and ions

Variety of models, depending on
– energy range
– particle type
– charge

Composition of models across the energy range, with
different approaches
– analytical
– based on data reviews + parameterizations

Specialized models for fluctuations (stochastic
straggling)
186
Protons











Bethe-Bloch model of energy loss, E > 2 MeV
5 parameterization models, E < 2 MeV based
on Ziegler and ICRU reviews
Free electron gas model below 1 keV
3 models of energy loss fluctuations
Density correction for high energy
Shell correction term for intermediate energy
Chemical effect for compounds
Nuclear stopping power (elastic Coulomb scattering)
PIXE included
Ziegler and ICRU, Si
Spin dependent term
Barkas (+ vs -) and Bloch terms
Stopping power
Z dependence for various energies
Ziegler and ICRU models
Straggling
Ziegler and ICRU, Fe
Nuclear stopping power
187
Positively charged hadrons (Z>1)
2
S
(
T
)
ST
(p)
, Tp  T
Z
io
n
io
n
p
mp

Scaling of Bethe-Bloch :




0.01 <  < 0.05 : parameterizations, Bragg p., based on Ziegler and ICRU reviews
 < 0.01 : free electron gas model
Effective charge model (picks up e- in the medium)
Nuclear stopping power (elastic Coulomb scattering with nuclei)
mion
188
Models for antiprotons
 > 0.5
 0.01 <  < 0.5
  < 0.01

Bethe-Bloch formula
Quantum harmonic oscillator model
Free electron gas model
Proton
G4 Antiproton
Antiproton
exp. data
Antiproton from Arista et. al
Proton
G4 Antiproton
Antiproton
exp. data
Antiproton from Arista et. al
189
Atomic relaxation
190
Atomic relaxation
●
The atomic relaxation can be triggered by other electromagnetic interactions
such as the photoelectric effect or ionisation, which leave the atom in an
excited state.
●
The Livermore Evaluation Atomic Data Library EADL contains data to describe
the relaxation of atoms back to neutrality after they are ionised.
●
The data in EADL includes the radiative and non-radiative transition
probabilities for each sub-shell of each element, for Z=1 to 100. The atom has
been ionised by a process that has caused an electron to be ejected from an
atom, leaving a vacancy or ``hole" in a given subshell. The EADL data are then
used to calculate the complete radiative and non-radiative spectrum of X-rays
and electrons emitted as the atom relaxes back to neutrality.
●
Non-radiative de-excitation can occur via the Auger effect (the initial and
secondary vacancies are in different shells) or Coster-Kronig effect (transitions
within the same shell).
191
192
Fluorescence
Microscopic validation:
against reference data
Experimental validation:
test beam data, in collaboration with ESA Advanced
Concepts & Science Payload Division
Fluorescent spectrum
of Icelandic Basalt
(“Mars-like”)
ESA Bepi Colombo mission to
Mercury Analysis of the
elemental composition of
Mercury crust through X-ray
spectroscopy
Fe lines
GaAs lines
Scattered
photons
10 keV photon beam, BESSY
Courtesy of A. Owens et al., ESA
193
Auger effect
Auger electron emission
from various materials
Sn, 3 keV photon beam
electron lines w.r.t.
published experimental results
194
PIXE
(Particle Induced X-ray Emission)

New model based on experimental data
–
Parameterisation of Paul & Sacher data library for ionization cross sections
–
Uses the EADL-based package of atomic de-excitation for the generation of
fluorescence and Auger secondary products

Current implementation: protons, K-shell

Coming in future: protons, L-shell and a, K-shell
Ionization cross section for p, K shell
Parameterization G4 (ligne)
Experimental data
195
LowE processes
based on the
Monte Carlo code
Penelope
196
Processes à la Penelope
● Compton scattering
● Rayleigh scattering
● Gamma conversion
● Photoelectric effect
● Bremsstrahlung
● Ionisation
● Positron Annihilation
In your
Physics list
G4PenelopeAnnihilation
G4PenelopeBremsstrahlung
G4PenelopeCompton
G4PenelopeGammaConversion
G4PenelopeIonisation
G4PenelopePhotoElectric
G4PenelopeRayleigh
197
Processes à la Penelope

The whole physics content of the Penelope Monte Carlo code has
been re-engineered into Geant4 (except for multiple scattering)
– processes for photons: release 5.2, for electrons: release 6.0

Analytical Physics models by F. Salvat et al.

Power of the OO technology:
– extending the software system is easy
– all processes obey to the same abstract interfaces
– using new implementations in application code is simple

Profit of Geant4 advanced geometry modeling, interactive facilities
etc.
–
same physics as original Penelope
198
How to use the low energy package ?
199
Photon processes
• Compton scattering (class G4LowEnergyCompton)
• Polarized Compton scattering (class G4LowEnergyPolarizedCompton)
• Rayleigh scattering (class G4LowEnergyRayleigh)
• Gamma conversion (also called pair production, class G4LowEnergyGammaConversion)
• Photo-electric effect (class G4LowEnergyPhotoElectric)
Electron processes
• Bremsstrahlung (class G4LowEnergyBremsstrahlung)
• Ionisation and delta ray production (class G4LowEnergyIonisation)
Hadron and ion processes
• Ionisation and delta ray production (class G4hLowEnergyIonisation)
►The user should set the environment variable G4LEDATA to the directory where he/she has copied the files.
► Options are available for low energy electromagnetic processes for hadrons and ions in terms of public member functions of the G4hLowEnergyIonisation class:
- SetHighEnergyForProtonParametrisation(G4double)
- SetLowEnergyForProtonParametrisation(G4double)
- SetHighEnergyForAntiProtonParametrisation(G4double)
- SetLowEnergyForAntiProtonParametrisation(G4double)
- SetElectronicStoppingPowerModel(const G4ParticleDefinition*,const G4String& )
- SetNuclearStoppingPowerModel(const G4String&)
- SetNuclearStoppingOn()
- SetNuclearStoppingOff()
- SetBarkasOn()
- SetBarkasOff()
- SetFluorescence(const G4bool)
- ActivateAugerElectronProduction(G4bool)
- SetCutForSecondaryPhotons(G4double)
- SetCutForSecondaryElectrons(G4double)
The available models for ElectronicStoppingPower and NuclearStoppingPower are documented in the class diagrams.
► Options are available for low energy electromagnetic processes for electrons in the G4LowEnergyIonisation class:
- ActivateAuger(G4bool)
- SetCutForLowEnSecPhotons(G4double)
- SetCutForLowEnSecElectrons(G4double)
► Options are available for low energy electromagnetic processes for electrons/positrons in the G4LowEnergyBremsstrahlung class, that allow the use of alternative bremsstrahlung angular
generators:
- SetAngularGenerator(G4VBremAngularDistribution* distribution);
- SetAngularGenerator(const G4String& name);
Currently three angular generators are available: G4ModifiedTsai, 2BNGenerator and 2BSGenerator. G4ModifiedTsai is set by default, but it can be forced using the string "tsai". 2BNGenerator
and 2BSGenerator can be set using the strings "2bs" and "2bn". Information regarding conditions of use, performance and energy limits of different models are available in the Physics Reference
Manual and in the Geant4 Low Energy Electromagnetic Physics Working Group homepage.
► Other options G4LowEnergyBremsstrahlung class are:
- SetCutForLowEnSecPhotons(G4double)
200
Example of PhysicsList.cc
if (particleName == "gamma") {
pmanager->AddDiscreteProcess(new G4LowEnergyCompton);
photons
G4LowEnergyPhotoElectric * LePeprocess = new G4LowEnergyPhotoElectric();
LePeprocess->ActivateAuger(true);
LePeprocess->SetCutForLowEnSecPhotons(0.250 * keV);
LePeprocess->SetCutForLowEnSecElectrons(0.250 * keV);
pmanager->AddDiscreteProcess(LePeprocess);
pmanager->AddDiscreteProcess(new G4LowEnergyGammaConversion());
pmanager->AddDiscreteProcess(new G4LowEnergyRayleigh());
pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3);
} else if (particleName == "e-") {
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
electrons
G4LowEnergyIonisation * LeIoprocess = new G4LowEnergyIonisation("IONI");
LeIoprocess->ActivateAuger(true);
LeIoprocess->SetCutForLowEnSecPhotons(0.1*keV);
LeIoprocess->SetCutForLowEnSecElectrons(0.1*keV);
pmanager->AddProcess(LeIoprocess, -1, 2, 2);
G4LowEnergyBremsstrahlung * LeBrprocess = new G4LowEnergyBremsstrahlung();
pmanager->AddProcess(LeBrprocess, -1, -1, 3);
pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3);
} else if (particleName == "e+") {
pmanager->AddProcess(new
pmanager->AddProcess(new
pmanager->AddProcess(new
pmanager->AddProcess(new
pmanager->AddProcess(new
G4MultipleScattering,-1, 1,1);
G4eIonisation,
-1, 2,2);
G4eBremsstrahlung, -1,-1,3);
G4eplusAnnihilation, 0,-1,4);
G4StepLimiter(), -1, -1, 3);
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
pmanager->AddProcess(new G4MultipleScattering(),-1,1,1);
G4hLowEnergyIonisation* hLowEnergyIonisation = new G4hLowEnergyIonisation();
pmanager->AddProcess(hLowEnergyIonisation,-1,2,2);
hadrons
hLowEnergyIonisation->SetElectronicStoppingPowerModel(particle,"ICRU_R49He");
hLowEnergyIonisation->SetNuclearStoppingOn();
hLowEnergyIonisation->SetNuclearStoppingPowerModel("ICRU_R49");
hLowEnergyIonisation->SetFluorescence(true);
hLowEnergyIonisation->ActivateAugerElectronProduction(true);
pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3);
}
201
The Geant4 :
7/15 - Hadronic Physics (QCD)
PhysicsList.hh (.cc)
25 minutes
202
Outline


Processes and hadronic Physics
Models of hadronic showers
–
–
–
–
–



Data driven models
Parametrisation driven models
Theory driven models
Physics lists
Examples
Low energy neutrons
Ions inelastic reactions
Ions radioactive decay
203
Hadronic physics challenge

Even though there is an underlying theory (QCD),
applying it is much more difficult than applying QED
for simulating electromagnetic interactions

We must deal with at least three energy régimes:
– Chiral perturbation theory (< 100 MeV)
– Resonance and cascade region (100 MeV – 20 GeV)
– QCD strings (> 20 GeV)

Within each regime there are several (sub)-models:
– Many of these are phenomenological
204
Geant4 processes

A process uses cross sections to decide when and where an
interaction will occur:
– GetPhysicalInteractionLength()

A process uses an interaction model to generate the final state:
– DoIt()

Three types of process:
– AtRest
– AlongStep
– PostStep

Each particle has its own process manager

Each process has a set of models coordinated with energy range
manager
205
Hadronic processes

At rest:
– Stopped muon, pion, kaon, anti-proton
– Radioactive decay

Elastic:
– Same process for all long-lived hadrons

Inelastic:
– Different process for each hadron
– Photo-nuclear
– Electro-nuclear

Capture:
– Pion- and kaon- in flight

Fission
206
Cross sections

Default cross section sets are provided for each
type of hadronic process:
– Fission, capture, elastic, inelastic
– Can be overridden or completely replaced

Different types of cross section sets:
– Some contain only a few numbers to parameterize cross
section
– Some represent large databases (data driven models)

Cross Section Management:
– GetCrossSection() sees last set loaded for energy
range
207
Alternative cross sections

Low energy neutrons
– G4NDL available as Geant4 distribution data files
– Available with or without thermal cross sections

Neutron and proton reaction cross sections
– 20 MeV < E < 20 GeV

Ion-nucleus reaction cross sections
– Good for E/A < 1 GeV

Isotope production data
– E < 100 MeV
208
Different types of hadronic shower models
Three types



Data driven models
Parametrisation driven models
Theory driven models
209
Models in hadronic framework
210
Data driven models (1)

Characterized by lots of data:
– Cross section
– Angular distribution
– Multiplicity

To get interaction length and final state, models simply
interpolate data:
– Usually linear interpolation of cross section, and Legendre
polynomials

Examples:
– Coherent elastic scattering (pp, np, nn)
– Radioactive decay
– Neutrons (E < 20 MeV)
211
Data driven models (2)

Transport of low energy neutrons in matter:
– The energy coverage of these models is from thermal energies
to 20 MeV
– The modeling is based on the data formats of ENDF/B-VI, and
all distributions of this standard data format are implemented
– The data sets used are selected from data libraries that
conform to these standard formats
– The file system is used in order to allow granular access to, and
flexibility in, the use of the cross-sections for different
isotopes, and channels
– Code in sub-directory:
$G4INSTALL/source/processes/hadronic/models/neutron_hp
212
Parametrisation driven models (1)

Depends on both data and theory:
– Enough data to parameterize cross sections,
multiplicities, angular distributions

Final states determined by theory, sampling:
– Use conservation laws to get charge, energy, etc.

Examples:
– Fission
– Capture
– LEP, GEISHA based HEP models (inelastic scattering in
flight)
213
Parametrisation driven models (2)

Based on GHEISHA package of Geant3.21, two sets of models exist
for inelastic scattering of particles in flight:
– Low energy models:
• E < 20 GeV
• $G4INSTALL/source/processes/hadronic/models/low_energy
– High energy models:
• 20 GeV < E < O(TeV)
• $G4INSTALL/source/processes/hadronic/models/high_energy

Original approach to primary interaction, nuclear excitation, intranuclear cascade and evaporation is kept

Fission, capture and coherent elastic scattering are also modeled
214
through parametrised models
Theory driven models (1)

Dominated by theory (QCD, strings, chiral perturbation
theory)

Data used mainly for normalization and validation

Final states determined by sampling theoretical distributions

Philosophy implies the usage physics lists, providing wanted
collection of models, such as:
– parton string models at high energies
– intra-nuclear transport models at intermediate energies
– statistical break-up models for de-excitation
215
Theory driven models (2)

Parton string:
–
Projectiles with E > 5 GeV
– $G4INSTALL/source/processes/hadronic/models/parton_string

Chiral invariant phase space, CHIPS:
–
–
–
–
–
All energies
Quark-level event generator for the fragmentation of hadronic systems into hadrons
Interactions between hadrons are treated as purely kinematic effects of quark exchange
Decay of excited hadronic systems is treated as the fusion of two quark-partons within the
system
Includes nonrelativistic phase space of nucleons to explain evaporation
– $G4INSTALL/source/processes/hadronic/models/chiral_inv_phase_space

Nuclear de-excitation and breakup
216
Example : Bertini intra-nuclear
cascade model

Collection of theory driven models with parametrisation features:
– $G4INSTALL/source/processes/hadronic/models/cascade

Intermediate energies ~100 keV – 10MeV

Models included:
–
–
–
–
–
Bertini INC model with exitons
Pre-equilibrium model
Nucleus explosion model
Fission model
Evaporation model
217
Examples of theory driven models
Bertini cascade model
pion production from 730
MeV proton on Carbon
Binary cascade model
Double differential cross-section for
neutrons produced
by 256 MeV protons.
218
Physics list

User must implement a physics list:
–
–
–
–
–
–

Derive a class from G4VUserPhysicsList
Define the particles required
Register models and cross sections with processes
Register processes with particles
Set secondary production cuts
In main(), register your physics list with the Run Manager
Care is required:
– Multiple models, cross sections allowed per process
– No single model covers all energies, or all particles
– Choice of model is heavily dependent on physics studied
219
Physics list by use case

Geant4 recommendation:
– Use example physics lists
– Go to Geant4 home page > Site Index > physics lists

Many hadronic physics lists available including:
–
–
–
–
Low and high energy nucleon penetration shielding
Low energy dosimetric applications
Medical neutron applications
Low background experiments (underground)
220
Exemple – 1/2
void MyPhysicsList::ConstructProton()
{
G4ParticleDefinition* proton = G4Proton::ProtonDefinition();
G4ProcessManager* protonProcessManager = proton->GetProcessManager();
// Elastic scattering
G4HadronElasticProcess* protonElasticProcess = new G4HadronElasticProcess();
G4LElastic* protonElasticModel = new G4LElastic();
protonElasticProcess->RegisterMe(protonElasticModel);
protonProcessManager->AddDiscreteProcess(protonElasticProcess);
...
221
Exemple – 2/2
...
// Inelastic scattering
G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess();
G4LEProtonInelastic* protonLowEnergyInelasticModel =
new G4LEProtonInelastic();
protonLowEnergyInelasticModel->SetMaxEnergy(20.0*GeV);
protonInelasticProcess->RegisterMe(protonLowEnergyInelasticModel);
G4HEProtonInelastic* protonHighEnergyInelasticModel = new G4HEProtonInelastic();
protonHighEnergyInelasticModel->SetMinEnergy(20.0*GeV);
protonInelasticProcess->RegisterMe(protonHighEnergyInelasticModel);
}
222
Summary

Geant4 hadronic physics allows user to choose how a physics process should be
implemented:
– cross sections
– models

Many processes, models and cross sections to choose from
– hadronic framework makes it easier for users to add more

Parameterized models (LEP, HEP) handle the most particle types over the largest
energy range
– based on fits to data and some theory
– not very detailed
– Fast

Cascade models (Bertini, Binary) are valid for fewer particles over a smaller energy
range
– more theory-based
– more detailed
– slower
223
Low energy neutrons physics

Energy < 20 MeV

High Precision Neutron Models
(and Cross Section Data Sets)
– G4NDL
• ENDF
–
–
–
–

Elastic
Inelastic
Capture
Fission
NeutronHPorLEModel(s)
224
G4NDL
(Geant4 Neutron Data Library)

The neutron data files for High Precision Neutron models

The data are including both cross sections and final states.

The data are derived evaluations based on the following evaluated data
libraries (in alphabetic order)
–
–
–
–
–
–
–
–
–

Brond-2.1
CENDL2.2
EFF-3
ENDF/B-VI.0, 1, 4
FENDL/E2.0
JEF2.2
JENDL-FF
JENDL-3.1,2
MENDL-2
The data format is similar ENDF, however it is not equal to.
225
Evaluated Nuclear Data File-6

“ENDF” is used in two meanings

One is Data Formats and Procedures
– How to write Nuclear Data files
– How to use the Nuclear Data files

The other is Name of recommended libraries of USA
nuclear data projects.
– ENDF/B-VI.8 (latest)
• 313 isotopes including 5 isomers
• 15 elements

After G4NDL3.8 we concentrated translation from ENDF
library.
– No more evaluation by ourselves.
226
Ion Physics : inelastic reactions

Models
– G4BinaryLightIon
– G4WilsonAbrasion

Many cross section formulae for NN collisions are included
in Geant4
– Tripathi, Shen, Kox and Sihver

These are empirical and parameterized formulae with
theoretical insights.

G4GeneralSpaceNNCrossSection was prepared to assist
users in selecting the appropriate cross section formula
227
Ion physics : radioactive decay

To simulate the decay of radioactive nuclei

Empirical and data-driven model

α, β+, β- decay electron capture (EC) are implemented

Data (RadioactiveDecay) derived from Evaluated Nuclear Structure Data
File (ENSDF)
– nuclear half-lives
– nuclear level structure for the parent or daughter nuclide
– decay branching ratios
– the energy of the decay process

If the daughter of a nuclear decay is an excited isomer, its prompt nuclear
de-excitation is treated using the G4PhotonEvapolation

Internal conversion is also implemented
228
Hadronic model inventory
229
Conclusion

Geant4 provides a large number of hadronic
physics models for use in simulation

Cross sections, either calculated or from
databases, are available to be assigned to
processes

Interactions are implemented by models which
are then assigned to processes.

For hadrons there are many models to choose
from, so physics lists are provided by use-case
230
The Geant4 toolkit :
8/15 - Physics Lists
PhysicsList.hh (.cc)
15 minutes
231
What is a Physics List ?
 A class which collects all the particles, physics
processes and production thresholds needed for your
application
 It tells the run manager how and when to invoke physics
 It is a very flexible way to build a physics environment
 user can pick the particles he wants
 user can pick the physics to assign to each particle
 But, user must have a good understanding of the
physics required
 omission of particles or physics could cause errors or poor
simulation
232
Why do we need a physics list ?
• Physics is physics – shouldn't Geant4 provide, as a
default, a complete set of physics that everyone can
use ?
●
NO !
– there are many different physics models and approximations
• very much the case for hadronic physics
• but also the case for electromagnetic physics
– computation speed is an issue
• a user may want a less-detailed, but faster approximation
– no application requires all the physics and particles Geant4 has to
offer
• e.g., most medical applications do not want multi-GeV physics
233
Why do we need a physics list ?
 For this reason Geant4 takes an atomistic, rather than
an integral approach to physics
− provide many physics components (processes) which are decoupled from one another
− user selects these components in custom-designed physics
lists in much the same way as a detector geometry is built
Exceptions
− a few electromagnetic processes must be used together
− future processes involving interference of electromagnetic and
strong interactions may require coupling as well
234
Physics processes provided by Geant4
● ELECTROMAGNETIC physics
• “standard” from ~ 1 keV to ~ PeV
• “low energy” from 250 eV to ~ PeV
• Optical photons
● WEAK physics
• Decay of subatomic particles
• Radioactive decay of nuclei
● HADRONIC physics
• pure hadronic processes valid from 0 to ~100 TeV
 g mnuclear valid from 10 MeV to ~TeV
●
Parameterized or “fast simulation” physics
235
G4VUserPhysicsList
 All physics lists must derive from this class and then be
registered with the run manager
 Example
class myPhysicsList : public G4VUserPhysicsList
{
public:
BeamTestPhysicsList();
~BeamTestPhysicsList();
void ConstructParticle();
void ConstructProcess();
void SetCuts();
};
● User must implement the methods ConstructParticle,
ConstructProcess and SetCuts
236
G4VUserPhysicsList :
required methods

ConstructParticle()
– choose the particles you need in your simulation and define all of them here

ConstructProcess()
– for each particle, assign all the physics processes important in your simulation
• What's a process?
• a class that defines how a particle should interact with matter (it's where the
physics is!)
• more on this later

SetCuts()
–
•
•
•
set the range cuts for secondary production
What's a range cut?
essentially a low energy limit on particle production
more on this later
237
ConstructParticle() –
st
1
way
void BeamTestPhysicsList::ConstructParticle()
{
G4BaryonConstructor* baryonConstructor = new G4BaryonConstructor();
baryonConstructor->ConstructParticle();
delete baryonConstructor;
G4BosonConstructor* bosonConstructor = new G4BosonConstructor();
bosonConstructor->ConstructParticle();
delete bosonConstructor;
....
....
}
238
ConstructParticle() –
nd
2
way
void myPhysicsList::ConstructParticle()
{
G4Electron::ElectronDefinition();
G4Proton::ProtonDefinition();
G4Neutron::NeutronDefinition();
G4Gamma::GammaDefinition();
....
....
}
239
ConstructProcess()
void myPhysicsList::ConstructProcess()
{
AddTransportation();
// method provided by G4VUserPhysicsList
// assigned transportation process to all particles
// defined in ConstructParticle()
ConstructEM();
// method may be defined by user (for convenience)
// put electromagnetic physics here
ConstructGeneral();
// method may be defined by user (for convenience)
}
240
ConstructEM()
void BeamTestPhysicsList::ConstructEM()
{
theParticleIterator->reset();
while ( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
if (particleName == “gamma”)
{
pmanager->AddDiscreteProcess(new G4GammaConversion() );
...
}
}
.....
241
ConstructGeneral()
void BeamTestPhysicsList::ConstructGeneral()
{
// Ajouter le processus de désintégration
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while ( (*theParticleIterator)() )
{
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle) )
{
pmanager->AddProcess(theDecayProcess);
pmanager->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
242
SetCuts()
void BeamTestPhysicsList::SetCuts()
{
defaultCutValue = 1.0*mm;
SetCutValue(defaultCutValue, “gamma”);
SetCutValue(defaultCutValue, “e-”);
SetCutValue(defaultCutValue, “e+”);
//
//
These are all the production cut values you need to set
not required for any other particle
}
243
G4VModularPhysicsList
● The physics list in our example is relatively simple
● A realistic physics list is likely to have many more physics
processes
– such a list can become quite long, complicated and hard to
maintain
– try a modular physics list instead
● Features of G4VModularPhysicsList
– derived from G4VUserPhysicsList
– AddTransportation() automatically called for all registered
particles
– Allows you to define “physics modules”: EM physics,
hadronic physics, optical physics, etc.
244
A simple G4VModularPhysicsList
● Constructor :
MyModPhysList::MyModPhysList() : G4VModularPhysicsList()
{
defaultCutValue = 1.0*mm;
RegisterPhysics( new ProtonPhysics() );
// all physics processes having to do with protons
RegisterPhysics( new ElectronPhysics() );
// all physics processes having to do with electrons
RegisterPhysics( new DecayPhysics() );
// physics of unstable particles
}
● Set Cuts :
void MyModPhysList::SetCuts()
{ SetCutsWithDefault() ; }
245
Physics constructors
● Allow you to group particle and process construction according to
physics domains
class ProtonPhysics : public G4VPhysicsConstructor
{
public:
ProtonPhysics(const G4String& name = “proton”);
virtual ~ProtonPhysics();
virtual void ConstructParticle();
// easy – only one particle to build in this case
virtual void ConstructProcess();
// put here all the processes a proton can have
}
246
Pre-packaged Physics Lists (1)
●
●
Our example deals mainly with electromagnetic physics
A complete and realistic EM physics list can be found in
novice example N03
• good starting point
• add to it according to your needs
●
Adding hadronic physics is more delicate
• for any one hadronic process, user may choose from several
hadronic models to choose from
• choosing the right models for your application requires care
• to make things easier, hadronic physics lists are now provided
according to some use cases
247
Pre-packaged Physics Lists (2)
●
●
●
Referred to as “hadronic physics lists” but include
electromagnetic physics from example N03
Can be found on the Geant4 web page at
http://geant4.web.cern.ch/geant4/physics_lists
Caveats :
– these lists are provided as a “best guess” of the physics
needed in a given case
– the user is responsible for validating the physics for his own
application and adding (or subtracting) the appropriate physics
– they are intended as starting points or templates
248
In summary
●
●
●
●
All the particles, physics processes, and production cuts needed
for an application must go into a physics list
Two kinds of physics list classes are available for users to derive
from
– G4VUserPhysicsList – for relatively simple physics lists
– G4VModularPhysicsList – for detailed physics lists
Some pre-packaged physics lists are provided by Geant4 as
starting points for users
– electromagnetic physics lists
– hadronic physics lists
Care is required by user in choosing the right physics to use
249
The Geant4 toolkit :
9/15 - Primary particles generation
PrimaryGeneratorAction.hh (.cc)
10 minutes
250
Primary vertices and primary particles

Primary vertices and primary particles must be stored in an event
(G4Event) before it is processed. Need instances of :
– G4PrimaryVertex
• particle starting point in space, time
• can add user information as well
– G4PrimaryParticle
• initial momentum, polarization of particle to be propagated
• also PDG code
• linked list of daughters for decay chains

These classes do not depend on G4ParticleDefinition or
G4Track

Primary particles may not necessarily be particles which can be
tracked by Geant
251
Primary generator

All primary generators must be derived from
G4VPrimaryGenerator and implement its single pure
virtual method GeneratePrimaryVertex()
– this is where the primary vertex and primary particle are added to the
event

Geant4 provides some implementations of
G4VPrimaryGenerator :
–
–
–
–
G4HEPEvtInterface (ex. Pythia-Jetset)
G4HEPMCInterface
G4ParticleGun
G4GeneralParticleSource
252
Particle gun

G4ParticleGun is an implementation of
G4VPrimaryGenerator which is used to simulate
a beam of particles
– see novice example N02

It shoots a primary particle of a certain energy
and direction from a given point at a given time
– methods available to customize your particle gun
•
•
•
•
•
set particle type
set energy, momentum
set polarization
set charge
number of particles shot at one time
253
G4VUserPrimaryGeneratorAction (1)

This is one of the mandatory user action classes
– used to control the generation of primaries
– this class itself should not generate primaries – instead use
GeneratePrimaryVertex() method of primary generator

Geant4 developers are frequently asked to implement
“particle shot guns” or “particle machine guns”
– such fancy weapons can easily be implemented by the user with
•
•
•
•
set methods in G4ParticleGun
repeated use of G4ParticleGun in a single event
random sampling of particle type and direction
additional primary generators (described earlier)
254
G4VUserPrimaryGeneratorAction (2)

Constructor
– instantiate primary generator(s)
– set default items (particle, energy, etc.)

GeneratePrimaries() method :
– randomize particle-by-particle values
– assign them to primary generator(s)
– invoke GeneratePrimaryVertex() method
of primary generator(s)
255
G4VUserPrimaryGeneratorAction (3)
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
G4ParticleDefinition* particle;
particle = proton;
gun->SetParticleDefinition(particle);
G4double pp = momentum + (G4UniformRand() - 0.5)*sigmaMomentum;
G4double mass = particle->GetPDGMass();
G4double Ekin = sqrt(pp*pp + mass*mass) – mass;
gun->SetParticleEnergy(Ekin);
G4double angle = (G4UniformRand() - 0.5)*sigmaAngle;
gun->SetParticleMomentumDirection(G4ThreeVector(sin(angle), 0.,cos(angle));
gun->GeneratePrimaryVertex(anEvent);
}

Repeat the above as many times as desired per event
256
General Particle Source

G4GeneralParticleSource is another concrete
implementation of G4VPrimaryGenerator

Primary vertex is randomly chosen on surface of a given volume
– useful for radioactive sources
– pre-defined energy spectra (power law, etc.) available

Capable of event biasing (variance reduction)
– can enhance certain particle types
– bias the vertex point distribution
– bias energy and/or direction

Especially suitable for space and medical applications
– see advanced examples: x-ray telescope, underground physics
257
Square plane, cosine-law direction, linear energy
SphericalCylindrical
surface, isotropic
black-body
surface,radiation,
cosine-law
radiation,energy
Cosmic diffuse
Spherical volume with z biasing, isotropic radiation with
energy
theta and phi biasing, integral arbitrary point-wise
energy distribution with linear interpolation.
G4GeneralParticleSource
258
Exotic particles



“Exotic” particle means a type of particle that Geant4 physics processes do not
know how to deal with and would never generate as a secondary.
–
It is thus not provided as a class in particle category of Geant4 distribution.
–
E.g. Higgs, W/Z boson, SUSY particle, r-hadron, monopole, black hole, etc.
“Exotic” particle also includes a type of particle that should not be seen outside of
a hadron.
–
It is used inside Geant4 processes, but it should not be treated as a track.
–
E.g. quark, gluon.
Such exotic particle can be imported as a G4PrimaryParticle object.
–

It should have pre-assigned decay products (if it decays), since Geant4 does not know
how it decays.
There are two kinds of exotic particles from the view point of Geant4. We have to
deal them separately.
–
Particles that immediately decay without traveling finite distance.
–
Particles that travel a distance meaningful to Geant4 tracking.
259
The Geant4 toolkit :
10/15 - Particles and processes
40 minutes
260
G4ParticleDefinition &
G4ProcessManager
G4ParticleDefinition
G4ProcessManager
G4ParticleDefinition is the base class for defining
concrete particles. Contains intrinsic particle properties
(mass, width, spin, lifetime…) Does not know by
itself its
sensitivity to physics.
Process_1
Process_2
Process_3
G4ProcessManager manages the list of processes
the user wants. It is attached to
G4ParticleDefinition
G4ParticleDefinition.
G4ParticleWithCuts
G4VLepton
G4VShortLivedParticles
G4VBoson
G4Electron
G4VIon
G4VMeson
G4VBaryon
G4Geantino
G4PionPlus
G4Proton
G4Alpha
261
G4DynamicParticle & G4Track
G4DynamicParticle

Describes the purely dynamic
part (i.e. no position, nor
geometrical information…) of the
particle state:
– momentum, energy,
polarization

Holds a G4ParticleDefinition
pointer

Retains eventual pre-assigned
decay information
– decay products
– lifetime
G4Track

Defines the class of objects
propagated by Geant4 tracking

Represents a snapshot of the
particle state

Aggregates :
– a G4ParticleDefinition
– a G4DynamicParticle
– geometrical information:
• position, current volume …
– track ID, parent ID;
– process which created this
G4Track
– weight, used for event biasing
262
Summary view
G4Track
Propagated by the tracking
Snapshot of the particle state
G4DynamicParticle Momentum, pre-assigned decay…
The particle type
G4ParticleDefinition
G4Electron,
G4PionPlus…
G4ProcessManager Holds the physics
sensitivity
Process_1
The physics
Process_2 processes
Process_3
263
Geant4 Physics

Geant4 provides a wide variety of physics
components for use in simulation

Physics components are coded as processes
• a process is a class which tells a particle how to interact
• user may write his own processes (derived from Geant4
process)

Processes are grouped into
– electromagnetic, hadronic, and decay categories
264
Electromagnetic physics

Standard – complete set of processes covering charged particles
and gammas
• energy range 1 keV to ~PeV

Low energy – specialized routines for e+, e-, gamma, charged
hadrons
• more atomic shell structure details
• some processes valid down to 250 eV or below
• others not valid above a few GeV

Optical photons – only for long wavelength photons (x-rays, UV,
visible)
– processes for reflection/refraction, absorption, wavelength
shifting, Rayleigh scattering
265
Hadronic physics

Pure hadronic ( 0 - ~100 TeV)
•
•
•
•

elastic
inelastic
capture
fission
Radioactive decay
• at-rest and in-flight

photo-nuclear (~10 MeV - ~TeV)

lepto-nuclear (~10 MeV - ~TeV)
• e+, e- nuclear reactions
• muon-nuclear reactions
266
Decay & parameterization

Decay processes include
• weak decay (leptonic decays, semi-leptonic decays,
radioactive decay of nuclei)
• electromagnetic decay (p0 S0 , etc. decay)
• strong decays not included here (they are part of hadronic
models)

Parameterized processes
• electromagnetic showers propagated according to
parameters averaged over many events
• faster than detailed shower simulation
267
Data libraries and units

Systematic collection and evaluation of experimental data from many
sources worldwide

Databases
– ENDF/B, JENDL, FENDL, CENDL, ENSDF,JEF, BROND, EFF, MENDL, IRDF, SAID,
EPDL, EEDL, EADL, SANDIA, ICRU etc.

Collaborating distribution centres
– NEA, LLNL, BNL, KEK, IAEA, IHEP, TRIUMF, FNAL, Helsinki, Durham, Japan etc.

The use of evaluated data is important for the validation of physics results of
the experiments

Geant4 is independent from the system of units
– all numerical quantities expressed with their units explicitly
268
Physics processes - 1
● All the work of particle decays and interactions is done by
processes
• transportation is also handled by a process
● A process does two things:
• decides when and where an interaction will occur
− method: GetPhysicalInteractionLength()
− this requires a cross section, decay lifetime
− for the transportation process, the distance to the nearest object along the
track is required
• generates the final state of the interaction (changes momentum,
generates secondaries, etc.)
− method: DoIt()
− this requires a model of the physics
269
Processus physiques - 2

There are three flavors of processes:
•
•
•
well-located in space -> PostStep
distributed in space -> AlongStep
well-located in time -> AtRest
● A process may be a combination of all three of the above
•

in that case six methods must be implemented
(GetPhysicalInteractionLength() and DoIt() for each action)
“Shortcut” processes are defined which invoke only one
•
Discrete process (has only PostStep physics)
•
Continuous process (has only AlongStep physics)
•
AtRest process (has only AtRest physics)
270
Examples - 1
● Discrete process: Compton scattering
• step determined by cross section, interaction at end of step
o PostStepGPIL()
o PostStepDoIt()
● Continuous process: Cerenkov effect
• photons created along step, # roughly proportional to step length
o AlongStepGPIL()
o AlongStepDoIt()
● At rest process: positron annihilation
• no displacement, time is the relevant variable
o AtRestGPIL()
o AtRestDoIt()
● These are examples of so-called “pure” processes
271
Examples - 2
● Continuous + discrete : ionization
• energy loss is continuous
• Moller/Bhabha scattering and knock-on electrons are discrete
● Continuous + discrete : bremsstrahlung
• energy loss due to soft photons is continuous
• hard photon emission is discrete
● In both cases, the production threshold separates the
continuous and discrete parts of the process
• more on this later
● Multiple scattering is also continuous + discrete
272
particle
At rest
process
Energy range
manager
In flight
process
model 1
model 2
.
.
model n
Process
3
c.s. 1
c.s. 2
.
.
c.s. n
Process
n
Cross section
data store
273
Handling multiple processes
● Many processes (and therefore many interactions) can be
assigned to the same particle
● How does Geant4 decide which interaction happens at any one
time?
• interaction length or decay length is sampled from each process
• shortest one happens, unless
• a volume boundary is encountered in less than the sampled length. Then
no physics interaction occurs (just simple transport).
• the processes that were not chosen have their interaction lengths
shortened by the distance traveled in the previous step
• repeat the procedure
274
Processes ordering

Ordering of following processes is critical :
assuming n processes, the ordering of the
AlongGetPhysicalInteractionLength of the last processes should
be :
[n-2] …
[n-1] multiple scattering
[n] transportation

Why ?

– Processes return a true path length
– The multiple scattering virtually folds up this true path length into a
shorter geometrical path length
– Based on this new length, the transportation can geometrically limit
the step

Other processes ordering usually do not matter
275
Example : event with standard EM processes
• 50 MeV e- entering LAr-Pb
calorimeter
• Processes used:
• bremsstrahlung
• ionization
• multiple scattering
• positron annihilation
• pair production
• Compton scattering
276
The decay process

Derived from G4VRestDiscreteProcess
– decay can happen in-flight or at rest

Should be applied to all unstable, long-lived
particles

Different from other physical processes:
– mean free path for most processes:  = Nr /A
– for decay in-flight:  = gct

Same decay process for all eligible particles
– decay process retrieves BR and decay modes from
decay table stored in each particle type
277
Available decay modes

Phase space:
– 2-body e.g. p0 -> gg  L -> p p
– 3-body e.g. K0L -> p0 p p
– many body

Dalitz: P0 -> g l+ l-

Muon decay
– V – A, no radiative corrections, mono-energetic neutrinos

Leptonic tau decay
– like muon decay

Semi-leptonic K decay: K -> p l n
278
Pre-assigned decays

Geant4 provides decay modes for long-lived particles
– user can re-define decay channels if necessary

But decay modes for short-lived (e.g. heavy flavor) particles
not provided by Geant4
– user must “pre-assign” to particle:
• proper lifetime
• decay modes
• decay products
– decay process can invoke decay handler from the generator
• must use G4VExtDecayer interface

Take care that pre-assigned decays from generators do not
overlap with those defined by Geant4
– K0S , t
279
Specialized decay processes

G4DecayWithSpin
– produces positron spectrum with 1st order radiative
corrections
– initial muon spin is required
– propagates spin in magnetic field (precession) over
remainder of muon lifetime

G4UnknownDecay
– only for “unknown” particles ( Higgs, SUSY, etc.)
– discrete process – only in-flight decays allowed
– pre-assigned decay channels must be supplied by user
or generator
280
Optical photons (1)

Technically, should belong to electromagnetic category,
but:
– optical photon wavelength is >> atomic spacing
– ‘ treated as waves’ -> no smooth transition between optical
and gamma particle classes

Optical photons are produced by the following Geant4
processes:
– G4Cerenkov
– G4Scintillation
– G4TransitionRadiation

Warning: these processes generate optical photons without
energy conservation
281
Optical photons (2)

Optical photons undergo :
–
–
–
–

Rayleigh scattering
refraction and reflection at medium boundaries
bulk absorption
wavelength shifting
Geant4 keeps track of polarization
– but not overall phase -> no interference

Optical properties can be specified in G4Material
– reflectivity, transmission efficiency, dielectric constants,
surface properties

Photon spectrum properties also defined in G4Material
– scintillation yield, time structure (fast, slow components)
282
Optical photons (3)

Geant4 demands particle-like
behavior for tracking :
– thus, no “splitting”
– event with both refraction and
reflection must be simulated by
at least two events
q
283
Wavelength shifting

Handled by G4OpWLS
– initial photon is killed, one with
new wavelength is created
– builds it own physics table for
mean free path

User must supply :
– absorption length as function
of photon energy
– emission spectra parameters
as function of energy
– time delay between absorption
and re-emission
284
Boundary interactions

Handled by
G4OpBoundaryProcess

– dielectric-dielectric
– dielectric-metal
– dielectric-black material
– refraction
– reflection

User must supply surface
properties using
G4OpticalSurfaceModel
Boundary properties

Surface properties:
– polished
– ground
– front- or back-painted, ...
285
Absorption and Rayleigh scattering

G4OpAbsorption
– uses photon attenuation length from material
properties to get mean free path
– photon is simply killed after a selected path
length

G4OpRayleigh
– elastic scattering including polarization of
initial and final photons
– builds it own private physics table (for mean
free path) using G4MaterialTable
– may only be used for optical photons
286
Threshold for secondary production (1)
● Every simulation developer must answer the question :
how low can you go?
– at what energy do I stop tracking particles ?
● This is a balancing act
• need to go low enough to get the physics you're interested in
• can't go too low because some processes have infrared divergence
causing CPU time to skyrocket
● The traditional Monte Carlo solution is to impose an absolute cutoff in
energy
– particles are stopped when this energy is reached
– remaining energy is dumped at that point
287
Threshold for secondary production (2)
● But, such a cut may cause imprecise stopping location and
deposition of energy
● There is also a particle dependence
– range of 10 keV g in Si is a few cm
– range of 10 keV e- in Si is a few microns
● And a material dependence
– suppose you have a detector made of alternating sheets of Pb
and plastic scintillator
– if the cutoff is OK for Pb, it will likely be wrong for the
scintillator which does the actual energy deposition
measurement
288
Threshold for secondary production (3)
● Geant4 solution: impose a production threshold
– default = 1 mm
– this threshold is a distance, not an energy
– the primary particle loses energy by producing secondary electrons or
gammas
– if primary no longer has enough energy to produce secondaries which
travel at least 1mm, two things happen:
• discrete energy loss ceases (no more secondaries produced)
• the primary is tracked down to zero energy using continuous energy
loss
● Stopping location is therefore correct
● Only one value of production threshold distance is needed for all
materials because it corresponds to different energies depending on
289
material.
Production threshold vs. energy cut
500 MeV p in
LAr-Pb sampling
calorimeter
Cut = 2 MeV
Cut = 450 keV
production range = 1.5 mm
290
Threshold for secondary production (4)
● Geant4 default value is 1 mm
– user needs to decide the best value
– this will depend on the size of sensitive elements within the
simulated detector, and on available CPU
● This value is set in the SetCuts() method of your
physics list
● Instead of “secondary production threshold distance” it
is more convenient to simply say “cuts”
– but please remember that this does not mean that any particle is
actually stopped before it runs out of energy
291
G4VUserPhysicsList

It is one of the mandatory user classes
(abstract class)

Pure virtual methods
– ConstructParticles()
– ConstructProcesses()
– SetCuts()
to be implemented by the user in his/her
concrete derived class
292
Cuts per region (1)
● In a complex detector there may be many different types of
sub-detectors involving
–
–
–
–
finely segmented volumes
very sensitive materials
large, undivided volumes
inert materials
● The same value of the secondary production threshold may
not be appropriate for all of these
– user must define regions of similar sensitivity and granularity
and assign a different set of production thresholds (cuts) for
each
● Warning: this feature is for users who are
– simulating the most complex detectors
– experienced at simulating EM showers in matter
293
Cuts per region (2)
● A default region is created automatically for the
world volume
– it has the cuts which you set in SetCuts() in your
physics list
– these will be used everywhere except for user-defined
regions
● To define a special region with different cuts, user
must
– create a G4ProductionCuts object
– initialize it with the new cuts
– assign it to a region which has already been created
294
Cuts per region (3)
void BeamTestPhysicsList::SetCuts()
{
SetCutValue(defaultCutValue, “gamma”);
SetCutValue(defaultCutValue, “e-”);
SetCutValue(defaultCutValue, “e+”);
// Get the region
G4Region* aRegion =
G4RegionStore::GetInstance()->GetRegion(“NewRegion”);
// Define cuts object for the new region and set values
G4ProductionCuts* cuts = new G4ProductionCuts;
cuts->SetProductionCut(0.01*mm);
// same cut for gamma, e+, e// Assign cuts to region
aRegion->SetProductionCuts(cuts);
}
295
G4UserLimits

User limits are artificial limits affecting to the tracking.
G4UserLimits(G4double
G4double
G4double
G4double
G4double
–
–
–
–
–
uMaxStep;
uMaxTrack;
uMaxTime;
uMinEkine;
uMinRange;
ustepMax
utrakMax
utimeMax
uekinMin
urangMin
=
=
=
=
=
DBL_MAX,
DBL_MAX,
DBL_MAX,
0.,
0. );
// max allowed Step size in this volume
// max total track length
// max global time
// min kinetic energy remaining (only for charged particles)
// min remaining range (only for charged particles)
Blue : affecting to step
Yellow : affecting to track

You can set user limits to logical volume and/or to a region
–
–
–
User limits assigned to logical volume do not propagate to daughter volumes.
User limits assigned to region propagate to daughter volumes unless daughters belong to
another region.
If both logical volume and associated region have user limits, those of logical volume win.
296
Processes co-working with G4UserLimits

In addition to instantiating G4UserLimits and setting it to logical volume or region,
you have to assign the following process(es) to particle types you want to affect

Limit to step
fMaxStep : max allowed Step size in this volume

–
G4StepLimiter process must be defined to affected particle types
–
This process limits a step, but it does not kill a track.
Limits to track
fMaxTrack : max total track length
fMaxTime : max global time
fMinEkine : min kinetic energy (only for charged particles)
fMinRange : min remaining range (only for charged particles)
–
G4UserSpecialCuts process must be defined to affected particle types.
–
This process limits a step and kills the track when the track comes to one of these limits.
Step limitation occurs only for the final step.
297
Summary (1)
● Geant4 supplies many physics processes which
cover electromagnetic, hadronic and decay
physics
● Processes are organized according to when they
are used during the tracking of a particle
(discrete, continuous, at-rest, etc.)
● Many processes may be assigned to one particle
− which one occurs first depends on cross
sections, lifetimes, and distances to volume
298
boundaries
Summary (2)
● There is one decay process for all long-lived, unstable
particles
● Optical processes handle the reflection, refraction,
absorption, wavelength shifting and scattering of
long-wavelength photons
● The precision of particle stopping and the production
of secondary particles are determined by a secondary
production threshold
● For complex detectors with different types of
sensitive volumes, different production thresholds
may be defined for different regions within the
299
detector
The Geant4 toolkit :
11/15 - User interface
In the main()
15 minutes
300
Steering the simulation

A Geant4 simulation can be steered by a batch session or by
commands captured from an interactive session

Setting up batch mode is easy: in your main()
G4UImanager* UI = G4UImanager::GetUIpointer();
G4String command = “/control/execute”;
G4String fileName = argv[1];
UI -> applyCommand(command+fileName);

Setting up interactive mode is also easy – but there
are many choices of interface
– All must be derived from the abstract class G4UIsession
– Geant4 provides several implementations
301
User interface choices

G4UIterminal : C-shell-like character terminal
– runs on all Geant4-supported platforms

G4UItcsh : tcsh-like character terminal with command
completion, history, etc.
– runs only on Solaris and Linux

G4UIXm, G4UIXaw, G4UIXWin32 : G4UIterminal
implemented over Motif, Athena and WIN32 libraries
– runs on Unix/linux and Windows, respectively

G4UIGAG : Java-based GUI
– runs on all Geant4 platforms
302
How to use the interface

In your main(), add the lines :
#include “G4UIxxx.hh”
// xxx = terminal, Xm, Xaw, Win32, GAG
G4UISession* session = new G4UIxxx;
UI->ApplyCommand(“/control/execute somefile.mac”);
session->SessionStart();
delete session;

For a tcsh session, the seond line must be:
G4UIsession* session = new G4UIterminal(new G4UItcsh);

Many examples in :
$G4INSTALL/examples/novice/N01, N02, N03, ....
303
Environment variables

Not required in order to use G4UIterminal, G4UItcsh, G4UIGAG
these sessions do not need external libraries, so they are
automatically built and linked

To build G4UIXm, G4UIXaw, or G4UIXWin32
setenv G4UI_USE_XM 1
or
setenv G4UI_USE_XAW 1
or
setenv G4UI_USE_WIN32 1
304
Useful GUI tools relased by Geant4 developers

GGE: Geometry editor based on Java GUI
– http://erpc1.naruto-u.ac.jp/~geant4

GPE: Physics editor based on Java GUI
– http://erpc1.naruto-u.ac.jp/~geant4

OpenScientist: interactive environment for
analysis
– http://www.lal.in2p3.fr/OpenScientist
305
Built in user commands

Geant4 provides a number of user interface commands
which can be used :
– interactively via a (G)UI
– in a macro file via /control/execute <command>
– within C++ code using the ApplyCommand method of
G4UImanager :
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/run/verbose 1");

A complete list of built-in commands, roughly
organized according to Geant4 categories is available
in the Geant4 Application Developers Guide
306
Geant4 UI command

A command consists of
– Command directory
– Command
– Parameter(s)

/run/verbose 1
/vis/viewer/flush
A parameter can be a type of string, boolean, integer or double.
– Space is a delimiter
– Use double-quotes (“”) for string with space(s).

A parameter may be “omittable”. If it is the case, a default value will be
taken if you omit the parameter.
– Default value is either predefined default value or current value according to its
definition.
– If you want to use the default value for your first parameter while you want to
set your second parameter, use “!” as a place holder.
/dir/command ! second
307
Use of macro file (ex. run.mac)

Macro file is an ASCII file contains UI commands.

All commands must be given with their full-path directories.

Use “#” for comment line.
– First “#” to the end of the line will be ignored.
– Comment lines will be echoed if /control/verbose is set to 2.

Macro file can be executed
– interactively or in (other) macro file
/control/execute file_name
– hard-coded
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/control/execute file_name");308
User-defined commands

If built-in commands are not enough, you can make your own

Geant4 provides several command classes, all derived from
G4UIcommand :
– G4UIcmdWithoutParameter
– G4UIcmdWithABool
– G4UIcmdWithADouble
– and many more

Example
energyCmd = new G4UIcmdWithADoubleAndUnit(“/gun/energy”, this);
energyCmd->SetParameterName(“Energy”,true,true);
energyCmd->SetDefaultUnit(GeV);

See also Application Developers Guide
309
G4UIterminal - 1

G4UIterminal is a concrete implementation derived from the
G4UIsession abstract base class. It provides character-base
interactive terminal functionality to issue Geant4 UI commands.
– C-shell or TC-shell (Linux only)
new G4UIterminal(new G4UItcsh);
– For Windows
new G4UIWin32();

It supports some Unix-like commands for directory.
– cd, pwd : change and display current command directory
• By setting the current command directory, you may omit (part of)
directory string.
– ls : list available UI commands and sub-directories
310
G4UIterminal - 2

It also supports some other commands.
– history - show previous commands
– !historyID - re-issue previous command
– arrow keys (TC-shell only)
– ?UIcommand - show current parameter values of the
command
– help [UIcommand] - help
– exit - job termination

Above commands are interpreted in
G4UIterminal and are not passed to Geant4
kernel. You cannot use them in a macro file.
311
Analysis interface

Geant4 does not endorse or support particular analysis
packages

However an abstract analysis interface is provided
– AIDA (Abstract Interfaces for Data Analysis)
– will be built and linked to your application if enviroment variable
G4ANALYSIS_USE is set
– AIDA headers must be installed in code where analysis is set up
• #include AIDA/AIDA.h
– must use AIDA-compliant analysis tools

More AIDA information :
– http://aida.freehep.org
312
Some AIDA-compliant Analysis Packages

Anaphe
– http://cern.ch/anaphe/

Open Scientist Lab
– http://www.lal.in2p3.fr/OpenScientist
– an example using Open Scientist can be found in
$G4INSTALL/examples/extended/analysis/AnaEx01

JAS (Java Analysis Studio)
– http://jas.freehep.org
– for analysis example using JAS/AIDA see
$G4INSTALL/examples/extended/analysis/A01
313
The Geant4 toolkit :
12/15 - Documentation, examples, forum…
10 minutes
314
Geant4 web site
http://cern.ch/geant4
315
Installation guide
• From web site, in user guides
• List of required software
• C++ compiler, CLHEP, GNU make, Geant4
• Visualization software
• How to install on Linux
• Tips for installing on Windows
316
User guide
 From web site, in user guides
 Introduces new users to the Geant4 toolkit
 Description of the most useful tools
 Explain how to set up and run a simulation application
 Only an overview, not exhaustive…
317
Physics reference manual
 From web site, in user guides
 A reference for toolkit users and developers
who wish to consult the underlying physics of
an interaction
 Presents the theoretical formulation, model or
parameterization of the physics interactions
provided by Geant4
318
Toolkit’s developer guide
• From web site, in user guides

A description of the object-oriented design of the
Geant4 toolkit
−
−

class diagrams (some UML, some other)
philosophy behind design choices
A guide for users who want to extend the functionality
of Geant4
− adding new solids, modifying the navigator, creating
new fields, etc…
319
LXR code browser
● Internet :
●
Search entire Geant4 source tree by
●
●
●
●
http://www-geant4.kek.jp/LXR
filename (e.g. G4Track.hh)
text
identifier
Results: a source file fully hyper-linked to classes
and methods
●
●
tells where classes and methods are defined
also where they are referenced
320
User forum
• Internet : section user forum
• Discuss problems with other users, post
questions for experts, etc.
• 18 forums roughly based on Geant4 categories
• 3 forums for specific application areas
• New forums may be requested by users
• To join: click on “Membership” at bottom of
page and fill out form
321
Examples
• 7 novice examples from very easy to complex
• Will help you start your apllication
• Located in $G4INSTALL/examples/novice
• Several extended examples
• Users' Guide for Application Developers
• Located in $G4INSTALL/examples/extended
• 15 advanced examples
• Users’ Guide for Application Developers
• Located in $G4INSTALL/examples/advanced
322
The Linux environment
- minimum knowledge for Geant4 –
13/15
10 minutes
323
Introduction

Geant4 can be installed under
several environments : Linux,
Windows, Mac OS, Sun…

We are going to work with Geant4
under Scientific Linux, a OS standard
for scientific computation (constantly
updated, free, …)
324
Introduction

More precisely, we will use the VMware
virtualization tool (free) which can emulate
simultaneously a real Linux PC directly under a
Windows or Mac session. To learn more :
http://geant4.in2p3.fr

Easy exchange of files between Linux and Windows

We will work with Scientific Linux 4.5 (developped
by CERN & Fermilab) and Geant4 9.0+P01, already
installed for you
325
Access to Linux

Under your Windows session, start the VMware
player and select the Linux machine

Login with :
– Username: local1
– Password: local1

A mouse right clik anywhere on the desktop open
a terminal (select Open Terminal in the pop-up
menu) where you’re going to enter control
commands.
326
shells

They are the available command interpreters
/bin/sh
Shell POSIX, standard, scripts
/bin/ksh
Korn shell, improved for interactivity
/bin/csh
C-shell, syntax close to C
bash
Standard shell under Linux, Bourne Again shell
tcsh
Improved C-shell (by default here)
zsh
Improved Bash and tcsh
327
Navigate in directories
pwd
Display current directory
cd directory
Change to directory directory
cd
Go back to home directory (~)
cd ..
Go to parent directory
ls
List files
ls –a
Also list hidden files
328
Move, copy, create, delete…
mv source target
Move and/or rename a file
cp source target
Copy a file
cp –R source target
Copy a directory
mkdir directory
Create a directory
rmdir directory
Delete an empty directory
du –ks directory
Give the size in Ko of a directory
rm file
Delete a file
rm –f file
Delete a write protected file
rm –R directory
Delete a directory
329
Other useful commands
diff file1 file2
Display differences between two tet
files
wc file
Count number of lines, words and
octets in file
more file
Display a file page after page (space
for next page, enter for next ligne, u
to go up)
echo $envVariableName
Display the value of an environment
variable
330
Useful pre-installed tools

nedit : edit text files

xemacs : idem

snavigator : Integrated Development Environment to
manage a C++ project

make : to compile the Geant4 application

root : to start to data analysis ROOT software

Add & after command name to keep control command
331
Where is Geant4 installed ?

Source code accessible only to super user
(su) in directory :
/usr/local/geant4

A basic application on which we are going
to work is under :
/home/local1/geant4/simulation

After compilation, the application
executable will be stored in the directory :
$G4WORKDIR/bin/Linux-g++
332
The Geant4 toolkit :
14/15 - Write your own user application
15 minutes
333
User application

Geant4 is a toolkit
– i.e. you cannot “run” it out of the box
– You must write an application, which uses Geant4 tools

Consequences
– There are no such concepts as “Geant4 defaults”
– You must provide the necessary information to
configure your simulation
– You must deliberately choose which Geant4 tools to use

Guidance: we provide many examples
– Novice Examples: overview of Geant4 tools
– Extended and Advanced Examples: Geant4 tools
– Located in $G4INSTALL/examples
334
Basic concepts

What you MUST do:
– Describe your experimental set-up
– Provide the primary particles input to your simulation
– Decide which particles and physics models you want to
use out of those available in Geant4 and the precision of
your simulation (cuts to produce and track secondary particles)

You may also want
– To interact with Geant4 kernel to control your simulation
– To visualize your simulation configuration or results
– To produce histograms, tuples etc. to be further analysed
335
Interaction with Geant4 kernel

Geant4 design provides tools for a user application
– To tell the kernel about your simulation configuration
– To interact with Geant4 kernel itself

Geant4 tools for user interaction are base classes
– You create your own concrete class derived from the base classes
– Geant4 kernel handles your own derived classes transparently
through their base class interface (polymorphism)

Abstract base classes for user interaction
– User derived concrete classes are MANDATORY

Concrete base classes (with virtual dummy methods) for user
interaction
– User derived classes are OPTIONAL
336
User classes
Initialization classes
Invoked at initialization
 G4VUserDetectorConstruction
 G4VUserPhysicsList
In RED,
mandatory !
Action classes
Invoked during the execution loop
 G4VUserPrimaryGeneratorAction
 G4UserRunAction
 G4UserEventAction
 G4UserTrackingAction
 G4UserStackingAction
 G4UserSteppingAction
337
Particles
Geometry
Analysis
Physics
Stacks
Steps
Tracks
338
Hands On
Let’s build a simple dosimetry
application – 15/15
Calculate the dose deposited by a
3 MeV proton in a biological cell
Refer to provided manuscript
339
 The main() program

Geant4 does not provide the main()
– Geant4 is a toolkit !
– The main() is part of the user application

In his/her main(), the user must :
– construct G4RunManager (or his/her own derived class)
– notify the G4RunManager mandatory user classes derived from
• G4VUserDetectorConstruction
• G4VUserPhysicsList
• G4VUserPrimaryGeneratorAction

The user may define in his/her main()
– optional user action classes
– G4VisManager, (G)UI session
Simulation.cc
340
 Describe the experimental setup

Derive your own concrete class from the
G4VUserDetectorConstruction abstract base
class

Implement the Construct() method
–
–
–
–
–
construct all necessary materials
define shapes/solids required to describe the geometry
construct and place volumes of your detector geometry
define visualization attributes for the detector elements
define sensitive detectors and identify detector volumes to
associate them to
341
– associate magnetic field to detector regions
Define detector geometry


Three conceptual layers
– G4VSolid
– G4LogicalVolume
– G4VPhysicalVolume
shape, size
material, sensitivity, magnetic field, etc.
position, rotation
A unique physical volume (the WORLD volume), which represents the
experimental area, must exist and fully contain all other components
Volume B (daughter)
Volume A (mother)
WORLD
e. g. Volume A is mother
of Volume B
The mother must contain
the daughter volume
entirely
342et .cc
DetectorConstruction.hh
 Select physics processes

Geant4 does not have any default particles or processes

Derive your own concrete class from the G4VUserPhysicsList
abstract base class
– define all necessary particles
– define all necessary processes and assign them to proper particles
– define production thresholds (in terms of range)

Pure virtual methods of G4VUserPhysicsList that need to be
implemented
– ConstructParticles()
– ConstructProcess()
– SetCuts()
343
PhysicsList.hh
et .cc
 Primary events
• Derive your own concrete class from the
G4VUserPrimaryGeneratorAction
abstract base class
• Define primary particles providing : particle
type, initial position, initial direction, initial
energy
• Imlement the virtual member function
GeneratePrimaries()
344
PrimaryGeneratorAction.hh
et .cc
 Optional user action classes

Five concrete base classes whose virtual member functions the user may
override to gain control of the simulation at various stages
–
–
–
–
–

G4UserRunAction
G4UserEventAction
(G4UserTrackingAction)
(G4UserStackingAction)
G4UserSteppingAction
Each member function of the base classes has a dummy implementation
– Empty implementation: does nothing

The user may implement the member functions he desires in his/her
derived classes

345
Objects of user action classes must be registered with G4RunManager
Optional user action classes
G4UserRunAction

BeginOfRunAction(const G4Run*)
– For example: book histograms

EndOfRunAction(const G4Run*)
− For example: store histograms
G4UserEventAction

BeginOfEventAction(const G4Event*)
– For example: perform and event selection

EndOfEventAction(const G4Event*)
– For example: analyse the event
RunAction.hh et .cc
EventAction.hh et .cc
TrackingAction.hh et .cc
(G4UserTrackingAction)

PreUserTrackingAction(const G4Track*)
– For example: decide whether a trajectory should be stored or not

PostUserTrackingAction(const G4Track*)
346
Optional user action classes
G4UserSteppingAction

UserSteppingAction(const G4Step*)
– For example: kill, suspend, postpone the track
– For example: draw the step, collect physics information
(G4UserStackingAction)

PrepareNewEvent()
– For example: reset priority control

ClassifyNewTrack(const G4Track*)
SteppingAction.hh et .cc
StackingAction.hh et .cc
– Invoked every time a new track is pushed
– For example: classify a new track (priority control)
• Urgent, Waiting, PostponeToNextEvent, Kill

NewStage()
– Invoked when the Urgent stack becomes empty
– For example: change the classification criteria
– For example: event filtering (event abortion)
347
 GUI and visualization


In your main(), taking into
account your computer
environment, instantiate a
G4UIsession concrete class
provided by Geant4 and invoke
its sessionStart() method
Geant4 provides:
– G4UIterminal:csh or tcsh like
character terminal
– G4GAG : tcl/tk or Java PVM
based GUI
– G4Wo : Opacs
– G4UIBatch : batch job with
macro file
– …

In your main(), taking into
account your computer
environment, instantiate a
G4VisExecutive and invoke its
initialize() method

Geant4 provides interfaces to
various graphics drivers:
– DAWN (Fukui renderer)
– WIRED
– RayTracer (ray tracing by Geant4
tracking)
–
–
–
–
–
OPACS
OpenGL
OpenInventor
VRML
…
Simulation.cc
348