Geant4 User's Guide for Application Developers

Geant4 Collaboration

Version: geant4 9.6.0

30th November, 2012


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. How to Make an Executable Program
2.7.1. Building ExampleB1 Using CMake
2.7.2. Building ExampleB1 using Geant4Make
2.8. How to Set Up an Interactive Session
2.8.1. Introduction
2.8.2. A Short Description of Available Interfaces
2.8.3. How to Select Interface in Your Applications
2.9. How to Execute a Program
2.9.1. Introduction
2.9.2. 'Hard-coded' Batch Mode
2.9.3. Batch Mode with Macro File
2.9.4. Interactive Mode Driven by Command Lines
2.9.5. General Case
2.10. How to Visualize the Detector and Events
2.10.1. Introduction
2.10.2. Visualization Drivers
2.10.3. How to Incorporate Visualization Drivers into an Executable
2.10.4. Writing the main() Method to Include Visualization
2.10.5. Sample Visualization Sessions
2.10.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.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
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. Readout geometry
4.4.4. G4SDManager
4.4.5. G4MultiFunctionalDetector and G4VPrimitiveScorer
4.4.6. Concrete classes of G4VPrimitiveScorer
4.4.7. G4VSDFilter and its derived classes
4.4.8. Scoring for Event Biasing
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 Reflex 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?
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. Building Physics List from Scratch
6.1.2. Reference Physics Lists
6.1.3. Building Physics List Using Factory
6.1.4. Building Physics List from Physics Builders
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. Visualization of detector geometry tree
8.3.14. GAG Tree
8.3.15. 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. g4tools
9.1.1. inlib, exlib, g4tools
9.1.2. g4tools code is pure header
9.1.3. g4tools test
9.1.4. g4tools in Geant4
9.2. Analysis Manager Classes
9.2.1. Histograms
9.2.2. Analysis Messenger
9.2.3. Ntuples
9.2.4. Coexistence of Several Managers
9.2.5. Supported Features and Limitations
10. Examples
10.1. Introduction
10.2. Basic Examples
10.2.1. Basic Examples Summary
10.2.2. Basic Examples Macros
10.2.3. Example B1
10.2.4. Example B2
10.2.5. Example B3
10.2.6. Example B4
10.3. Novice Examples
10.3.1. Novice Example Summary
10.3.2. Example N01
10.3.3. Example N02
10.3.4. Example N03
10.3.5. Example N04
10.3.6. Example N05
10.3.7. Example N06
10.3.8. Example N07
10.4. Extended Examples
10.4.1. Extended Example Summary
10.5. Advanced Examples
FAQ. Frequentry Asked Questions
FAQ.1. Installation
FAQ.2. Run Time Problems
FAQ.3. Geometry
FAQ.4. Tracks and steps
FAQ.5. Physics and cuts
FAQ.6. Visualization
FAQ.7. User Support Policy
Appendix
1. Tips for Program Compilation
1.1. Unix/Linux - g++
1.2. Windows - MS Visual C++
1.3. Mac OS X - g++
2. Histogramming
2.1. JAS
2.2. iAida
2.3. Open Scientist Lab
2.4. rAIDA
2.5. Examples
3. CLHEP Foundation Library
4. C++ Standard Template Library
5. Geant4Config.cmake CMake Config File
5.1. Usage of Geant4Config.cmake
5.2. Building an Application against a Build of Geant4
6. GNUMake System: Makefiles and Environment Variables
6.1. Geant4Make System
6.2. Environment variables
6.3. Linking External Libraries with Geant4
7. Step-by-Step Installation Guides
7.1. Building on MS Visual C++
8. Development and Debug Tools
8.1. Unix/Linux
8.2. Windows
9. Python Interface
9.1. Installation
9.2. Using Geant4Py
9.3. Site-modules
9.4. Examples
10. Geant4 Material Database
10.1. Pure Materials
10.2. NIST Compounds
10.3. HEP Materials
Bibliography