Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation •...

65
Experimental techniques for nuclear and particle physics Monte Carlo Method Simple way of integration based on random numbers: Expansion to multidimensional space is rather trivial, just ensure that your statistics (N) is large The whole concept is very intuitive A s = 4r 2 A c = πr 2 A c /A s = π/4 I = F ( x ) dx a b = 1 N F ( x i ) ( b a ) i= 1 N

Transcript of Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation •...

Page 1: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Experimental techniques for nuclear and particle physics Monte Carlo Method

Simple way of integration based on random numbers:

Expansion to multidimensional space is rather trivial, just ensure that your statistics (N) is large

The whole concept is very intuitive

As = 4r2 Ac = πr2

Ac/As = π/4

I = F(x)dxa

b∫ =

1N

F(xi ) ⋅ (b− a)i=1

N

Page 2: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Radia%on  transport  as  an  integra%on  in  mul%dimensional  space  

1

∫ F1(θ1, φ1, R1)

2

• F2(θ2, φ2, R2) • F3(θ3, φ3, R3)

3

<R>=∫ R · p(θ, φ, R) dθdφdR

Example:

= ∫ R · p(R) dR

f – any function p – Probability Density Function

1/N•∑ F1i(θ1

i, φ1i, R1

i) • F2i (θ2

i, φ2i, R2

i) • F3i (θ3

i, φ3i, R3

i)

<f>=∫ f(θ, φ, R) · p(θ, φ, R) dθdφdR

Page 3: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Remark  about  computer  random  numbers  

Two cases: •  Fixed starting point: useful to test the codes •  Random starting point: To obtain the results as the statistics is increased.

CLHEP`s HepRandom module

Pseudo-random numbers

Not really random numbers as they are generated by algebraic algorithms

Geant4

CLHEP Reference guide: http://proj-clhep.web.cern.ch/proj-clhep/manual/RefGuide/ CLHEP user manual: http://proj-clhep.web.cern.ch/proj-clhep/manual/UserGuide/

Page 4: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Monte-­‐Carlo  simula%on  toolkits  •  EGS4,  EGS5  (Mortran3,  Fortran)    only  Photons  and  Electrons    hEp://rcwww.kek.jp/research/egs/  

•  FLUKA  (Fortran)    hEp://pcfluka.mi.infn.it/  

•  GEANT3  (Fortran)  •  GEANT4  (C++)  

 hEp://geant4.cern.ch/  

•  MCNP  (Fortran)    hEp://mcnpx.lanl.gov/  

•  Penelope  (Fortran)    only  Photons  and  Electrons    hEp://www.nea.fr/html/dbprog/penelope.pdf  

Page 5: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

C++  

•  OOP  –  is  the  basis  of  modern  physics  soXware  •  Learn  ANSI  C++  see  e.g.    ANSI-­‐ISOCppProfessionalProgrammersHandbook.pdf    

•  Useful  books  on  C++:  •  B.  Stroustrup  “The  Annotated  C++  Reference  Manual”  •  B.  Stroustrup  “The  C++  Programming  Language”  •  D.  Knuth  “The  Art  of  Computer  Programming”  •  …  •  W.  Press  et  al.  “Numerical  Recipes”  (C,  Fortran)  

Page 6: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Geant4  (Geometry  ANd  Tracking)  Documentation •  Installation guide •  User guide – For Application developers (for those whising to use Geant4) •  User Guide - For toolkit developers for those wishing to extend Geant4

funcionality •  Software reference Manual: Documentation of the public interface of all

Geant4 classes •  Physics reference Manual: Extended documentation on Geant4 physics

Examples: Main functionality of Geant4 in realistic setups •  Novice examples •  Extended examples •  Advanced examples

https://geant4.web.cern.ch/geant4/

Page 7: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Geant4  Valida%on  Comparison Low Energy, Standard Energy and NIST data base (National Institute of Standars and Technology)

Atenuation coefficient of γ in water

Photon Energy (MeV)

µ/ρ

(cm

2 /g)

in w

ater

Page 8: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Multi-nucleon transfer reaction: 76Ge + 238U @ E(76Ge) = 577 MeV Channel of interest: 76Ge

AGATA-Demonstrator coupled to PRISMA + Cologne plunger

Life%me  measurements  in  76Ge  

Page 9: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Life%me  measurements  in  76Ge  

Recoil Distance Doppler Shift Method (RDDS)

Page 10: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Life%me  measurements  in  76Ge  

By C. Michelagnoli

Page 11: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Geant4  user  program  components    (C++  classes)  

•  Geant4 does not provide the main program() •  In his/her main(), the user must

–  construct G4RunManager (or his/her own derived class) –  notify the mandatory user classes to G4RunManager

Detector Construction: G4VUserDetectorConstruction Physics List: G4VUserPhysicsList Primary Generator: G4VUserPrimaryGeneratorAction

Stepping Action (optional) Sensitive Detector (optional) Hit (optional) Event Action Run Action

Page 12: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Run

Act

ion

(initi

aliz

atio

n)

Pr

γ C

γ`

e-

C γ``

e- Ph

e-

Prim

ary

Gen

erat

or

(prim

ary

parti

cle)

Phy

sics

list

Ste

ppin

g A

ctio

n

Hit

Run

Act

ion

(sto

ring

resu

lts)

Eve

nt A

ctio

n (e

vent

ana

lysi

s)

Energy/Range Cuts

Sen

sitiv

e D

etec

tor

Sen

sitiv

e D

etec

tor

detector inactive materials

Page 13: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

●  Geometry (solids, materials, elements...) ●  User Physics Lists ●  Particles and Tracks ●  Tracking ●  Physics Processes ●  Production Cuts ●  Primary Events ●  Detector response ●  Execution and Visualization

GEANT4  (Geometry  ANd  Tracking)  

Page 14: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Describe  the  experimental  set-­‐up  •  Derive your own concrete class from the

G4VUserDetectorConstruction abstract base class

•  Implement the Construct() method   (modularize it according to each detector component or sub-

detector) –  define shapes/solids required to describe the geometry –  construct and place volumes of your detector geometry –  define sensitive detectors and identify detector volumes to

associate them to –  construct all necessary materials –  associate magnetic/electric field to detector regions –  define visualization attributes for the detector elements

Page 15: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Define  detector  geometry  

–  G4VSolid -- shape, size –  G4LogicalVolume -- daughter physical volumes, material, sensitivity, etc. –  G4VPhysicalVolume -- position, rotation

A unique physical volume (the world volume), which represents the experimental area, must exist and fully contain all other components

G4Box

G4Tubs

G4VSolid G4VPhysicalVolume

G4Material

G4VSensitiveDetector

G4PVPlacement

G4PVParameterised

G4VisAttributes

G4LogicalVolume

Creating a Simple Volume What do you need to do to create a Volume??

Page 16: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Solids  Solids defined in Geant4: •  CSG (Constructed Solid Geometry) solids

–  G4Box, G4Tubs, G4Cons, G4Trd, … •  Specific solids (CSG like)

–  G4Polycone, G4Polyhedra, G4Hype, … •  BREP (Boundary REPresented) solids

–  G4BREPSolidPolycone, G4BSplineSurface… –  Any order surface

•  Boolean solids –  G4UnionSolid, G4SubtractionSolid, …

Page 17: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

G4LogicalVolume  

G4LogicalVolum (G4VSolid* solid, G4Material* material, const G4String& name, G4FieldManager* fieldManager=0, G4VSensitiveDetector* sensitiveDetector=0, G4UserLimits* userLimits=0);

•  Contains all information of volume except position: –  Shape and dimension (G4VSolid) –  Material, sensitivity, visualization attributes –  Position of daughter volumes –  Magnetic field, User limits –  Shower parameterization

•  Physical volumes of same type can share a logical volume

Page 18: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physical  Volumes  •  Placement: it is one positioned volume

•  Repeated: a volume placed many times –  can represent any number of volumes –  reduces use of memory –  Replica: simple repetition, similar to G3 divisions –  Parameterised

•  A mother volume can contain either –  many placement volumes OR –  one repeated volume repeated

placement

Page 19: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

G4VPhysicalVolume  

•  G4PVPlacement 1 Placement = One Volume –  A volume instance positioned once in a mother volume

•  G4PVParameterized 1 Parameterized = Many Volumes –  Parameterized by the copy number

•  Shape, size, material, position and rotation can be parameterized, by implementing a concrete class of G4PVParameterisation

–  Reduction of memory consumption

•  G4PVReplica 1 Replica = Many Volumes –  Slicing a volume into smaller pieces (if it has a symmetry)

Page 20: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Creating a box (experimental hall dimensions) G4double expHall_x = 3.0*m; G4double expHall_y = 1.0*m; G4double expHall_z = 1.0*m; G4Box* experimentalHall_box = new G4Box("expHall_box",expHall_x,expHall_y,expHall_z);

Example: Creating a cylinder (tube). G4double innerRadius = 0.*cm; G4double outerRadius = 60.*cm; G4double hz = 25.*cm; G4double startAngle = 0.*deg; G4double spanningAngle = 360.*deg; G4Tubs* trackerTube = new G4Tubs("Tracker", innerRadius, outerRadius, hz, startAngle, spanningAngle);

Page 21: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Create complex solids from basic geometries G4Box* box = new G4Box("Box",20*mm,30*mm,40*mm); G4Tubs* cyl = new G4Tubs("Cylinder",0,50*mm,50*mm,0,twopi); // r: 0 mm -> 50 mm

// z: -50 mm -> 50 mm // phi: 0 -> 2 pi

G4UnionSolid* union = new G4UnionSolid("Box+Cylinder", box, cyl); G4IntersectionSolid* intersection = new G4IntersectionSolid("Box*Cylinder", box, cyl); G4SubtractionSolid* subtraction = new G4SubtractionSolid("Box-Cylinder", box, cyl);

Complex  solids  

Page 22: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Creating a logical volume (experimental hall) G4LogicalVolume* experimentalHall_log =

new G4LogicalVolume(experimentalHall_box,air,"expHall_log");

This mother volume must not be rotated and is centered at the origin G4VPhysicalVolume* experimentalHall_phys =

new G4PVPlacement(0, // no rotation G4ThreeVector(0.,0.,0.), // translation position experimentalHall_log, // its logical volume "expHall", // its name 0, // its mother volume false, // no boolean operations 0); // its copy number

Experimental  hall  

Page 23: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: creating a physical volume (tracker) G4double trackerPos_x = -1.0*meter; G4double trackerPos_y = 0.0*meter; G4double trackerPos_z = 0.0*meter; G4VPhysicalVolume* tracker_phys =

new G4PVPlacement(0, // no rotation G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z), // translation position tracker_log, // its logical volume "tracker", // its name experimentalHall_log, // its mother (logical) volume false, // no boolean operations 0); // its copy number

“Tracker  detector”  Example: Creating a logical volume for detector (tracker) G4LogicalVolume* trackerLog = new G4LogicalVolume(trackerTube, Al, "Tracker"); // geometry defined above

Page 24: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Creating liquid argon. G4double z, a, density; density = 1.390*g/cm3; a = 39.95*g/mole; G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density); /* The pointer to the material, lAr, will be used to specify the matter of which a given logical volume is made: */ G4LogicalVolume* myLbox = new G4LogicalVolume(aBox,lAr,"Lbox",0,0,0); // Here the geometry aBox is predefined

Detector  materials  

Page 25: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Creating water by defining its molecular components. G4double z, a, density; G4String name, symbol; G4int ncomponents, natoms; a = 1.01*g/mole; G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); density = 1.000*g/cm3; G4Material* H2O = new G4Material(name="Water",density,ncomponents=2); H2O->AddElement(elH, natoms=2); H2O->AddElement(elO, natoms=1);

Detector  materials:  defining  a  molecule  

Page 26: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Creating air by defining the fractional mass of its components. G4double z, a, fractionmass, density; G4String name, symbol; G4int ncomponents; a = 14.01*g/mole; G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); a = 16.00*g/mole; G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); density = 1.290*mg/cm3; G4Material* Air = new G4Material(name="Air ",density,ncomponents=2); Air->AddElement(elN, fractionmass=70*perCent); Air->AddElement(elO, fractionmass=30*perCent);

Detector  materials:  defining  a  mixture  

Page 27: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Defining air and water from the internal Geant4 database. G4NistManager* man = G4NistManager::Instance(); G4Material* H2O = man->FindOrBuildMaterial("G4_WATER"); G4Material* Air = man->FindOrBuildMaterial("G4_AIR");

Detector  materials:  from  database  

Example: Geant4 material database may be accessed via UI commands. /material/nist/printElement Fe \\ print element by name /material/nist/printElementZ 13 \\ print element by atomic number /material/nist/listMaterials type \\ print materials type = [simple | compound | hep | all] /material/g4/printElement elmName \\ print instantiated element by name /material/g4/printMaterial matName \\ print instantiated material by name

Page 28: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physics  in  Geant4   PhysicsList is the class where the user defines which particles,

processes and production thresholds are to be used in his/her application User must have a good understanding of the physics required

 

ConstructParticle(); // construction of particles ConstructProcess(); // construct processes and register them to particles SetCuts(); // setting a range cut value for all particles

What is a particle in Geant4? A collection of all the information needed to propagate it through a material Particle (ParticleDefinition): A definition, no information of energy, direction…

Dynamic Particle: gives the particle its kinematic properties What is a track? A “fully dressed” particle which at any step along its trajectory contains the

instantaneous particle information

Page 29: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physics  in  Geant4  Geant4 provides various types of particles: •  Ordinary particles, such as electrons, protons, and gammas •  Resonant particles with very short lifetimes, such as vector mesons and delta baryons •  Nuclei, such as deuteron, alpha, and heavy ions (including hyper-nuclei) •  Quarks, di-quarks, and gluons Particles are organized into six major categories: Lepton, Meson, Baryon, Boson, Shortlived and Ion (G4LeptonConstructor, G4MesonConstructor, G4BaryonConstructor, G4BosonConstructor, G4ShortlivedConstructor and G4IonContructor) Track object lifetime

A created particle lives until it decays, goes out of the world volume, goes to zero KE, or is killed by the user

User access to track info many public methods: GetPosition(), GetVolume(), GetMaterial(), GetCreatorProcess(), GetMomentum(), GetParticleDefinition()…

Page 30: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physics  lists  provided  by  Geant4  ●  EM physics (N02, N03, N06)

- Standard: valid from 1 keV to ~ PeV - Low-energy: valid from 250 eV to ~ 100 GeV - Optical photons: λ  ≥ 10nm which corresponds to an E ≤ 100 eV

●  Weak physics (B3) - Decay of subatomic particles - Radioactive decay of nuclei

●  Hadronic physics (Hadr00, Hadr01, Hadr02) - Pure hadonic processes: valid from 0 to ~100 TeV

●  Parameterized or “fast simulation” physics The Advanced Examples offer a guidance for various

typical experimental domains

Page 31: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

G4VProcess    AlongStep

PostStep •  Define three kinds of actions:

–  AtRest actions: decay, annihilation … –  AlongStep actions: continuous interactions occurring along the path,

like ionisation –  PostStep actions: point-like interactions, like decay in flight, hard

radiation… •  A process can implement any combination of the three AtRest, AlongStep

and PostStep actions: eg: decay = AtRest + PostStep •  Each action defines two methods:

–  GetPhysicalInteractionLength()   used to limit the step size –  DoIt()

•  implements the actual action to be applied to the track •  implements the related production of secondaries

Abstract class defining the common interface of all processes in Geant4

Page 32: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

G4VProcess    

●  The most general process may invoke all three of the above actions   in that case six methods must be implemented

(GetPhysicalInteractionLength() and DoIt() for each action)

●  For ease of use, “shortcut” processes are defined which invoke only one - Discrete process: has only PostStep physics (Compton Scattering) - Continuous process: has only AlongStep physics (Cerenkov effect) - AtRest process: has only AtRest physics (Positron annihilation at rest)

Page 33: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

FindParticle(G4String name); // find the particle by name FindParticle(G4int PDGencoding) // find the particle by PDG encoding .

void GeTelescopePhysicsList::ConstructParticle() { ConstructBosons(); ConstructLeptons(); } void GeTelescopePhysicsList::ConstructBosons() { // gamma G4Gamma::GammaDefinition(); } void GeTelescopePhysicsList::ConstructLeptons() { // leptons e+/- G4Electron::ElectronDefinition(); G4Positron::PositronDefinition(); }

Page 34: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Example: Register processes for a gamma void MyPhysicsList::ConstructProcess() { // Define transportation process AddTransportation(); // electromagnetic processes ConstructEM(); } void MyPhysicsList::ConstructEM() { G4ParticleDefinition* particle = G4Gamma::GammaDefinition(); // Get the process manager for gamma G4ProcessManager* pmanager = particle->GetProcessManager(); // Construct processes for gamma G4PhotoElectricEffect * thePhotoElectricEffect = new G4PhotoElectricEffect(); G4ComptonScattering * theComptonScattering = new G4ComptonScattering(); G4GammaConversion* theGammaConversion = new G4GammaConversion(); // Register processes to gamma's process manager pmanager->AddDiscreteProcess(thePhotoElectricEffect); pmanager->AddDiscreteProcess(theComptonScattering); pmanager->AddDiscreteProcess(theGammaConversion); }

Page 35: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Tracking  &  Trajectory  ●  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

Start of step point End of step point

●  The Trajectory is a record of a track’s history (for every step, some information is stored as an object of the G4Trajectory class) ●  The user can create his own trajectory class (derived from G4VTrajectory) WARNING! Storing trajectories for secondaries generated in a shower may consume large amounts of memory

Page 36: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Tracking  Algorithm  (simplified)  ●  Each physics process must propose a step length

- interaction dependent, look up cross section - “physical step length” is the minimum of all proposed lengths

●  Navigator finds “safety” distance to nearest boundary ●  If physical step length is < safety take physical step length ●  If not, step is limited by geometry instead of physics: take step to

boundary, subtract step length from mean free path of physics processes ●  If physics process has limited the step, do the interaction ●  Update track properties and check for track termination ●  If step limited by volume boundary, assign it to next volume ●  Invoke G4UserSteppingAction to allow user intervention

Page 37: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

SetCuts  •  The production of secondary particles is relevant if it can

generate visible effects in the detector (otherwise “local energy deposit”)

Energy cut below which secondaries are not produced Such a cut may cause imprecise stopping location and deposition of energy

- Particle dependence - range of 10 keV γ in Si is around 130 microns - range of 10 keV e- in Si is about 1.5 microns ~100 times difference

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

Page 38: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

●  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.

SetCuts  

Page 39: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Produc%on  Threshold  vs  E  Cut  

Threshold in range = 1.5 mm

Corresponding Cuts in Pb: 2MeV in Liquid Ar: 450 keV

Pb Liquid Ar Pb

Liquid Ar

500 MeV incident protons in Liquid Ar-Pb samplig calorimeter

Cut = 2 MeV Cut = 450 keV

Page 40: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Generate  primary  events  •  Derive your concrete class from the

G4VUserPrimaryGeneratorAction abstract base class •  Pass a G4Event object to one or more primary generator

concrete class objects, which generate primary vertices and primary particles

particleGun = new G4ParticleGun(n_particle); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-"); particleGun->SetParticleDefinition(particle); particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.)); particleGun->SetParticleEnergy(50.*MeV); particleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));

void PrimaryGeneratorAction::GeneratePrimaries(G4Event*anEvent){ particleGun->GeneratePrimaryVertex(anEvent);

}

Page 41: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Detector  sensi%vity  (response)  •  A logical volume becomes sensitive if it has a pointer to a

concrete class derived from G4VSensitiveDetector

•  A sensitive detector –  either constructs one or more hit objects –  or accumulates values to existing hits

using information given in a G4Step object

G4SDManager* SDman = G4SDManager::GetSDMpointer(); SDman->AddNewDetector(det); LogicVolume->SetSensitiveDetector(det);

Page 42: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Hit  •  Hit is a user-defined class derived from G4VHit •  You can store all information by implementing your own concrete Hit class:

–  position and time of the step –  momentum and energy of the track –  energy deposition of the step…

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

•  The collection is associated to a G4Event object via G4HCofThisEvent •  Hit collections are accessible

–  through G4Event at the end of event –  through G4SDManager during processing an event

class DetHit: public G4VHit{ G4double G4ThreeVector position G4String namevolume G4String nameproc

}

Page 43: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Sensi%ve  detector  G4bool DetSensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist) { G4double edep = aStep->GetTotalEnergyDeposit(); G4ThreeVector position = aStep->GetPostStepPoint()->GetPosition(); G4String namevolume = aStep->GetPreStepPoint()->GetPhysicalVolume()

->GetName(); G4String nameproc = aStep->GetPostStepPoint()->GetProcessDefinedStep()

->GetProcessName(); CloversHitDetector* newHit = new CloversHitDetector(); newHit->SetTrackID( aStep->GetTrack()->GetTrackID() ); // trackID newHit->SetEdep( edep ); // energy release newHit->SetPos( position ); // position of the interaction newHit->SetName( namevolume ); // volume name newHit->SetProcName( nameproc ); // proc name theHits->insert( newHit ); return true; }

Page 44: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Op%onal  user  ac%on  classes  G4UserRunAction •  BeginOfRunAction(const G4Run*)

–  example: book histograms •  EndOfRunAction(const G4Run*)

–  example: store histograms

G4UserEventAction •  BeginOfEventAction(const G4Event*)

–  example: event selection •  EndOfEventAction(const G4Event*)

–  example: analyse the event

G4UserSteppingAction •  UserSteppingAction(const G4Step*)

–  example: kill, suspend, postpone the track

Page 45: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Execu%on  and  Visualiza%on  /vis/open OGLIX /vis/open VRML2FILE /vis/drawVolume /vis/viewer/set /viewpointThetaPhi 90 0 /vis/viewer/flush /vis/scene/add/trajectories /vis/scene/add/hits/tracking/storeTrajectory 1 /vis/scene/endOfEventAction accumulate /run/beamOn 1

Visualization’s drivers not installed by default!!! Check carefully!!!!

Page 46: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

ATLAS  (A  Toroidal  Lhc  AparatuS  )  

Particle detector for a wide range of energy

Page 47: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

AGATA  (Advanced  GAmma  Tracking  Array)  

For γ ray spectroscopy studies

Page 48: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Quick  example  

γ

Ge

Al

Page 49: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Detector  construc%on  defineMaterials() // Al density = 2.700*g/cm3; a = 26.98*g/mole; G4Material* Al = new G4Material(name="Aluminium", z=13., a, density); // Ge density = 5.323*g/cm3; a = 72.640*g/mole; G4Material* Ge = new G4Material(name="Germanium", z= 32., a, density); Construct(): //World G4Box* solidWorld = new G4Box("World",100*mm,100*mm,100*mm); G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, Vacuum, "World"); G4VPhysicalVolume* physiWorld = new G4PVPlacement(0, G4ThreeVector(0,0,0), logicWorld, “World", 0, false, 0);

Page 50: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Detector  construc%on  //Ge crystal G4Tubs* detectorSolid = new G4Tubs("detectorSolid",0,40*mm,45*mm,0,360*deg); G4LogicalVolume* detectorLogic = new G4LogicalVolume(detectorSolid, Ge, "detectorLogic"); G4VPhysicalVolume* detectorPhysic = new G4PVPlacement(0, G4ThreeVector(0,0,0), detectorLogic, "detectorPhysic", logicWorld, false, 0); //Housing G4Tubs* housingSolid = new G4Tubs("shieldSolid",41*mm,42*mm,45*mm,0,360*deg); G4LogicalVolume* housingLogic = new G4LogicalVolume(housingSolid, Al, "housingLogic"); G4VPhysicalVolume* housingPhysic = new G4PVPlacement(0, G4ThreeVector(0,0,0), housingLogic, "housingPhysic", logicWorld, false, 0);

Page 51: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Detector  construc%on  Properties: detectorLogic -> SetSensitiveDetector(telescopeSD); defineColors(): detectorLogic->SetVisAttributes(Grey); housingLogic->SetVisAttributes(Black);

Page 52: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physics  List  void GeTelescopePhysicsList::ConstructEM() { // Add standard EM Processes theParticleIterator->reset(); while( (*theParticleIterator)() ){ G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == "gamma") { // gamma pmanager->AddDiscreteProcess(new G4PhotoElectricEffect); pmanager->AddDiscreteProcess(new G4ComptonScattering); pmanager->AddDiscreteProcess(new G4GammaConversion);

Page 53: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Physics  List  } else if (particleName == "e-") { //electron pmanager->AddProcess(new G4MultipleScattering, -1, 1,1); pmanager->AddProcess(new G4eIonisation, -1, 2,2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);

} else if (particleName == "e+") { //positron pmanager->AddProcess(new G4MultipleScattering, -1, 1,1); pmanager->AddProcess(new G4eIonisation, -1, 2,2); pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3); pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4); } } }

Page 54: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Primary  Generator  

particleGun = new G4ParticleGun(n_particle); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4ParticleDefinition* particle = particleTable->FindParticle("gamma"); particleGun->SetParticleDefinition(particle); particleGun->SetParticleEnergy(8*MeV); particleGun->SetParticlePosition(G4ThreeVector(0,0,0)); particleGun->SetParticleMomentumDirection(G4ThreeVector(0,0,1)); particleGun->GeneratePrimaryVertex(anEvent);

Page 55: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Detector  Hit  

class GeTelescopeHit : public G4VHit{ public: G4double edep; G4ThreeVector pos; }

Page 56: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Sensi%ve  Detector  

G4bool GeTelescopeSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { G4double edep = aStep->GetTotalEnergyDeposit(); G4ThreeVector pos = aStep->GetPostStepPoint()->GetPosition(); GeTelescopeHit* newHit = new GeTelescopeHit(); newHit->SetEdep( edep ); newHit->SetPos( pos ); trackerCollection->insert( newHit ); return true; }

Page 57: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

void GeTelescopeEventAction::EndOfEventAction(const G4Event* evt) { G4HCofThisEvent* HC = evt -> GetHCofThisEvent(); if(HC){ GeTelescopeHitsCollection* THC =(GeTelescopeHitsCollection*)

(HC -> GetHC(telescopeCollectionID)); if(THC){ int n_hits = THC -> entries(); double totalEnergy=0; for(int i=0; i < n_hits; i++){ G4double edep = (*THC)[i]->GetEdep(); totalEnergy += edep; } runAction -> fillHistogram(totalEnergy); } } }

Event  Ac%on  

Page 58: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Result

Interpretation?

0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.90.0

0.2

0.4

0.6

0.8

1.0

0.5 MeV

inte

nsity

recoil electron energy, MeV

1 MeV

Page 59: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Result

Interpretation?

Typical response of a detector to monoenergetic gamma rays

Page 60: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Result

Interpretation?

Processes ocurring in gamma-ray detection

Page 61: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

γ

Ge

γ

Ge

Compton edge???

Page 62: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

Commands already defined in Geant4 http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/AllResources/Control/UIcommands/_.html

Information: http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/index.html

Useful information…

/usr/local/geant4.10/examples README.HowToRun

Page 63: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

How to run… $Id: README,v 1.16 2010-11-29 10:34:36 gcosmo Exp $ ------------------------------------------------------------------- ========================================================= Geant4 - an Object-Oriented Toolkit for Simulation in HEP ========================================================= How to build and run an example ------------------------------- All novice, basic and most of extended examples have a similar structure. The main () function is included in exampleXYZ.cc in the example top directory and the example source code is structered in include and src subdirectories. When the example is built, the executable takes the same name as the file with main() function without .cc extension, exampleXYZ. Then several macros are provided to run the example with various start-up conditions. These macros have usually .mac extension. Besides these macros, there is often a macro exampleXYZ.in (note its different extension) which is used in Geant4 testing and which output, exampleXYZ.out, can also included in the distribution.

Page 64: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

How to run…

You can find all details about building the examples in the Geant4 Installation Guide: "http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/index.html" in the section 3.2. Building Applications with Geant4: http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s02.html" Here we recall only the basics. 1) COMPILE AND LINK TO GENERATE AN EXECUTABLE 1a) With CMake % cd path_to_exampleXYZ # go to directory which contains your example % mkdir exampleXYZ_build % cd exampleXYZ_build % cmake -DGeant4_DIR=path_to_Geant4_installation/lib[64]/Geant4-9.6.0/ ../exampleXYZ % make -j N exampleXYZ # "N" is the number of processes % make install # this step is optional

Page 65: Monte Carlo Method - KTH Nuclear Physics · Geant4((Geometry(ANd(Tracking)(Documentation • Installation guide • User guide – For Application developers (for those whising to

How to run…

Cmake –DGeant4_DIR=/usr/local/geant4.9.6.p02-install/lib/Geant4-9.6.2/ /usr/local/geant4.9.6.2.p02/examples/advanced/air_shower

In the builder folder (N03-build) you will have the executable and the macros to run the code but to modify the code itself (src and include folders) you should go to the original folder (N003).