Title: Other GEANT4 capabilities
1Other GEANT4 capabilities
- Event biasing
- Parameterisation (fast simulation)
- Scoring
- Persistency
- Parallelisation and integration in a
distributed computing environment
Alex Howard
Susanna Guatelli
2Ackowledgements
- Most of this material has been provided by
Makoto Asai, Tsukasa Aso and Jane Tinslay - SLAC 2006 course
3Fast simulation
Geant4 allows to perform full and fast simulation
in the same environment
- The parameterisation process produces a direct
detector response, from the knowledge of particle
and volume properties - hits, digis, reconstructed-like objects (tracks,
clusters etc.) - Great flexibility
- activate fast /full simulation by detector
- example full simulation for inner detectors,
fast simulation for calorimeters - activate fast /full simulation by geometry region
- example fast simulation in central areas and
full simulation near cracks - activate fast /full simulation by particle type
- example in e.m. calorimeter, e/g
parameterisation full simulation of hadrons - parallel geometries in fast/full simulation
- example inner and outer tracking detectors
distinct in full simulation, but handled together
in fast simulation
4Event biasing
- Geant4 provides facilities for event biasing
- The effect consists in producing a small number
of secondaries, which are artificially recognized
as a huge number of particles by their
statistical weights - Event biasing can be used, for instance, for the
transportation of slow neutrons or in the
radioactive decay simulation - Various variance reduction techniques available
5Event biasing techniques
- Production cuts / threshold
- This is a biasing technique most popular for
many applications - Geometry based biasing
- Importance weighting for volume/region
- Duplication or sudden death of tracks
- Leading particle biasing
- Taking only the most energetic (or most
important) secondary - Primary event biasing
- Biasing primary events and/or primary particles
in terms of type of event, momentum distribution,
etc. - Forced interaction
- Force a particular interaction, e.g. within a
volume - Enhanced process or channel
- Increasing cross section for a process
- Physics based biasing
- Biasing secondary production in terms of particle
type, momentum distribution, cross-section, etc. -
gt Weight on track / event.
6Current features in Geant4
- Partial MARS migration
- n, p, pi, K (lt 5 GeV)
- Since Geant4 0.0
- General particle source module
- Primary particle biasing
- Since Geant4 3.0
- Radioactive decay module
- Physics process biasing in terms of decay
products and momentum distribution - Since Geant4 3.0
- Geometry based biasing
- Weight associating with real volume or artificial
volume - Since Geant4 4.2
- Weight cutoff and weight window
- Since Geant4 5.2
- Hadronic process module
- Cross-section biasing (PhotoInelactic,ElectronNucl
ear,PositronNuclear) - Leading particle biasing for hadronic processes
- Since Geant4 7.0
7Leading particle biasing
- Simulating a full shower is an expensive
calculation - Instead of generating a full shower, trace only
the most energetic secondary - Other secondary particles are immediately killed
before being stacked - Convenient way to roughly estimate, e.g. the
thickness of a shield - Physical quantities such as energy are not
conserved for each event
8Geometric Biasing
The purpose of geometry based event biasing is
to save computing time by sampling less often
the particle histories entering less important
geometry regions, and more often in more
important regions.
Importance sampling technique Weight window
technique
9Variance Reduction
- Use variance reduction techniques to reduce
computing time taken to calculate a result with a
given variance - Want to increase efficiency of the Monte Carlo
- Measure of efficiency is given by
- s variance on calculated quantitiy
- T computing time
10- Remove bias introduced from generating multiple
secondaries by assigning a statistical weight to
each secondary - N number of secondary photons
- Preserves photon energy and angluar distributions
- Currently, no default bremsstrahlung splitting in
Geant4 toolkit - User can implement bremsstrahlung splitting by
- Directly modifying bremsstrahlung source code
- Using G4WrapperProcess
- May be slightly less efficient
- Less invasive
- Easier to implement
10
11Importance sampling technique
- Importance sampling acts on particles crossing
boundaries between importance cells. - The action taken depends on the importance value
assigned to the cell. - In general, a track is played either split or
Russian roulette at the geometrical boundary
depending on the importance value assigned to the
cell.
- Survival probability (P) is defined by the ratio
of importance value. P Ipost / Ipre - The track weight is changed to W/P.
I1
I2
W0.5
W1
- Splitting a track ( P gt 1 )
- E.g. creating two particles with half the
weight if it moves into volume with double
importance value.
W0.5
P 2
- Russian-roulette (P lt 1 ) in opposite direction
- E.g. Kill particles according to the survival
probability (1 - P).
P 0.5
X
W0.5
W1
12Geometrical importance biasing
- Define importance for each geometrical region
- Duplicate a track with half (or relative) weight
if it goes toward more important region - Russian-roulette in another direction
- Scoring particle flux with weights
- at the surface of volumes
13 Importance biasing
Analogue simulation
10 MeV neutron in thick concrete cylinder
14Examples/extended/biasing
15Biasing example B01
- Shows the importance sampling in the mass
(tracking) geometry - Option to show weight window
- 10 MeV neutron shielding by cylindrical thick
concrete material - Geometry
- 80 cm high concrete cylinder divided into 18
slabs - Importance values assigned to 18 concrete slabs
in the DetectorConstruction for simplicity. - The G4Scorer is used for the checking result
- Top level class uses the framework provided for
scoring.
Air
Air
1 1 2 4 8 16 32 64 .. 2n
16Flux multiplied by Kinetic energy of particle
(MeV)
17Example B02
- B02 example for showing
- importance sampling in a parallel geometry
- a customized scoring making use of the scoring
framework. - Mass geometry consists of a 180 cm high simple
bulk concrete cylinder - A parallel geometry is created to hold importance
values for slabs of width 10cm and for scoring. - Note The parallel world volume must overlap the
mass world volume - The radii of the slabs is larger than the radius
of the concrete cylinder in the mass geometry. - The importance value is assigned to each
G4GeometryCell - Pairs of G4GeometryCell and importance values are
stored in the importance store, G4IStore. - The scoring uses the G4CellSCorer and one
customized scorer for the last slab. - It can be built and run using the PI
implementation of AIDA - For this see http//cern.ch/PI.
- At the end a histogram called b02.hbook" is
created.
18Example B03
- Uses Geant4 importance sampling and scoring
through python. - It creates a simple histogram.
- It demonstrates how to use a customized scorer
and importance sampling in combination with a
scripting language, python. - Geant4 code is executed from a python session.
- Note the swig package is used to create python
shadow classes and to generate the code necessary
to use the Geant4 libraries from a python
session. - It can be built and run using the PI
implementation of AIDA - For this see http//cern.ch/PI.
- At the end a histogram called "trackentering.hbook
" is created.
19SCORING
- examples/extended/runAndEvent/RE02
20Extract useful information
- Given geometry, physics and primary track
generation, Geant4 does proper physics simulation
silently. - You have to add a bit of code to extract
information useful to you. - There are two ways
- Use user hooks (G4UserTrackingAction,
G4UserSteppingAction, etc.) - You have full access to almost all information
- Straight-forward, but do-it-yourself
- Use Geant4 scoring functionality
- Assign G4VSensitiveDetector to a volume
- Hit is a snapshot of the physical interaction of
a track or an accumulation of interactions of
tracks in the sensitive (or interested) part of
your detector. - Hits collection is automatically stored in
G4Event object, and automatically accumulated if
user-defined Run object is used. - Use user hooks (G4UserEventAction,
G4UserRunAction) to get event / run summary
21For example
- MyDetectorConstructionConstruct()
- G4LogicalVolume myCellLog new
G4LogicalVolume() - G4VPhysicalVolume myCellPhys new
G4PVParametrised() - G4MultiFunctionalDetector myScorer new
G4MultiFunctionalDetector(myCellScorer) - G4SDManagerGetSDMpointer()-gtAddNewDetector(mySco
rer) - myCellLog-gtSetSensitiveDetector(myScorer)
- G4VPrimitiveSensitivity totalSurfFlux new
G4PSFlatSurfaceFlux(TotalSurfFlux) - myScorer-gtRegister(totalSurfFlux)
- G4VPrimitiveSensitivity totalDose new
G4PSDoseDeposit(TotalDose) - myScorer-gtRegister(totalDose)
No need of implementing sensitive detector !
22A tip for scoring
- For scoring purposes, you need to accumulate a
physical quantity (e.g. energy deposition of a
step) for entire run of many events. In such a
case, do NOT sum up individual energy deposition
of each step directly to a variable for entire
run. - Compared to the total sum for entire run, each
energy deposition of single step is too tiny.
Rounding error problem may easily happen. - Total energy deposition of 1 million events of 1
GeV incident particle ends up to 1 PeV (1015 eV),
while energy deposition of each single step is
O(1 keV) or even smaller. - Create your own Run class derived from G4Run, and
implement RecordEvent(const G4Event) virtual
method. Here you can get all output of the event
so that you can accumulate the sum of an event to
a variable for entire run. - RecordEvent(const G4Event) is automatically
invoked by G4RunManager. - Your run class object should be instantiated in
GenerateRun() method of your UserRunAction.
23G4VPrimitiveScorer
- G4VPrimitiveScorer is an abstract base class
representing a class to be registered to
G4MultiFunctionalDetector. - Geant4 provides concrete primitive scorer classes
such as dose scoring, surface flux counting, etc.
- Of course, users can develop his/her own
primitive scorer classes. - Primitive scorers are designed to score one kind
of quantity and generates one hits collection per
event. - The name of hits collection is automatically
assigned asltMultiFunctionalDetector
namegt/ltPrimitive Scorer namegt.The hits
collection is maintained by G4HCofThisEvent
object with a unique collection ID number which
is assigned by G4SDManager. - Each primitive scorer object must be instantiated
with a unique name among primitive scorers
registered in a G4MultiFunctionalDetector object. - A primitive scorer object must not be shared by
more than one G4MultiFunctionalDetector object.
Otherwise, the results are mixed together.
24List of concrete primitive scorer
- Concrete Primitive Scorers ( See Application
Developers Guide 4.4.6 ) - Track length
- G4PSTrackLength, G4PSPassageTrackLength
- Deposited energy
- G4PSEnergyDepsit, G4PSDoseDeposit
- Current/Flux
- G4PSFlatSurfaceCurrent, G4PSSphereSurfaceCurrent,G
4PSPassageCurrent, G4PSFlatSurfaceFlux,
G4PSCellFlux, G4PSPassageCellFlux - Others
- G4PSMinKinEAtGeneration, G4PSNofSecondary,
G4PSNofStep
SurfaceCurrent Count number of injecting
particles at defined surface.
SurfaceFlux Sum up 1/cos(angle) of injecting
particlesat defined surface
CellFlux Sum of L / V of injecting particles
in the geometrical cell.
V Volume
25Summary
- Geant4 offers the possibility to improve
computing performance via fast simulation and
biasing - A number of biasing techniques are available but
are the users responsibility to use the results
correctly - Scoring is implemented with a degree of
flexibility to reduce hits collection and
persistency whilst offering convenience of
keeping tallies of common qualities - A number of examples are available within
the G4INSTALL/examples/extended source tree - See documentation for more details