the geant4 monte carlo toolkit n.
Skip this Video
Loading SlideShow in 5 Seconds..
The Geant4 Monte Carlo toolkit PowerPoint Presentation
Download Presentation
The Geant4 Monte Carlo toolkit

Loading in 2 Seconds...

play fullscreen
1 / 348

The Geant4 Monte Carlo toolkit - PowerPoint PPT Presentation

  • Uploaded on Do-Son school on Advanced Computing and GRID Technologies for Research Institute of Information Technology, VAST, Hanoi, Vietnam 5-16 November 2007. The Geant4 Monte Carlo toolkit. On behalf of the Geant4 collaboration. Sébastien Incerti IN2P3/CNRS

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

The Geant4 Monte Carlo toolkit

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

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

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. Do-Son school on Advanced Computing and GRID Technologies for ResearchInstitute of Information Technology, VAST, Hanoi, Vietnam 5-16 November 2007 The Geant4 Monte Carlo toolkit On behalf of the Geant4 collaboration Sébastien Incerti IN2P3/CNRS Centre d’Etudes Nucléaires de Bordeaux Gradignan France

    2. Thank you ! • Do-Son school organizers • IN2P3 • Vincent Breton (IN2P3) • François Le Diberder (IN2P3) • Geant4 • Makoto Asai (SLAC) • Michel Maire (IN2P3) • The whole Geant4 collaboration

    3. Outline of the course • Introduction 15 minutes • Basic structure 25 minutes • Definition of materials 10 minutes • Geometry construction 30+40 minutes • Electromagnetic Physics : standard version 20 minutes • Electromagnetic Physics : low energy version 35 minutes • Hadronic Physics 25 minutes • Physics lists 15 minutes • Primary particles generation 10 minutes • Particles and processes 40 minutes • User interface 15 minutes • Documentation, examples, forum 10 minutes • Linux 10 minutes • Write your own application 5 minutes • Hands on rest of day

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

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

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

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

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

    13. What can Geant4 do for you ? • 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

    14. What you have to do for Geant4 • 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.

    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. Tools for input preparation 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 !)

    17. Choices of Physics processes Geant4 provides a wide variety of physics models of particle interactions with matter you can select • Category of physics processes • Standard electromagnetic processes • Low energyelectromagnetic 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

    18. Geant4 training and user support • 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

    19. Other tutorial material Documentation and tutorials available at :

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

    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. 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. Event • At beginning of processing, an eventcontains 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)

    24. Track • 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

    25. Step • 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

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

    27. D 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

    28. Tracking • Geant4 tracking is general • Itisindependentof • 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)

    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. 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. User classes • 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()-notprovidedbyGeant4

    32. Manager classes • 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

    33. Build your simulation in 7 steps

    34. 1 - Describe your detector • 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

    35. 2 – Select physics processes • Geant4 does not have any default particles or processes • even particle transporation must be explicitly defined by user • Derive your own concrete class from G4VUserPhysicsListabstract 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

    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. 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 eventfiltering 4 – User action classes • G4UserRunAction • BeginOfRunAction(define histograms) • EndOfRunAction(fill histograms) • G4UserEventAction • BeginOfEventAction (event selection) • EndOfEventAction(analyze event) • G4UserTrackingAction • PreUserTrackingAction(create user defined trajectory) • PostUserTrackingAction

    38. 5 - The main()program • 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

    39. 6 – Setting up a user interface session • 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 • UIsessions 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

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

    41. In the directorysimulation GNUMakefile In simulation/src Insimulation/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) Application files : example In purple : mandatory files In white : optional files

    42. The G4 prefix • 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

    43. System of units • 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 • Divide a variable by a unit you want to get. G4cout << dE / MeV << “ (MeV)” << G4endl;

    44. System of units • 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

    45. Summary • 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

    46. More

    47. Geant4 as a state machine D 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

    48. Definition of new units • 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

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