Geant4 Training 2003 Basic structure of the Geant4 Simulation Toolkit The full set of lecture notes of this Geant4 Course is available.

Slides:



Advertisements
Similar presentations
The Geant4 Kernel: Status and Recent Developments John Apostolakis, Gabriele Cosmo – CERN / PH Makoto Asai – SLAC On behalf the Geant4 collaboration April.
Advertisements

IEEE Nuclear Science Symposium and Medical Imaging Conference Short Course The Geant4 Simulation Toolkit Sunanda Banerjee (Saha Inst. Nucl. Phys., Kolkata,
山下智弘 JST CREST/ 神戸大学 Borrowing especially from presentations of M. Asai(SLAC) Geant4 Japan Oct, RCNS, based on Geant4 9.0.p01.
Geant4 v9.2p02 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Improvement of G4Exception (and an announcement on G4ApplicationState) Makoto Asai (SLAC) on behalf of Architecture team.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Primary particle generation Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002.
Makoto Asai (SLAC) Geant4 Tutorial Course
Introduction and Getting Started ESA/ESTEC Makoto Asai (SLAC)
Makoto Asai (SLAC) Geant4 Users CERN Nov. 15 th, 2002 Customizing Run Management.
Geant4 v9.4 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11 th, 2002 Getting Started.
14 User Documents and Examples I SLAC Geant4 Tutorial 3 November 2009 Dennis Wright Geant4 V9.2.p02.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 18 th, 2002 Getting Started.
Highlights of latest developments ESA/ESTEC Makoto Asai (SLAC)
Geant4 v9.3p01 Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users SLAC Feb. 20th, 2002 Stack management, Digitization and Pile-up.
Geant4 v9.3p01 Kernel I Makoto Asai (SLAC) Geant4 Tutorial Course.
Makoto Asai (SLAC) Geant4 Users CERN Nov. 13th, 2002 Stack management, Digitization and Pile-up.
Software Installation, release 4.0 Geant4 Users’ Workshop Tutorial SLAC February 18-22, 2002 Takashi Sasaki, Gabriele Cosmo,
Primary Particle Makoto Asai (SLAC) Geant4 Tutorial Course Geant4 v8.2p01.
Software Installation The full set of lecture notes of this Geant4 Course is available at
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Japan.
Introduction to Geant4 Makoto Asai (SLAC) Geant4 Tutorial Course the 2nd Finnish Geant4 Workshop June , Helsinki Institute of Physics June 2005,
A introduction Luciano Pandola INFN-LNGS Partially based on a presentation by G.A.P. Cirrone (INFN-LNS) and M.G. Pia (INFN-Ge) Queen’s University, Belfast.
Introduction to Geant4 John Apostolakis (CERN) Geant4 Tutorial LAPP, Nov 2008 Original slides by Makoto Asai (SLAC) Geant4 ver 9.1.
User Documents and Examples I Sébastien Incerti Slides thanks to Dennis Wrigth, SLAC.
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
1 Primary particles Geant4 User's Tutorial CERN, February 2010 Talk from previous tutorial by Giovanni Santin Ecole Geant4, Annecy 2008.
Introduction to Geant4 Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Basic Structure of the Geant4 Simulation Toolkit
Primary particle Giovanni Santin ESA / ESTEC and RheaTech Ltd On behalf of the Geant4 collaboration Ecole Geant4 Annecy, and Nov 2008 With.
Geant4 internal Classes and Objects Gunter Folger / CERN Geant4 course, Annecy 2008 User Action & Information Classes.
Computing Performance Recommendations #13, #14. Recommendation #13 (1/3) We recommend providing a simple mechanism for users to turn off “irrelevant”
User Application Toolkit + User application toolkit Geant4 is a toolkit –i.e. you cannot “run” it out of the box –You must write.
User Application Luciano Pandola INFN-LNGS Partially based on a presentation by Maria Grazia Pia (INFN-Ge)
17-19 Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan Oct, 2007Geant4 Japan 2007 Geant4 Collaboration.
Geant4 internal Classes and Objects Geant4 Users’ Tutorial February 2010 Gunter Folger / CERN User Action & Information Classes.
Maria Grazia Pia INFN Genova Salamanca, July 2002
Basics of Primary Particle Generation and Tracking Makoto Asai (SLAC) Geant4 Tutorial CERN May 25-27, 2005 May 2005, Geant4 v7.0p01.
Run and Event G4Run and G4RunManager In Geant4, the Run is the largest unit of simulation and it consist of a series of events Within a Run, the detector.
Geant4 examples Sébastien Incerti On behalf of the Geant4 collaboration with special thanks to Luciano Pandola, INFN.
Makoto Asai (SLAC) Getting Started MGP: added class diagram of basic user application.
Geant4 Training 2003 Primary Particle Generation The full set of lecture notes of this Geant4 Course is available at
Geant4 internal Classes and Objects Gunter Folger / CERN MC-PAD, DESY/Hamburg January 2010 User Action & Information Classes.
Geant4 release 5.1 summary Gabriele Cosmo EP/SFT.
Introduction to Geant4 Makoto Asai (SLAC) Geant4 Tutorial Course the 2nd Finnish Geant4 Workshop June , Helsinki Institute of Physics June 2005,
Physics II : processes Paris Geant4 Tutorial 5 June 2007 Marc Verderi Ecole Polytechnique - LLR.
A Short Course on Geant4 Simulation Toolkit Introduction
Interaction with the Geant4 kernel
Interaction with the Geant4 kernel
Basics of a user application
Introduction to Geant4 Makoto Asai (SLAC Computing Services)
Primary Particle Generation
Makoto Asai (SLAC) Geant4 Users CERN Nov. 11th, 2002
G.A.P.Cirrone, S.E.Mazzaglia - INFN/LNS, Italy
Primary Particle Generation
Software Installation
A Short Course on Geant4 Simulation Toolkit Introduction
User Application
The n-3He Simulation Using Geant4
User Application
Marc Verderi GEANT4 collaboration meeting 01/10/2002
User Application
The full set of lecture notes of this Geant4 Course is available at
Customizing Run Management
The full set of lecture notes of this Geant4 Course is available at
Kernel Author: Makoto Asai.
The full set of lecture notes of this Geant4 Course is available at
Simulation in Experiments searching for rare events
Presentation transcript:

Geant4 Training 2003 Basic structure of the Geant4 Simulation Toolkit The full set of lecture notes of this Geant4 Course is available at

Geant4 Training 2003 Contents Basic concepts in Geant4 Geant4 architecture –Category structure –System of units –Intercoms and G4cout User classes

Geant4 Training 2003 Run in Geant4 As an analogy of the real experiment, a run of Geant4 starts with “ Beam On ”. Within a run, the user cannot change –detector geometry –settings of physics processes ---> detector is inaccessible during a run Conceptually, a run is a collection of events which share the same detector conditions. At the beginning of a run, geometry is optimized for navigation and cross-section tables are calculated according to materials appear in the geometry and the cut-off values defined.

Geant4 Training 2003 Event in Geant4 At beginning of processing, an event contains primary particles. These primaries are pushed into a stack. When the stack becomes empty, processing of an event is over. G4Event class represents an event. It has following objects at the end of its processing. –List of primary vertexes and particles (as input) –Hits collections –Trajectory collection (optional) –Digits collections (optional)

Geant4 Training 2003 Track in Geant4 Track is a snapshot of a particle. –It has only position and physical quantities of current instance. Step is a “ delta ” information to a track. –Track is not a collection of steps. Track is deleted when –it goes out of the world volume –it disappears (e.g. decay) –it goes down to zero kinetic energy and no “ AtRest ” additional process is required –the user decides to kill it No track object persists at the end of event. –For the record of track, use trajectory class objects.

Geant4 Training 2003 Step in Geant4 Step has two points and also “ delta ” information of a particle (energy loss on the step, time-of-flight spent by the step, etc.). Each point knows the volume (and material). In case a step is limited by a volume boundary, the end point physically stands on the boundary, and it logically belongs to the next volume. –Because one step knows two volumes, boundary processes such as transition radiation or refraction could be simulated. Begin of step point End of step point Step Boundary

Geant4 Training 2003 Tracking and processes Geant4 tracking is general. –It is independent of  the particle type  the physics processes involving to a particle –It gives the chance to all processes  To contribute to determining the step length  To contribute any possible changes in physical quantities of the track  To generate secondary particles  To suggest changes in the state of the track e.g. to suspend, postpone or kill it.

Geant4 Training 2003 Processes in Geant4 In Geant4, particle transportation is a process as well, by which a particle interacts with geometrical volume boundaries and field of any kind. –Shower parameterization process can take over from the ordinary transportation. Each particle has its own list of applicable processes. At each step, all processes listed are invoked to get proposed physical interaction lengths. The process which requires the shortest interaction length (in space-time) limits the step.

Geant4 Training 2003 How Geant4 runs (one step) Stepping Manager Physics Process Particle Change StepTrackLogical Volume Sensitive Detector GetPhysicalInteractionLength SelectShortest DoIt Fill Update IsSensitive GenerateHits

Geant4 Training 2003 Cuts in Geant4 A Cut in Geant4 is a production threshold. –Only for physics processes that have infra-red divergence –Not tracking cut, which does not exist in Geant4 Energy threshold must be determined at which discrete energy loss is replaced by continuous loss –Old way:  Track primary until cut-off is reached, calculate continuous loss and dump it at that point, stop tracking primary  Create secondaries only above cut-off, or add to continuous loss of primary for less energetic secondaries –Geant4 way:  specify range (which is converted to energy for each material) at which continuous loss begins, track primary down to zero range  Create secondaries only above specified range, or add to continuous loss of primary for less energetic secondaries

Geant4 Training 2003 Stack G4Track is a class object, thus it is easy to treat suspending or postponing tracks. For example, –Suspend tracks at the entrance of calorimeter, i.e. simulate all tracks in tracking region before generating showers. –Suspend a “looper” track after certain time and postpone it to next event. Prioritized tracking without performance cost Well-thought prioritization/abortion of tracks/events makes entire simulation process much more efficient.

Geant4 Training 2003 Geant4 as a state machine Geant4 has six application states. –G4State_PreInit  Material, Geometry, Particle and/or Physics Process need to be initialized/defined –G4State_Idle  All necessary initializations are done  Ready to start a run  Or, ready to modify geometry/physics to proceed to the next run –G4State_GeomClosed  Geometry is optimized  Cross-section tables are updated  Ready to process an event –G4State_EventProc  An event is processing –G4State_Quit  (Normal) termination –G4State_Abort  A fatal exception occurred and program is aborting PreInit Idle EventProc GeomClosed Quit Abort initialize beamOn exit

Geant4 Training 2003 Geant4 kernel Geant4 consists of 17 categories. –Independently developed and maintained by WG(s) responsible to each (sub-)category. –Interfaces between categories are maintained by the global architecture WG. Geant4 Kernel –Handles run, event, track, step, hit, trajectory. –Provides framework for, or interfaces to  physics processes  Visualization drivers  (G)UI  Persistency mechanism  Histogramming  User's framework Geant4 ReadoutVisuali zation Persis tency Run Event Inter faces Tracking Digits + Hits Processes Track GeometryParticle Graphic _reps Material Intercoms Global

Geant4 Training 2003 Unit system Internal unit system used in Geant4 is completely hidden not only from user’s code but also from Geant4 source code implementation. Each hard-coded number must be multiplied by its proper unit. radius = 10.0 * cm; kineticE = 1.0 * GeV; To get a number, it must be divided by a proper unit. G4cout << eDep / MeV << “ [MeV]” << G4endl; Most of commonly used units are provided and user can add his/her own units. By this unit system, importing / exporting physical quantities becomes straightforward and source code becomes more readable. –For particular application, user can change the internal unit with suitable precision without affecting to the result.

Geant4 Training 2003 Intercoms “Intercoms” category handles the framework mechanism of defining and delivering commands. –Exportable to any other application  Independent to other Geant4 categories –Strong type and range checking  Range description by C++ syntax aCmd->SetRange(“x>0. && y>0.”); –Dynamic command definition / activation –Commands can be hard-coded or issued by (G)UI. Macro file –Recursive variable definition –Loop

Geant4 Training 2003 G4cout, G4cerr G4cout and G4cerr are ostream objects defined by Geant4. –G4endl is also provided. Some GUIs are buffering output streams so that they display print-outs on another window or provide storing / editing functionality. –The user should not use std::cout, etc. The user should not use std::cin for input. Use user-defined commands provided by intercoms category in Geant4.

Geant4 Training 2003 User classes Initialization classes –Invoked at the initialization  G4VUserDetectorConstruction  G4VUserPhysicsList Action classes –Invoked during an event loop  G4VUserPrimaryGeneratorAction  G4UserRunAction  G4UserEventAction  G4UserStackingAction  G4UserTrackingAction  G4UserSteppingAction main() –Geant4 does not provide main(). Note : classes written in Red are mandatory.

Geant4 Training 2003 Describe your detector Derive your own concrete class from G4VUserDetectorConstruction abstract base class. In the virtual method Construct(), –Construct all necessary materials –Construct volumes of your detector geometry –Construct your sensitive detector classes and set them to the detector volumes Optionally you can define –Regions for any part of your detector –Visualization attributes of your detector elements

Geant4 Training 2003 Select physics processes Geant4 does not have any default particles or processes. –Even for the particle transportation, you have to define it explicitly. Derive your own concrete class from G4VUserPhysicsList abstract base class. –Define all necessary particles –Define all necessary processes and assign them to proper particles –Define cut-off ranges applied to the world and each region Geant4 provides lots of utility classes/methods and examples. –"Educated guess" physics lists for defining hadronic processes for various use-cases.

Geant4 Training 2003 Generate primary event Derive your concrete class from G4VUserPrimaryGeneratorAction abstract base class. Pass a G4Event object to one or more primary generator concrete class objects which generate primary vertices and primary particles. Geant4 provides several generators in addition to the G4VPrimaryParticlegenerator base class. –G4ParticleGun –G4HEPEvtInterface, G4HepMCInterface  Interface to /hepevt/ common block or HepMC class –G4GeneralParticleSource  Define radioactivity

Geant4 Training 2003 Optional user action classes All user action classes, methods of which are invoked during “Beam On”, must be constructed in the user’s main() and must be set to the RunManager. G4UserRunAction –BeginOfRunAction(const G4Run*)  Define histograms –EndOfRunAction(const G4Run*)  Store histograms G4UserEventAction –BeginOfEventAction(const G4Event*)  Event selection  Define histograms –EndOfEventAction(const G4Event*)  Analyze the event G4UserStackingAction –PrepareNewEvent()  Reset priority control –ClassifyNewTrack(const G4Track*)  Invoked every time a new track is pushed  Classify a new track -- priority control Urgent, Waiting, PostponeToNextEvent, Kill –NewStage()  Invoked when the Urgent stack becomes empty  Change the classification criteria  Event filtering (Event abortion) G4UserTrackingAction –PreUserTrackingAction(const G4Track*)  Decide trajectory should be stored or not  Create user-defined trajectory –PostUserTrackingAction(const G4Track*) G4UserSteppingAction –UserSteppingAction(const G4Step*)  Kill / suspend / postpone the track  Draw the step (for a track not to be stored by a trajectory)

Geant4 Training 2003 The main program Geant4 does not provide the main(). In your main(), you have to –Construct G4RunManager (or your derived class) –Set user mandatory classes to RunManager  G4VUserDetectorConstruction  G4VUserPhysicsList  G4VUserPrimaryGeneratorAction You can define VisManager, (G)UI session, optional user action classes, and/or your persistency manager in your main().

Geant4 Training 2003 Select (G)UI In your main(), according to your computer environments, construct a G4UIsession concrete class provided by Geant4 and invoke its sessionStart() method. Geant4 provides –G4UIterminal -- C- and TC-shell like character terminal –G4GAG -- Tcl/Tk or Java PVM based GUI –G4Wo -- Opacs –G4JAG -- Interface to JAS (Java Analysis Studio) –G4UIBatch -- Batch job with macro file

Geant4 Training 2003 Visualization Derive your own concrete class from G4VVisManager according to your computer environments. Geant4 provides interfaces to graphics drivers –DAWN -- Fukui renderer –WIRED –RayTracer -- Ray tracing by Geant4 tracking –OPACS –OpenGL –OpenInventor –VRML

Geant4 Training 2003 Environment variables You need to set following environment variables to compile, link and run Geant4-based simulation. –Mandatory variables  G4SYSTEM – OS (e.g. Linux-g++)  G4INSTALL – base directory of Geant4  G4WORKDIR – your temporary work space  CLHEP_BASE_DIR – base directory of CLHEP –Variables for physics processes in case corresponding processes are used  G4LEVELGAMMADATA - photon evaporation  G4LEDATA - cross-sections for Low-E EM module  G4RADIOACTIVEDATA - radioactive decay  NeutronHPCrossSections - neutron cross-section –Additional variables for GUI/Vis/Analysis