Geant4 tutorial european medical physics school archamps france
Download
1 / 79

Geant4 Tutorial European Medical Physics School, Archamps, France - PowerPoint PPT Presentation


  • 156 Views
  • Uploaded on

Geant4 Tutorial European Medical Physics School, Archamps, France. Overview of the contents. Software process Geant4 advanced example brachytherapy Integration of the brachytherapy application in a distributed computing environment Run the brachytherapy example . Software Process.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Geant4 Tutorial European Medical Physics School, Archamps, France' - alice


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Geant4 tutorial european medical physics school archamps france

Geant4 TutorialEuropean Medical Physics School, Archamps, France


Overview of the contents

Overview of the contents

Software process

Geant4 advanced example brachytherapy

Integration of the brachytherapy application

in a distributed computing environment

Run the brachytherapy example


Software process

Software Process

How to develop a rigorous and reliable

software application

Documentation:http://www.ge.infn.it/geant4

link: training, software engineering documentation


Software process1
Software process

For example, a process model is the

Unified Software Development Process (USDP)

Iterative-incremental method

Concepts:

  • User Requirements

  • Define the software functionality

  • Design

  • Project of the software structure

  • Implementation

  • Test


Capture User Requirements

Define the scope of the software system to be built (“what it should do”)


How to collect user requirements

How to collect User Requirements

Example of User Requirement

UR1. The user shall be able to define electromagnetic processes for gamma

Need: Essential

Priority: High

Source: ESA


Collect User Requirements

in proper domains

User Requirements


Design

Define the structure of the software by a

software engineering point of view


Design

OOAD

Primary

particles

Design

Physics

Run

Event

Analysis

Detector

Visualisation


Software development

design

implementation

test

Software development

UR1

Test phase is crucial and extremely

important


Test

  • Important and crucial issue

  • Always in respect to experimental data

  • Comparisons in respect to other MC toolkit are just

    curiosity

  • Levels of tests:

  • Microscopic test

    Test on components of the application (i.e. Physics models adopted)

  • Macroscopic test

    Test on the experimental set-up (physics, geometry, etc. together)


Iterative incremental method

implementation

UR1

design

test

UR3

design

implementation

test

UR2

test

implementation

design

Iterative, incremental method

  • Gain feedback on the developed software:

    Examples: - Is the UR satisfied?

    - Do we need new UR?

    - How can we improve the software ?

  • UR1

  • UR2

  • UR3

…..


Documentation
Documentation

  • User Requirement document

  • Design

  • Traceability documents

  • How to use the software application

  • Comments in the code

  • Software process and documentation are important for:

  • Develop a rigorous and reliable software

  • Develop clear and clean software

  • Limit the possibility of introducing bugs

  • Help other people to understand the software application


Geant4 brachytherapy advanced example

Geant4 brachytherapy advanced example

F. Foppiano3, S.Guatelli2,J.Moscicki1, M.G. Pia2

CERN1 ,INFN Genova2, National Institute for Cancer Research, IST Genova3

www.ge.infn.it/geant4, advanced examples


Brachytherapy

Endocavitary

brachytherapy

(lungs, uterus)

Brachytherapy

  • Brachytherapy is a medical therapy used for cancer treatment

Radioactive sources are used to deposit therapeutic doses near tumors, while preserving surrounding healthy tissues

  • Treatment planning: how to set (where?, how long?)

  • radioactive sources in treatment’s target area

Superficial brachytherapy(skin)

  • Software is used to define patient’s treatment planning

  • It calculates the dose in the patient

Interstitial brachytherapy (prostate)


Commercial software for brachytherapy
Commercial software for brachytherapy

  • Various commercial software products for treatment planning

  • No commercial software available for superficial brachytherapy with Leipzig applicators

Precision

  • Based on approximated analytical methods, because of speed constraints

  • Uniform material: water

Cost

  • Each software is specific to one technique

  • Treatment planning software is expensive (~ hundreds K $/euro)


dosimetric

system

precise

Develop a

general purpose

Patient’s anatomy modeling

with the capability of

interface to CT images

with a

user-friendly interface

adequate speed for clinical usage

performing at


Requirements
Requirements

Calculation of3-D dose distributionin the treatment area

Determination ofisodose curves

Based on Monte Carlo methods

Accurate description of physics interactions

Precision

Accurate model of the real experimental set-up

Realistic description of geometry and tissue

Possibility to interface to CT images

Simple user interface + Graphic visualisation

Elaboration of dose distributions and isodoses

Easy configuration

for hospital usage

Parallelisation

Access to distributed computing resources

Speed

Transparent

Open to extension and new functionality

Publicly accessible

Other requirements


User requirements
User Requirements

The application provides the simulation of energy deposit of brachytherapic sources in a phantom

1.The user shall be able to visualise the geometry involved and the trajectories of the particles

1.The phantom is a box

2.The user shall be able to change the absorber material of

the phantom

3.The user shall be able to model patient anatomy

4.The dose should be collected in 1. mm wide voxels

  • Geometry

1. Particles: e+,e-, gamma

2. Low Energy electromagnetic processes

  • Physics

  • 1. The user shall be able to calculate the total absorbed energy in the phantom:

    • 3D distribution in the volume

    • 2D distribution in the plain containing the source

  • Analysis

  • Visualisation


Precision

Based on Monte Carlo methods

Experimental validationof physics involved

Microscopic validation of the physics models

Comparison with experimental data

specific to the brachytherapic practice


Low energy package
Low Energy Package

Validity range: 250 eV – 100 GeV

250 eV is a “suggested” lower limit

data libraries down to 10 eV

1 < Z < 100

Exploit evaluated data libraries(from LLNL):

EADL (Evaluated Atomic Data Library)

EEDL (Evaluated Electron Data Library)

EPDL97 (Evaluated Photon Data Library)

for the calculation of total cross section and generation

of the final state

Photon transmission, 1mm Al

shell effects

Photon transmission, 1mm Pb

shell effects

  • Compton scattering

  • Rayleigh scattering

  • Photoelectric effect

  • Pair production

  • Bremsstrahlung

  • Ionisation

    • + atomic relaxation


Photon attenuation coefficient

Simulation

Nucletron

Data

Stopping power

2N-L=13.1 – =20 - p=0.87

NIST

Geant4-LowE

Geant4-Standard

2N-S=23.2 – =15 - p=0.08

NIST

Geant4-LowE

Geant4-Standard

Al

Al

F. Foppiano et al., IST Genova

Distance along Z (mm)

Microscopic validation

Photons and electron physics processes

Dosimetric validation

Comparison to

protocol data,

original experimental data


General purpose system

For any brachytherapy technique

Object Oriented technology

Software system designed in terms of Abstract Interfaces

For any source type

Abstract Factory design pattern

Source spectrum and geometry transparently interchangeable


Flexibility of modeling
Flexibility of modeling

  • Configuration of

  • any brachytherapy technique

  • any source type

  • through an Abstract Factory

  • to define geometry, primary spectrum

Abstract Factory

  • CT DICOM interface

  • through Geant4 parameterised volumes

  • parameterisation function: material

  • Phantom

  • various materials

  • water, soft tissue, bone, muscle etc.

General purpose software system for brachytherapy

No commercial general software exists!


Realistic model

of the experimental set-up

Radioactive source

Spectrum (192Ir, 125I)

Geometry

Patient

Phantom with realistic material model

Possibility to interface the system to CT images


Model of a i 125 brachytherapic source geometry and materials

Model the source geometry

Model of a I-125 brachytherapic sourcegeometry and materials

Precise geometry and material model of any type of source

Titanium capsule tips

Titanium tube

Iodium core

Golden

marker

Air

Titanium tube:

Outer radius:0.40mm

Half length:1.84mm

Iodium core:

Inner radius :0

Outer radius: 0.30mm

Half length:1.75mm

Golden marker:

Inner radius :0

Outer radius: 0.085 mm

Half length:1.75mm

Air:

Outer radius:0.35mm

half length:1.84mm

Ir-192 source + applicator

for superficial brachytherapy

Titanium capsule tip:

Semisphere

radius:0.40mm

Ir-192


Effects of source anisotropy

Effects of source anisotropy

Simulation

Plato

Simulation

Plato

Data

Distance along X (mm)

Distance along Z (mm)

Effects of source anisotropy

Plato-BPS treatment planning algorithm makes some crude approximation

( dependence,

no radial dependence)

Rely onsimulation for better accuracy than conventional treatment planning software

Transverse axis of the source

Comparison with experimental data

Longitudinal axis of the source

Difficult to make direct measurements


Modeling the patient

source

Modeling the patient

Modeling a phantom

Modeling geometry and materials from CT data

of any material

(water, tissue, bone, muscle etc.)

thanks to the flexibility of Geant4 materials package


DICOM

DigitalImagingandCOmunicationinMedicine

Computerized Tomography allows to reproduce the real 3D geometry of the patient

3D patient anatomy

Acquisition of CT image

file

Pixels

grey tone proportional to material density

DICOM is the universal standard for sharing resources between heterogeneous and multi-vendor equipment


Geant4 dicom interface
Geant4-DICOM interface

  • Developed by L. Archambault, L. Beaulieu, V.-H. Tremblay (Univ. Laval and l'Hôtel-Dieu, Québec)

  • Donated to Geant4 for the common profit of the scientific community

    • under the condition that further improvements and developments are made publicly available to the community

  • Released with Geant4 5.2, June 2003 in an extended example

    • with some software improvement by S. Guatelli and M.G. Pia

  • First implementation, further improvements foreseen


User-friendly interface

to facilitate the usage in hospitals

AIDA + Anaphe

Dosimetric analysis

Store simulation information in histograms and ntuples

Graphic visualisation of dose distributions

Web interface

Application configuration

Job submission


Dosimetry

Dose distribution

Analysis of the energy deposit in the phantom resulting from the simulation

Isodose curves

Dosimetry

Simulation of energy deposit through

Geant4 Low Energy Electromagnetic package

to obtain accurate dose distribution

Production threshold: 100 mm

AIDA + Anaphe

for analysis


Data Analysis

source

AIDA

Histograms

Ntuples

Data vectors

Fit

Visualisation of results

Abstract Interfaces for Data Analysis

Energy deposit

(2D histogram)

Primary particles

Energy Spectrum

(1D histogram)

http://aida.freehep.org


0.16 mGy =100%

Isodose curves

Dosimetry

Interstitial

brachytherapy

Bebig Isoseed I-125 source

Superficial

brachytherapy

MicroSelectron-HDR source

Endocavitary

Brachytherapy

Leipzig applicator


Application configuration
Application configuration

Fully configurable from the web

  • Run modes:

  • demo

  • parallel on a cluster

  • (under test)

  • on the GRID

  • (under development)

Type of source

Phantom configuration

# events


Speed adequate for clinic use

Parallelisation

Transparent configuration in sequential or parallel mode

Access to distributed computing resources

Transparent access to the GRID through an intermediate software layer


Performance
Performance

Endocavitary brachytherapy

1M events

61 minutes

Superficial brachytherapy

1M events

65 minutes

Interstitial brachytherapy

1M events

67 minutes

on an “average” PIII machine, as an “average” hospital may own

Monte Carlo simulation is not practically conceivable for clinical application, even if more precise


Performance parallel mode

preliminary: further optimisation in progress

prototype for an intermediate layer between applications and the GRID

Performance: parallel mode

Endocavitary brachytherapy

1M events

4 minutes 34’’

Superficial brachytherapy

1M events

4 minutes 25’’

1M events

4 minutes 36’’

Interstitial brachytherapy

Diane has been developed by J. Moscicki

E-mail: [email protected]

http://www.cern.ch/diane

on up to 50 workers, LSF at CERN, PIII machine, 500-1000 MHz

Performance adequate for clinical application, but…

it is not realistic to expect any hospital to own and maintain a PC farm


Running on the grid
Running on the GRID

  • Via DIANE

  • Same application code as running on a sequential machine or on a dedicated cluster

    • completely transparent to the user

Distributed Geant4 application

A hospital is not required to own and maintain extensive computing resources to exploit the scientific advantages of Monte Carlo simulation for radiotherapy

Any hospital

– even small ones, or in less wealthy countries, that cannot afford expensive commercial software systems –

may have access to

advanced software technologies and tools for radiotherapy


Traceback from a run on crossgrid testbed

Current #Grid setup (computing elements):

5000 events, 2 workers, 10 tasks (500 events each)

- aocegrid.uab.es:2119/jobmanager-pbs-workq

- bee001.ific.uv.es:2119/jobmanager-pbs-qgrid

- cgnode00.di.uoa.gr:2119/jobmanager-pbs-workq

- cms.fuw.edu.pl:2119/jobmanager-pbs-workq

- grid01.physics.auth.gr:2119/jobmanager-pbs-workq

- xg001.inp.demokritos.gr:2119/jobmanager-pbs-workq

- xgrid.icm.edu.pl:2119/jobmanager-pbs-workq

- zeus24.cyf-kr.edu.pl:2119/jobmanager-pbs-infinite

- zeus24.cyf-kr.edu.pl:2119/jobmanager-pbs-long

- zeus24.cyf-kr.edu.pl:2119/jobmanager-pbs-medium

- zeus24.cyf-kr.edu.pl:2119/jobmanager-pbs-short

- ce01.lip.pt:2119/jobmanager-pbs-qgrid

Spain

Greece

Poland

Portugal

Traceback from a run on CrossGrid testbed

Resource broker running in Portugal

matchmaking CrossGrid computing elements


Summary
Summary

  • A precise dosimetric system, based on Geant4

    • Accurate physics, geometry and material modeling, CT interface

  • Full dosimetric analysis

    • AIDA + Anaphe

  • Simple interface

    • configuration from WWW

  • Fast performance

    • parallel processing

  • Access to distributed computing resources

    • GRID

Beware: R&D prototype!


General dosimetric system for radiotherapy
General dosimetric system for radiotherapy

  • The system was developed for endocavitary brachytherapy

  • It has been extended to all the brachytherapic techniques

  • It is possible to generalise the system to other radiotherapic techniques

Thanks to Object Oriented

technique

Plug-in system under development



Structure of the brachytherapy example
Structure of the brachytherapy example

  • Brachytherapy example

    • header files in include/*.hh, source code in src/ *.cc

    • main in Brachy.cc

    • macro: VisualisationMacro.mac

  • Classes

    • BrachyAnalysisManager

    • BrachyDetectorConstruction

    • BrachyDetectorMessenger

    • BrachyEventAction

    • BrachyMaterial

    • BrachyPhantomHit

    • BrachyPhantomROGeometry

  • BrachyPhantomSD

  • BrachyPrimaryGeneratorAction

  • BrachyPhysicsList

  • BrachyRunAction

  • BrachyEventAction

  • BrachyVisManager


How to run
How to run

  • Define necessary environment variables

    • source geant4/env.csh

  • How to compile and link

    • gmake

  • How to run

    • $G4WORKDIR/bin/Linux-g++/Brachy


Details on the brachytherapy

advanced example implementation


Mandatory user classes
Mandatory user classes

Primary events

Physics

Detector


Abstract factories
Abstract Factories

  • Configuration of

  • any brachytherapy technique

  • any source type

  • through an Abstract Factory

  • to define geometry, primary spectrum


Model of a i 125 brachytherapic source geometry and materials1

BrachyDetectorConstruction

Model of a I-125 brachytherapic sourcegeometry and materials

Iodium core

Air

Golden marker

Titanium capsule tips

Titanium tube

Iodium core:

Inner radius :0

Outer radius: 0.30mm

Half length:1.75mm

Titanium tube:

Outer radius:0.40mm

Half length:1.84mm

Air:

Outer radius:0.35mm

half length:1.84mm

Golden marker:

Inner radius :0

Outer radius: 0.085 mm

Half length:1.75mm

Titanium capsule tip:

Semisphere

radius:0.40mm


Brachydetectorconstruction brachydetectorconstruction
BrachyDetectorConstruction::BrachyDetectorConstruction{}

BrachyDetectorConstruction

BrachyDetectorConstruction::~BrachyDetectorConstruction{}

G4VPhysicalVolume* BrachyDetectorConstruction::Construct()

{

pMaterial-> DefineMaterials();

ConstructSource();

ConstructPhantom();

ConstructSensitiveDetector();

return WorldPhys;

}


Constructsource
ConstructSource()

// source Bebig Isoseed I-125 ...

…. construct iodium core and golden marker…

Air

the mother volume is an air tube

// Iodium core

iodiumCore = new G4Tubs("ICore",0.085*mm,0.35*mm,1.75*mm,0.*deg,360.*deg);

iodiumCoreLog = new G4LogicalVolume(iodiumCore,iodium,"iodiumCoreLog");

iodiumCorePhys = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "iodiumCorePhys",

iodiumCoreLog, defaultTubPhys, false, 0);

// Golden marker

marker = new G4Tubs("GoldenMarker",0.*mm,0.085*mm,1.75*mm,0.*deg,360.*deg);

markerLog = new G4LogicalVolume(marker,gold,"MarkerLog");

markerPhys = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.), "MarkerPhys", markerLog,

defaultTubPhys, false, 0);


Brachyphysicslist
BrachyPhysicsList

void BrachyPhysicsList::ConstructProcess()

{

AddTransportation();

ConstructEM();

}

BrachyPhysicsList::BrachyPhysicsList():

G4VUserPhysicsList()

{

defaultCutValue = 0.1*mm;

…..}

BrachyPhysicsList::~BrachyPhysicsList(){}

void BrachyPhysicsList::ConstructParticle()

{

ConstructBosons();

ConstructLeptons();

}

void BrachyPhysicsList::ConstructBosons()

{

G4Gamma::GammaDefinition();

}

void BrachyPhysicsList::ConstructLeptons()

{

G4Electron::ElectronDefinition();

G4Positron::PositronDefinition();

}


Brachyphysicslist set the em processes

void BrachyPhysicsList::ConstructEM()

{ theParticleIterator->reset();

while( (*theParticleIterator)() ){

G4ParticleDefinition* particle = theParticleIterator->value();

G4ProcessManager* pmanager = particle->GetProcessManager();

G4String particleName = particle->GetParticleName();

if (particleName == "gamma") {

lowePhot = new G4LowEnergyPhotoElectric("LowEnPhotoElec");

pmanager->AddDiscreteProcess(new G4LowEnergyRayleigh);

pmanager->AddDiscreteProcess(lowePhot);

pmanager->AddDiscreteProcess(new G4LowEnergyCompton);

pmanager->AddDiscreteProcess(new G4LowEnergyGammaConversion);

} else if (particleName == "e-") {

loweIon = new G4LowEnergyIonisation("LowEnergyIoni");

loweBrem = new G4LowEnergyBremsstrahlung("LowEnBrem");

pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);

pmanager->AddProcess(loweIon, -1, 2,2);

pmanager->AddProcess(loweBrem, -1,-1,3);

} else if (particleName == "e+"){…}

}

BrachyPhysicsList Set the EM processes

Set EM processes

for e-, e+, gamma


Brachyprimarygeneratoraction
BrachyPrimaryGeneratorAction

  • I-125 delivers gamma

  • Gamma Energy Spectrum

  • Random direction

  • Random position inside the iodium core

void BrachyPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)

{

…..

particleGun->SetParticlePosition(position);

particleGun -> SetParticleDirection(direction);

particleGun -> SetParticleEnergy(energy);

particleGun->GeneratePrimaryVertex(anEvent);

}


Energy deposit
Energy deposit

How to retrieve the energy deposit in the phantom

Concepts:

  • Sensitive Detector

  • Readout Geometry

  • Hits


Set sensitive detector and ro geometry
Set Sensitive Detector and RO Geometry

void BrachyDetectorConstruction::ConstructSensitiveDetector()

{

G4SDManager* pSDManager = G4SDManager::GetSDMpointer();

if(!phantomSD){

phantomSD = new BrachyPhantomSD(sensitiveDetectorName,numberOfVoxelsAlongX,

numberOfVoxelsAlongZ);

G4String ROGeometryName = "PhantomROGeometry";

phantomROGeometry = newBrachyPhantomROGeometry(ROGeometryName,

phantomDimensionX,phantomDimensionZ,numberOfVoxelsAlongX,numberOfVoxelsAlongZ);

phantomROGeometry->BuildROGeometry();

phantomSD->SetROgeometry(phantomROGeometry);

pSDManager->AddNewDetector(phantomSD);

PhantomLog->SetSensitiveDetector(phantomSD);

}


Readout geometry
Readout Geometry

BrachyPhantomROGeometry::BrachyPhantomROGeometry() {}

BrachyROGeometry::~BrachyROGeometry() {}

G4VPhysicalVolume* BrachyPhantomROGeometry :: Build()

{

// example : X division

ROPhantomXDivision = new G4Box( ….);

ROPhantomXDivisionLog = newG4LogicalVolume(….);

ROPhantomXDivisionPhys = new G4PVReplica(….);

……..

}

x


Sensitive detector

G4bool BrachyPhantomSD::ProcessHits

(G4Step* aStep, G4TouchableHistory* ROhist)

{….

G4double energyDeposit = aStep->GetTotalEnergyDeposit();

….

G4VPhysicalVolume* physVol = ROhist->GetVolume();

// Read Voxel indexes: i is the x index, k is the z index

G4int k = ROhist->GetReplicaNumber(1);

G4int i = ROhist->GetReplicaNumber(2);

G4int j= ROhist->GetReplicaNumber();

…..

BrachyPhantomHit* PhantomHit = new BrachyPhantomHit(

physVol ->GetLogicalVolume(), i,j,k)

PhantomHit->SetEdep(energyDeposit);

PhantomHit->SetPos(physVol->GetTranslation());

… }

Sensitive Detector

Store the energy

deposit in one hit


Hit is a user-defined class derived from G4VHit

You can store various types information by implementing your own concrete Hit class:

position and time of the step

momentum and energy of the track

energy deposit of the step

geometrical information

etc.

Hit objects of a concrete hit class must be stored in a dedicated collection, which is instantiated from G4THitsCollection template class

Hits


Brachyphantomhit header file
BrachyPhantomHit (header file)

class BrachyPhantomHit : public G4VHit

{

public:

BrachyPhantomHit(G4LogicalVolume* ,G4int ,G4int ,G4int );

~BrachyPhantomHit();

…..

inline void SetCellID(G4int XID,G4int YID,G4int ZID) // Set Hit position

{xHitPosition = XID; zHitPosition = ZID; yHitPosition = YID; }

inline void SetEdep(G4double edep) {energyDeposit = edep;} //Set hit energy deposit

inline void SetPos(G4ThreeVector xyz) {hitPosition = xyz;} // Set hit position

inline G4int GetXID() {return xHitPosition;} //Get hit x coordinate

inline G4int GetZID() {return zHitPosition;} // Get hit z coordinate

inline G4int GetYID() {return yHitPosition;} // Get hit y coordinate

inline G4double GetEdep() {return energyDeposit;} // Get energy deposit

….}


Brachyeventaction

void BrachyEventAction::EndOfEventAction(const G4Event* evt)

{….

G4HCofThisEvent* HCE = evt->GetHCofThisEvent();

BrachyPhantomHitsCollection* CHC = NULL;

if(HCE)

CHC = (BrachyPhantomHitsCollection*)(HCE->GetHC(hitsCollectionID));

if(CHC)

{

G4int hitCount = CHC->entries();

for (G4int h = 0; h < hitCount; h++)

{

G4int i=((*CHC)[h])->GetZID();

G4int k=((*CHC)[h])->GetXID();

G4int j=((*CHC)[h])->GetYID();

G4double EnergyDep=((*CHC)[h]->GetEdep());

…}

…}

…}

BrachyEventAction

Retrieve energy deposit in

the phantom


Initialisation
Initialisation

Describe the geometrical set-up

Activate electromagnetic/hadronic processes appropriate to the energy range of the experiment


Beam on
Beam On

Generate primary events


Event processing
Event processing

Record theenergy deposit and

the position associated


  • How to produce

  • 1D histograms

  • 2D histograms

  • Ntuple

  • Analysis Tool

  • AIDA 3.0

  • Anaphe 5.0.5


Brachyanalysismanager
BrachyAnalysisManager

BrachyAnalysisManager::BrachyAnalysisManager() :

….

{

//build up the factories

aFact = AIDA_createAnalysisFactory();

AIDA::ITreeFactory *treeFact = aFact->createTreeFactory();

theTree = treeFact->create(fileName,"hbook",false, true);

….

histFact = aFact->createHistogramFactory( *theTree );

tupFact = aFact->createTupleFactory ( *theTree );

}

void BrachyAnalysisManager::finish()

{

theTree->commit(); // write all histograms to file ...

theTree->close(); // close (will again commit) ...

}

Create the .hbk file…

Close the .hbk file


Brachyanalysismanager1

void BrachyAnalysisManager::book()

{

//creating a 2D histogram ...

h1 = histFact->createHistogram2D("10","Energy, pos",

300 ,-150.,150., //bins'number,xmin,xmax

300,-150.,150. );//bins'number,ymin,ymax

//creating a 1D histogram ...

h2 = histFact->createHistogram1D("20","Initial Energy", 500,0.,50.);

//creating a ntuple ...

if (tupFact) ntuple = tupFact->create("1","1",columnNames, options);

….}

BrachyAnalysisManager


Brachyanalysismanager2
BrachyAnalysisManager

How to fill histograms….

void BrachyAnalysisManager::FillHistogramWithEnergy (G4double x, G4double z,G4float energyDeposit)

{

//2DHistogram: energy deposit in a voxel which center is fixed in position(x,z)

h1->fill(x,z,energyDeposit);

}

void BrachyAnalysisManager::PrimaryParticleEnergySpectrum

(G4double primaryParticleEnergy)

{

//1DHisotgram: energy spectrum of primary particles

h2->fill(primaryParticleEnergy);

}


Brachyanalysismanager3
BrachyAnalysisManager

How to fill Ntuples….

void BrachyAnalysisManager::FillNtupleWithEnergy(G4double xx,G4double yy, G4double zz, G4float en)

{…..

G4int indexX = ntuple->findColumn( "x" );

G4int indexY = ntuple->findColumn( "y" );

G4int indexZ = ntuple->findColumn( "z" );

G4int indexEnergy = ntuple->findColumn( "energy" );

ntuple->fill(indexEnergy, en);

ntuple->fill(indexX, xx);

ntuple->fill(indexY, yy);

ntuple->fill(indexZ, zz);

ntuple ->addRow();

}


Analysis management
Analysis management

void BrachyRunAction::BeginOfRunAction(const G4Run*)

{

….

BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance();

analysis->book();

….

}

void BrachyRunAction::EndOfRunAction(const G4Run* aRun)

{

…..

BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance()

…..

analysis->finish();

….

}

Booking histograms and ntuple …

…Closing the hbook file

In the BrachyRunAction


Energy deposit1
Energy deposit

void BrachyEventAction::EndOfEventAction(const G4Event* evt)

{

…. // here the energy deposit information is retrieved

//Store information about energy deposit in a 2DHistogram and in a ntuple ...

BrachyAnalysisManager* analysis = BrachyAnalysisManager::getInstance

analysis->FillHistogramWithEnergy(x,z,EnergyDep/MeV);}}

analysis->FillNtupleWithEnergy(x,y,z,EnergyDep/MeV);

}

In the BrachyEventAction


Gamma energy spectrum
Gamma energy spectrum

BrachyPrimaryGeneratorAction:: GeneratePrimaries(G4Event* anEvent)

{

//Store the initial energy in a 1D histogram

analysis-> PrimaryParticleEnergySpectrum(primaryParticleEnergy/keV);

// generate primary particle

}

In the BrachyPrimaryGeneratorAction



Some results
Some Results

Primary particles

Energy Spectrum

(1D histogram)

Energy deposit

(2D histogram)



Brachydetectormessenger
BrachyDetectorMessenger

BrachyDetectorMessenger::BrachyDetectorMessenger( BrachyDetectorConstruction* Det): detector(Det)

{detectorDir = new G4UIdirectory("/phantom/");

detectorDir->SetGuidance(" phantom control.");

phantomMaterialCmd = new G4UIcmdWithAString("/phantom/selectMaterial",this);

phantomMaterialCmd->SetGuidance("Select Material of the detector.");

phantomMaterialCmd->SetParameterName("choice",false);

phantomMaterialCmd->AvailableForStates(G4State_Idle);

}

void BrachyDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)

{

if( command == phantomMaterialCmd )

{ detector->SetPhantomMaterial(newValue);}

}


(G)UI

How to change the phantom absorber material

  • Run $G4WORKDIR/bin/Linux-g++/Brachy

  • (G)UI session : interactive session

  • Type /phantom/selectMaterial Lead

The phantom absorber material now is lead


Macro

A macro is an ASCII file containing UI commands

All commands must be given with their full-path directories

A macro can be executed by

/control/execute

/control/loop

/control/foreach

in UI session

Macro

/control/verbose 1

/run/verbose 1

/event /verbose 1

/phantom/selectMaterial Lead

# run 10 events

/run/beamOn 10

A macro can be executed also typing:

$G4WORKDIR/bin/Linux-g++/Brachy macro.mac


Visualisation
Visualisation

# Macro file for the visualisation

# create empty scene

#

/vis/scene/create

#/vis/open OGLIX

/vis/open DAWN

/vis/viewer/flush

# for drawing the tracks

/tracking/storeTrajectory 1

/vis/scene/endOfEventAction accumulate

/vis/viewer/update

/run/initialize

/run/beamOn 10

  • Control of several kinds

    of visualisation

    • detector geometry

    • particle trajectories

    • hits in the detectors

  • In the Brachytherapy Example

    OGLIX, DAWN

  • VisualisationMacro.mac


ad