Contents Previous Next Geant4 User's Guide
For Application Developers
Getting Started with Geant4

2.4 How to Specify Particles



G4VuserPhysicsList is one of the mandatory user base classes described in Section 2.1 . Within this class all particles and physics processes to be used in your simulation must be defined. The range cut-off parameter should also be defined in this class.

The user must create a class derived from G4VuserPhysicsList and implement the following pure virtual methods:
ConstructParticle(): construction of particles
ConstructProcess(): construct processes and register them to particles
SetCuts(): setting a range cut value for all particles

This section provides some simple examples of the ConstructParticle() and SetCuts() methods. For infomation on ConstructProcess() methods, please see Section 2.5.


2.4.1 Particle Definition

Geant4 provides various types of particles for use in simulations:

Each particle is represented by its own class, which is derived from G4ParticleDefinition. Particles are organized into six major categories:

each of which is defined in a corresponding sub-directory under geant4/source/particles. There is also a corresponding granular library for each particle category.

2.4.1.1 The G4ParticleDefinition Class

G4ParticleDefinition has properties which characterize individual particles, such as, name, mass, charge, spin, and so on. Most of these properties are "read-only" and can not be changed by users without rebuilding the libraries.

2.4.1.2 How to Access a Particle

Each particle class type represents an individual particle type, and each class has a single static object. There are some exceptions to this rule; please see Section 5.3 for details.

For example, the class G4Electron represents the electron and its only object is G4Electron::theElectron. The object is therefore referred to as a "singleton" of the G4Electron class. The pointer to this object is available through the static method G4Electron::ElectronDefinition().

More than 100 types of particles are provided by default, to be used in various physics processes. In normal applications, users will not need to define their own particles.

Because particles are static objects of individual particle classes, these objects are instantiated automatically before the main() routine is executed. However, you must explicitly declare the particle classes required by your program, otherwise the compiler can not recognize which classes you need, and no particles will be instantiated.

2.4.1.3 Dictionary of Particles

The G4ParticleTable class is provided as a dictionary of particles. Various utility methods are provided, such as:
FindParticle(G4String name): find the particle by name
FindParticle(G4int PDGencoding): find the particle by PDG encoding .

G4ParticleTable is also defined as a singleton object, and the static method G4ParticleTable::GetParticleTable() provides its pointer.

Particles are registered automatically during construction. The user has no control over particle registration.

2.4.1.4 Constructing Particles

ConstructParticle() is a pure virtual method, in which the static member functions for all the particles you require should be called. This ensures that objects of these particles will be created.

WARNING: You must define "All PARTICLE TYPES" which are used in your application, except for heavy ions. "All PARTICLE TYPES" means not only primary particles, but also all other particles which may appear as secondaries generated by physics processes you use. Beginning with Geant4 version 8.0, you should keep this rule strictly because all particle definitions are revised to "non-static" objects.

For example, suppose you need a proton and a geantino, which is a virtual particle used for simulation and which does not interact with materials. The ConstructParticle() method is implemented as below:

 void ExN01PhysicsList::ConstructParticle()
 {
   G4Proton::ProtonDefinition();
   G4Geantino::GeantinoDefinition();
 }
Source listing 2.4.1
Construct a proton and a geantino.

Due to the large number of pre-defined particles in Geant4, it is cumbersome to list all the particles by this method. If you want all the particles in a Geant4 particle category, there are six utility classes, corresponding to each of the particle categories, which perform this function:

An example of this is shown in ExN05PhysicsList, listed below.

void ExN05PhysicsList::ConstructLeptons()
{
  // Construct all leptons
  G4LeptonConstructor pConstructor;
  pConstructor.ConstructParticle();
}
Source listing 2.4.2
Construct all leptons.


2.4.2 Range Cuts

To avoid infrared divergence, some electromagnetic processes require a threshold below which no secondary will be generated. Because of this requirement, gammas, electrons and positrons require production thresholds which the user should define. This threshold should be defined as a distance, or range cut-off, which is internally converted to an energy for individual materials. The range threshold should be defined in the initialization phase using the SetCuts() method of G4VUserPhysicsList. Section 5.4 discusses threshold and tracking cuts in detail.

2.4.2.1 Setting the cuts

Production threshold values should be defined in SetCuts() which is a pure virtual method of the G4VUserPhysicsList class. Construction of particles, materials, and processes should precede the invocation of SetCuts(). G4RunManager takes care of this sequence in usual applications.

The idea of a "unique cut value in range" is one of the important features of Geant4 and is used to handle cut values in a coherent manner. For most applications, users need to determine only one cut value in range, and apply this value to gammas, electrons and positrons alike.

In such a case, the SetCutsWithDefault() method may be used. It is provided by the G4VuserPhysicsList base class, which has a defaultCutValue member as the default range cut-off value. SetCutsWithDefault() uses this value.

It is possible to set different range cut values for gammas, electrons and positrons, and also to set different range cut values for each geometrical region. In such cases however, one must be careful with physics outputs because Geant4 processes (especially energy loss) are designed to conform to the "unique cut value in range" scheme.

void ExN04PhysicsList::SetCuts()
{
  //   the G4VUserPhysicsList::SetCutsWithDefault() method sets 
  //   the default cut value for all particle types 
  SetCutsWithDefault();   
}
Source listing 2.4.3
Set cut values by using the default cut value.

The defaultCutValue is set to 1.0 mm by default. Of course, you can set the new default cut value in the constructor of your physics list class as shown below.

ExN04PhysicsList::ExN04PhysicsList():  G4VUserPhysicsList()
{
  // default cut value  (1.0mm) 
  defaultCutValue = 1.0*mm;
}
Source listing 2.4.4
Set the default cut value.

The SetDefaultCutValue() method in G4VUserPhysicsList may also be used, and the "/run/setCut" command may be used to change the default cut value interactively.

WARNING: DO NOT change cut values inside the event loop. Cut values may however be changed between runs.

An example implementation of SetCuts() is shown below:

void ExN03PhysicsList::SetCuts()
{
  // set cut values for gamma at first and for e- second and next for e+,
  // because some processes for e+/e- need cut values for gamma 
  SetCutValue(cutForGamma, "gamma");
  SetCutValue(cutForElectron, "e-");
  SetCutValue(cutForElectron, "e+");
}
Source listing 2.4.5
Example implementation of the SetCuts() method.

Beginning with Geant4 version 5.1, it is now possible to set production thresholds for each geometrical region. This new functionality is described in Section 5.5.


About the authors