gamos may 18th 2009 1 gamos an easy and flexible framework for geant4 simulations pedro arce juan...

51
GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT) CIEMAT, Madrid, 18 May 2009

Upload: florence-hill

Post on 20-Jan-2016

231 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 1

GAMOSan easy and flexible framework for

GEANT4 simulations

Pedro ArceJuan Ignacio LagaresPedro Rato Mendes

Mario Cañadas(CIEMAT)

CIEMAT, Madrid, 18 May 2009

Page 2: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 2

Introduction GEANT4-based frameworks GAMOS objectives GAMOS plug-in’s GAMOS history

GAMOS functionality Geometry Movements Primary generator Physics User actions Sensitive detector and hits Histogramming Parameter management Scoring

Outline

Analysis and optimisation Control histograms Verbosity Optimisation

Applications PET Radiotherapy

Accelerator Dose in phantom Analysis Optimisation

Documentation Installation Release and user support Usage

Page 3: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 3

Introduction

Page 4: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 4

GEANT4 is a very powerful and flexible toolkit

But: it is not easy for a beginner Everything requires writing C++, and a good knowledge of GEANT4 details No complete set of tools for an application

Several frameworks try to make GEANT4 easy to use in a specific domain: Providing an scripting language, so that no C++ is needed Trying to cover with it all the user requirements in the field

But a common problem of these frameworks is that the user sooner or later wants to do something not foreseen by the framework Understand how the framework works and modify it (difficult and risky) Do it by her/himself, without the framework

SOLUTION: plug-in based framework Any new component can be inserted (plugged) in the framework without touching it or

knowing its details, and then used as a command

+ good modularity and documentation

GEANT4-based frameworks

Page 5: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 5

The first objective of GAMOS is to allow the user to: Simulate fully a medical physics project with a minimal knowledge of GEANT4 and no

need of C++ (only text scripts)

Already operative for PET and radiotherapy

The second objective is to allow the user to: Easily add new functionality and combine it with the existing functionality in

GAMOS And also reuse any GEANT4 C++ code (from the user, from GEANT4 examples, …)

Transform C++ code into user commands in a very simple way

The third objective is to provide a comprehensive set of tools: to extract the required information and optimize an application

Flexible user actions + filters & classifiers

Powerful scoring framework

Utilities to optimize CPU in a simple way

GAMOS objectives

Page 6: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 6

Most users will be able to do their simulation with simple user commands If they want to have something not foreseen by the framework use plug-

in’s

GAMOS has no predefined components At run-time user selects which components to load through user commands They are loaded through the plug-in mechanism

User has full freedom in choosing components

User can define a component not foreseen by GAMOS

Take a C++ class and use it through an user command

Mix it with any other component

For example: instead of GAMOS generator use the one from G4 example underground_physics

DEFINE_GAMOS_GENERATOR(DMXPrimaryGeneratorAction);

and then you can select it in your script

/gamos/generator DMXPrimaryGeneratorAction

For the plug-in's implementation in GAMOS it has been chosen the CERN library: SEAL

GAMOS plug-in´s

Page 7: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 7

GAMOS started as a framework beginning 2007 to help in the simulation of CIEMAT PET detector projects

it was after extended for radiotherapy applications

GATE was considered and rejected because it was too rigid: not possible to

simulate the projects at CIEMAT Compton-PET detector

BrainPET (optical photons)

Pixel-PET (trapezoidal detectors, different hit logic)

GAMOS is the fruit of several years experience developing Geant4-based frameworks Member of Geant4 since 1998

Coordination of the CMS Geant4 framework during its first years The first LHC Geant4 framework to be fully operative

Coordination the HARP (PS) Geant4 framework (by nomination from S.Giani, first

Geant4 spokeman)

CIEMAT group had several years experience with PET detectors and radiotherapy

GAMOS history

Page 8: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 8

Functionality

Page 9: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 9

Three different ways to define it:

C++ code: The usual GEANT4 way Add one line to transform your class in a plug-inDEFINE_GAMOS_GEOMETRY (MyGeometry);

so that you can select it in your input macro/gamos/geometry MyGeometry

Define it in ASCII (text) files The easiest way to define a geometry Based on simple tags Same order of parameters as corresponding GEANT4 classes

Using one of the GAMOS examples for simple cases Simple PET can be defined through an 8-parameters file (n_crystals,

crystal_x/y/z, radius, …) Simple phantoms with a few user commands

Geometry

Page 10: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 10

Based on simple tags, with same order of parameters as corresponding GEANT4 classes

:MATE Cu 29 63.54 8.9333*g/cm3:VOLU yoke TUBE  62.*cm 820. 1.27*m Cu:ROTM RM0 0. 0. 0.:PLACE  yoke  1   expHall  RM0   0.   0.   370.*cm

MATERIALS: Isotopes Elements Simple materials Material mixtures by weight, volume or number of atoms GEANT4 intrinsic materials + 300 predefined materials common in medical field

SOLIDS: All GEANT4 “CSG” and “specific” solids Twisted solids Tesellated solids Boolean solids

ROTATION MATRICES: 3 rotation angles around X,Y,Z 6 theta and phi angles of X,Y,Z axis 9 matrix values

Geometry from text files

Page 11: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 11

PLACEMENTS: Simple placements Divisions Replicas Parameterisations

Linear, circular or square

For complicated parameterisations example of how to mix the

C++ parameterisation with the ASCII geometry file

COLOUR

VISUALISATION ON/OFF

PARAMETERS: Can be defined to use them later

:P InnerR 12. :VOLU yoke :TUBS  Iron   3  $InnerR 820. 1270.

ARITHMETIC EXPRESSIONS: Elaborated expressions can be used

:SOLID yoke TUBE sin($ANGX)*2+4*exp(1.5) 820. 1270.

UNITS: Default units for each parameter

Each value can be overridden by user

Geometry from text files

Page 12: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 12

INCLUDE OTHER FILES (hierarchical approach):#include mygeom2.txt.

User can extend it: add new tags and process it without touching base code

Can mix a C++ geometry with a text geometry

GEANT4 in memory geometry text files

Install and use it as another GEANT4 library

G4VPhysicalVolume* MyDetectorConstruction::Construct(){

G4tgbVolumeMgr* volmgr = G4tgbVolumeMgr::GetInstance();

volmgr->AddTextFile(filename); // SEVERAL FILES CAN BE ADDED

return = volmgr->ReadAndConstructDetector();

HISTORY: In use to build GEANT4 geometries since 10 years ago

An evolving code… It is part of the GEANT4 release since December ‘08

Geometry from text files

:ROTM R00 0. 0. 0.:VOLU world BOX 100. 100. 100. G4_AIR:VIS world OFF:VOLU "my tube" TUBE 0. 10. 20. G4_WATER:P POSX 5:PLACE "my tube" 1 world R00 0. 0. -$POSX:VOLU sphere ORB 5. G4_Si:PLACE sphere 1 "my tube" R00 0. 1. $POSX

Page 13: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 13

User can move a volume by using commands

Displacements or rotations Every N events or every interval of time N times or forever Offset can be defined Several movements of the same volume or different ones

can be set

Movements

Page 14: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 14

GeneratorC++ code• The usual GEANT4 way• Add one line to transform your class in a plug-in DEFINE_GAMOS_GENERATOR(MyGenerator); so that you can select it in your input macro/gamos/generator MyGenerator

GAMOS generator• Combine any number of single particles or isotopes decaying to e+, e-, • For each particle or isotope user may select by user commands any combination of

time, energy, position and direction distributions Or create its own and select it by a user command (transforming it into a plug-in)

/gamos/generator/directionDist source GmGenerPositionDiscGaussian 1.*mm/gamos/generator/timeDist source GmGenerTimeDecay

Page 15: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 15

Generator distributionsPOSITION:Point Square RectangleDisc DiscGaussian LineStepsInG4Volumes (sphere/box/tube_section/ellipsoid) InG4VolumeSurfaces (sphere/box/tube_section/ellipsoid) InG4VolumesGeneral (any solid) VoxelPhantomMaterials

DIRECTION:Random Const Cone

ENERGY:

Constant Gaussian RandomFlat

BetaDecay ConstantIsotopeDecay

TIME:Constant Decay

POSITION & DIRECTION:InVolumeSurfaceTowardsCentre TowardsBox

A template provided for each type: users only have to write a few C++ lines to create their own distribution

F18 decay

Page 16: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 16

Physics

C++ code

• The usual GEANT4 way

• Add one line to transform your class in a plug-in

DEFINE_GAMOS_PHYSICS_LIST (ExN02PhysicsList);

so that you can select it in your input macro

/gamos/physicsList ExN02PhysicsList

Any GEANT4 physics list can be easily selected through a user command

GAMOS physics list

• Based on hadrotherapy advanced example

• User can combine different physics lists for photons, electrons,

positrons, muons, protons and ions

• A dummy one for visualisation

Page 17: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 17

User actions They are the main way for a user to extract information of what is

happening and modify the running conditions: flexible framework is

needed

User can have as many user actions of any type as desired Only 1 of each type in GEANT4

One user action can be of several types (run/event/stacking/tracking/stepping) Only 1 class - 1 type in GEANT4

User actions can use filters and classifiers /gamos/userAction GmTrackHistosUA GmGammaFilter

User can activate any user action by a user command

User can create new user actions

• Just adding a line to transform it into a plug-inDEFINE_GAMOS_USER_ACTION(MyUserAction);

that can be selected with a user command

/gamos/userAction MyUserAction

Page 18: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 18

Sensitive Detectors

To produce hits in GEANT4 a user has to (with C++): Define a class inheriting from G4VSensitiveDetector Associate it to a G4LogicalVolume Create hits in the ProcessHits method Clean the hits at EndOfEvent

In GAMOS you can do all this with a user command

/gamos/assocSD2LogVol SD_CLASS SD_TYPE LOGVOL_NAME

• SD_CLASS: the G4VSensitiveDetector class• SD_TYPE: an identifier string, so that different SD/hits can have different treatment

Users can create her/his own SD class and make it a plug-in

DEFINE_GAMOS_SENSDET(MySD);

Page 19: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 19

Hits

A GAMOS hit has the following information:• ID of the sensitive volume copy

• event ID

• energy

• time of the first E deposit

• time of the last E deposit

• position

• list of all tracks that contributed

• list of all ‘primary´tracks that contributed

• list of all deposited energies

• SD type

Users can create his/her own hit class

Hits can be stored in a job and read in another job• Format compatible with STIR software (PET reconstruction)

511 keV photoelectric (PE) peak

escapepeak

backscattering peak

Bi fluorescencepeak

E > 511 keVphotoelectric

peaks

/gamos/userAction GmHitsHistosUA

Page 20: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 20

Detector effects

Measuring time - A detector is not able to separate signals from different events if they come close in time

Dead time - When a detector is triggered, this detector (or even the whole group it belongs to) is not able to take data during some time

- Paralizable or non-paralizable

• Both can be set by the user in the input macro• A different time for each SD_TYPE

/gamos/setParam SD:MeasuringTime:MySD_1 1000.*ns

/gamos/setParam SD:MeasuringTime:MySD_2 250.*ns

Page 21: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 21

Hits digitization and reconstruction

• Framework to transform simulated hits digital signals reconstructed hits (energy/time/position)

• Digitization and hits reconstruction are very detector specific : it is not possible to provide a general solution

• GAMOS just provide a few simple digitizers and hits reconstructor s

• 1 hit 1 digit• Merge hits close enough

• Same set of sensitive volumes• Closer than a given distance

• … and a basic structure• Hits compatible in time

• spanning various events• Trigger• Pulse simulation• Sampling• Noise

-- hits-- clusters of hits

/gamos/userAction GmHitsHistosUA/gamos/userAction GmRecHitsHistosUA

Page 22: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 22

Histogramming Own format: can write histograms in text files (CSV) without any external dependency

Read them in Excel, Matlab, Origin, GNUplot, … Also ROOT histograms supported AIDA will be supported soon

0

500

1000

1500

2000

2500

Energy

N e

ntr

ies

++

MS Excel graphics of energy of e+ from F18 decay

/gamos/userAction GmGenerHistosUA/gamos/analysis/fileFormat CSV

Page 23: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 23

Histogramming

Same code to create and fill histograms independent of the format

• GAMOS takes care of writing the file in the chosen format at the end of job

Easy for a user to create a new one GmAnalysisMgr keeps a list of histograms so that they can be accessed from any part of the code, by number or name

GmAnalysisMgr::GetInstance(“pet”)->GetHisto1(1234)->Fill(ener);

GmAnalysisMgr::GetInstance(“pet”)->GetHisto1(“CalorSD: hits energy”)->Fill(ener);

There can be several files, each one with its own histograms• When creating an histogram, user chooses file name

User can define a suffix name, so all histogram files of a job

will have a unique identification/gamos/setParam GmAnalysisMgr:FileNameSuffix testParam_1

Page 24: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 24

Parameter management

Many classes change their behaviour depending on the value of some parameters that the user can set

GAMOS utilities use parameters extensively to maximise the flexibility

Always a default value in case the user does not care

Parameters can be numbers, strings, list of numbers or list

of strings

GAMOS provides a unique command to manage all these parameters

• A parameter is defined in the input macro/gamos/setParam SD:EnergyResol 0.1

• Any class can use this value in any part of the codefloat enerResol = GmParameterMgr::GetInstance()

->GetNumericValue(“SD:EnergyResol”,0.);

Page 25: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 25

ScoringScoring is an important part of your simulation powerful and flexible framework developed:

Many possible quantities can be scored in one or several volumes● Dose ● Deposited energy ● Flux (in/out/passage)● Current (in/out/passage) ● Charge ● Step length● Number of particles ● Number of interactions ● Number of 2ary particles● Number of steps ● Minimum kinetic energy

For each scored quantity one or several filters can be used• Only electrons, only particles of a certain energy range, …

Several ways to classify the different scores• One different score for each different volume copy, or volume name, or energy bin, …

Results can be printed in one or several formats for each scored

quantity• Standard output, text file, binary file, histograms

All scored quantities can be calculated with/without errors

All scored quantities can be calculated per event or per job • Taking into account correlations from particles from same event

Everything managed with user commands

Page 26: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 26

Analysis and

Optimisation

Page 27: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 27

Analysis and optimisation

We have made a substantial effort to provide tools to help users in

Knowing all the details of what is happening in the simulation

Optimising GEANT4 for her/his application

Flexible user actions Flexible and powerful scoring Many control histograms Detailed verbosity control Detailed CPU time study Profiling your simulation Setting physics cuts by volumes through user commands Automatic optimisation of cuts Variance reduction techniques

Page 28: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 28

Control histograms

Many control histograms, available through user commands: Track/step: initial energy, energy lost, energy deposited, number of steps, track length, step length,

position, deviation Secondaries (for each process type): number of secondaries, energy of secondaries, total energy lost,

step length, energy of primary, angle deviation of primary, angle primary-secondary Primary generator: energy, 1D and 2D positions, angles, time between events Table of interactions: how many times each process type happened, how many times a particle was

created by a process type Hits (for each SD type): number of hits, energy, number of energy deposits, width, time span, distance

between hits, positions (Cartesian, cylindrical) Reconstructed hits (for each SD type): number of rechits, energy, number of hits, width, time span,

distance between hits, positions (Cartesian, cylindrical) Positron: initial energy, final energy, final time, final range, final distance to origin, gamma energies,

gamma angles, range vs energy, range vs distance, … PET: distance PET line to vertex, hit energies, positron gammas histos (to disentangle detector effects) PET classification table: true/scatter/random coincidences/random&scatter, close or far from vertex,

recovered Compton hits or not Radiotherapy phase space: X, Y, XY, theta, phi, energy, Vx, Vy, Vz Radiotherapy dose in phantoms: dose, dose-volume, PDD, profile, user selection of voxels

Page 29: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 29

Control histograms

Controlled by filters● Start/End/Enter/Exit/Traverse/In LogicalVolume/PhysicalVolume/Touchable/Region (24 filters) ● Gamma ● Electron ● Positron

● Particle in list ● Energy in an interval ● Primary● Secondary ● Step Number ● Inverse filter ● OR filter ● XOR filter● Filter with history (pass filter in any previous track step)● Filter with ancestor history (one ancestor pass filter in any previous track step)

and classifiers

● ByParticle ● ByKineticEnergy ● By1Ancestor

● ByNAncestors ● ByLogicalVolume ● ByPhysicalVolume

● ByTouchable ● ByRegion ● ByExtraInfoPhaseSpace

Filters and classifiers are plug-in’s: more can be easily added

+200 histograms & 23 scorers + 44 filters & 12 classifiers, all managed with

simple user commands: vast amount of possibilities to extract required

information User actions/scorers/filters/classifiers are plug-in’s: easy to add a new one

Page 30: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 30

Verbosity

Verbosity controlled through user commands Different verbosities for different simulation parts (geometry, physics,

generator, PET, radiotherapy, …) 6 levels of verbosity (silent, error, warning, info, debug, test) Selectable by user commands/gamos/verbosity PETVerbosity debug

Verbosity managers are plug-ins: user can easily create its own one

GEANT4 tracking verbosity can be controlled by event and by

track some events very verbose, others not /gamos/setParam GmTrackingVerboseUA:EventMin 14632 /gamos/setParam GmTrackingVerboseUA:EventMin 14635 /gamos/setparam GmTrackingVerboseUA:TrackMin 1 /gamos/setparam GmTrackingVerboseUA:TrackMax 20

Page 31: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 31

Optimisation: time studies

User commands to get CPU time study By particle, energy bins, volume, region (or combination of them)

Just add a user command:/gamos/userAction GmTimeStudyUA GmClassifierByParticle GmClassifierByEnergy

gamma/0.001-0.01: User=0.01 Real=0 Sys=0gamma/0.01-0.1: User=2.01 Real=2.45 Sys=0.27gamma/0.1-1: User=19.12 Real=22.05 Sys=1.51gamma/1-10: User=4.25 Real=5.4 Sys=0.3e-/0.0001-0.001: User=0.07 Real=0.1 Sys=0e-/0.001-0.01: User=0.54 Real=0.69 Sys=0.06e-/0.01-0.1: User=4.71 Real=5.41 Sys=0.38e-/0.1-1: User=15.59 Real=18.19 Sys=1.79e-/1-10: User=82.83 Real=98.62 Sys=7.45

Example to get detailed gprof profiling about where (in which methods) the time is spent

Time spent in a method and integrated time in all the methods called by it

Page 32: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 32

Optimisation: setting cuts All GEANT4 commands are available, for example to control cuts and electromagnetic physics parameters

Cuts by region can be defined through user commands or in the

TEXT geometry file

Automatic conversion energy cut range cutJust add two user commands:/gamos/userAction GmCutsEnergy2RangeUA/gamos/ECuts2RangeCuts * 10.*keV gamma

MATERIAL: G4_AIR PART: gamma ENERGY CUT: 0.01 (MeV) = RANGE CUT: 17407.7 (mm)MATERIAL: G4_Cu PART: gamma ENERGY CUT: 0.01 (MeV) = RANGE CUT: 0.185575 (mm)MATERIAL: G4_W PART: gamma ENERGY CUT: 0.01 (MeV) = RANGE CUT: 0.0149411 (mm)

User limits can be attached to one/several logical volume(s) through user commands

MaxStep, MaxTrkLength, MaxTOF, MinKinE, MinRange

Automatic determination of best cuts and user limits in one job

Method based on tagging particles instead of killing them

Page 33: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 33

Applications

Page 34: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 34

PET Any PET detector can be simulated with simple text format Utility to create siple geometries from a few parameters (number of crystals per block, number of block per ring, radius, ...)

Several sensitive detectors types selectable by user commands User can create it own one and make it a plug-in

Automatic creation of hits with detailed information/gamos/assocSD2LogVol GmSDSimple SD_TYPE VOLUME_NAME Writing hits into text or binary file

Retrieving them in next job (for doing parametric studies) Format compatible with STIR software

Digitizer and reconstructed hits framework and examples

Detector effects Energy resolution Time resolution Dead time (paralyzable / non-paralyzable) Measuring time PET coincidence time

LSO

LaBr3

Page 35: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 35

PET

Table of PET classification True / scattered / random coincidences / scattered&random PET line far or close to vertex Optionally merge hits if there is more than one because of Compton

interactions

Histograms of hits or reconstructed hits with a user command Histograms of positron history Histograms of PET information

Several detectors simulated with GAMOS: CTI ECAT Exact (922) GE Discovery ST (PET/CT) ClearPET BrainPET (optical photons) Pixel-PET prototype

Results agree with data

Page 36: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 36

Any accelerator (with any kind of MLCs) can be simulated with simple text

format Building complicated parts (MLCs/jaws/applicators) with a few parameters under progress

Write phase space files in IAEA format Several Z planes in the same job Stop after last Z plane or not Save header after N events (not to lose

everything if job is aborted) Save extra info:

Regions particle traversed Regions particle created Regions particle interacted Particle origin Z More can be easily added (they are plug-in’s)

Kill particles at big XY at different Z’s Automatic or user-defined limits

Command for replication of particles at a given Z (no need to write phase space)

Command for optional histograms by particle type at each Z plane

Radiotherapy: accelerator

Page 37: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 37

Reading IAEA phase space files

Displace or rotate phase space particles

Reuse phase space particles Optional automatic calculation of reuse number

Optional mirroring in X, Y or XY

Recycle phase space files

Command for skipping of first N events

Command for optional histograms of particles read

Filter particles by extra info

Also read EGSnrc phase space format

Radiotherapy: read PS files

Page 38: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 38

Use DICOM files Read GEANT4 format (example advanced/medical/DICOM: DICOM ASCII)

Read EGS format

Split one material in several if voxel densities are different User defines an interval width and a new material is created for the densities at each

interval

Displace or rotate read-in phantom geometry

PTV/CTV/GTV management

Simple phantoms can be created with a few commands Define voxel limits

Define number of voxels

Define material for each Z plane

Geant4 allows to build parallel worlds But only geometry is seen, not materials (=no interactions)

We have developed a tool that allows to insert objects in phantom geometries and produce

the interactions in them

Realistic simulation of brachytherapy sources or ionisation chambers!

Radiotherapy: phantom geometry

Page 39: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 39

Fast navigation (4-5 times faster than any other G4

algorithm) Released in official Geant4 release

Different printing formats in each run Text in standard output

Dose histograms (X, Y, Z, XY, XZ, YZ, dose, dose-volume) User can define several XY, XZ, YZ planes (= simple dose visualisation)

File with dose and error at each voxel

File with dose and dose2 at each voxel (to properly take into account

correlations)

Dose in total or by event Proper management of original number of events when reading phase

space files

Radiotherapy: dose in phantom

Page 40: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 40

Radiotherapy

gMocren visualisation of DICOM geometry and tracks

Page 41: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 41

Radiotherapy

IMRT dose visualisation with CIEMAT’s tool (MIRAS)

Page 42: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 42

A set of easy-to-use executables and ROOT scripts

Phase space files Sum phase space files Analyse phase space files

Statistics Histograms by particle type at each Z plane

(= histograms when writing PS) Compare two phase space files

Dose files Sum dose files Analyse dose files

Statistics Dose histograms (X, Y, Z, XY, XZ, YZ, dose,

dose-volume) (= histos when writing dose) Compare two dose files

GUI under development (MIRAS project)

Radiotherapy: analysis

PDDPDD

aa

Datos exper. - GAMOS

Datos exper. - GAMOS

Position (mm)

Position (mm)

Do

se

(no

rmal

ized

)

Do

se

(no

rmal

ized

)

Page 43: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 43

GEANT4 electromagnetic parameters are not optimised for radiotherapy They cover a wide range of energy and applications they have to be

conservative We have started to optimise GEANT4 electromagnetic parameters for

radiotherapy: http://kds.kek.jp/contributionDisplay.py?contribId=50&sessionId=2&confId=2027

VARIAN 2100 gamma accelerator: 106 events on Pentium Dual-Core 3

GHzEGSnrc GAMOS/GEANT4 GAMOS/GEANT4

(auto. optim cuts)

6 MeV 277.3 s 272.8 s 226.1 s18 MeV* 1020 s 897 s 499 s

Radiotherapy: optimisation

DOSXYZnrc GAMOS/GEANT4 GAMOS/GEANT4(auto. optim cuts)

water 234.2 s 149.4 s 104.4 s

patient 299.6 s 210.4 s 208.7 s

Dose in 104 5x5x3 mm water phantom: 106 events on Pentium Dual-Core 3 GHzDose in 4.5 106 patient, 23 materials: 106 events on Pentium Dual-Core 3 GHz

* Same parameters as for 6MeV

Page 44: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 44

Radiotherapy: variance reduction

Three bremsstrahlung splitting techniques are available through user commands

Uniform bremsstrahlung splitting Z-plane direction bremsstrahlung splitting Particle splitting

Split particles at each interaction to get equal weights at phantom Inspired on EGSnrc DBS

Preliminary efficiency gain of a factor 45 (EGSnrc DBS a factor 80

in same accelerator)

Other techniques are under study

Page 45: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 45

Documentation Installation

Usage

Page 46: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 46

Documentation

User’s Guide: Installation All available functionality How to provide new functionality by creating a plug-in

Examples:

A simple one and a few more complicated ones/gamos/setParam GmGeometryFromText:FileName mygeom.txt/gamos/geometry GmGeometryFromText/gamos/physics GmEMPhysics/gamos/generator GmGenerator/run/initialize/gamos/generator/addIsotopeSource myF18 F18 1.E6*becquerel/run/beamOn 10

Page 47: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 47

Documentation

Tutorials:

Three tutorials PET tutorial Radiotherapy tutorial plug-in tutorial

Propose about 15 exercises each Explained in detailIncreasing in difficulty Reference output provided Solutions provided

4 GAMOS tutorial courses have been given About 70 attendees

Page 48: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 48

Installation

GAMOS is freely available from CIEMAT web• User registers and downloads installation scripts

We provide a no-choice but very easy way: one-line installationsource installGamos.csh/sh $HOME/gamos

Installs and compiles SEAL, CLHEP, Geant4 and (optionally) ROOT in one directory GAMOS compiles = Geant4

Optionally an expert user can make several choices

Current installation tested in Scientific Linux 4, Fedora Core 6,7,8 and Ubuntu 8.04

But installing a software on linux is never easy…We have paid an expert to work for three months on GAMOS installation (autoconfiguration tools)

Starting end of May And also on the Web and automatic testing

Page 49: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 49

Release and user support

One release every three months Minor releases in between

Major releases are checked in two different platforms 50 tests are run An automatic comparison tool is under progress

Two mailing lists for support:• For users: [email protected]• For developers: [email protected]

Page 50: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 50

Usage

Several groups are using GAMOS in Spain: CIEMAT (Medical Physics Applications): PET CIEMAT (Dosimetry): microdosimetry CSIC: microdosimetry Univ. Sevilla: gamma radiotherapy Univ. Navarra: brachytherapy Hosp. General Albacete: gamma radiotherapy CIEMAT-Hosp. Puerta de Hierro, Madrid: gamma radiotherapy, tomotherapy CNM Barcelona: effects in detector electronics

And abroad: CEADEN (Cuba): PET Univ. UPCH (Perou): PET Univ. UNSAAC (Perou): astroparticle physics Univ. Autónoma Chiapas (Mexico): gamma radiotherapy Vrije Univ. Brussel (Belgium): PET INFN Torino: PET

And some groups (including Geant4 developers) have shown interest in helping in GAMOS development:

Hosp. Santa e Croce (Torino): radiotherapy A group in the USA: use GAMOS as base for a hadrontherapy application

Page 51: GAMOS May 18th 2009 1 GAMOS an easy and flexible framework for GEANT4 simulations Pedro Arce Juan Ignacio Lagares Pedro Rato Mendes Mario Cañadas (CIEMAT)

GAMOS May 18th 2009 51

Summary

GAMOS is a user-friendly and flexible framework many utilities allow to do full GEANT4 simulation through user commands plug-in’s allow to extend functionality by converting C++ classes into user

commands, by adding one or a few lines

Special effort to provide analysis and optimisation tools flexible and powerful framework to extract detailed information several tools to optimise CPU performance

GAMOS core is application independent Several medical applications are being built on top of GAMOS core

PET and radiotherapy fully functional

http://fismed.ciemat.es/GAMOS