Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 The Geant4 Monte Carlo toolkit Sebasten Incerti / Alfonso Mantero IN2P3/CNRS Centre d’Etudes Nucléaires de Bordeaux Gradignan France

Similar presentations


Presentation on theme: "1 The Geant4 Monte Carlo toolkit Sebasten Incerti / Alfonso Mantero IN2P3/CNRS Centre d’Etudes Nucléaires de Bordeaux Gradignan France"— Presentation transcript:

1 1 The Geant4 Monte Carlo toolkit Sebasten Incerti / Alfonso Mantero IN2P3/CNRS Centre d’Etudes Nucléaires de Bordeaux Gradignan France incerti@cenbg.in2p3.frincerti@cenbg.in2p3.fr / mantero@cenbg.in2p3.fr On behalf of the Geant4 collaboration http://cern.ch/geant4

2 2 Thank you ! ACGRID school organizers –Giuseppe La Rocca IN2P3 –Vincent Breton (IN2P3/Org) – Inga Khoudir (IN2P3) Geant4 –Sebastien Incerti (CENBG/IN2P3) –The whole Geant4 collaboration

3 3 1. Introduction15 minutes 2. Basic structure25 minutes 3. Definition of materials10 minutes 4. Geometry construction30+40 minutes 5. Electromagnetic Physics : standard version20 minutes 6. Electromagnetic Physics : low energy version35 minutes 7. Hadronic Physics25 minutes 8. Physics lists15 minutes 9. Primary particles generation10 minutes 10. Particles and processes40 minutes 11. User interface15 minutes 12. Documentation, examples, forum10 minutes 13. Linux10 minutes 14. Write your own application5 minutes 15. Hands onrest of day Outline of the course

4 4 The Geant4 toolkit : 1/15 - Introduction 15 minutes

5 5 Color code In red : what is very important In violet : new definitions In yellow : important In yellow and courier : code : attention !

6 6 Simulation plays a fundamental role in various domains and phases of an experimental physics project design of the experimental set-up evaluation and definition of the potential physics output of the project evaluation of potential risks to the project assessment of the performance of the experiment development, test and optimization of reconstruction and physics analysis software contribution to the calculation and validation of physics results The role of simulation

7 7 Detector simulation - general General characteristics of a detector simulation system –You specify the geometry of a particle detector –Then the software system automatically transports the particle you shoot into the detector by simulating the particle interactions in matter based on the Monte Carlo method The heart of the simulation: the Monte Carlo method –a method to search for solutions to a mathematical problem using a statistical sampling with random numbers

8 8 Basic requirements for a simulation system Modeling the experimental set-up Tracking particles through matter Interaction of particles with matter Modeling the detector response Run and event control Accessory utilities (random number generators, PDG particle information etc.) Interface to event generators Visualization of the set-up, tracks and hits User interface Persistency

9 9 OO Toolkit for the simulation of next generation HEP detectors … of the current generation too... not only of HEP detectors Distributed software production and management Application of rigorous software engineering methodologies and Object Oriented technology to the HEP environment … also… Born from the requirements of large scale HEP experiments Geant3 Fortran CERN product Inadequate for LHC experiments R&D phase : RD44, 1994 - 1998 1 st release: December 1998 2 new releases/year What is Geant4 ? GEometry ANd Tracking

10 10 ATLAS LHCb 9 orders of magnitude ! Higgs All interactions Born from the requirements of large scale HEP experiments

11 11 Geant4 collaboration CERN, ESA, KEK, SLAC, TRIUMF, TJNL, INFN, IN2P3, PPARC Barcelona Univ., Budker Inst., Frankfurt Univ., Karolinska Inst., Helsinki Univ., Lebedev Inst., LIP, Northeastern Univ. etc.

12 12 EGS4, EGS5, EGSnrc Geant3, Geant4 MARS MCNP, MCNPX, A3MCNP, MCNP-DSP, MCNP4B MVP, MVP-BURN Penelope Peregrine Tripoli-3, Tripoli-3 A, Tripoli-4 DPM EA-MC FLUKA GEM HERMES LAHET MCBEND MCU MF3D NMTC MONK MORSE RTS&T-2000 SCALE TRAX VMC++ Many codes are not publicly distributed Much activity around MC ! The zoo

13 13 ✔ Transports a particle step-by-step by taking into account the interactions with materials and external electromagnetic fields until the particle -loses its kinetic energy to zero, -disappears by an interaction, -comes to the end of the simulation volume ✔ Provides a way for the user to access the transportation process and grab the simulation results -at the beginning and end of transportation, -at the end of each stepping in transportation, -at the time when the particle is going into the sensitive volume of the detector -etc. These are called User Actions What can Geant4 do for you ?

14 14 ✔ Three essential information you have to provide : -Geometrical information of the detector -Choice of physics processes -Kinematical information of particles going into the detector ✔ Auxiliary you have to prepare : -Magnetic and electric field -Actions you want to take when you access the particle transportation -Actions you want to take when a particle goes into a sensitive volume of the detector -etc. What you have to do for Geant4

15 15 Minimum software knowledge to use Geant4 C++ –Geant4 is implemented in C++, therefore a basic knowledge of C++ is mandatory –C++ is a complex language, but you are not required to be a C++ expert to use Geant4 Object Oriented Technology –basic concepts –in-depth knowledge needed only for the development of complex applications Unix/Linux Unix/Linux is a standard working environment for Geant4, therefore a minimum knowledge/experience is required –How to use basic Unix command –How to compile a C++ code Windows You can use Visual C++ Though still you need some knowledge of Unix (cygwin) for installation

16 16 Geant4 provides standard tools to help you to prepare input information ●Multiple choices to describe the detector geometry −Combining basic geometry elements (box, cylinder, trapezoid, etc) −Representation by surface planes −Representation by Boolean operation, etc. ●Standard way to define materials in the detector −A large collection of examples to define various materials ●A set of wide variety of particles −Standard elementary particles (electron, muon, proton,….) −Unstable particles (resonances, quarks, …) −Ions −Exotic particles (geantino, charged geantino,… yours !) Tools for input preparation

17 17 Geant4 provides a wide variety of physics models of particle interactions with matter you can select ●Category of physics processes −Standard electromagnetic processes − Low energy electromagnetic processes − Hadronic processes ●How to use physics processes −A rich samples of Physics List provided with example applications −Recommended Physics List (educated guess) for hadronic physics Choices of Physics processes

18 18 This course is part of the training programme offered by the Geant4 Collaboration –an international collaboration of scientists, developing and maintaining the Geant4 Simulation Toolkit This course is a brief introduction to the architecture, modeling capabilities, physics, functionality and applications of the Geant4 Toolkit –it does not replace the study of Geant4 User Documentation More extensive courses, with hands-on exercises, are organized by the Geant4 Collaboration –information available from Geant4 web site http://cern.ch/geant4 Geant4 training and user support

19 19 Documentation and tutorials available at : http://cern.ch/geant4 Other tutorial material

20 20 25 minutes The Geant4 toolkit : 2/15 - Basic structure

21 21 The Geant4 kernel Handles runs, events, tracks, steps, hits, trajectories Implements Geant4 as a state machine provides a framework for −physics processes −visualization drivers −GUIs −persistency −histogramming/analysis −user code

22 22 Run A run is a collection of events which are produced under identical conditions Within a run, user cannot change: –Detector or apparatus geometry –Physics process settings By analogy to high energy physics, a Geant4 run begins with the command “beamOn”. Detector is inaccessible once beam is on At beginning of run: –Geometry is optimized for navigation –Cross sections are calculated according to materials in setup –Low-energy cutoff values are defined The class G4Run defines a run object

23 23 At beginning of processing, an event contains primary particles (from generator, particle gun,...), which are pushed onto a stack During processing, each particle is popped from the stack and tracked When the stack is empty, processing of the event is over The class G4Event defines an event object At the end of processing it has the following objects: –List of primary vertices and particles (the input) –Hits collections –Trajectory collections (optional) –Digitizations collections (optional) Event

24 24 A track is a snapshot of a particle within its environment –as the particle moves, the quantities in the snapshot change –at any particular instance, a track has position, physical quantities –it is not a collection of steps Track object lifetime –created by a generator or physics process (e.g. decay) –deleted when it: leaves world volume disappears (particle decays or is absorbed) goes to zero energy and no “at rest” process is defined user kills it No track object survives the end of an event (not persistent). User must take action to store track record in trajectory The G4Track class defines a track object Track

25 25 The step is the basic unit of simulation –Associated class is G4Step –Has two points (pre-step, post-step) –Contains the incremental particle information (energy loss, elapsed time, etc.) –Each point contains volume and material information –If step is limited by a boundary, the end point stands exactly on the boundary, but is logically part of next volume –Hence boundary processes such as refraction and transition radiation can be simulated Step

26 26 A Geant4 simulation as a HEP experiment Incident particles : e.g. beam of protons RUN = all the beam protons EVENT = a proton TargetDetectors TRACK = a snapshot of a particle STEP = the elementary interation step Secondary particles

27 27 Geant4 categories Geant4 consists of 17 categories –Each is independently developed and maintained by a working group Categories designed to minimize dependence –Geant4 kernel consists of categories in red D

28 28 Geant4 tracking is general –It is independent of the particle type the physics processes assigned to the particle –It enables all processes to contribute to the determination of the step length contribute to any possible changes in physical quantities of the track generate secondary particles suggest changes in the state of the track (e.g. to suspend, postpone or kill) Tracking

29 29 Processes All the work of particle decays and interactions is done by processes –Particle transportation is also a process; the particle can interact with geometrical boundaries and any kind of field –There is also a shower parameterization process which can take over from transportation Each particle has its own list of applicable processes. At the beginning of each step, all of these processes are queried for a proposed physical interaction length The process with the shortest proposed length (in space-time) is the one that occurs –The chosen process also limits the step size

30 30 Cuts A “cut” in Geant4 is really a production threshold –Only applies to physics processes which have infrared divergence –It is not a tracking cut An energy threshold must be determined at which discrete energy loss is replaced by continuous energy loss Specify range (which is converted to energy for each material) at which continuous energy loss begins, track primary down to zero range above specified range create secondaries, below range add to continuous energy loss of primary

31 31 Use these classes to build your application on top of the Geant4 toolkit (class names in purple are mandatory) Initialization classes –G4VUserDetectorConstruction –G4VUserPhysicsList Action classes –G4VUserPrimaryGeneratorAction –G4UserRunAction –G4UserEventAction –G4UserStackingAction –G4UserTrackingAction –G4UserSteppingAction Main() - not provided by Geant4 User classes

32 32 Managers classes broker transactions between objects within a category and communicate with other managers They are singletons The user will have the most contact with G4RunManager –Must register detector geometry, physics list, particle generator to it Other manager classes: –G4EventManager – handles event processing, user actions –G4TrackingManager – handles tracks, trajectory storage, user actions –G4SteppingManager – handles steps, physics processes, hit scoring, user actions –G4VisManager – handles visualization drivers Manager classes

33 33 Build your simulation in 7 steps

34 34 Derive your own concrete class from the abstract base class G4VUserDetectorConstruction In the virtual method Construct() –assemble all necessary materials –build the volumes of your detector geometry Optionally you may define: –sensitive detector classes and assign them to the detector volumes –regions for any part of your detector (for production ranges) –visualization attributes of detector elements –magnetic (or other) fields 1 - Describe your detector

35 35 Geant4 does not have any default particles or processes –even particle transporation must be explicitly defined by user Derive your own concrete class from G4VUserPhysicsList abstract base class –define all necessary particles –define all necessary processes and assign them to the proper particles –define production threshold (cutoff) ranges and assign them to world volume and each region Geant4 provides many utility classes/methods to assist in the above tasks Example (educated guess) physics lists exist for electromagnetic and hadronic physics 2 – Select physics processes

36 36 3 – Generate primary event For each event, user must define all details of initial particle Derive concrete class from G4VUserPrimaryGeneratorAction abstract base class Geant4 provides several ways to do this: –derive your own generator from G4VPrimaryGenerator –use provided generators: G4ParticleGun (user provides number, energy, direction, type) G4HEPEvtInterface, G4HepMCInterface (interfaces to high energy generator programs) G4GeneralParticleSource (mostly for radioactivity)

37 37 G4UserRunAction –BeginOfRunAction (define histograms) –EndOfRunAction (Save histogram files) G4UserEventAction –BeginOfEventAction (event selection) –EndOfEventAction (fill histograms) G4UserTrackingAction –PreUserTrackingAction (create user defined trajectory) –PostUserTrackingAction G4UserSteppingAction –UserSteppingAction (kill, suspend, postpone track) G4UserStackingAction –PrepareNewEvent (reset priority control) –ClassifyNewTrack invoked when new track is pushed can set track as urgent, waiting, postpone or kill –NewStage invoked when urgent stack is empty event filtering 4 – User action classes

38 38 Geant4 does not provide a main() –However, many examples are provided in the Application Developers Guide In main(), you must: –Construct G4RunManager (or a class derived from it) –Provide to G4RunManager pointers to mandatory user classes: G4VUserDetectorConstruction G4VUserPhysicsList G4VUserPrimaryGeneratorAction Other classes which can be defined in main() –G4VisManager –(G)UI session –Optional user classes 5 - The main() program

39 39 Geant4 provides several G4UISession concrete classes –Select the one that is appropriate for your computing envirnoment –In main(), construct one of them –Invoke its sessionStart() method UI sessions provided: –G4UIterminal – C- and TC-shell like character terminal –G4GAG – Tcl/Tk of Java PVM based GUI –G4JAG – interface to JAS (Java Analysis Studio) –G4UIBatch – batch job with macro file 6 – Setting up a user interface session

40 40 Geant4 provides interfaces to several graphics drivers: –DAWN – Fukui renderer –WIRED – event display –RayTracer – ray tracing by Geant4 tracking –OpenGL –OpenInventor –VRML 7 - Visualization

41 41 Application files : example In the directory simulation –Simulation.cc –GNUMakefile In simulation/src –DetectorConstruction.cc –PhysicsList.cc –PrimaryGeneratorAction.cc –UserRunAction.cc –UserEventAction.cc –UserTrackingAction.cc –UserSteppingAction.cc In simulation/include –DetectorConstruction.hh –PhysicsList.hh –PrimaryGeneratorAction.hh –UserRunAction.hh –UserEventAction.hh –UserTrackingAction.hh –UserSteppingAction.hh –main() –Instructions for gmake –Materials and geometries –Particles and Physics processes –Primary particles –User action class (run) –User action class(event) –User action class(track) –User action class(step) In purple : mandatory files In white : optional files

42 42 For portability “ G4 ” is prepended to raw C++ type names –G4int, G4double,... –This way Geant4 implements correct type for a given architecture G4cout and G4cerr are ostream objects defined by Geant4 –G4endl is also provided Some GUIs are buffer output streams so that they display print-outs on another window or provide storing/editing functionality –The user should not use std::cout, etc. Users should not use std::cin for input. Instead use the user-defined commands provided by the intercoms category –e.g. G4UIcmdWithADouble The G4 prefix

43 43 System of units INPUT: Geant4 has no default unit. To give a number, unit must be “multiplied” to the number. –for example : G4double width = 12.5*m; G4double density = 2.7*g/cm3; –If no unit is specified, the internal G4 unit will be used, but this is discouraged ! –Almost all commonly used units are available. –The user can define new units. –Refer to CLHEP: SystemOfUnits.h OUTPUT: Divide a variable by a unit you want to get. G4cout << dE / MeV << “ (MeV)” << G4endl;

44 44 System of units are defined in CLHEP, based on: –millimetre (mm), nanosecond (ns), Mega eV (MeV), positron charge (eplus) degree Kelvin (kelvin), the amount of substance (mole), luminous intensity (candela), radian (radian), steradian (steradian) All other units are computed from the basic ones. In output, Geant4 can choose the most appropriate unit to use. Just specify the category for the data (Length, Time, Energy, etc…): G4cout << G4BestUnit(StepSize, “Length”); StepSize will be printed in km, m, mm or … fermi, depending on its value New units can be defined System of units

45 45 The Geant4 toolkit consists of 17 categories, each designed for minimal dependence on the others The largest unit of a simulation application is the run, which consists in turn of events, tracks, and steps –a track is a snapshot of a dynamic particle, not a trajectory Tracking and physics are carried out by processes Production thresholds and stacking allow for efficient simulation –Geant4 tracks particles down to zero energy User classes allow the simulation to be customized –user must build the apparatus, select the physics –commands allow user to communicate with simulation Summary

46 46 More

47 47 Geant4 as a state machine Geant4 has six application states G4State_PreInit : initialization, definition of geometry, material, particles and physics G4State_Idle : may start run or modify geometry/physics for next run G4State_GeomClosed : geometry is optimized, cross section tables updated, ready to process event G4State_EventProc : an event is being processed G4State_Quit : normal termination G4State_Abort : fatal exception and program is aborting D

48 48 New units can be defined directly as constants, or (suggested way) via G4UnitDefinition. G4UnitDefinition ( name, symbol, category, value ) Example (mass thickness): G4UnitDefinition (“grammpercm2”, “g/cm2”, “MassThickness”, g/cm2); –The new category “ MassThickness” will be registered in the kernel in G4UnitsTable To print the list of units: –From the code G4UnitDefinition::PrintUnitsTable(); –At run-time, as UI command: Idle> /units/list Definition of new units

49 49 Environment variables To compile, link and run a Geant4-based simulation, the following environment variables must be set: –$G4SYSTEM – operating system (e.g. Linux-g++) –$G4INSTALL – base directory of Geant4 (where the compiled libraries are) –$G4WORKDIR – where you run your application –$CLHEP_BASE_DIR – location of the compiled CLHEP libraries Variables for physics processes (if those processes are used): –$G4LEVELGAMMADATA – location of photon evaporation data –$G4LEDATA -- location of cross sections for low energy EM module –$G4RADIOACTIVEDATA – for radioactive decay processes –$NeutronHPCrossSections – location of high precision neutron db Additional variables for GUI, Visualization, Analysis

50 50 Commands & intercoms In Geant4, user can define commands and macros to run applications The Intercoms category handles the framework mechanism of defining and delivering commands –It is exportable to any other application –It is independent of other Geant4 categories –Uses strong type and range checking C++ syntax : aCmd -> SetRange(“x>0. && y>0.”); –Dynamic command definition / activation –Commands can be hard coded or issued by (G)UI Macro files are enabled –Loop, foreach, alias,...

51 51 Track stacking G4Track is a class object -> easy to suspend or postpone tracks Example: –Suspend tracks at entrance to calorimeter, i.e. simulate all tracks in tracking region before generating showers –Suspend “looper” tracks or abort or postpone them to next event Stacking allows prioritized tracking without a perfomance penalty Well thought-out prioritization or abortion of tracks/events make simulation more efficient

52 52 Initialization Describe your experimental set-up Activate physics processes appropriate to your experiment

53 53 Beam On Generate primary events according to distributions relevant to your experiment

54 54 Event computation Record the physics quantities generated by the simulation, that are relevant to your experiment

55 55 Step computation

56 56 10 minutes DetectorConstruction.hh (.cc) The Geant4 toolkit : 3/15 - Definition of materials

57 57 Different kinds of materials can be defined: –isotopes<> G4Isotope –elements<> G4Element –molecules<> G4Material –compounds and mixtures <> G4Material Attributes associated: –temperature, pressure, state, density Definition of materials

58 58 G4Isotope and G4Element describe the properties of the atoms: –Atomic number, number of nucleons, mass of a mole, shell energies –Cross-sections per atoms, etc… G4Material describes the macroscopic properties of the matter: –temperature, pressure, state, density –Radiation length, absorption length, etc… Isotopes, elements and materials

59 59 Isotopes can be assembled into elements G4Isotope (const G4String& name, G4int z, // atomic number G4int n, // number of nucleons G4double a ); // mass of mole … building elements as follows: G4Element (const G4String& name, const G4String& symbol, // element symbol G4int nIso ); // # of isotopes G4Element::AddIsotope(G4Isotope* iso, // isotope G4double relAbund); // fraction of atoms // per volume Elements & isotopes

60 60 G4double density = 1.390*g/cm3; G4double a = 39.95*g/mole; G4Material* lAr = new G4Material("liquidArgon",z=18.,a,density); Material of one element (lAr)

61 61 A molecule is made of several elements (composition by number of atoms): a = 1.01*g/mole; G4Element* elH = new G4Element("Hydrogen",symbol="H",z=1.,a); a = 16.00*g/mole; G4Element* elO = new G4Element("Oxygen",symbol="O",z=8.,a); density = 1.000*g/cm3; G4Material* H2O = new G4Material("Water",density,ncomp=2); H2O->AddElement(elH, natoms=2); H2O->AddElement(elO, natoms=1); Material : molecule (water)

62 62 Compound: composition by fraction of mass 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, 70.0*perCent); Air->AddElement(elO, 30.0*perCent); Material : compound (air)

63 63 Composition of compound materials G4Element* elC = …; // define “carbon” element G4Material* SiO2 = …; // define “quartz” material G4Material* H2O = …; // define “water” material density = 0.200*g/cm3; G4Material* Aerog = new G4Material("Aerogel",density,ncomponents=3); Aerog->AddMaterial(SiO2,fractionmass=62.5*perCent); Aerog->AddMaterial(H2O,fractionmass=37.4*perCent); Aerog->AddElement (elC,fractionmass= 0.1*perCent); Material : mixture (aerogel)

64 64 It may be necessary to specify temperature and pressure –(dE/dx computation affected) G4double density = 27.*mg/cm3; G4double temperature = 325.*kelvin; G4double pressure = 50.*atmosphere; G4Material* CO2 = new G4Material(“CarbonicGas", density, ncomponents=2 kStateGas, temperature, pressure); CO2->AddElement(C,natoms = 1); CO2->AddElement(O,natoms = 2); Exemple : gas (CO 2 )

65 65 Absolute vacuum does not exist. It is a gas at very low density ! –Cannot define materials composed of multiple elements through Z or A, or with  = 0 G4double atomicNumber = 1.; G4double massOfMole = 1.008*g/mole; G4double density = 1.e-25*g/cm3; G4double temperature = 2.73*kelvin; G4double pressure = 3.e-18*pascal; G4Material* Vacuum = new G4Material(“interGalactic", atomicNumber, massOfMole, density, kStateGas, temperature, pressure); Exemple : vacuum

66 66 Material NIST database ==================================== ### Elementary Materials from the NIST Data Base ================================== Z Name ChFormula density(g/cm^3) I(eV) ==================================== 1 G4_H H_2 8.3748e-05 19.2 2 G4_He 0.000166322 41.8 3 G4_Li 0.534 40 4 G4_Be 1.848 63.7 5 G4_B 2.37 76 6 G4_C 2 81 7 G4_N N_2 0.0011652 82 8 G4_O O_2 0.00133151 95 9 G4_F 0.00158029 115 10 G4_Ne 0.000838505 137 11 G4_Na 0.971 149 12 G4_Mg 1.74 156 13 G4_Al 2.6989 166 14 G4_Si 2.33 173 Elements Compounds Nuclear applications Space applications =================================== ### Compound Materials from the NIST Data Base =================================== N Name ChFormula density(g/cm^3) I(eV) =================================== 13 G4_Adipose_Tissue 0.92 63.2 1 0.119477 6 0.63724 7 0.00797 8 0.232333 11 0.0005 12 2e-05 15 0.00016 16 0.00073 17 0.00119 19 0.00032 20 2e-05 26 2e-05 30 2e-05 4 G4_Air 0.00120479 85.7 6 0.000124 7 0.755268 8 0.231781 18 0.012827 2 G4_CsI 4.51 553.1 53 0.47692 55 0.52308

67 67 No need to predefine elements and materials Dedicated user interfaces G4NistManager* manager = G4NistManager::GetPointer(); G4Element* elm = manager->FindOrBuildElement(“symb”, G4bool iso); G4Element* elm = manager->FindOrBuildElement(G4int Z, G4bool iso); G4Material* mat = manager->FindOrBuildMaterial(“name”, G4bool iso); G4Material* mat = manager->ConstructNewMaterial(“name”, const std::vector & Z, const std::vector & weight, G4double density, G4bool iso); G4double isotopeMass = manager->GetMass(G4int Z, G4int N); How to use it ?

68 68 70 minutes DetectorConstruction.hh (.cc) The Geant4 toolkit : 4/15 - Geometry construction

69 69 Outline 1. The basics 2. Logical and physical volumes 3. Solids 4. Touchables 5. Sensitive detector, digitizer 6. Magnetic field 7. Visualization 8. Advanced features 9. Geometry examples

70 70 Geometry : 1 – the basics

71 71 Describe your detector Derive your own concrete class from G4VUserDetectorConstruction abstract base class Implementing the method Construct() Modularize it according to each detector component or sub- detector : Construct all necessary materials Define shapes/solids required to describe the geometry Construct and place volumes of your detector geometry  Options −Define sensitive detectors and identify detector volumes which to associate them −Associate magnetic field to detector regions −Define visualization attributes for the detector elements

72 72 Creating a detector volume Start with its Shape & Size –Box 3x5x7 cm, sphere R=8m Add properties: –material, B/E field –(make it sensitive) Place it within another volume –in one place –repeatedly using a function Solid Logical Physical

73 73 Define detector geometry Three conceptual layers –G4VSolid : shape, size –G4LogicalVolume : daughter physical volumes, material, sensitivity, user limits, etc. –G4VPhysicalVolume : position, rotation G4Box G4Tubs G4VSolid G4VPhysicalVolume G4Material G4VSensitiveDetector G4PVPlacement G4PVParameterised G4VisAttributes G4LogicalVolume

74 74 Basic strategy G4VSolid* pBoxSolid = new G4Box(“aBoxSolid”, 1.*m, 2.*m, 3.*m); G4LogicalVolume* pBoxLog = new G4LogicalVolume( pBoxSolid, pBoxMaterial, “aBoxLog”, 0, 0, 0); G4VPhysicalVolume* aBoxPhys = new G4PVPlacement( pRotation, G4ThreeVector(posX, posY, posZ), pBoxLog, “aBoxPhys”, pMotherLog, 0, copyNo); Solid : shape and size Logical volume : + material, sensitivity, etc. Physical volume : + rotation and position Geometry  A volume is placed in its mother volume.  Position and rotation of the daughter volume is described with respect to the local coordinate system of the mother volume.  The origin of mother volume’s local coordinate system is at the center of the mother volume.  Daughter volume cannot protrude from mother volume

75 75 One logical volume can be placed more than once. One or more volumes can be placed to a mother volume. Note that the mother-daughter relationship is an information of G4LogicalVolume. –If the mother volume is placed more than once, all daughters are by definition appear in all of mother physical volumes. The world volume must be a unique physical volume which fully contains all the other volumes. –The world volume defines the global coordinate system. The origin of the global coordinate system is at the center of the world volume. –Position of a track is given with respect to the global coordinate system. Geometrical hierarchy

76 76 Geometry : 2 – logical and physical volumes

77 77 G4LogicalVolume(G4VSolid* pSolid, G4Material* pMaterial, const G4String& name, G4FieldManager* pFieldMgr=0, G4VSensitiveDetector* pSDetector=0, G4UserLimits* pULimits=0, G4bool optimise=true); –Contains all information of volume except position: Shape and dimension ( G4VSolid ) Material, sensitivity, visualization attributes Position of daughter volumes Magnetic field, User limits Shower parameterisation –Physical volumes of same type can share a logical volume. –The pointers to solid and material must be NOT null –Once created it is automatically entered in the LV store –It is not meant to act as a base class 1) G4LogicalVolume

78 78 2) G4VPhysicalVolume –G4PVPlacement 1 Placement = ONE volume A volume instance positioned once in a mother volume –G4PVParameterised 1 Parameterised = MANY Volumes Parameterised by the copy number –Shape, size, material, position and rotation can be parameterised, by implementing a concrete class of G4VPVParameterisation. Reduction of memory consumption –Currently: parameterisation can be used only for volumes that either have no further daughters are identical in size & shape –G4PVReplica 1 Replica = MANY Volumes Slicing a volume into smaller pieces (if it has a symmetry)

79 79 2) G4VPhysicalVolume - next repeated placement 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

80 80 G4VPhysicalVolume G4PVPlacement G4PVParameterised G4PVReplica G4PVDivision

81 81 G4PVPlacement(G4RotationMatrix* pRot, const G4ThreeVector& tlate, G4LogicalVolume* pCurrentLogical, const G4String& pName, G4LogicalVolume* pMotherLogical, G4bool pMany, G4int pCopyNo); Single volume positioned relatively to the mother volume –In a frame rotated and translated relative to the coordinate system of the mother volume Three additional constructors –A simple variation: specifying the mother volume as a pointer to its physical volume instead of its logical volume. –Using G4Transform3D to represent the direct rotation and translation of the solid instead of the frame –The combination of the two variants above G4PVPlacement

82 82 G4PVPlacement G4PVPlacement(G4RotationMatrix* pRot, // rotation of mother frame const G4ThreeVector &tlate, // position in rotated frame G4LogicalVolume *pDaughterLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, // ‘true’ not implemented yet… G4int pCopyNo, // unique arbitrary integer G4bool pSurfChk=false); // optional : boundary check rotation translation in the frame after rotation Mother volume

83 83 G4PVPlacement( G4Transform3D(G4RotationMatrix &pRot, // rotation of mother frame const G4ThreeVector &tlate), // position in mother frame G4LogicalVolume *pDaughterLogical, const G4String &pName, G4LogicalVolume *pMotherLogical, G4bool pMany, G4int pCopyNo, G4bool pSurfChk=false); rotation Mother volume Translation in mother frame Alternative G4PVPlacement

84 84 G4VPhysicalVolume G4PVPlacement G4PVParameterised G4PVReplica G4PVDivision

85 85 User written functions define: –the size of the solid (dimensions) function ComputeDimensions(…) –where it is positioned (transformation) function ComputeTransformations(…) Optional: –the type of the solid function ComputeSolid(…) –the material function ComputeMaterial(…) Limitations: –Applies to simple CSG solids only –Daughter volumes allowed only for special cases Very powerful: –Consider parameterised volumes as “leaf” volumes Parameterised physical volumes

86 86 Complex detectors –with large repetition of volumes regular or irregular Medical applications –the material in animal tissue is measured cubes with varying material Use of parameterised volumes

87 87 G4PVParameterised(const G4String& pName, G4LogicalVolume* pCurrentLogical, G4LogicalVolume* pMotherLogical, const EAxis pAxis, const G4int nReplicas, G4VPVParameterisation* pParam); Replicates the volume nReplicas times using the parameterisation pParam, within the mother volume The positioning of the replicas is dominant along the specified Cartesian axis –If kUndefined is specified as axis, 3D voxelisation for optimisation of the geometry is adopted Represents many touchable detector elements differing in their positioning and dimensions. Both are calculated by means of a G4VPVParameterisation object Alternative constructor using pointer to physical volume for the mother G4PVParameterised

88 88 G4VPhysicalVolume G4PVPlacement G4PVParameterised G4PVReplica G4PVDivision

89 89 repeated The mother volume is sliced into replicas, all of the same size and dimensions. Represents many touchable detector elements differing only in their positioning. Replication may occur along: –Cartesian axes (X, Y, Z) – slices are considered perpendicular to the axis of replication Coordinate system at the center of each replica –Radial axis (Rho) – cons/tubs sections centered on the origin and un-rotated Coordinate system same as the mother –Phi axis (Phi) – phi sections or wedges, of cons/tubs form Coordinate system rotated such as that the X axis bisects the angle made by each wedge Replicated physical volumes

90 90 G4PVReplica(const G4String& pName, G4LogicalVolume* pCurrentLogical, G4LogicalVolume* pMotherLogical, const EAxis pAxis, const G4int nReplicas, const G4double width, const G4double offset=0); Alternative constructor: using pointer to physical volume for the mother An offset can only be associated to a mother offset along the axis of replication Features and restrictions: –Replicas can be placed inside other replicas –Normal placement volumes can be placed inside replicas, assuming no intersection/overlaps with the mother volume or with other replicas –No volume can be placed inside a radial replication –Parameterised volumes cannot be placed inside a replica A daughter volume to be replicated mother volume G4PVReplica

91 91 Cartesian axes - kXaxis,kYaxis,kZaxis –offset shall not be used –Center of n-th daughter is given as -width*(nReplicas-1)*0.5+n*width Radial axis - kRaxis –Center of n-th daughter is given as width*(n+0.5)+offset Phi axis - kPhi –Center of n-th daughter is given as width*(n+0.5)+offset offset width offset width Replica – axis, width, offset

92 92 G4VPhysicalVolume G4PVPlacement G4PVParameterised G4PVReplica G4PVDivision

93 93 Implemented as “special” kind of parameterised volumes –Applies to CSG-like solids only (box, tubs, cons, para, trd, polycone, polyhedra) –Divides a volume in identical copies along one of its axis (copies are not strictly identical) e.g. - a tube divided along its radial axis Offsets can be specified The possible axes of division vary according to the supported solid type Represents many touchable detector elements differing only in their positioning G4PVDivision is the class defining the division –The parameterisation is calculated automatically using the values provided in input G4PVDivision

94 94 Geometry : 3 - solids

95 95 Abstract class All solids in Geant4 derive from it –Defines but does not implement all functions required to: compute distances to/from the shape check whether a point is inside the shape compute the extent of the shape compute the surface normal to the shape at a given point Once constructed, each solid is automatically registered in a specific solid store G4VSolid

96 96 Solids defined in Geant4 –CSG (Constructed Solid Geometry) solids G4Box, G4Tubs, G4Cons, G4Trd, … Analogous to simple Geant3 CSG solids –Specific solids (CSG like) G4Polycone, G4Polyhedra, G4Hype, … G4TwistedTubs, G4TwistedTrap, … –BREP (Boundary REPresented) solids G4BREPSolidPolycone, G4BSplineSurface, … Any order surface –Boolean solids G4UnionSolid, G4SubtractionSolid, … Solids

97 97 G4Tubs(const G4String& pname, // name G4double pRmin, // inner radius G4double pRmax, // outer radius G4double pDz, // Z half length G4double pSphi, // starting Phi G4double pDphi); // segment angle G4Cons(const G4String& pname, // name G4double pRmin1, // inner radius -pDz G4double pRmax1, // outer radius -pDz G4double pRmin2, // inner radius +pDz G4double pRmax2, // outer radius +pDz G4double pDz, // Z half length G4double pSphi, // starting Phi G4double pDphi); // segment angle CSG: G4Tubs, G4Cons

98 98 CSG: G4Box, G4Tubs G4Box(const G4String &pname, // name G4double half_x, // X half size G4double half_y, // Y half size G4double half_z); // Z half size G4Tubs(const G4String &pname, // name G4double pRmin, // inner radius G4double pRmax, // outer radius G4double pDz, // Z half length G4double pSphi, // starting Phi G4double pDphi); // segment angle

99 99 Other CSG solids G4Cons G4Para (parallelepiped) G4Trd G4Trap G4Sphere G4Orb (full sphere) G4Torus Consult Geant4 Application Developers Guide for all available shapes.

100 100 G4Polycone(const G4String& pName, G4double phiStart, G4double phiTotal, G4int numRZ, const G4double r[], const G4double z[]); ●numRZ : numbers of corners in the r,z space ●r, z : coordinates of corners ●Additional constructor Specific CSG Solids: G4Polycone

101 101 Other Specific CSG solids G4Polyhedra G4EllipticalTube G4Ellipsoid G4EllipticalCone G4HypeG4Tet (tetrahedra) G4TwistedBox G4TwistedTrd G4TwistedTrap G4TwistedTubs Consult Geant4 Application Developers Guide for all available shapes.

102 102 BREP = Boundary REPresented Solid Listing all its surfaces specifies a solid –e.g. 6 squares for a cube Surfaces can be –planar, 2 nd or higher order elementary BREPS –Splines, B-Splines, NURBS (Non-Uniform B-Splines) advanced BREPS Few elementary BREPS pre-defined –box, cons, tubs, sphere, torus, polycone, polyhedra Advanced BREPS built through CAD systems BREP solids

103 103 G4BREPSolidPolyhedra(const G4String& pName, G4double phiStart, G4double phiTotal, G4int sides, G4int nZplanes, G4double zStart, const G4double zval[], const G4double rmin[], const G4double rmax[]); sides - numbers of sides of each polygon in the x-y plane nZplanes - numbers of planes perpendicular to the z axis zval[] - z coordinates of each plane rmin[], rmax[] - radii of inner and outer polygon at each plane BREPS: G4BREPSolidPolyhedra

104 104 Boolean solids Solids can be combined using boolean operations: –G4UnionSolid, G4SubtractionSolid, G4IntersectionSolid –Requires: 2 solids, 1 boolean operation, and an (optional) transformation for the 2 nd solid –2 nd solid is positioned relative to the coordinate system of the 1 st solid –Result of boolean operation becomes a solid. Thus the third solid can be combined to the resulting solid of first operation. Solids to be combined can be either CSG or other Boolean solids. Note: tracking cost for the navigation in a complex Boolean solid is proportional to the number of constituent CSG solids G4UnionSolidG4IntersectionSolid G4SubtractionSolid

105 105 Boolean solids

106 106 Boolean Solids - example G4VSolid* box = new G4Box(“Box",50*cm,60*cm,40*cm); G4VSolid* cylinder = new G4Tubs(“Cylinder”,0.,50.*cm,50.*cm,0.,2*M_PI*rad); G4VSolid* union = new G4UnionSolid("Box+Cylinder", box, cylinder); G4VSolid* subtract = new G4SubtractionSolid("Box-Cylinder", box, cylinder, 0, G4ThreeVector(30.*cm,0.,0.)); G4RotationMatrix* rm = new G4RotationMatrix(); rm->RotateX(30.*deg); G4VSolid* intersect = new G4IntersectionSolid("Box&&Cylinder", box, cylinder, rm, G4ThreeVector(0.,0.,0.)); The origin and the coordinates of the combined solid are the same as those of the first solid.

107 107 Geometry : 4 - touchables

108 108 Touchables Suppose a geometry is made of 4x5 voxels and it is implemented by two levels of replica. In reality, there is only one physical volume object for each level. Its position is parameterized by its copy number. To get the copy number of each level, use touchable to get the copy number of each level CopyNo = 0 CopyNo = 1 CopyNo = 2 CopyNo = 3 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 G4VTouchable has a method GetCopyNumber(G4int nLevel=0) –nLevel = 0 : returns the copy number of the bottom level –nLevel = 1 : returns the copy number of the mother volume –nLevel = 2 : returns the copy number of the grandmother volume, etc.

109 109 Geometry : 5 – sensitive detector and digitizer

110 110 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 NOTE: you must get the volume information from the “PreStepPoint” Detector sensitivity

111 111 Sensitive detector and hit Each “Logical Volume” can have a pointer to a sensitive detector Hit is a snapshot of the physical interaction of a track or an accumulation of interactions of tracks in the sensitive region of your detector A sensitive detector creates hit(s) using the information given in G4Step object. The user has to provide his/her own implementation of the detector response Hit objects, which still are the user’s class objects, are collected in a G4Event object at the end of an event. –The UserSteppingAction class should NOT do this

112 112 Hit is a user-defined class derived from G4VHit You can store various types information by implementing your own concrete Hit class For example: –Position and time of the step –Momentum and energy of the track –Energy deposition of the step –Geometrical information –or any combination of above Hit class – 1

113 113 Hit objects of a concrete hit class must be stored in a dedicated collection which is instantiated from G4THitsCollection template class The collection will be associated to a G4Event object via G4HCofThisEvent Hits collections are accessible –through G4Event at the end of event, –through G4SDManager during processing an event Used for Event filtering Hit class - 2

114 114 Readout geometry is a virtual and artificial geometry which can be defined in parallel to the real detector geometry A readout geometry is optional Each one is associated to a sensitive detector Readout geometry

115 115 Digit represents a detector output (e.g. ADC/TDC count, trigger signal) Digit is created with one or more hits and/or other digits by a concrete implementation derived from G4VDigitizerModule In contradiction to the Hit which is generated at tracking time automatically, the digitize() method of each G4VDigitizerModule must be explicitly invoked by the user’s code (e.g. EventAction) Digitization

116 116 Basic strategy G4LogicalVolume* myLogCalor = ……; G4VSensitiveDetector* pSensitivePart = new MyCalorimeterSD(“/mydet/calorimeter”); G4SDManager* SDMan = G4SDManager::GetSDMpointer(); SDMan->AddNewDetector(pSensitivePart); myLogCalor->SetSensitiveDetector(pSensitivePart) ; Defining a sensitive detector

117 117 Geometry : 6 – magnetic field

118 118 Magnetic field Create your magnetic field class –Uniform field : use a G4UniformMagField class object G4MagneticField* magField = new G4UniformMagField(G4ThreeVector(1.*Tesla,0.,0.); –Non uniform field : create a concrete class derived from G4MagneticField and implement the GetFieldValue method void MyField::GetFieldValue( const double Point[4], double *field) const Point[0..2] are the positions in the GLOBAL reference frame Point[3] is time field[0..2] returns magnetic field coordinates Also, possibility to define any kind of field !

119 119 Field integration In order to propagate a particle inside a field (e.g. magnetic, electric or both), we solve the equation of motion of the particle in the field. We use a Runge-Kutta method for the integration of the ordinary differential equations of motion. –Several Runge-Kutta ‘steppers’ are available. In specific cases other solvers can also be used: –In a uniform field, using the analytical solution. –In a smooth but varying field, with RK+helix. Using the method to calculate the track's motion in a field, Geant4 breaks up this curved path into linear chord segments. –We determine the chord segments so that they closely approximate the curved path. Tracking Step Chords Real trajectory

120 120 Tracking in field We use the chords to interrogate the G4Navigator, to see whether the track has crossed a volume boundary. One physics/tracking step can create several chords. –In some cases, one step consists of several helix turns. User can set the accuracy of the volume intersection, –By setting a parameter called the “miss distance” It is a measure of the error in whether the approximate track intersects a volume. It is quite expensive in CPU performance to set too small “miss distance”. "miss distance" Tracking step Chords Real trajectory

121 121 Example Tell Geant4 to use your field 1.Find the global Field Manager G4FieldManager* globalFieldMgr = G4TransportationManager::GetTransportationManager() -> GetFieldManager(); 1.Set the field for this FieldManager, globalFieldMgr-> SetDetectorField(magField); 1.and create a Chord Finder. globalFieldMgr-> CreateChordFinder(magField); $G4INSTALL/example/novice/N04/ExN04 is a good starting point

122 122 Geometry : 7 - visualization

123 123 Visualization of detector Each logical volume can have associated a G4VisAttributes object –Visibility, visibility of daughter volumes –Color, line style, line width –Force flag to wire-frame or solid-style mode For parameterised volumes, attributes can be dynamically assigned to the logical volume Lifetime of visualization attributes must be at least as long as the objects they’re assigned to

124 124 Visualization of hits and trajectories Each G4VHit concrete class must have an implementation of Draw() method. –Colored marker –Colored solid –Change the color of detector element G4Trajectory class has a Draw() method. –Blue : positive –Green : neutral –Red : negative –You can implement alternatives by yourself

125 125 Geometry : 8 – advanced functions

126 126 Cuts by region Geant4 has had a unique production threshold (‘cut’) expressed in length (i.e. minimum range of secondary) –For all volumes –Possibly different for each particle. Yet appropriate length scales can vary greatly between different areas of a large detector –E.g. a vertex detector (5  m) and a muon detector (2.5 cm) –Having a unique (low) cut can create a performance penalty Geant4 allows for several cuts –Globally or per particle –Enabling the tuning of production thresholds at the level of a sub-detector, i.e. region –Cuts are applied only for gamma, electron and positron and only for processes which have infrared divergence

127 127 Detector region Concept of region –Set of geometry volumes, typically of a sub-system barrel + end-caps of the calorimeter; “Deep” areas of support structures can be a region. –Or any group of volumes A set of cuts in range is associated to a region –a different range cut for each particle among gamma, e-, e+ is allowed in a region Region B Region B Default Region Region B Region A C C

128 128 Region and cut Each region has its unique set of cuts. World volume is recognized as the default region. The default cuts defined in Physics list are used for it. –User is not allowed to define a region to the world volume or a cut to the default region A logical volume becomes a root logical volume once it is assigned to a region. –All daughter volumes belonging to the root logical volume share the same region (and cut), unless a daughter volume itself becomes to another root Important restriction : No logical volume can be shared by more than one regions, regardless of root volume or not World Volume - Default Region Root logical - Region A Root logical - Region B

129 129 GGE (Graphical Geometry Editor) Implemented in JAVA, GGE is a graphical geometry editor compliant to Geant4. It allows to : –Describe a detector geometry including: materials, solids, logical volumes, placements –Graphically visualize the detector geometry using a Geant4 supported visualization system, e.g. DAWN –Store persistently the detector description –Generate the C++ code according to the Geant4 specifications GGE can be downloaded from Web as a separate tool : http://erpc1.naruto-u.ac.jp/~geant4/

130 130 Computing volumes and masses Geometrical volume of a generic solid or boolean composition can be computed from the solid G4double GetCubicVolume(); Overall mass of a geometry setup (subdetector) can be computed from the logical volume G4double GetMass(G4Bool forced=false, G4Material* parameterisedMaterial=0);

131 131 Debugging geometries An overlapping volume is a contained volume which actually protrudes from its mother volume –Volumes are also often positioned in a same volume with the intent of not provoking intersections between themselves. When volumes in a common mother actually intersect themselves are defined as overlapping Geant4 does not allow for malformed geometries The problem of detecting overlaps between volumes is bounded by the complexity of the solid models description Utilities are provided for detecting wrong positioning –Graphical tools (DAVID, OLAP) –Kernel run-time commands

132 132 Moving objects In some applications, it is essential to simulate the movement of some volumes. –E.g. particle therapy simulation Geant4 can deal with moving volume –In case speed of the moving volume is slow enough compared to speed of elementary particles, so that you can assume the position of moving volume is still within one event. Two tips to simulate moving objects : 1.Use parameterized volume to represent the moving volume. 2.Do not optimize (voxelize) the mother volume of the moving volume(s).

133 133 Geometry 9 - examples

134 134 Vertex localizer LHCb detector at CERN Courtesy of the LHCb Collaboration

135 SUSY events Courtesy of the CMS Collaboration CMS detector at CERN

136 Courtesy of the ATLAS Collaboration ATLAS detector at CERN

137 137 Courtesy of H.Ikeda (Tohoku) Anti-neutrino detector – Kamioka liquid scintillator

138 138 Courtesy T. Ersmark, KTH Stockholm International Space Station

139 139 More

140 140 G4VSolid* solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm); G4LogicalVolume* logicChamber = new G4LogicalVolume(solidChamber, ChamberMater, "Chamber", 0, 0, 0); G4double firstPosition = -trackerSize + 0.5*ChamberWidth; G4double firstLength = fTrackerLength/10; G4double lastLength = fTrackerLength; G4VPVParameterisation* chamberParam = new ChamberParameterisation( NbOfChambers, firstPosition, ChamberSpacing, ChamberWidth, firstLength, lastLength); G4VPhysicalVolume* physChamber = new G4PVParameterised( "Chamber", logicChamber, logicTracker, kZAxis, NbOfChambers, chamberParam); Use kUndefined to activate voxelization 3D for optimization Parameterization : example

141 141 class ChamberParameterisation : public G4VPVParameterisation { public: ChamberParameterisation( G4int NoChambers, G4double startZ, G4double spacing, G4double widthChamber, G4double lenInitial, G4double lenFinal ); ~ChamberParameterisation(); void ComputeTransformation (const G4int copyNo, G4VPhysicalVolume* physVol) const; void ComputeDimensions (G4Box& trackerLayer, const G4int copyNo, const G4VPhysicalVolume* physVol) const; } Parameterization : example - next

142 142 void ChamberParameterisation::ComputeTransformation (const G4int copyNo, G4VPhysicalVolume* physVol) const { G4double Zposition= fStartZ + (copyNo+1) * fSpacing; G4ThreeVector origin(0, 0, Zposition); physVol->SetTranslation(origin); physVol->SetRotation(0); } void ChamberParameterisation::ComputeDimensions (G4Box& trackerChamber, const G4int copyNo, const G4VPhysicalVolume* physVol) const { G4double halfLength= fHalfLengthFirst + copyNo * fHalfLengthIncr; trackerChamber.SetXHalfLength(halfLength); trackerChamber.SetYHalfLength(halfLength); trackerChamber.SetZHalfLength(fHalfWidth); } Parameterization : example - end

143 143 G4double tube_dPhi = 2.* M_PI; G4VSolid* tube = new G4Tubs("tube", 20*cm, 50*cm, 30*cm, 0., tube_dPhi*rad); G4LogicalVolume * tube_log = new G4LogicalVolume(tube, Ar, "tubeL", 0, 0, 0); G4VPhysicalVolume* tube_phys = new G4PVPlacement(0,G4ThreeVector(-200.*cm, 0., 0.*cm), "tubeP", tube_log, world_phys, false, 0); G4double divided_tube_dPhi = tube_dPhi/6.; G4VSolid* divided_tube = new G4Tubs("divided_tube", 20*cm, 50*cm, 30*cm, -divided_tube_dPhi/2.*rad, divided_tube_dPhi*rad); G4LogicalVolume* divided_tube_log = new G4LogicalVolume(divided_tube, Ar, "div_tubeL", 0, 0, 0); G4VPhysicalVolume* divided_tube_phys = new G4PVReplica("divided_tube_phys", divided_tube_log, tube_log, kPhi, 6, divided_tube_dPhi); Replica : examples

144 144 20 minutes PhysicsList.hh (.cc) The Geant4 toolkit : 5/15 - Electromagnetic Physics (QED) STANDARD version

145 145 Content Available EM Physics processes How to use them ? Important processes –Compton scattering –Ionization –Multiple scattering

146 146 Available packages Standard –from 1 keV –gammas, e+- up to 100 TeV –Hadrons up to 100 TeV –ions up to 100 TeV Muons –Up to 1 PeV Rayons X –Processes for X ray and optical photons production Optical –Interactions of optical photons High energy –High energy processes (E>10GeV) –Exotic particles physics Polarization –Polarized beams

147 147 Photons and electrons Photons –Conversion into e+e- –Compton scattering –Photoelectric effect –Rayleigh scattering in low energy package –Photo-nuclear interactions in the –Hadronic sub-package CHIPS Electrons and positrons –Ionization –Coulomb scattering –Bremsstrahlung –Nuclear interactions in the hadronic sub-package CHIPS –Positron annihilation Calorimeter Medical linac

148 148 Muons Ionization Bremsstrahlung e+e- pair production Muon-nucleus interactions in hadronic packages

149 149 Hadrons and ions Coulomb scattering Ionization –Corrected Bethe-Bloch formula for E>2 MeV –Parametrizations of Bragg peak for E< 2 MeV (from ICRU’49 & NIST databases)

150 150 X rays and optical photons Standard package –Cherenkov radiation –Synchrotron radiation –Transition radiation –Scintillation Low energy package –Atomic relaxation (fluorescence & Auger transitions) Optical –Reflexion –Refraction –Absorption –Rayleigh scattering

151 151 How to use EM processes ?

152 152 Physics list For each particle type, the ProcessManager maintains a list of applicable processes Three types of processes –Action at rest : AtRest –Action along step : AlongStep –Action after step : PostStep Declared in the UserPhysicsList class

153 153 Example of Physics list (1) The -1 parameter indicates inactive DoIt AtRestDoIt AlongStepDoIt PostStepDoIt

154 154 Example de Physics list (2)

155 155 Example of Physics list (3) Order has no importance for processes with PostStepAction only … is a shortcut of …

156 156 Examples of processes

157 157 Compton scattering Describes photon scattering by quasi-free atomic electrons  + e   + e Each electron behaves as an independent target : it is an incoherent scattering Cross section per atom = Z x Cross section per electron The differential cross section in scattered energy is described by the Klein-Nishina formula, corrected by a factor taking into account the binding energy of the atomic electron Linked to annihilitation (e+,e-) by crossing symmetry

158 158 Example of Compton scattering 10 MeV  in 10 cm Al

159 159 Ionization The base mechanism is an inelastic collision of the moving charged particle with the material atomic electrons, ejecting an atomic electron  + atom   + atom + + e - During each individual collision, the energy transferred to the electron is small. But the total number of collisions is large and one can define a mean energy loss per macroscopic unit of range

160 160 Generation of secondary electrons (delta rays) In Geant4, one may choose to simulate or not ejected electrons (delta electrons) and their interactions with energies above a threshold T cut –Below this threshold, electrons are taken into account in the continuous energy loss of the ionizing particle and they are not explicitly simulated –above, they are explicitly generated. They are excluded from the continuous energy loss of the ionizing particle. The continuous energy loss is computed from the troncated Bethe Bloch formula (dE/dx for T<T cut )

161 161 Example of delta ray production e-, p,  of 200 MeV in 1 cm Al

162 162 Energy loss fluctuations (straggling) The Bethe Bloch formula only gives the mean energy loss per ionization. There are fluctuations (straggling). The distribution of the energy loss  within a thickness  x can be very dissymmetric (Landau distribution) Large fluctuations are caused by rare collisions having large energy transfers

163 163 16 MeV e- in 10 cm water 105 MeV p in 10 cm water Straggling example Fluctuations on  E  fluctuations on range

164 164 Multiple Coulomb scattering Charged particles travelling through a finite thickness of matter undergo multiple elastic Coulomb scattering. The cumulated effect of these small angle scatterings lead to a global deviation of the particle’s direction of propagation. Theory by Lewis

165 165 Multiple scattering example

166 166 35 minutes PhysicsList.hh (.cc) The Geant4 toolkit : 6/15 - Electromagnetic Physics (QED) LOW ENERGY version

167 167 Content Introduction Processes based on the Livermore database Processes based on the Monte Carlo code Penelope How to use this package ?

168 168 The low energy package A package in the Geant4 electromagnetic package  in $G4INSTALL/source/processes/electromagnetic/lowenergy/ A set of processes extending the coverage of electromagnetic interactions in Geant4 down to “low” energy –250 eV (in principle even below this limit) / 100 eV for electrons and photons –down to approximately the ionization potential of the interacting material for hadrons and ions –up to 100 GeV (unless specified) –based on theoretical models and evaluated data sets ; they involve two distinct phases : calculation and use of total cross sections generation of the final state Models are detailed –shell structure of the atom –precise angular distributions Complementary to the “standard” electromagnetic package Driven by requirements which come from medicine and space research and from users in HEP instrumentation

169 169 Come in two “flavours” of models: based on the Livermore Library à la Penelope (+ positron annihil.) Photons Compton Scattering Compton Scattering by Linearly Polarized Gamma Rays Rayleigh Scattering Gamma Conversion Photoelectric effect Electrons Bremsstrahlung Ionisation Hadrons and ion ionisation Energy loss of slow & fast hadrons Energy loss in compounds Delta-ray production Effective charge of ions Barkas and Bloch effects (hadron sign + relativistic) Nuclear stopping power PIXE Atomic relaxation Fluorescence Auger process Overview of Physics

170 170 A set of LowE processes are based on the Livermore Library

171 171 Based on evaluated data librairies from LLNL : –EADL (Evaluated Atomic Data Library) –EEDL (Evaluated Electrons Data Library) –EPDL97 (Evaluated Photons Data Library) Validity range : 250 eV - 100 GeV –The processes can be used down to 100 eV, with degraded accuracy –In principle the validity range of the data libraries extends down to ~10 eV Elements Z=1 to Z=100 –Atomic relaxation : Z > 5 (transition data available in EADL) Photons and electrons

172 172 E1 and E2 are the lower and higher energy for which data (  1 and  2) are available n i = atomic density of the ith element contributing to the material composition  Interpolation from the data libraries Calculation of cross sections  Mean free path for a process, at energy E :

173 173 Photons

174 174

175 175 Energy distribution of the scattered photon according to the Klein- Nishina formula, multiplied by scattering function F(q) (Hubbel’s atomic factor) from EPDL97 data library The effect of scattering function becomes significant at low energies in suppressing forward scattering Angular distribution of the scattered photon and the recoil electron also based on EPDL97 Klein-Nishina cross section (E’/E) × Scattering Function (q) q = E sin 2 (  /2) momentum transfer Compton scattering (incoherent)

176 176 Depends on charge distribution of atom Angular distribution F(E,  )=[1+cos 2 (  )]sin  F 2 (q) Rayleigh formula times F(q), the energy dependent Hubbel’s form factor obtained from EPDL97 (forward peak at high energies) Only available in the lowenergy package Rayleigh scattering (coherent)

177 177 Cross section –Integrated cross section (over the shells) from EPDL + interpolation –Shell from which the electron is emitted selected according to the detailed cross sections of the EPDL library Final state generation –Various angular distribution generators (“naïve”, Sauter-Gavrila, Gavrila) De-excitation via the atomic relaxation sub-process –Initial vacancy + following chain of vacancies created Photoelectric effect

178 178 The secondary e - and e + energies are sampled using Bethe- Heitler cross sections with Coulomb correction (screening) e - and e + assumed to have symmetric angular distribution Energy and polar angle sampled w.r.t. the incoming photon using Tsai differential cross section Azimuthal angle generated isotropically Choice of which particle in the pair is e - or e + is made randomly Gamma conversion

179 179 Comparison with NIST data photons in Fe All simulation results lie with  3  w.r.t. the corresponding NIST data (National Institute of Standards and Technologies) LE EPDL LE Penelope STD data Illustration : mass attenuation coefficient N/N 0 = exp [-(  /  x ]

180 180 Electrons

181 181 Parameterisation of EEDL data –16 parameters for each atom –At high energy the parameterization reproduces the Bethe-Heitler formula –Precision is ~ 1.5 % –Three LowE generators available : G4ModifiedTsai (HE), G4Generator2BS and G4Generator2BN (<500 keV) Delta electrons in Si from 100 keV e- Gamma in Si from 100 keV e-Bremsstrahlung

182 182 Parameterisation based on 5 parameters for each shell Precision of parameterization is better than 5% for 50 % of shells, less accurate for the remaining shells Ionisation

183 183 ● Compared to NIST database ● All simulation results lie within  3  w.r.t. the corresponding NIST data The stopping power can be used to calculate the distance it takes to slow an electron down to a given energy. This distance is called the continuous slowing down approximation range, or CSDA range, because the calculation assumes that the electron slows down continuously from the initial energy E to the final energy. Comparaison avec données NIST électrons in Uranium LE EEDL LE Penelope STD data Illustration : range

184 184 Hadrons

185 185

186 186 Variety of models, depending on –energy range –particle type –charge Composition of models across the energy range, with different approaches –analytical –based on data reviews + parameterizations Specialized models for fluctuations (stochastic straggling) Hadrons and ions

187 187 Protons Stopping power Z dependence for various energies Ziegler and ICRU models Ziegler and ICRU, Si Nuclear stopping power Ziegler and ICRU, Fe Straggling Bethe-Bloch model of energy loss, E > 2 MeV 5 parameterization models, E < 2 MeV based on Ziegler and ICRU reviews Free electron gas model below 1 keV 3 models of energy loss fluctuations Density correction for high energy Shell correction term for intermediate energy Chemical effect for compounds Nuclear stopping power (elastic Coulomb scattering) PIXE included Spin dependent term Barkas (+ vs -) and Bloch terms

188 188 Scaling of Bethe-Bloch : 0.01 <  < 0.05 : parameterizations, Bragg p., based on Ziegler and ICRU reviews  < 0.01 : free electron gas model Effective charge model (picks up e- in the medium) Nuclear stopping power (elastic Coulomb scattering with nuclei) Positively charged hadrons (Z>1)

189 189 Models for antiprotons  > 0.5Bethe-Bloch formula 0.01 <  < 0.5Quantum harmonic oscillator model  < 0.01Free electron gas model Proton G4 Antiproton Antiproton from Arista et. al Antiproton exp. data Proton G4 Antiproton Antiproton from Arista et. al Antiproton exp. data

190 190 Atomic relaxation

191 191 ● The atomic relaxation can be triggered by other electromagnetic interactions such as the photoelectric effect or ionisation, which leave the atom in an excited state. ● The Livermore Evaluation Atomic Data Library EADL contains data to describe the relaxation of atoms back to neutrality after they are ionised. ● The data in EADL includes the radiative and non-radiative transition probabilities for each sub-shell of each element, for Z=1 to 100. The atom has been ionised by a process that has caused an electron to be ejected from an atom, leaving a vacancy or ``hole" in a given subshell. The EADL data are then used to calculate the complete radiative and non-radiative spectrum of X-rays and electrons emitted as the atom relaxes back to neutrality. ● Non-radiative de-excitation can occur via the Auger effect (the initial and secondary vacancies are in different shells) or Coster-Kronig effect (transitions within the same shell). Atomic relaxation

192 192

193 193 Fluorescence Scattered photons Fe lines GaAs lines Microscopic validation: against reference data Experimental validation: test beam data, in collaboration with ESA Advanced Concepts & Science Payload Division ESA Bepi Colombo mission to Mercury Analysis of the elemental composition of Mercury crust through X-ray spectroscopy 10 keV photon beam, BESSY Courtesy of A. Owens et al., ESA Fluorescent spectrum of Icelandic Basalt (“Mars-like”)

194 194 Auger effect Auger electron emission from various materials Sn, 3 keV photon beam electron lines w.r.t. published experimental results

195 195 PIXE (Particle Induced X-ray Emission) New model based on experimental data –Parameterisation of Paul & Sacher data library for ionization cross sections –Uses the EADL-based package of atomic de-excitation for the generation of fluorescence and Auger secondary products Current implementation: protons, K-shell Coming in future: protons, L-shell and , K-shell Ionization cross section for p, K shell Parameterization G4 (ligne) Experimental data

196 196 LowE processes based on the Monte Carlo code Penelope

197 197 ● Compton scattering ● Rayleigh scattering ● Gamma conversion ● Photoelectric effect ● Bremsstrahlung ● Ionisation ● Positron Annihilation G4PenelopeAnnihilation G4PenelopeBremsstrahlung G4PenelopeCompton G4PenelopeGammaConversion G4PenelopeIonisation G4PenelopePhotoElectric G4PenelopeRayleigh In your Physics list Processes à la Penelope

198 198 The whole physics content of the Penelope Monte Carlo code has been re-engineered into Geant4 (except for multiple scattering) –processes for photons: release 5.2, for electrons: release 6.0 Analytical Physics models by F. Salvat et al. Power of the OO technology: –extending the software system is easy –all processes obey to the same abstract interfaces –using new implementations in application code is simple Profit of Geant4 advanced geometry modeling, interactive facilities etc. – same physics as original Penelope Processes à la Penelope Processes à la Penelope

199 199 How to use the low energy package ?

200 200 Photon processes Compton scattering (class G4LowEnergyCompton) Polarized Compton scattering (class G4LowEnergyPolarizedCompton) Rayleigh scattering (class G4LowEnergyRayleigh) Gamma conversion (also called pair production, class G4LowEnergyGammaConversion) Photo-electric effect (class G4LowEnergyPhotoElectric) Electron processes Bremsstrahlung (class G4LowEnergyBremsstrahlung) Ionisation and delta ray production (class G4LowEnergyIonisation) Hadron and ion processes Ionisation and delta ray production (class G4hLowEnergyIonisation) ►The user should set the environment variable G4LEDATA to the directory where he/she has copied the files. ► Options are available for low energy electromagnetic processes for hadrons and ions in terms of public member functions of the G4hLowEnergyIonisation class: - SetHighEnergyForProtonParametrisation(G4double) - SetLowEnergyForProtonParametrisation(G4double) - SetHighEnergyForAntiProtonParametrisation(G4double) - SetLowEnergyForAntiProtonParametrisation(G4double) - SetElectronicStoppingPowerModel(const G4ParticleDefinition*,const G4String& ) - SetNuclearStoppingPowerModel(const G4String&) - SetNuclearStoppingOn() - SetNuclearStoppingOff() - SetBarkasOn() - SetBarkasOff() - SetFluorescence(const G4bool) - ActivateAugerElectronProduction(G4bool) - SetCutForSecondaryPhotons(G4double) - SetCutForSecondaryElectrons(G4double) The available models for ElectronicStoppingPower and NuclearStoppingPower are documented in the class diagrams.class diagrams ► Options are available for low energy electromagnetic processes for electrons in the G4LowEnergyIonisation class: - ActivateAuger(G4bool) - SetCutForLowEnSecPhotons(G4double) - SetCutForLowEnSecElectrons(G4double) ► Options are available for low energy electromagnetic processes for electrons/positrons in the G4LowEnergyBremsstrahlung class, that allow the use of alternative bremsstrahlung angular generators: - SetAngularGenerator(G4VBremAngularDistribution* distribution); - SetAngularGenerator(const G4String& name); Currently three angular generators are available: G4ModifiedTsai, 2BNGenerator and 2BSGenerator. G4ModifiedTsai is set by default, but it can be forced using the string "tsai". 2BNGenerator and 2BSGenerator can be set using the strings "2bs" and "2bn". Information regarding conditions of use, performance and energy limits of different models are available in the Physics Reference Manual and in the Geant4 Low Energy Electromagnetic Physics Working Group homepage.Physics Reference Manualhomepage ► Other options G4LowEnergyBremsstrahlung class are: - SetCutForLowEnSecPhotons(G4double)

201 201 Example of PhysicsList.cc if (particleName == "gamma") { pmanager->AddDiscreteProcess(new G4LowEnergyCompton); G4LowEnergyPhotoElectric * LePeprocess = new G4LowEnergyPhotoElectric(); LePeprocess->ActivateAuger(true); LePeprocess->SetCutForLowEnSecPhotons(0.250 * keV); LePeprocess->SetCutForLowEnSecElectrons(0.250 * keV); pmanager->AddDiscreteProcess(LePeprocess); pmanager->AddDiscreteProcess(new G4LowEnergyGammaConversion()); pmanager->AddDiscreteProcess(new G4LowEnergyRayleigh()); pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3); } else if (particleName == "e-") { pmanager->AddProcess(new G4MultipleScattering,-1, 1,1); G4LowEnergyIonisation * LeIoprocess = new G4LowEnergyIonisation("IONI"); LeIoprocess->ActivateAuger(true); LeIoprocess->SetCutForLowEnSecPhotons(0.1*keV); LeIoprocess->SetCutForLowEnSecElectrons(0.1*keV); pmanager->AddProcess(LeIoprocess, -1, 2, 2); G4LowEnergyBremsstrahlung * LeBrprocess = new G4LowEnergyBremsstrahlung(); pmanager->AddProcess(LeBrprocess, -1, -1, 3); pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3); } else if (particleName == "e+") { pmanager->AddProcess(new G4MultipleScattering,-1, 1,1); pmanager->AddProcess(new G4eIonisation, -1, 2,2); pmanager->AddProcess(new G4eBremsstrahlung, -1,-1,3); pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4); pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3); } else if( particleName == "mu+" || particleName == "mu-" ) { } else if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0) && (particle->GetParticleName() != "chargedgeantino")) { pmanager->AddProcess(new G4MultipleScattering(),-1,1,1); G4hLowEnergyIonisation* hLowEnergyIonisation = new G4hLowEnergyIonisation(); pmanager->AddProcess(hLowEnergyIonisation,-1,2,2); hLowEnergyIonisation->SetElectronicStoppingPowerModel(particle,"ICRU_R49He"); hLowEnergyIonisation->SetNuclearStoppingOn(); hLowEnergyIonisation->SetNuclearStoppingPowerModel("ICRU_R49"); hLowEnergyIonisation->SetFluorescence(true); hLowEnergyIonisation->ActivateAugerElectronProduction(true); pmanager->AddProcess(new G4StepLimiter(), -1, -1, 3); } photons electrons hadrons

202 202 25 minutes PhysicsList.hh (.cc) The Geant4 : 7/15 - Hadronic Physics (QCD)

203 203 Outline Processes and hadronic Physics Models of hadronic showers –Data driven models –Parametrisation driven models –Theory driven models –Physics lists –Examples Low energy neutrons Ions inelastic reactions Ions radioactive decay

204 204 Hadronic physics challenge Even though there is an underlying theory (QCD), applying it is much more difficult than applying QED for simulating electromagnetic interactions We must deal with at least three energy régimes: –Chiral perturbation theory (< 100 MeV) –Resonance and cascade region (100 MeV – 20 GeV) –QCD strings (> 20 GeV) Within each regime there are several (sub)-models: –Many of these are phenomenological

205 205 Geant4 processes A process uses cross sections to decide when and where an interaction will occur: –GetPhysicalInteractionLength() A process uses an interaction model to generate the final state: –DoIt() Three types of process: –AtRest –AlongStep –PostStep Each particle has its own process manager Each process has a set of models coordinated with energy range manager

206 206 Hadronic processes At rest: –Stopped muon, pion, kaon, anti-proton –Radioactive decay Elastic: –Same process for all long-lived hadrons Inelastic: –Different process for each hadron –Photo-nuclear –Electro-nuclear Capture: –Pion- and kaon- in flight Fission

207 207 Cross sections Default cross section sets are provided for each type of hadronic process: –Fission, capture, elastic, inelastic –Can be overridden or completely replaced Different types of cross section sets: –Some contain only a few numbers to parameterize cross section –Some represent large databases (data driven models) Cross Section Management: –GetCrossSection() sees last set loaded for energy range

208 208 Alternative cross sections Low energy neutrons –G4NDL available as Geant4 distribution data files –Available with or without thermal cross sections Neutron and proton reaction cross sections –20 MeV < E < 20 GeV Ion-nucleus reaction cross sections –Good for E/A < 1 GeV Isotope production data –E < 100 MeV

209 209 Three types Data driven models Parametrisation driven models Theory driven models Different types of hadronic shower models

210 210 Models in hadronic framework

211 211 Data driven models (1) Characterized by lots of data: –Cross section –Angular distribution –Multiplicity To get interaction length and final state, models simply interpolate data: –Usually linear interpolation of cross section, and Legendre polynomials Examples: –Coherent elastic scattering (pp, np, nn) –Radioactive decay –Neutrons (E < 20 MeV)

212 212 Data driven models (2) Transport of low energy neutrons in matter: –The energy coverage of these models is from thermal energies to 20 MeV –The modeling is based on the data formats of ENDF/B-VI, and all distributions of this standard data format are implemented –The data sets used are selected from data libraries that conform to these standard formats –The file system is used in order to allow granular access to, and flexibility in, the use of the cross-sections for different isotopes, and channels –Code in sub-directory : $G4INSTALL/source/processes/hadronic/models/neutron_hp

213 213 Depends on both data and theory: –Enough data to parameterize cross sections, multiplicities, angular distributions Final states determined by theory, sampling: –Use conservation laws to get charge, energy, etc. Examples: –Fission –Capture –LEP, GEISHA based HEP models (inelastic scattering in flight) Parametrisation driven models (1)

214 214 Parametrisation driven models (2) Based on GHEISHA package of Geant3.21, two sets of models exist for inelastic scattering of particles in flight: –Low energy models: E < 20 GeV $G4INSTALL/source/processes/hadronic/models/low_energy –High energy models: 20 GeV < E < O(TeV) $G4INSTALL/source/processes/hadronic/models/high_energy Original approach to primary interaction, nuclear excitation, intra- nuclear cascade and evaporation is kept Fission, capture and coherent elastic scattering are also modeled through parametrised models

215 215 Theory driven models (1) Dominated by theory (QCD, strings, chiral perturbation theory) Data used mainly for normalization and validation Final states determined by sampling theoretical distributions Philosophy implies the usage physics lists, providing wanted collection of models, such as: –parton string models at high energies –intra-nuclear transport models at intermediate energies –statistical break-up models for de-excitation

216 216 Theory driven models (2) Parton string: –Projectiles with E > 5 GeV –$G4INSTALL/source/processes/hadronic/models/parton_string Chiral invariant phase space, CHIPS: –All energies –Quark-level event generator for the fragmentation of hadronic systems into hadrons –Interactions between hadrons are treated as purely kinematic effects of quark exchange –Decay of excited hadronic systems is treated as the fusion of two quark-partons within the system –Includes nonrelativistic phase space of nucleons to explain evaporation –$G4INSTALL/source/processes/hadronic/models/chiral_inv_phase_space Nuclear de-excitation and breakup

217 217 Example : Bertini intra-nuclear cascade model Collection of theory driven models with parametrisation features: –$G4INSTALL/source/processes/hadronic/models/cascade Intermediate energies ~100 keV – 10MeV Models included: –Bertini INC model with exitons –Pre-equilibrium model –Nucleus explosion model –Fission model –Evaporation model

218 218 Bertini cascade model pion production from 730 MeV proton on Carbon Examples of theory driven models Binary cascade model Double differential cross-section for neutrons produced by 256 MeV protons.

219 219 Physics list User must implement a physics list: –Derive a class from G4VUserPhysicsList –Define the particles required –Register models and cross sections with processes –Register processes with particles –Set secondary production cuts –In main(), register your physics list with the Run Manager Care is required: –Multiple models, cross sections allowed per process –No single model covers all energies, or all particles –Choice of model is heavily dependent on physics studied

220 220 Physics list by use case Geant4 recommendation: –Use example physics lists –Go to Geant4 home page > Site Index > physics lists Many hadronic physics lists available including: –Low and high energy nucleon penetration shielding –Low energy dosimetric applications –Medical neutron applications –Low background experiments (underground)

221 221 void MyPhysicsList::ConstructProton() { G4ParticleDefinition* proton = G4Proton::ProtonDefinition(); G4ProcessManager* protonProcessManager = proton->GetProcessManager(); // Elastic scattering G4HadronElasticProcess* protonElasticProcess = new G4HadronElasticProcess(); G4LElastic* protonElasticModel = new G4LElastic(); protonElasticProcess->RegisterMe(protonElasticModel); protonProcessManager->AddDiscreteProcess(protonElasticProcess);... Exemple – 1/2

222 222... // Inelastic scattering G4ProtonInelasticProcess* protonInelasticProcess = new G4ProtonInelasticProcess(); G4LEProtonInelastic* protonLowEnergyInelasticModel = new G4LEProtonInelastic(); protonLowEnergyInelasticModel->SetMaxEnergy(20.0*GeV); protonInelasticProcess->RegisterMe(protonLowEnergyInelasticModel); G4HEProtonInelastic* protonHighEnergyInelasticModel = new G4HEProtonInelastic(); protonHighEnergyInelasticModel->SetMinEnergy(20.0*GeV); protonInelasticProcess->RegisterMe(protonHighEnergyInelasticModel); } Exemple – 2/2

223 223 Geant4 hadronic physics allows user to choose how a physics process should be implemented: –cross sections –models Many processes, models and cross sections to choose from –hadronic framework makes it easier for users to add more Parameterized models (LEP, HEP) handle the most particle types over the largest energy range –based on fits to data and some theory –not very detailed –Fast Cascade models (Bertini, Binary) are valid for fewer particles over a smaller energy range –more theory-based –more detailed –slower Summary

224 224 Low energy neutrons physics Energy < 20 MeV High Precision Neutron Models (and Cross Section Data Sets) –G4NDL ENDF –Elastic –Inelastic –Capture –Fission NeutronHPorLEModel(s)

225 225 G4NDL (Geant4 Neutron Data Library) The neutron data files for High Precision Neutron models The data are including both cross sections and final states. The data are derived evaluations based on the following evaluated data libraries (in alphabetic order) –Brond-2.1 –CENDL2.2 –EFF-3 –ENDF/B-VI.0, 1, 4 –FENDL/E2.0 –JEF2.2 –JENDL-FF –JENDL-3.1,2 –MENDL-2 The data format is similar ENDF, however it is not equal to.

226 226 Evaluated Nuclear Data File-6 “ENDF” is used in two meanings One is Data Formats and Procedures –How to write Nuclear Data files –How to use the Nuclear Data files The other is Name of recommended libraries of USA nuclear data projects. –ENDF/B-VI.8 (latest) 313 isotopes including 5 isomers 15 elements After G4NDL3.8 we concentrated translation from ENDF library. – No more evaluation by ourselves.

227 227 Ion Physics : inelastic reactions Models –G4BinaryLightIon –G4WilsonAbrasion Many cross section formulae for NN collisions are included in Geant4 –Tripathi, Shen, Kox and Sihver These are empirical and parameterized formulae with theoretical insights. G4GeneralSpaceNNCrossSection was prepared to assist users in selecting the appropriate cross section formula

228 228 To simulate the decay of radioactive nuclei Empirical and data-driven model α, β +, β - decay electron capture (EC) are implemented Data (RadioactiveDecay) derived from Evaluated Nuclear Structure Data File (ENSDF) –nuclear half-lives –nuclear level structure for the parent or daughter nuclide –decay branching ratios –the energy of the decay process If the daughter of a nuclear decay is an excited isomer, its prompt nuclear de-excitation is treated using the G4PhotonEvapolation Internal conversion is also implemented Ion physics : radioactive decay

229 229 Hadronic model inventory

230 230 Conclusion Geant4 provides a large number of hadronic physics models for use in simulation Cross sections, either calculated or from databases, are available to be assigned to processes Interactions are implemented by models which are then assigned to processes. For hadrons there are many models to choose from, so physics lists are provided by use-case

231 231 15 minutes PhysicsList.hh (.cc) The Geant4 toolkit : 8/15 - Physics Lists

232 232  A class which collects all the particles, physics processes and production thresholds needed for your application  It tells the run manager how and when to invoke physics  It is a very flexible way to build a physics environment  user can pick the particles he wants  user can pick the physics to assign to each particle  But, user must have a good understanding of the physics required  omission of particles or physics could cause errors or poor simulation What is a Physics List ?

233 233 Physics is physics – shouldn't Geant4 provide, as a default, a complete set of physics that everyone can use ? ● NO ! –there are many different physics models and approximations very much the case for hadronic physics but also the case for electromagnetic physics –computation speed is an issue a user may want a less-detailed, but faster approximation –no application requires all the physics and particles Geant4 has to offer e.g., most medical applications do not want multi-GeV physics Why do we need a physics list ?

234 234  For this reason Geant4 takes an atomistic, rather than an integral approach to physics −provide many physics components (processes) which are de- coupled from one another −user selects these components in custom-designed physics lists in much the same way as a detector geometry is built Exceptions −a few electromagnetic processes must be used together −future processes involving interference of electromagnetic and strong interactions may require coupling as well Why do we need a physics list ?

235 235 ●ELECTROMAGNETIC physics “standard” from ~ 1 keV to ~ PeV “low energy” from 250 eV to ~ PeV Optical photons ●WEAK physics Decay of subatomic particles Radioactive decay of nuclei ●HADRONIC physics pure hadronic processes valid from 0 to ~100 TeV   nuclear valid from 10 MeV to ~TeV ● Parameterized or “fast simulation” physics Physics processes provided by Geant4

236 236  All physics lists must derive from this class and then be registered with the run manager  Example class myPhysicsList : public G4VUserPhysicsList { public: BeamTestPhysicsList(); ~BeamTestPhysicsList(); void ConstructParticle(); void ConstructProcess(); void SetCuts(); }; ●User must implement the methods ConstructParticle, ConstructProcess and SetCuts G4VUserPhysicsList

237 237 ConstructParticle() –choose the particles you need in your simulation and define all of them here ConstructProcess() –for each particle, assign all the physics processes important in your simulation What's a process? a class that defines how a particle should interact with matter (it's where the physics is!) more on this later SetCuts() –set the range cuts for secondary production What's a range cut? essentially a low energy limit on particle production more on this later G4VUserPhysicsList : required methods

238 238 void BeamTestPhysicsList::ConstructParticle() { G4BaryonConstructor* baryonConstructor = new G4BaryonConstructor(); baryonConstructor->ConstructParticle(); delete baryonConstructor; G4BosonConstructor* bosonConstructor = new G4BosonConstructor(); bosonConstructor->ConstructParticle(); delete bosonConstructor;.... } ConstructParticle() – 1 st way

239 239 void myPhysicsList::ConstructParticle() { G4Electron::ElectronDefinition(); G4Proton::ProtonDefinition(); G4Neutron::NeutronDefinition(); G4Gamma::GammaDefinition();.... } ConstructParticle() – 2 nd way

240 240 void myPhysicsList::ConstructProcess() { AddTransportation(); // method provided by G4VUserPhysicsList // assigned transportation process to all particles // defined in ConstructParticle() ConstructEM(); // method may be defined by user (for convenience) // put electromagnetic physics here ConstructGeneral(); // method may be defined by user (for convenience) } ConstructProcess()

241 241 void BeamTestPhysicsList::ConstructEM() { theParticleIterator->reset(); while ( (*theParticleIterator)() ) { G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); G4String particleName = particle->GetParticleName(); if (particleName == “gamma”) { pmanager->AddDiscreteProcess(new G4GammaConversion() );... }..... ConstructEM()

242 242 void BeamTestPhysicsList::ConstructGeneral() { // Ajouter le processus de désintégration G4Decay* theDecayProcess = new G4Decay(); theParticleIterator->reset(); while ( (*theParticleIterator)() ) { G4ParticleDefinition* particle = theParticleIterator->value(); G4ProcessManager* pmanager = particle->GetProcessManager(); if (theDecayProcess->IsApplicable(*particle) ) { pmanager->AddProcess(theDecayProcess); pmanager->SetProcessOrdering(theDecayProcess, idxPostStep); pmanager->SetProcessOrdering(theDecayProcess, idxAtRest); } ConstructGeneral()

243 243 void BeamTestPhysicsList::SetCuts() { defaultCutValue = 1.0*mm; SetCutValue(defaultCutValue, “gamma”); SetCutValue(defaultCutValue, “e-”); SetCutValue(defaultCutValue, “e+”); // These are all the production cut values you need to set // not required for any other particle } SetCuts()

244 244 G4VModularPhysicsList ●The physics list in our example is relatively simple ●A realistic physics list is likely to have many more physics processes –such a list can become quite long, complicated and hard to maintain –try a modular physics list instead ● Features of G4VModularPhysicsList –derived from G4VUserPhysicsList –AddTransportation() automatically called for all registered particles –Allows you to define “physics modules”: EM physics, hadronic physics, optical physics, etc.

245 245 A simple G4VModularPhysicsList ●Constructor : MyModPhysList::MyModPhysList() : G4VModularPhysicsList() { defaultCutValue = 1.0*mm; RegisterPhysics( new ProtonPhysics() ); // all physics processes having to do with protons RegisterPhysics( new ElectronPhysics() ); // all physics processes having to do with electrons RegisterPhysics( new DecayPhysics() ); // physics of unstable particles } ●Set Cuts : void MyModPhysList::SetCuts() { SetCutsWithDefault() ; }

246 246 Physics constructors ●Allow you to group particle and process construction according to physics domains class ProtonPhysics : public G4VPhysicsConstructor { public: ProtonPhysics(const G4String& name = “proton”); virtual ~ProtonPhysics(); virtual void ConstructParticle(); // easy – only one particle to build in this case virtual void ConstructProcess(); // put here all the processes a proton can have }

247 247 Pre-packaged Physics Lists (1) ● Our example deals mainly with electromagnetic physics ● A complete and realistic EM physics list can be found in novice example N03 good starting point add to it according to your needs ● Adding hadronic physics is more delicate for any one hadronic process, user may choose from several hadronic models to choose from choosing the right models for your application requires care to make things easier, hadronic physics lists are now provided according to some use cases

248 248 ● Present in the release of Geant4 from version 8.0 in $G4INSTALL/source/physics_lists/lists ● Documentation can be found on the Geant4 web page at http://geant4.cern.ch/support/index.shtml ● Caveats : –these lists are provided as a “ best guess ” of the physics needed in a given case –the user is responsible for validating the physics for his own application and adding (or subtracting) the appropriate physics –they are intended as starting points or templates Pre-packaged Physics Lists

249 249 ● All the particles, physics processes, and production cuts needed for an application must go into a physics list ● Two kinds of physics list classes are available for users to derive from –G4VUserPhysicsList – for relatively simple physics lists –G4VModularPhysicsList – for detailed physics lists ● Some pre-packaged physics lists are provided by Geant4 as starting points for users –electromagnetic physics lists –hadronic physics lists ● Care is required by user in choosing the right physics to use In summary

250 250 10 minutes PrimaryGeneratorAction.hh (.cc) The Geant4 toolkit : 9/15 - Primary particles generation

251 251 Primary vertices and primary particles Primary vertices and primary particles must be stored in an event ( G4Event ) before it is processed. Need instances of : –G4PrimaryVertex particle starting point in space, time can add user information as well –G4PrimaryParticle initial momentum, polarization of particle to be propagated also PDG code linked list of daughters for decay chains These classes do not depend on G4ParticleDefinition or G4Track Primary particles may not necessarily be particles which can be tracked by Geant

252 252 All primary generators must be derived from G4VPrimaryGenerator and implement its single pure virtual method GeneratePrimaryVertex() –this is where the primary vertex and primary particle are added to the event Geant4 provides some implementations of G4VPrimaryGenerator : –G4HEPEvtInterface (ex. Pythia-Jetset) –G4HEPMCInterface –G4ParticleGun –G4GeneralParticleSource Primary generator

253 253 G4ParticleGun is an implementation of G4VPrimaryGenerator which is used to simulate a beam of particles –see novice example N02 It shoots a primary particle of a certain energy and direction from a given point at a given time –methods available to customize your particle gun set particle type set energy, momentum set polarization set charge number of particles shot at one time Particle gun

254 254 G4VUserPrimaryGeneratorAction (1) This is one of the mandatory user action classes –used to control the generation of primaries –this class itself should not generate primaries – instead use GeneratePrimaryVertex() method of primary generator Geant4 developers are frequently asked to implement “particle shot guns” or “particle machine guns” –such fancy weapons can easily be implemented by the user with set methods in G4ParticleGun repeated use of G4ParticleGun in a single event random sampling of particle type and direction additional primary generators (described earlier)

255 255 Constructor –instantiate primary generator(s) –set default items (particle, energy, etc.) GeneratePrimaries() method : –randomize particle-by-particle values –assign them to primary generator(s) –invoke GeneratePrimaryVertex() method of primary generator(s) G4VUserPrimaryGeneratorAction (2)

256 256 G4VUserPrimaryGeneratorAction (3) void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { G4ParticleDefinition* particle; particle = proton; gun->SetParticleDefinition(particle); G4double pp = momentum + (G4UniformRand() - 0.5)*sigmaMomentum; G4double mass = particle->GetPDGMass(); G4double Ekin = sqrt(pp*pp + mass*mass) – mass; gun->SetParticleEnergy(Ekin); G4double angle = (G4UniformRand() - 0.5)*sigmaAngle; gun->SetParticleMomentumDirection(G4ThreeVector(sin(angle), 0.,cos(angle)); gun->GeneratePrimaryVertex(anEvent); } Repeat the above as many times as desired per event

257 257 General Particle Source G4GeneralParticleSource is another concrete implementation of G4VPrimaryGenerator Primary vertex is randomly chosen on surface of a given volume –useful for radioactive sources –pre-defined energy spectra (power law, etc.) available Capable of event biasing (variance reduction) –can enhance certain particle types –bias the vertex point distribution –bias energy and/or direction Especially suitable for space and medical applications –see advanced examples: x-ray telescope, underground physics

258 258 G4GeneralParticleSource Square plane, cosine-law direction, linear energy Spherical surface, isotropic radiation, black-body energy Cylindrical surface, cosine-law radiation, Cosmic diffuse energy Spherical volume with z biasing, isotropic radiation with theta and phi biasing, integral arbitrary point-wise energy distribution with linear interpolation.

259 259 Exotic particles “Exotic” particle means a type of particle that Geant4 physics processes do not know how to deal with and would never generate as a secondary. –It is thus not provided as a class in particle category of Geant4 distribution. –E.g. Higgs, W/Z boson, SUSY particle, r-hadron, monopole, black hole, etc. “Exotic” particle also includes a type of particle that should not be seen outside of a hadron. –It is used inside Geant4 processes, but it should not be treated as a track. –E.g. quark, gluon. Such exotic particle can be imported as a G4PrimaryParticle object. –It should have pre-assigned decay products (if it decays), since Geant4 does not know how it decays. There are two kinds of exotic particles from the view point of Geant4. We have to deal them separately. –Particles that immediately decay without traveling finite distance. –Particles that travel a distance meaningful to Geant4 tracking.

260 260 40 minutes The Geant4 toolkit : 10/15 - Particles and processes

261 261 G4ParticleDefinition G4ProcessManager Process_2 Process_3 Process_1 G4Electron G4Geantino G4PionPlusG4Proton G4Alpha G4ParticleDefinition G4VLepton G4VBoson G4VMesonG4VBaryon G4VIon G4VShortLivedParticles G4ParticleWithCuts G4ParticleDefinition is the base class for defining concrete particles. Contains intrinsic particle properties (mass, width, spin, lifetime…) Does not know by itself its sensitivity to physics. G4ProcessManager manages the list of processes the user wants. It is attached to G4ParticleDefinition. G4ParticleDefinition & G4ProcessManager

262 262 G4DynamicParticle Describes the purely dynamic part (i.e. no position, nor geometrical information…) of the particle state: –momentum, energy, polarization Holds a G4ParticleDefinition pointer Retains eventual pre-assigned decay information –decay products –lifetime G4Track Defines the class of objects propagated by Geant4 tracking Represents a snapshot of the particle state Aggregates : –a G4ParticleDefinition –a G4DynamicParticle –geometrical information: position, current volume … –track ID, parent ID; –process which created this G4Track –weight, used for event biasing G4DynamicParticle & G4Track

263 263 G4Track G4ParticleDefinition G4DynamicParticle G4ProcessManager Propagated by the tracking Snapshot of the particle state Momentum, pre-assigned decay… The particle type G4Electron, G4PionPlus … Holds the physics sensitivity The physics processes Process_2 Process_1 Process_3 Summary view

264 264 Geant4 provides a wide variety of physics components for use in simulation Physics components are coded as processes a process is a class which tells a particle how to interact user may write his own processes (derived from Geant4 process) Processes are grouped into –electromagnetic, hadronic, and decay categories Geant4 Physics

265 265 Standard – complete set of processes covering charged particles and gammas energy range 1 keV to ~PeV Low energy – specialized routines for e+, e-, gamma, charged hadrons more atomic shell structure details some processes valid down to 250 eV or below others not valid above a few GeV Optical photons – only for long wavelength photons (x-rays, UV, visible) –processes for reflection/refraction, absorption, wavelength shifting, Rayleigh scattering Electromagnetic physics

266 266 Pure hadronic ( 0 - ~100 TeV) elastic inelastic capture fission Radioactive decay at-rest and in-flight photo-nuclear (~10 MeV - ~TeV) lepto-nuclear (~10 MeV - ~TeV) e+, e- nuclear reactions muon-nuclear reactions Hadronic physics

267 267 Decay processes include weak decay (leptonic decays, semi-leptonic decays, radioactive decay of nuclei) electromagnetic decay (    0, etc. decay) strong decays not included here (they are part of hadronic models) Parameterized processes electromagnetic showers propagated according to parameters averaged over many events faster than detailed shower simulation Decay & parameterization

268 268 Data libraries and units Systematic collection and evaluation of experimental data from many sources worldwide Databases –ENDF/B, JENDL, FENDL, CENDL, ENSDF,JEF, BROND, EFF, MENDL, IRDF, SAID, EPDL, EEDL, EADL, SANDIA, ICRU etc. Collaborating distribution centres –NEA, LLNL, BNL, KEK, IAEA, IHEP, TRIUMF, FNAL, Helsinki, Durham, Japan etc. The use of evaluated data is important for the validation of physics results of the experiments Geant4 is independent from the system of units –all numerical quantities expressed with their units explicitly

269 269 ●All the work of particle decays and interactions is done by processes transportation is also handled by a process ●A process does two things: decides when and where an interaction will occur −method: GetPhysicalInteractionLength() −this requires a cross section, decay lifetime −for the transportation process, the distance to the nearest object along the track is required generates the final state of the interaction (changes momentum, generates secondaries, etc.) −method: DoIt() −this requires a model of the physics Physics processes - 1

270 270 There are three flavors of processes: well-located in space -> PostStep distributed in space -> AlongStep well-located in time -> AtRest ●A process may be a combination of all three of the above in that case six methods must be implemented ( GetPhysicalInteractionLength() and DoIt() for each action) “Shortcut” processes are defined which invoke only one Discrete process (has only PostStep physics) Continuous process (has only AlongStep physics) AtRest process (has only AtRest physics) Physics processes - 2

271 271 ●Discrete process: Compton scattering step determined by cross section, interaction at end of step oPostStepGPIL() oPostStepDoIt() ●Continuous process: Cerenkov effect photons created along step, # roughly proportional to step length oAlongStepGPIL() oAlongStepDoIt() ●At rest process: positron annihilation no displacement, time is the relevant variable oAtRestGPIL() oAtRestDoIt() ●These are examples of so-called “pure” processes Examples - 1

272 272 ●Continuous + discrete : ionization energy loss is continuous Moller/Bhabha scattering and knock-on electrons are discrete ●Continuous + discrete : bremsstrahlung energy loss due to soft photons is continuous hard photon emission is discrete ●In both cases, the production threshold separates the continuous and discrete parts of the process more on this later ●Multiple scattering is also continuous + discrete Examples - 2

273 273 particle At rest process In flight process Process 3 Process n model 1 model 2. model n c.s. 1 c.s. 2. c.s. n Cross section data store Energy range manager

274 274 ●Many processes (and therefore many interactions) can be assigned to the same particle ●How does Geant4 decide which interaction happens at any one time? interaction length or decay length is sampled from each process shortest one happens, unless a volume boundary is encountered in less than the sampled length. Then no physics interaction occurs (just simple transport). the processes that were not chosen have their interaction lengths shortened by the distance traveled in the previous step repeat the procedure Handling multiple processes

275 275 Ordering of following processes is critical : assuming n processes, the ordering of the AlongGetPhysicalInteractionLength of the last processes should be : [n-2] … [n-1] multiple scattering [n] transportation Why ? –Processes return a true path length –The multiple scattering virtually folds up this true path length into a shorter geometrical path length –Based on this new length, the transportation can geometrically limit the step Other processes ordering usually do not matter  Processes ordering

276 276 50 MeV e- entering LAr-Pb calorimeter Processes used: bremsstrahlung ionization multiple scattering positron annihilation pair production Compton scattering Example : event with standard EM processes

277 277 The decay process Derived from G4VRestDiscreteProcess –decay can happen in-flight or at rest Should be applied to all unstable, long-lived particles Different from other physical processes: –mean free path for most processes: = N  /A –for decay in-flight: =  c   Same decay process for all eligible particles –decay process retrieves BR and decay modes from decay table stored in each particle type

278 278 Available decay modes Phase space: –2-body e.g.   ->  -> p   –3-body e.g. K 0 L ->       –many body Dalitz: P 0 ->  l + l - Muon decay –V – A, no radiative corrections, mono-energetic neutrinos Leptonic tau decay –like muon decay Semi-leptonic K decay: K ->  l

279 279 Pre-assigned decays Geant4 provides decay modes for long-lived particles –user can re-define decay channels if necessary But decay modes for short-lived (e.g. heavy flavor) particles not provided by Geant4 –user must “pre-assign” to particle: proper lifetime decay modes decay products –decay process can invoke decay handler from the generator must use G4VExtDecayer interface Take care that pre-assigned decays from generators do not overlap with those defined by Geant4 –K 0 S, 

280 280 Specialized decay processes G4DecayWithSpin –produces positron spectrum with 1 st order radiative corrections –initial muon spin is required –propagates spin in magnetic field (precession) over remainder of muon lifetime G4UnknownDecay –only for “unknown” particles ( Higgs, SUSY, etc.) –discrete process – only in-flight decays allowed –pre-assigned decay channels must be supplied by user or generator

281 281 Optical photons (1) Technically, should belong to electromagnetic category, but: –optical photon wavelength is >> atomic spacing –‘ treated as waves’ -> no smooth transition between optical and gamma particle classes Optical photons are produced by the following Geant4 processes: –G4Cerenkov –G4Scintillation –G4TransitionRadiation Warning: these processes generate optical photons without energy conservation

282 282 Optical photons (2) Optical photons undergo : –Rayleigh scattering –refraction and reflection at medium boundaries –bulk absorption –wavelength shifting Geant4 keeps track of polarization –but not overall phase -> no interference Optical properties can be specified in G4Material –reflectivity, transmission efficiency, dielectric constants, surface properties Photon spectrum properties also defined in G4Material –scintillation yield, time structure (fast, slow components)

283 283 Optical photons (3) Geant4 demands particle-like behavior for tracking : –thus, no “splitting” –event with both refraction and reflection must be simulated by at least two events q

284 284 Wavelength shifting Handled by G4OpWLS –initial photon is killed, one with new wavelength is created –builds it own physics table for mean free path User must supply : –absorption length as function of photon energy –emission spectra parameters as function of energy –time delay between absorption and re-emission

285 285 Boundary interactions Handled by G4OpBoundaryProcess –refraction –reflection User must supply surface properties using G4OpticalSurfaceModel Boundary properties –dielectric-dielectric –dielectric-metal –dielectric-black material Surface properties: –polished –ground –front- or back-painted,...

286 286 Absorption and Rayleigh scattering G4OpAbsorption –uses photon attenuation length from material properties to get mean free path –photon is simply killed after a selected path length G4OpRayleigh –elastic scattering including polarization of initial and final photons –builds it own private physics table (for mean free path) using G4MaterialTable –may only be used for optical photons

287 287 Threshold for secondary production (1) ●Every simulation developer must answer the question : how low can you go? –at what energy do I stop tracking particles ? ●This is a balancing act need to go low enough to get the physics you're interested in can't go too low because some processes have infrared divergence causing CPU time to skyrocket ●The traditional Monte Carlo solution is to impose an absolute cutoff in energy –particles are stopped when this energy is reached –remaining energy is dumped at that point

288 288 ●But, such a cut may cause imprecise stopping location and deposition of energy ●There is also a particle dependence –range of 10 keV  in Si is a few cm –range of 10 keV e- in Si is a few microns ●And a material dependence –suppose you have a detector made of alternating sheets of Pb and plastic scintillator –if the cutoff is OK for Pb, it will likely be wrong for the scintillator which does the actual energy deposition measurement Threshold for secondary production (2)

289 289 ●Geant4 solution: impose a production threshold –default = 1 mm –this threshold is a distance, not an energy –the primary particle loses energy by producing secondary electrons or gammas –if primary no longer has enough energy to produce secondaries which travel at least 1mm, two things happen: discrete energy loss ceases (no more secondaries produced) the primary is tracked down to zero energy using continuous energy loss ●Stopping location is therefore correct ●Only one value of production threshold distance is needed for all materials because it corresponds to different energies depending on material. Threshold for secondary production (3)

290 290 Production threshold vs. energy cut Production threshold vs. energy cut Cut = 2 MeV Cut = 450 keV production range = 1. 5 mm 500 MeV p in LAr-Pb sampling calorimeter

291 291 ●Geant4 default value is 1 mm –user needs to decide the best value –this will depend on the size of sensitive elements within the simulated detector, and on available CPU ●This value is set in the SetCuts() method of your physics list ●Instead of “secondary production threshold distance” it is more convenient to simply say “cuts” –but please remember that this does not mean that any particle is actually stopped before it runs out of energy Threshold for secondary production (4)

292 292 G4VUserPhysicsList It is one of the mandatory user classes (abstract class) Pure virtual methods –ConstructParticles() –ConstructProcesses() –SetCuts() to be implemented by the user in his/her concrete derived class

293 293 Cuts per region (1) ●In a complex detector there may be many different types of sub-detectors involving –finely segmented volumes –very sensitive materials –large, undivided volumes –inert materials ●The same value of the secondary production threshold may not be appropriate for all of these –user must define regions of similar sensitivity and granularity and assign a different set of production thresholds (cuts) for each ●Warning: this feature is for users who are –simulating the most complex detectors –experienced at simulating EM showers in matter

294 294 Cuts per region (2) ●A default region is created automatically for the world volume –it has the cuts which you set in SetCuts() in your physics list –these will be used everywhere except for user-defined regions ●To define a special region with different cuts, user must –create a G4ProductionCuts object –initialize it with the new cuts –assign it to a region which has already been created

295 295 Cuts per region (3) void BeamTestPhysicsList::SetCuts() { SetCutValue(defaultCutValue, “gamma”); SetCutValue(defaultCutValue, “e-”); SetCutValue(defaultCutValue, “e+”); // Get the region G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion(“NewRegion”); // Define cuts object for the new region and set values G4ProductionCuts* cuts = new G4ProductionCuts; cuts->SetProductionCut(0.01*mm); // same cut for gamma, e+, e- // Assign cuts to region aRegion->SetProductionCuts(cuts); }

296 296 G4UserLimits User limits are artificial limits affecting to the tracking. G4UserLimits(G4double ustepMax = DBL_MAX, G4double utrakMax = DBL_MAX, G4double utimeMax = DBL_MAX, G4double uekinMin = 0., G4double urangMin = 0. ); –uMaxStep; // max allowed Step size in this volume –uMaxTrack; // max total track length –uMaxTime; // max global time –uMinEkine; // min kinetic energy remaining (only for charged particles) –uMinRange; // min remaining range (only for charged particles) Blue : affecting to step Yellow : affecting to track You can set user limits to logical volume and/or to a region –User limits assigned to logical volume do not propagate to daughter volumes. –User limits assigned to region propagate to daughter volumes unless daughters belong to another region. –If both logical volume and associated region have user limits, those of logical volume win.

297 297 Processes co-working with G4UserLimits In addition to instantiating G4UserLimits and setting it to logical volume or region, you have to assign the following process(es) to particle types you want to affect Limit to step fMaxStep : max allowed Step size in this volume –G4StepLimiter process must be defined to affected particle types –This process limits a step, but it does not kill a track. Limits to track fMaxTrack : max total track length fMaxTime : max global time fMinEkine : min kinetic energy (only for charged particles) fMinRange : min remaining range (only for charged particles) –G4UserSpecialCuts process must be defined to affected particle types. –This process limits a step and kills the track when the track comes to one of these limits. Step limitation occurs only for the final step.

298 298 ●Geant4 supplies many physics processes which cover electromagnetic, hadronic and decay physics ●Processes are organized according to when they are used during the tracking of a particle (discrete, continuous, at-rest, etc.) ●Many processes may be assigned to one particle −which one occurs first depends on cross sections, lifetimes, and distances to volume boundaries Summary (1)

299 299 Summary (2) ●There is one decay process for all long-lived, unstable particles ●Optical processes handle the reflection, refraction, absorption, wavelength shifting and scattering of long- wavelength photons ●The precision of particle stopping and the production of secondary particles are determined by a secondary production threshold ●For complex detectors with different types of sensitive volumes, different production thresholds may be defined for different regions within the detector

300 300 15 minutes The Geant4 toolkit : 11/15 - User interface In the main()

301 301 A Geant4 simulation can be steered by a batch session or by commands captured from an interactive session Setting up batch mode is easy: in your main() G4UImanager* UI = G4UImanager::GetUIpointer(); G4String command = “/control/execute”; G4String fileName = argv[1]; UI -> applyCommand(command+fileName); Setting up interactive mode is also easy – but there are many choices of interface –All must be derived from the abstract class G4UIsession –Geant4 provides several implementations Steering the simulation

302 302 G4UIterminal : C-shell-like character terminal –runs on all Geant4-supported platforms G4UItcsh : tcsh-like character terminal with command completion, history, etc. –runs only on Solaris and Linux G4UIXm, G4UIXaw, G4UIXWin32 : G4UIterminal implemented over Motif, Athena and WIN32 libraries –runs on Unix/linux and Windows, respectively G4UIGAG : Java-based GUI –runs on all Geant4 platforms User interface choices

303 303 In your main(), add the lines : #include “G4UIxxx.hh” // xxx = terminal, Xm, Xaw, Win32, GAG G4UISession* session = new G4UIxxx; UI->ApplyCommand(“/control/execute somefile.mac”); session->SessionStart(); delete session; For a tcsh session, the seond line must be: G4UIsession* session = new G4UIterminal(new G4UItcsh); Many examples in : $G4INSTALL/examples/novice/N01, N02, N03,.... How to use the interface

304 304 Not required in order to use G4UIterminal, G4UItcsh, G4UIGAG these sessions do not need external libraries, so they are automatically built and linked To build G4UIXm, G4UIXaw, or G4UIXWin32 setenv G4UI_USE_XM 1 or setenv G4UI_USE_XAW 1 or setenv G4UI_USE_WIN32 1 Environment variables

305 305 Useful GUI tools relased by Geant4 developers GGE: Geometry editor based on Java GUI –http://erpc1.naruto-u.ac.jp/~geant4 GPE: Physics editor based on Java GUI –http://erpc1.naruto-u.ac.jp/~geant4 OpenScientist: interactive environment for analysis –http://www.lal.in2p3.fr/OpenScientist

306 306 Geant4 provides a number of user interface commands which can be used : –interactively via a (G)UI –in a macro file via /control/execute –within C++ code using the ApplyCommand method of G4UImanager : G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/run/verbose 1"); A complete list of built-in commands, roughly organized according to Geant4 categories is available in the Geant4 Application Developers Guide Built in user commands

307 307 Geant4 UI command A command consists of –Command directory –Command –Parameter(s) A parameter can be a type of string, boolean, integer or double. –Space is a delimiter –Use double-quotes (“”) for string with space(s). A parameter may be “omittable”. If it is the case, a default value will be taken if you omit the parameter. –Default value is either predefined default value or current value according to its definition. –If you want to use the default value for your first parameter while you want to set your second parameter, use “!” as a place holder. /dir/command ! second /run/verbose 1 /vis/viewer/flush

308 308 Macro file is an ASCII file contains UI commands. All commands must be given with their full-path directories. Use “ # ” for comment line. –First “ # ” to the end of the line will be ignored. –Comment lines will be echoed if /control/verbose is set to 2. Macro file can be executed –interactively or in (other) macro file /control/execute file_name –hard-coded G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/control/execute file_name"); Use of macro file (ex. run.mac )

309 309 User-defined commands If built-in commands are not enough, you can make your own Geant4 provides several command classes, all derived from G4UIcommand : –G4UIcmdWithoutParameter –G4UIcmdWithABool –G4UIcmdWithADouble –and many more Example energyCmd = new G4UIcmdWithADoubleAndUnit(“/gun/energy”, this); energyCmd->SetParameterName(“Energy”,true,true); energyCmd->SetDefaultUnit(GeV); See also Application Developers Guide

310 310 G4UIterminal - 1 G4UIterminal is a concrete implementation derived from the G4UIsession abstract base class. It provides character-base interactive terminal functionality to issue Geant4 UI commands. –C-shell or TC-shell (Linux only) new G4UIterminal(new G4UItcsh); –For Windows new G4UIWin32(); It supports some Unix-like commands for directory. –cd, pwd : change and display current command directory By setting the current command directory, you may omit (part of) directory string. –ls : list available UI commands and sub-directories

311 311 G4UIterminal - 2 It also supports some other commands. –history - show previous commands –! historyID - re-issue previous command –arrow keys (TC-shell only) –?UIcommand - show current parameter values of the command –help [UIcommand] - help –exit - job termination Above commands are interpreted in G4UIterminal and are not passed to Geant4 kernel. You cannot use them in a macro file.

312 312 Analysis interface Geant4 does not endorse or support particular analysis packages However an abstract analysis interface is provided –AIDA (Abstract Interfaces for Data Analysis) –will be built and linked to your application if enviroment variable G4ANALYSIS_USE is set –AIDA headers must be installed in code where analysis is set up #include AIDA/AIDA.h –must use AIDA-compliant analysis tools More AIDA information : –http://aida.freehep.org

313 313 Some AIDA-compliant Analysis Packages Anaphe –http://cern.ch/anaphe/ Open Scientist Lab –http://www.lal.in2p3.fr/OpenScientist –an example using Open Scientist can be found in $G4INSTALL/examples/extended/analysis/AnaEx01 JAS (Java Analysis Studio) –http://jas.freehep.org –for analysis example using JAS/AIDA see $G4INSTALL/examples/extended/analysis/A01

314 314 10 minutes The Geant4 toolkit : 12/15 - Documentation, examples, forum…

315 315 Geant4 web site http://cern.ch/geant4

316 316 From web site, in user guides List of required software C++ compiler, CLHEP, GNU make, Geant4 Visualization software How to install on Linux Tips for installing on Windows Installation guide

317 317  From web site, in user guides  Introduces new users to the Geant4 toolkit  Description of the most useful tools  Explain how to set up and run a simulation application  Only an overview, not exhaustive… User guide

318 318  From web site, in user guides  A reference for toolkit users and developers who wish to consult the underlying physics of an interaction  Presents the theoretical formulation, model or parameterization of the physics interactions provided by Geant4 Physics reference manual

319 319 From web site, in user guides A description of the object-oriented design of the Geant4 toolkit − class diagrams (some UML, some other) − philosophy behind design choices A guide for users who want to extend the functionality of Geant4 − adding new solids, modifying the navigator, creating new fields, etc… Toolkit’s developer guide

320 320 ●Internet : http://www-geant4.kek.jp/LXR ● Search entire Geant4 source tree by ● filename (e.g. G4Track.hh ) ● text ● identifier ● Results: a source file fully hyper-linked to classes and methods ● tells where classes and methods are defined ● also where they are referenced LXR code browser

321 321 Internet : section user forum Discuss problems with other users, post questions for experts, etc. 18 forums roughly based on Geant4 categories 3 forums for specific application areas New forums may be requested by users To join: click on “Membership” at bottom of page and fill out form User forum

322 322 7 novice examples from very easy to complex Will help you start your apllication Located in $G4INSTALL/examples/novice Several extended examples Users' Guide for Application Developers Located in $G4INSTALL/examples/extended 15 advanced examples Users’ Guide for Application Developers Located in $G4INSTALL/examples/advanced Examples

323 323 The Linux environment - minimum knowledge for Geant4 – 13/15 10 minutes

324 324 Introduction Geant4 can be installed under several environments : Linux, Windows, Mac OS, Sun… We are going to work with Geant4 under Scientific Linux, a OS standard for scientific computation (constantly updated, free, …)

325 325 Introduction More precisely, we will use the VMware virtualization tool (free) which can emulate simultaneously a real Linux PC directly under a Windows or Mac session. To learn more : Easy exchange of files between Linux and Windows We will work with Scientific Linux 4.5 (developped by CERN & Fermilab) and Geant4 9.0+P01, already installed for you http://geant4.in2p3.fr

326 326 Access to Linux Under your Windows session, start the VMware player and select the Linux machine Login with : –Username: local1 –Password: local1 A mouse right clik anywhere on the desktop open a terminal (select Open Terminal in the pop-up menu) where you’re going to enter control commands.

327 327 shells They are the available command interpreters

328 328 Navigate in directories

329 329 Move, copy, create, delete…

330 330 Other useful commands

331 331 Useful pre-installed tools nedit : edit text files xemacs : idem snavigator : Integrated Development Environment to manage a C++ project make : to compile the Geant4 application root : to start to data analysis ROOT software Add & after command name to keep control command

332 332 Where is Geant4 installed ? Source code accessible only to super user (su) in directory : /usr/local/geant4 A basic application on which we are going to work is under : /home/local1/geant4/simulation After compilation, the application executable will be stored in the directory : $G4WORKDIR/bin/Linux-g++

333 333 15 minutes The Geant4 toolkit : 14/15 - Write your own user application

334 334 User application Geant4 is a toolkit –i.e. you cannot “run” it out of the box –You must write an application, which uses Geant4 tools Consequences –There are no such concepts as “Geant4 defaults” –You must provide the necessary information to configure your simulation –You must deliberately choose which Geant4 tools to use Guidance: we provide many examples –Novice Examples: overview of Geant4 tools –Extended and Advanced Examples: Geant4 tools –Located in $G4INSTALL/examples

335 335 What you MUST do: –Describe your experimental set-up –Provide the primary particles input to your simulation –Decide which particles and physics models you want to use out of those available in Geant4 and the precision of your simulation (cuts to produce and track secondary particles) You may also want –To interact with Geant4 kernel to control your simulation –To visualize your simulation configuration or results –To produce histograms, tuples etc. to be further analysed Basic concepts

336 336 Geant4 design provides tools for a user application –To tell the kernel about your simulation configuration –To interact with Geant4 kernel itself Geant4 tools for user interaction are base classes –You create your own concrete class derived from the base classes –Geant4 kernel handles your own derived classes transparently through their base class interface (polymorphism) Abstract base classes for user interaction –User derived concrete classes are MANDATORY Concrete base classes (with virtual dummy methods) for user interaction –User derived classes are OPTIONAL Interaction with Geant4 kernel

337 337 Initialization classes Invoked at initialization G4VUserDetectorConstruction G4VUserPhysicsList Action classes Invoked during the execution loop G4VUserPrimaryGeneratorAction G4UserRunAction G4UserEventAction G4UserTrackingAction G4UserStackingAction G4UserSteppingAction User classes In RED, mandatory !

338 338 Physics Geometry Particles Analysis Tracks Steps Stacks

339 339 Hands On Let’s build a simple dosimetry application – 15/15 Novice Examples – N01 & N02

340 340 Geant4 does not provide the main() –Geant4 is a toolkit ! –The main() is part of the user application In his/her main(), the user must : –construct G4RunManager (or his/her own derived class) –notify the G4RunManager mandatory user classes derived from G4VUserDetectorConstruction G4VUserPhysicsList G4VUserPrimaryGeneratorAction The user may define in his/her main() –optional user action classes –G4VisManager, (G)UI session Simulation.cc  The main() program

341 341 Derive your own concrete class from the G4VUserDetectorConstruction abstract base class Implement the Construct() method –construct all necessary materials –define shapes/solids required to describe the geometry –construct and place volumes of your detector geometry –define visualization attributes for the detector elements –define sensitive detectors and identify detector volumes to associate them to –associate magnetic field to detector regions ☑ Describe the experimental setup

342 342 ☑ Define detector geometry DetectorConstruction.hh et.cc WORLD Volume B (daughter) Volume A (mother) Three conceptual layers –G4VSolid shape, size –G4LogicalVolume material, sensitivity, magnetic field, etc. –G4VPhysicalVolume position, rotation A unique physical volume (the WORLD volume), which represents the experimental area, must exist and fully contain all other components e. g. Volume A is mother of Volume B The mother must contain the daughter volume entirely

343 343 ☑ Select physics processes Geant4 does not have any default particles or processes Derive your own concrete class from the G4VUserPhysicsList abstract base class –define all necessary particles –define all necessary processes and assign them to proper particles –define production thresholds (in terms of range) Pure virtual methods of G4VUserPhysicsList that need to be implemented –ConstructParticles() –ConstructProcess() –SetCuts() PhysicsList.hh et.cc

344 344 ☑ Primary events Derive your own concrete class from the G4VUserPrimaryGeneratorAction abstract base class Define primary particles providing : particle type, initial position, initial direction, initial energy Imlement the virtual member function GeneratePrimaries() PrimaryGeneratorAction.hh et.cc

345 345 virtual member functions Five concrete base classes whose virtual member functions the user may override to gain control of the simulation at various stages –G4UserRunAction –G4UserEventAction –(G4UserTrackingAction) –(G4UserStackingAction) –G4UserSteppingAction Each member function of the base classes has a dummy implementation –Empty implementation: does nothing The user may implement the member functions he desires in his/her derived classes Objects of user action classes must be registered with G4RunManager ☑ Optional user action classes

346 346 G4UserRunAction BeginOfRunAction(const G4Run*) –For example: book histograms EndOfRunAction(const G4Run*) −For example: store histograms G4UserEventAction BeginOfEventAction(const G4Event*) –For example: perform and event selection EndOfEventAction(const G4Event*) –For example: analyse the event (G4UserTrackingAction) PreUserTrackingAction(const G4Track*) –For example: decide whether a trajectory should be stored or not PostUserTrackingAction(const G4Track*) Optional user action classes RunAction.hh et.cc EventAction.hh et.cc TrackingAction.hh et.cc

347 347 G4UserSteppingAction UserSteppingAction(const G4Step*) –For example: kill, suspend, postpone the track –For example: draw the step, collect physics information (G4UserStackingAction) PrepareNewEvent() –For example: reset priority control ClassifyNewTrack(const G4Track*) –Invoked every time a new track is pushed –For example: classify a new track (priority control) Urgent, Waiting, PostponeToNextEvent, Kill NewStage() –Invoked when the Urgent stack becomes empty –For example: change the classification criteria –For example: event filtering (event abortion) Optional user action classes SteppingAction.hh et.cc StackingAction.hh et.cc

348 348 ☑ GUI and visualization In your main(), taking into account your computer environment, instantiate a G4UIsession concrete class provided by Geant4 and invoke its sessionStart() method Geant4 provides: –G4UIterminal: csh or tcsh like character terminal –G4GAG : tcl/tk or Java PVM based GUI –G4Wo : Opacs –G4UIBatch : batch job with macro file –… In your main(), taking into account your computer environment, instantiate a G4VisExecutive and invoke its initialize() method Geant4 provides interfaces to various graphics drivers: –DAWN (Fukui renderer) –WIRED –RayTracer (ray tracing by Geant4 tracking) –OPACS –OpenGL –OpenInventor –VRML –… Simulation.cc


Download ppt "1 The Geant4 Monte Carlo toolkit Sebasten Incerti / Alfonso Mantero IN2P3/CNRS Centre d’Etudes Nucléaires de Bordeaux Gradignan France"

Similar presentations


Ads by Google