+ All Categories
Home > Documents > Introduction to Geant4

Introduction to Geant4

Date post: 04-Feb-2016
Category:
Upload: lily
View: 75 times
Download: 2 times
Share this document with a friend
Description:
February 2004, Geant4 v6.0p01. Introduction to Geant4. Makoto Asai (SLAC Computing Services) Geant4 Tutorial Course. Overview. Introduction Basic Structure How to use G4 Detector Modelling Interactions of particles with matter Interactive Capabilities G4-Applications – examples - PowerPoint PPT Presentation
Popular Tags:
53
Introduction to Geant4 Makoto Asai (SLAC Computing Services) Geant4 Tutorial Course February 2004, Geant4 v6.0p01
Transcript
Page 1: Introduction to Geant4

Introductionto

Geant4

Makoto Asai (SLAC Computing Services)

Geant4 Tutorial Course

February 2004, Geant4 v6.0p01

Page 2: Introduction to Geant4

Overview

Introduction Basic Structure How to use G4 Detector Modelling Interactions of particles with matter Interactive Capabilities G4-Applications – examples How to learn more

Page 3: Introduction to Geant4

Introduction to Geant4

Introduction

Page 4: Introduction to Geant4

Example Event with Standard EM Processes Turned On

50 MeV e- entering LAr-Pb calorimeter

Processes used: bremsstrahlung ionization multiple scattering positron-annihilation pair production Compton scattering

Page 5: Introduction to Geant4

Geant4 – Its history and future Dec ’94 - Project start Apr ’97 - First alpha release Jul ’98 - First beta release Dec ’98 - First Geant4 public release … Jun ’03 - Geant4 5.2 release Dec ’03 - Geant4 6.0 release

– Feb 12th, ’04 - Patch01 release Planned near future releases

– Mar 25th, ’04 - Geant4 6.1 release• A few more fixes + minor improvements in verbosity for easily pointing out any

potential problems with mass production

– Jun 25th, ’04 - Geant4 6.2 release– Dec 17th, ’04 - Geant4 7.0 release

We currently provide two to three public releases and bimonthly beta releases in between public releases every year.

Page 6: Introduction to Geant4

What is Geant4?

Geant4 is the successor of GEANT3

Redesigned using an Object-Oriented environment

requirements from heavy ion physics, CP violation

physics, cosmic ray physics, astrophysics, space

science and medical applications.

In order to meet such requirements, a large degree

of functionality and flexibility are provided.

Page 7: Introduction to Geant4

Flexibility of Geant4 Geant4 has many types of geometrical descriptions to

describe most complicated and realistic geometries

– CSG, BREP, Boolean

– STEP compliant

– XML interface

Everything is open to the user

– Choice of physics processes/models

– Choice of GUI/Visualization/persistency/histogramming

technologies

Page 8: Introduction to Geant4

Unit system Internal unit system used in Geant4 is completely hidden not only

from user’s code but also from Geant4 source code implement.

Each hard-coded number must be multiplied by its proper unit.

radius = 10.0 * cm; kineticE = 1.0 * GeV;

To get a number, it must be divided by a proper unit.

G4cout << eDep / MeV << “ [MeV]” << G4endl;

Most of commonly used units are provided and user can add

his/her own units.

By this unit system, source code becomes more readable and

importing / exporting physical quantities becomes straightforward.

– For particular application, user can change the internal unit to

suitable alternative unit without affecting to the result.

Page 9: Introduction to Geant4

Geant4 as a state machine Geant4 has six application states.

– G4State_PreInit• Material, Geometry, Particle and/or Physics

Process need to be initialized/defined

– G4State_Idle• Ready to start a run

– G4State_GeomClosed• Geometry is optimized and ready to process

an event

– G4State_EventProc• An event is processing

– G4State_Quit• (Normal) termination

– G4State_Abort• A fatal exception occurred and program is

aborting

PreInit

Idle

EventProc

GeomClosed

Quit

Abort

initialize

beamOnexit

Page 10: Introduction to Geant4

Introduction to Geant4

Basic Structure

Page 11: Introduction to Geant4

Introduction into Geant4

How to use Geant4

Page 12: Introduction to Geant4

The main program

Geant4 does not provide the main().

In your main(), you have to

– Construct G4RunManager (or your derived class)

– Set user mandatory classes to RunManager

• G4VUserDetectorConstruction

• G4VUserPhysicsList

• G4VUserPrimaryGeneratorAction

You can define VisManager, (G)UI session,

optional user action classes, and/or your persistency

manager in your main().

Page 13: Introduction to Geant4

User classes Initialization classes

– Invoked at the initialization• G4VUserDetectorConstruction• G4VUserPhysicsList

Action classes– Invoked during an event loop

• G4VUserPrimaryGeneratorAction• G4UserRunAction• G4UserEventAction• G4UserStackingAction• G4UserTrackingAction• G4UserSteppingAction

main()– Geant4 does not provide main(). Note : classes written in yellow are mandatory.

Page 14: Introduction to Geant4

Generate primary event Derive your concrete class from

G4VUserPrimaryGeneratorAction abstract base class.

Pass a G4Event object to one or more primary generator concrete

class objects which generate primary vertices and primary

particles.

Geant4 provides several generators in addition to the

G4VPrimaryParticlegenerator base class.

– G4ParticleGun

– G4HEPEvtInterface, G4HepMCInterface

• Interface to /hepevt/ common block or HepMC class

– G4GeneralParticleSource

• Define radioactivity

Page 15: Introduction to Geant4

G4ParticleGun

Concrete implementations of G4VPrimaryGenerator– A good example for experiment-specific primary

generator implementation It shoots one primary particle of a certain energy

from a certain point at a certain time to a certain direction.– Various set methods are available

– Intercoms commands are also available

Page 16: Introduction to Geant4

G4VUserPrimaryGeneratorActionvoid T01PrimaryGeneratorAction:: GeneratePrimaries(G4Event* anEvent){ G4ParticleDefinition* particle; G4int i = (int)(5.*G4UniformRand()); switch(i) { case 0: particle = positron; break; ... } particleGun->SetParticleDefinition(particle); G4double pp = momentum+(G4UniformRand()-0.5)*sigmaMomentum; G4double mass = particle->GetPDGMass(); G4double Ekin = sqrt(pp*pp+mass*mass)-mass; particleGun->SetParticleEnergy(Ekin); G4double angle = (G4UniformRand()-0.5)*sigmaAngle; particleGun->SetParticleMomentumDirection (G4ThreeVector(sin(angle),0.,cos(angle))); particleGun->GeneratePrimaryVertex(anEvent);}

You can repeat this for generating more than one primary particles.

Page 17: Introduction to Geant4

Event in Geant4 At beginning of processing, an event contains primary particles.

These primaries are pushed into a stack.

When the stack becomes empty, processing of an event is over.

G4EventManager class manages processing an event.

G4Event class represents an event. It has following objects at

the end of its processing.

– List of primary vertexes and particles (as input)

– Hits collections

– Trajectory collection (optional)

– Digits collections (optional)

Page 18: Introduction to Geant4

Introduction to Geant4

Detector modelling

Page 19: Introduction to Geant4

Describe your detector Derive your own concrete class from

G4VUserDetectorConstruction abstract base class. In the virtual method Construct(),

– Instantiate all necessary materials

– Instantiate volumes of your detector geometry

– Instantiate your sensitive detector classes and set them to the corresponding logical volumes

Optionally you can define – Regions for any part of your detector

– Visualization attributes (color, visibility, etc.) of your detector elements

Page 20: Introduction to Geant4

Describe your detector Derive your own concrete class from G4VUserDetectorConstruction

abstract base class. Implementing the method Construct()

1) Construct all necessary materials2) Define shapes/solids required to describe the geometry3) Construct and place volumes of your detector geometry4) Instantiate sensitive detectors and set them to corresponding volumes

(optional)5) Associate magnetic field to detector (optional)6) Define visualization attributes for the detector elements (optional)7) Define regions (optional)

Set your construction class to G4RunManager Modularize it w.r.t. each detector component or sub-detector for

easier maintenance of your code

Page 21: Introduction to Geant4

Definition of Materials Different kinds of materials can be described:

– isotopes <-> G4Isotope– elements <-> G4Element– molecules, compounds and mixtures <-> G4Material

Attributes associated to G4Material:– temperature, pressure, state, density

Single element materialdouble density = 1.390*g/cm3;double a = 39.95*g/mole;G4Material* lAr = new G4Material("liquidArgon",z=18.,a,density);

Prefer low-density material to vacuum

Page 22: Introduction to Geant4

Material: molecule 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);

Page 23: Introduction to Geant4

Volume Three conceptual layers

– G4VSolid -- shape, size (abstract class. all solids in Geant4 derive from it)

– G4LogicalVolume -- daughter physical volumes,

material, sensitivity, user limits, etc.

– G4VPhysicalVolume -- position, rotation

Detector sensitivity should be described by the user in his/her concrete implementation of G4VSensitiveDetector and set to G4LogicalVolume.

Page 24: Introduction to Geant4

Define detector geometry Basic strategy

G4VSolid* pBoxSolid = new G4Box(“aBoxSolid”, 1.*m, 2.*m, 3.*m);G4LogicalVolume* pBoxLog = new G4LogicalVolume( pBoxSolid, pBoxMaterial, “aBoxLog”, 0, 0, 0);

G4VPhysicalVolume* aBoxPhys = new G4PVPlacement( pRotation, G4ThreeVector(posX, posY, posZ), pBoxLog, “aBoxPhys”, pMotherLog, 0, copyNo);

A unique physical volume which represents the experimental area must exist and fully contains all other componentsThe world volume

Page 25: Introduction to Geant4

Sensitive detector and Hit Each Logical Volume can have a pointer to a sensitive detector.

– Then this volume becomes sensitive.

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.

– UserSteppingAction class should NOT do this.

Hit objects, which are still the user’s class objects, are collected in a

G4Event object at the end of an event.

Page 26: Introduction to Geant4

Digitizer module and digit Digit represents a detector output (e.g. ADC/TDC count,

trigger signal, etc.).

Digit is created with one or more hits and/or other digits by a

user's concrete implementation derived from

G4VDigitizerModule.

In contradiction to the sensitive detector which is accessed at

tracking time automatically, the digitize() method of each

G4VDigitizerModule must be explicitly invoked by the user’s

code (e.g. at EventAction).

Page 27: Introduction to Geant4

Introduction to Geant4

Physics Processes

Page 28: Introduction to Geant4

Select physics processes Geant4 does not have any default particles or processes.

– Even for the particle transportation, you have to define it explicitly.

Derive your own concrete class from G4VUserPhysicsList abstract base class.– Define all necessary particles

– Define all necessary processes and assign them to proper particles

– Define cut-off ranges applied to the world (and each region)

Geant4 provides lots of utility classes/methods and examples.– "Educated guess" physics lists for defining hadronic processes for

various use-cases.

Page 29: Introduction to Geant4

Physics Lists (1)● This is where the user defines all the physics to be used in his simulation

● First step: derive a class (e.g. MyPhysicsList) from the G4VUserPhysicsList base class

● Next, implement the methods: ConstructParticle() - define all necessary particles ConstructProcess() - assign physics processes to each particle SetCuts() - set the range cuts for secondary production

● Register the physics list with the run manager in the main program runManager -> SetUserInitialization(new MyPhysicsList);

Page 30: Introduction to Geant4

Physics List (ConstructParticle)

void MyPhysicsList::ConstructParticle() { G4Electron::ElectronDefinition(); G4Positron::PositronDefinition(); G4Gamma::GammaDefinition();

G4MuonPlus::MuonPlusDefinition(); G4MuonMinus::MuonMinusDefinition(); G4NeutrinoE::NeutrinoEDefinition(); G4AntiNeutrinoE::AntiNeutrinoEDefinition(); G4NeutrinoMu::NeutrinoMuDefinition(); G4AntiNeutrinoMu::AntiNeutrinoMuDefinition(); }

Page 31: Introduction to Geant4

Physics List (SetCuts and ConstructProcess)

void MyPhysicsList::SetCuts() { defaultCutValue = 1.0*mm; SetCutsWithDefault(); }

void MyPhysicsList::ConstructProcess() { AddTransportation(); // Provided by Geant4 ConstructEM(); // Not provided by Geant4 ConstructDecay(); // “ “ “ “ }

Page 32: Introduction to Geant4

Physics List (ConstructEM)

void MyPhysicsList::ConstructEM()

{

theParticleIterator -> Reset();

while( (*theParticleIterator)() ) {

G4ParticleDefinition* particle = theParticleIterator -> Value();

G4ProcessManager* pm = particle -> GetProcessManager();

G4String particleName = particle -> GetParticleName();

if (particleName == “gamma”) {

pm -> AddDiscreteProcess(new G4ComptonScattering);

pm -> AddDiscreteProcess(new G4GammaConversion);

Page 33: Introduction to Geant4

Particles and Tracks (1)● What is a particle in Geant4?

a collection of all the information needed to propagate it through a material Geant4 arranges this information in layers, starting with:

Particle (ParticleDefinition) simply a definition, no information of energy, direction, … only one instance of each type

Dynamic Particle gives the particle its kinematic properties

Track places the dynamic particle in context snapshot of particle not a collection of steps

Page 34: Introduction to Geant4

Particles and Tracks (2)

G4Track

G4DynamicParticle

G4ParticleDefinition PDG info: mass, charge, spin,

lifetime, decay table

E, p, polarization, time pre-assigned decays

Position, volume, track lengthTOF, ID of itself and mother

many public methods: GetPosition(), GetVolume(), GetMaterial(), many public methods: GetPosition(), GetVolume(), GetMaterial(), GetCreatorProcess(), GetMomentum(), GetParticleDefinition(), …GetCreatorProcess(), GetMomentum(), GetParticleDefinition(), …

Page 35: Introduction to Geant4

Track in Geant4 Track is a snapshot of a particle.

– It has only position and physical quantities of current instance.

Step is a “delta” information to a track.

– Track is not a collection of steps. Track is deleted when

– it goes out of the world volume

– it disappears (e.g. decay)

– it goes down to zero kinetic energy and no “AtRest” additional process is required

– the user decides to kill it

No track object persists at the end of event.– For the record of track, use trajectory class objects.

G4TrackingManager manages processing a track, a track is represented by G4Track class.

Page 36: Introduction to Geant4

Tracking (2)● The basic element of tracking is the Step● It consists of two points and the “delta” information of a particle

step length, energy loss during step, change in elapsed time, etc.● Each point knows which volume it is in

if step limited by boundary, end point is located on boundary, but it logically belongs to next volume

– Because one step knows materials of two volumes, boundary processes such

as transition radiation or refraction could be simulated.

G4SteppingManager class manages processing a step, a step is represented by

G4Step class.

Start of step point End of step point

Page 37: Introduction to Geant4

How Geant4 runs (one step)

Stepping Manager

Physics Process

Particle Change

Step Track Logical Volume

Sensitive Detector

GetPhysicalInteractionLength

SelectShortest

DoIt Fill

Update

Update

IsSensitive

GenerateHits

Page 38: Introduction to Geant4

Threshold for Secondary Production (1)

● A simulation must impose an energy cut below which secondaries are not produced

avoid infrared divergence save CPU time used to track low energy particles

● But, such a cut may cause imprecise stopping location and deposition of energy Particle dependence

range of 10 keV in Si is a 130 microns range of 10 keV e- in Si is about 1.5 microns

~100 times difference range of 100 keV in Si is a 130 microns range of 100 keV e- in Si is about 2.3 cm

~300 times differenece Inhomogeneous materials

Pb-scintillator sandwich: if cut OK for Pb, energy deposited in sensitive scintillator may be wrong

Page 39: Introduction to Geant4

Threshold for Secondary Production (2)

● Solution: impose a cut in range Given a single range cut, Geant4 calculates for all

materials the corresponding energy at which production of secondaries stops

● During tracking: Particle loses energy by generation of secondaries

down to an energy corresponding to the range cut Then the particle is tracked down to zero energy using

continuous energy loss.

Page 40: Introduction to Geant4

Energy cut vs. range cut 500 MeV/c proton in liq.Ar (4mm) / Pb (4mm)

sampling calorimeter

liq.Ar

Pb liq.Ar

Pb

•Geant3 (energy cut)•Ecut = 450 keV

•Geant4 (range cut)•Rcut = 1.5 mm•Corresponds to Ecut in liq.Ar = 450 keV, Ecut in Pb = 2 MeV

Page 41: Introduction to Geant4

Run in Geant4 a run of Geant4 starts with “Beam On”.

Within a run, the user cannot change

– detector geometry

– settings of physics processes

a run is a collection of events sharing the same detector conditions.

beginning of a run: geometry optimized for navigation, cross-

section tables are calculated according to materials in the geometry

and the cut-off values defined.

G4RunManager class manages processing a run, a run is

represented by G4Run class or a user-defined class derived from

G4Run.

Page 42: Introduction to Geant4

Optional user action classes All user action classes, methods of which are invoked during

“Beam On”, must be constructed in the user’s main() and must be set to the RunManager.

G4UserRunAction– G4Run* GenerateRun()

• Instantiate user-customized run object

– void BeginOfRunAction(const G4Run*)• Define histograms

– void EndOfRunAction(const G4Run*)• Store histograms

G4UserEventAction– void BeginOfEventAction(const G4Event*)

• Event selection• Define histograms

– void EndOfEventAction(const G4Event*)• Analyze the event

Page 43: Introduction to Geant4

Optional user action classes G4UserTrackingAction

– void PreUserTrackingAction(const G4Track*)

• Decide trajectory should be stored or not

• Create user-defined trajectory

– void PostUserTrackingAction(const G4Track*)

G4UserSteppingAction

– void UserSteppingAction(const G4Step*)

• Kill / suspend / postpone the track

• Draw the step (for a track not to be stored as a trajectory)

Page 44: Introduction to Geant4

Introduction into Geant4

Interactive Capabilities

Page 45: Introduction to Geant4

Geant4 UI command A command consists of

– Command directory

– Command

– Parameter(s) A parameter can be a type of string, boolean, integer or

double.– Space is a delimiter.

– Use double-quotes (“”) for string-type parameter 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

/run/verbose 1

/vis/viewer/flush

Page 46: Introduction to Geant4

Command submission Geant4 UI command can be issued by

– (G)UI interactive command submission– Macro file– Hard-coded implementation

• Slow but no need for the targeting class pointer• Should not be used inside an event loop

G4UImanager* UI = G4UImanager::GetUIpointer();UI->ApplyCommand("/run/verbose 1");

The availability of individual command, the ranges of parameters, the available candidates on individual command parameter vary according to the implementation of your application and may even vary dynamically during the execution of your job.

some commands are available only for limited Geant4 application state(s).– E.g. /run/beamOn is available only for Idle states.

Page 47: Introduction to Geant4

Introduction to Geant4 Introduction to Geant4 VisualizationVisualization

Joseph PerlSLAC Computing Services

HepRep/WIRED

DAWN

OpenGL

Page 48: Introduction to Geant4

Steps of Visualization Open a driver (instantiates scene handler and viewer), such as:

– /vis/open HepRepFile Iset camera parameters and drawing style, such as:

– /vis/viewer/reset– /vis/viewer/set/viewpointThetaPhi 70 20– /vis/viewer/set/style wireframe

Create an empty scene:– /vis/scene/create

Declare what 3D data should be added to the created scene:– /vis/scene/add/volume– /vis/scene/add/trajectories– /vis/scene/add/hits

Attach scene to sceneHandler:– /vis/sceneHandler/attach

Run simulation with appropriate options to store trajectory information:– /tracking/storeTrajectory 1– /run/beamOn 1

Execute the visualization (done automatically with each /run/beamOn) /vis/viewer/flush

If using an external viewer, such as for HepRepFile or DAWNFILE:– import the .heprep or .prim file into WIRED or DAWN, set camera parameters,

drawing style, etc., view the visualization

Page 49: Introduction to Geant4

some applications

Page 50: Introduction to Geant4

calorimetrycalorimetry

trackingtracking

Courtesy of D. Wright, BaBar

Page 51: Introduction to Geant4

ATLAS

Courtesy of ATLAS Collaboration

-100 1000 200 300 400 5000

600

100

200

300

400

500

700

800

Calorimeter Signal [nA]

Events

/10 n

A

180 GeV μ180 GeV μ

HEC Testbeam: HEC Testbeam: Muon Response Muon Response ComparisonsComparisons

HEC Testbeam: HEC Testbeam: Muon Response Muon Response ComparisonsComparisons

Extensive comparisons with test beam data(see, for instance, CALOR-2002 conference)

Page 52: Introduction to Geant4

Profile curves at 9.8 cm depth PLATO overestimate the dose at ~ 5% level

CT-simulation with a Rando phantomExperimental data obtained with TLD LiF dosimeter

CT images used to define the geometry:

a thorax slice from a Rando

anthropomorphic phantom

Comparison with commercial treatment planning systemsM. C. Lopes 1, L. Peralta 2, P. Rodrigues 2, A. Trindade 2

1 IPOFG-CROC Coimbra Oncological Regional Center - 2 LIP - Lisbon

Agreement better than 2% between GEANT4 and TLD dosimeters

81.0)(2 TMSndf52.0)4(2 GEANTndf

71.6)(2 PLATOndf

Page 53: Introduction to Geant4

Geant4 users workshop Users workshops were held or are going to be held hosted by

several institutes for various user communities.– KEK - Dec.2000, Jul.2001, Mar.2002, Jul.2002, Mar.2003, Jul.2003

– SLAC - Feb.2002

– Spain (supported by INFN) - Jul.2002

– CERN - Nov.2002

– ESA - Jan.2003

– NASA/ESA/Vanderbilt - May.2004 (planned)

– Helsinki - Oct.2003

– GSI, May 2004 => GSI-Kurier


Recommended