Geant4 User's Guide for Application Developers

Geant4 Collaboration

Version: geant4 10.2

4 December 2015


Table of Contents

1. Introduction
1.1. Scope of this manual
1.2. How to use this manual
2. Getting Started with Geant4 - Running a Simple Example
2.1. How to Define the main() Program
2.1.1. A Sample main() Method
2.1.2. G4RunManager
2.1.3. User Initialization and Action Classes
2.1.4. G4UImanager and UI CommandSubmission
2.1.5. G4cout and G4cerr
2.2. How to Define a Detector Geometry
2.2.1. Basic Concepts
2.2.2. Create a Simple Volume
2.2.3. Choose a Solid
2.2.4. Create a Logical Volume
2.2.5. Place a Volume
2.2.6. Create a Physical Volume
2.2.7. Coordinate Systems and Rotations
2.3. How to Specify Materials in the Detector
2.3.1. General Considerations
2.3.2. Define a Simple Material
2.3.3. Define a Molecule
2.3.4. Define a Mixture by Fractional Mass
2.3.5. Define a Material from the Geant4 Material Database
2.3.6. Define a Material from the Base Material
2.3.7. Print Material Information
2.3.8. Access to Geant4 material database
2.4. How to Specify Particles
2.4.1. Particle Definition
2.4.2. Range Cuts
2.5. How to Specify Physics Processes
2.5.1. Physics Processes
2.5.2. Managing Processes
2.5.3. Specifying Physics Processes
2.6. How to Generate a Primary Event
2.6.1. Generating Primary Events
2.6.2. G4VPrimaryGenerator
2.7. Geant4 General Particle Source
2.7.1. Introduction
2.7.2. Configuration
2.7.3. Macro Commands
2.7.4. Example Macro File
2.8. How to Make an Executable Program
2.8.1. Using CMake to build Applications: Geant4Config.cmake
2.8.2. Using Geant4Make to build Applications: binmake.gmk
2.9. How to Set Up an Interactive Session
2.9.1. Introduction
2.9.2. A Short Description of Available Interfaces
2.9.3. How to Select Interface in Your Applications
2.10. How to Execute a Program
2.10.1. Introduction
2.10.2. 'Hard-coded' Batch Mode
2.10.3. Batch Mode with Macro File
2.10.4. Interactive Mode Driven by Command Lines
2.10.5. General Case
2.11. How to Visualize the Detector and Events
2.11.1. Introduction
2.11.2. Visualization Drivers
2.11.3. How to Incorporate Visualization Drivers into an Executable
2.11.4. Writing the main() Method to Include Visualization
2.11.5. Sample Visualization Sessions
2.11.6. For More Information on Geant4 Visualization
3. Toolkit Fundamentals
3.1. Class Categories and Domains
3.1.1. What is a class category?
3.1.2. Class categories in Geant4
3.2. Global Usage Classes
3.2.1. Signature of Geant4 classes
3.2.2. The HEPRandom module in CLHEP
3.2.3. The HEPNumerics module
3.2.4. General management classes
3.3. System of units
3.3.1. Basic units
3.3.2. Input your data
3.3.3. Output your data
3.3.4. Introduce new units
3.3.5. Print the list of units
3.4. Run
3.4.1. Basic concept of Run
3.4.2. Geant4 as a state machine
3.4.3. User's hook for state change
3.4.4. Customizing the Run Manager
3.4.5. Managing worker thread
3.5. Event
3.5.1. Representation of an event
3.5.2. Structure of an event
3.5.3. Mandates of G4EventManager
3.5.4. Stacking mechanism
3.6. Event Generator Interface
3.6.1. Structure of a primary event
3.6.2. Interface to a primary generator
3.6.3. Event overlap using multiple generators
3.7. Event Biasing Techniques
3.7.1. Scoring, Geometrical Importance Sampling and Weight Roulette
3.7.2. Physics Based Biasing
3.7.3. Adjoint/Reverse Monte Carlo
3.7.4. Generic Biasing
4. Detector Definition and Response
4.1. Geometry
4.1.1. Introduction
4.1.2. Solids
4.1.3. Logical Volumes
4.1.4. Physical Volumes
4.1.5. Touchables: Uniquely Identifying a Volume
4.1.6. Creating an Assembly of Volumes
4.1.7. Reflecting Hierarchies of Volumes
4.1.8. The Geometry Navigator
4.1.9. A Simple Geometry Editor
4.1.10. Converting Geometries from Geant3.21
4.1.11. Detecting Overlapping Volumes
4.1.12. Dynamic Geometry Setups
4.1.13. Importing XML Models Using GDML
4.1.14. Importing ASCII Text Models
4.1.15. Saving geometry tree objects in binary format
4.2. Material
4.2.1. General considerations
4.2.2. Introduction to the Classes
4.2.3. Recipes for Building Elements and Materials
4.2.4. The Tables
4.3. Electromagnetic Field
4.3.1. An Overview of Propagation in a Field
4.3.2. Practical Aspects
4.3.3. Spin Tracking
4.4. Hits
4.4.1. Hit
4.4.2. Sensitive detector
4.4.3. G4SDManager
4.4.4. G4MultiFunctionalDetector and G4VPrimitiveScorer
4.4.5. Concrete classes of G4VPrimitiveScorer
4.4.6. G4VSDFilter and its derived classes
4.5. Digitization
4.5.1. Digi
4.5.2. Digitizer module
4.6. Object Persistency
4.6.1. Persistency in Geant4
4.6.2. Using Root-I/O for persistency of Geant4 objects
4.7. Parallel Geometries
4.7.1. A parallel world
4.7.2. Defining a parallel world
4.7.3. Detector sensitivity in a parallel world
4.8. Command-based scoring
4.8.1. Introduction
4.8.2. Defining a scoring mesh
4.8.3. Drawing scores
4.8.4. Writing scores to a file
5. Tracking and Physics
5.1. Tracking
5.1.1. Basic Concepts
5.1.2. Access to Track and Step Information
5.1.3. Handling of Secondary Particles
5.1.4. User Actions
5.1.5. Verbose Outputs
5.1.6. Trajectory and Trajectory Point
5.2. Physics Processes
5.2.1. Electromagnetic Interactions
5.2.2. Hadronic Interactions
5.2.3. Particle Decay Process
5.2.4. Gamma-nuclear and Lepto-nuclear Processes
5.2.5. Optical Photon Processes
5.2.6. Parameterization
5.2.7. Transportation Process
5.3. Particles
5.3.1. Basic concepts
5.3.2. Definition of a particle
5.3.3. Dynamic particle
5.4. Production Threshold versus Tracking Cut
5.4.1. General considerations
5.4.2. Set production threshold (SetCut methods)
5.4.3. Apply cut
5.4.4. Why produce secondaries below threshold in some processes?
5.4.5. Cuts in stopping range or in energy?
5.4.6. Summary
5.4.7. Special tracking cuts
5.5. Cuts per Region
5.5.1. General Concepts
5.5.2. Default Region
5.5.3. Assigning Production Cuts to a Region
5.6. Physics Table
5.6.1. General Concepts
5.6.2. Material-Cuts Couple
5.6.3. File I/O for the Physics Table
5.6.4. Building the Physics Table
5.7. User Limits
5.7.1. General Concepts
5.7.2. Processes co-working with G4UserLimits
5.8. Track Error Propagation
5.8.1. Physics
5.8.2. Trajectory state
5.8.3. Trajectory state error
5.8.4. Targets
5.8.5. Managing the track propagation
5.8.6. Limiting the step
6. User Actions
6.1. Mandatory User Actions and Initializations
6.1.1. G4VUserDetectorConstruction
6.1.2. Physics Lists
6.1.3. User Action Initialization
6.2. Optional User Actions
6.2.1. Usage of User Actions
6.2.2. Killing Tracks in User Actions and Energy Conservation
6.3. User Information Classes
6.3.1. G4VUserEventInformation
6.3.2. G4VUserTrackInformation
6.3.3. G4VUserPrimaryVertexInformation and G4VUserPrimaryTrackInformation
6.3.4. G4VUserRegionInformation
7. Communication and Control
7.1. Built-in Commands
7.2. User Interface - Defining New Commands
7.2.1. G4UImessenger
7.2.2. G4UIcommand and its derived classes
7.2.3. An example messenger
7.2.4. How to control the output of G4cout/G4cerr
8. Visualization
8.1. Introduction to Visualization
8.1.1. What Can be Visualized
8.1.2. You have a Choice of Visualization Drivers
8.1.3. Choose the Driver that Meets Your Needs
8.1.4. Controlling Visualization
8.1.5. Visualization Details
8.2. Adding Visualization to Your Executable
8.2.1. Installing Visualization Drivers
8.2.2. How to Realize Visualization Drivers in an Executable
8.2.3. Visualization Manager
8.2.4. How to Write the main() Function
8.3. The Visualization Drivers
8.3.1. Availability of drivers on the supported systems
8.3.2. OpenGL
8.3.3. Qt
8.3.4. OpenInventor
8.3.5. OpenInventor Extended Viewer
8.3.6. HepRepFile
8.3.7. HepRepXML
8.3.8. DAWN
8.3.9. Remote Visualization with the DAWN-Network Driver
8.3.10. VRML
8.3.11. RayTracer
8.3.12. gMocren
8.3.13. Wt (WARNING: this driver is experimental and should be used with caution)
8.3.14. Visualization of detector geometry tree
8.3.15. GAG Tree
8.3.16. XML Tree
8.4. Controlling Visualization from Commands
8.4.1. Scene, scene handler, and viewer
8.4.2. Create a scene handler and a viewer: /vis/open command
8.4.3. Create an empty scene: /vis/scene/create command
8.4.4. Visualization of a physical volume: /vis/drawVolume command
8.4.5. Visualization of a logical volume: /vis/specify command
8.4.6. Visualization of trajectories: /vis/scene/add/trajectories command
8.4.7. Visualization of hits: /vis/scene/add/hits command
8.4.8. Visualization of Scored Data
8.4.9. HepRep Attributes for Hits
8.4.10. Basic camera workings: /vis/viewer/ commands
8.4.11. Declare the end of visualization for flushing: /vis/viewer/flush command
8.4.12. End of Event Action and End of Run Action: /vis/viewer/endOfEventAction and /vis/viewer/endOfRunAction commands
8.4.13. HepRep Attributes for Trajectories
8.4.14. How to save a visualized views to PostScript files
8.4.15. Culling
8.4.16. Cut view
8.5. Controlling Visualization from Compiled Code
8.5.1. G4VVisManager
8.5.2. Visualization of detector components
8.5.3. Visualization of trajectories
8.5.4. Enhanced trajectory drawing
8.5.5. HepRep Attributes for Trajectories
8.5.6. Visualization of hits
8.5.7. HepRep Attributes for Hits
8.5.8. Visualization of text
8.5.9. Visualization of polylines and tracking steps
8.5.10. Visualization User Action
8.5.11. Standalone Visualization
8.6. Visualization Attributes
8.6.1. Visibility
8.6.2. Colour
8.6.3. Forcing attributes
8.6.4. Other attributes
8.6.5. Constructors of G4VisAttributes
8.6.6. How to assign G4VisAttributes to a logical volume
8.6.7. Additional User-Defined Attributes
8.7. Enhanced Trajectory Drawing
8.7.1. Default Configuration
8.7.2. Trajectory Drawing Models
8.7.3. Controlling from Commands
8.7.4. Controlling from Compiled Code
8.7.5. Drawing by time
8.8. Trajectory Filtering
8.8.1. Controlling from Commands
8.8.2. Example commands
8.8.3. Hit Filtering
8.9. Polylines, Markers and Text
8.9.1. Polylines
8.9.2. Markers
8.9.3. Text
8.10. Making a Movie
8.10.1. OGLX
8.10.2. Qt
8.10.3. DAWNFILE
8.10.4. RayTracerX
9. Analysis
9.1. Introduction
9.2. Analysis Manager Classes
9.2.1. Analysis Manager
9.2.2. Files handling
9.2.3. Histograms
9.2.4. Profiles
9.2.5. Plotting
9.2.6. Ntuples
9.2.7. Parallel Processing
9.2.8. Coexistence of Several Managers
9.2.9. Supported Features and Limitations
9.3. Analysis Reader Classes
9.3.1. Analysis Reader
9.3.2. Files handling
9.3.3. Histograms and Profiles
9.3.4. Ntuples
9.4. Parameters
9.4.1. G4Parameter<T>
9.4.2. User defined parameters
9.5. g4tools
9.5.1. g4tools package
9.5.2. User API
10. Examples
10.1. Introduction
10.2. Basic Examples
10.2.1. Basic Examples Summary
10.2.2. Basic Examples Macros
10.2.3. Multi-threading
10.2.4. Example B1
10.2.5. Example B2
10.2.6. Example B3
10.2.7. Example B4
10.2.8. Example B5
10.3. Extended Examples
10.3.1. Extended Example Summary
10.4. Advanced Examples
10.5. Novice Examples
Appendices
1. CLHEP Foundation Library
2. Geant4Config.cmake CMake Config File
2.1. Usage of Geant4Config.cmake
2.2. Building an Application against a Build of Geant4
3. GNUMake System: Makefiles and Environment Variables
3.1. Geant4Make System
3.2. Environment variables
3.3. Linking External Libraries with Geant4
4. Development and Debug Tools
4.1. Unix/Linux
4.2. Windows
5. Python Interface
5.1. Installation
5.2. Using Geant4Py
5.3. Site-modules
5.4. Examples
6. Geant4 Material Database
6.1. Simple Materials (Elements)
6.2. NIST Compounds
6.3. HEP and Nuclear Materials
6.4. Space (ISS) Materials
6.5. Bio-Chemical Materials
Bibliography