Overview Contents Previous Next Geant4 User's Guide
For Application Developers
Tracking and Physics


5.1 Tracking


5.1.1 Basic Concepts

Philosophy of Tracking

All Geant4 processes, including the transportation of particles, are treated generically. In spite of the name "tracking", particles are not transported in the tracking category. G4TrackingManager is an interface class which brokers transactions between the event, track and tracking categories. An instance of this class handles the message passing between the upper hierarchical object, which is the event manager, and lower hierarchical objects in the tracking category. The event manager is a singleton instance of the G4EventManager class.

The tracking manager receives a track from the event manager and takes the actions required to finish tracking it. G4TrackingManager aggregates the pointers to G4SteppingManager, G4Trajectory and G4UserTrackingAction. Also there is a "use" relation to G4Track and G4Step.

G4SteppingManager plays an essential role in tracking the particle. It takes care of all message passing between objects in the different categories relevant to transporting a particle (for example, geometry and interactions in matter). Its public method Stepping() steers the stepping of the particle. The algorithm to handle one step is given below.

  1. The particle's velocity at the beginning of the step is calculated.
  2. Each active discrete or continuous process must propose a step length based on the interaction it describes. The smallest of these step lengths is taken.
  3. The geometry navigator calculates "Safety", the distance to the next volume boundary. If the minimum physical-step-length from the processes is shorter than "Safety", the physical-step-length is selected as the next step length. In this case, no further geometrical calculations will be performed.
  4. If the minimum physical-step-length from the processes is longer than "Safety", the distance to the next boundary is re-calculated.
  5. The smaller of the minimum physical-step-length and the geometric step length is taken.
  6. All active continuous processes are invoked. Note that the particle's kinetic energy will be updated only after all invoked processes have completed. The change in kinetic energy will be the sum of the contributions from these processes.
  7. The track is checked to see whether or not it has been terminated by a continuous process.
  8. The current track properties are updated before discrete processes are invoked. This includes:
  9. The discrete process is invoked. After the invocation,
  10. The track is checked to see whether or not it has been terminated by the discrete process.
  11. "Safety" is updated.
  12. If the step was limited by the volume boundary, push the particle into the next volume.
  13. Invoke the user intervention G4UserSteppingAction.
  14. Handle hit information.
  15. Save data to Trajectory.
  16. Update the mean free paths of the discrete processes.
  17. If the parent particle is still alive, reset the maximum interaction length of the discrete process which has occurred.
  18. One step completed.

What is a Step?

G4Step stores the transient information of a step. This includes the two endpoints of the step, PreStepPoint and PostStepPoint, which contain the points' coordinates and the volumes containing the points. G4Step also stores the change in track properties between the two points. These properties, such as energy and momentum, are updated as the various active processes are invoked.

What is a Track?

G4Track keeps information on the final status of the particle after the completion of one step. This means that G4Track has information on the previous step while the AlongStepDoIts are being invoked for the step in progress. Only after finishing all AlongStepDoIts, will G4Track have the final information (e.g., the final position) for the step in progress. Also, G4Track will be updated after each invocation of a PostStepDoIt.


5.1.2 Access to Track and Step Information

How to Get Track Information

Track information may be accessed by invoking various Get methods provided in the G4Track class. For details, see the Software Reference Manual. Typical information available includes:

How to Get Step Information

Step and step-point information can be retrieved by invoking various Get methods provided in the G4Step/G4StepPoint classes. For details, see the Software Reference Manual. Information in G4Step includes:

Information in G4StepPoint (PreStepPoint and PostStepPoint) includes:

How to Get "particle change"

Particle change information can be accessed by invoking various Get methods provided in the G4ParticleChange class. Typical information available includes (for details, see the Software Reference Manual):


5.1.3 Handling of Secondary Particles

Secondary particles are passed as G4Tracks from a physics process to tracking. G4ParticleChange provides the following four methods for a physics process: In all but the first, the construction of G4Track is done in the methods using informaton given by the arguments.


5.1.4 User Actions

There are two classes which allow the user to intervene in the tracking. These are: Each provides methods which allow the user access to the Geant4 kernel at specific points in the tracking. For details, see the Software Reference Manual.

5.1.5 Verbose Outputs

The verbose information output flag can be turned on or off. The amount of information printed about the track/step, from brief to very detailed, can be controlled by the value of the verbose flag, for example,

G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/tracking/verbose 1");


5.1.6 Trajectory and Trajectory Point

G4Trajectory and G4TrajectoryPoint

G4Trajectory and G4TrajectoryPoint are default concrete classes provided by Geant4, which are derived from the G4VTrajectory and G4VTrajectoryPoint base classes, respectively. A G4Trajectory class object is created by G4TrackingManager when a G4Track is passed from the G4EventManager. G4Trajectory has the following data members:

G4TrajectoryPoint corresponds to a step point along the path followed by the track. Its position is given by a G4ThreeVector. A G4TrajectoryPoint class object is created in the AppendStep() method of G4Trajectory and this method is invoked by G4TrackingManager at the end of each step. The first point is created when the G4Trajectory is created, thus the first point is the original vertex.

The creation of a trajectory can be controlled by invoking G4TrackingManager::SetStoreTrajectory(G4bool). The UI command /tracking/storeTrajectory _bool_ does the same. The user can set this flag for each individual track from his/her G4UserTrackingAction::PreUserTrackingAction() method.

The user should not create trajectories for secondaries in a shower due to the large amount of memory consumed.
All the created trajectories in an event are stored in G4TrajectoryContainer class object and this object will be kept by G4Event. To draw or print trajectories generated in an event, the user may invoke the DrawTrajectory() or ShowTrajectory() methods of G4VTrajectory, respectively, from his/her G4UserEventAction::EndOfEventAction(). The geometry must be drawn before the trajectory drawing. The color of the drawn trajectory depends on the particle charge:
Due to improvements in G4Navigator, a track can execute more than one turn of its spiral trajectory without being broken into smaller steps as long as the trajectory does not cross a geometrical boundary. Thus a drawn trajectory may not be circular.

Customizing trajectory and trajectory point

G4Track and G4Step are transient classes; they are not available at the end of the event. Thus, the concrete classes G4VTrajectory and G4VTrajectoryPoint are the only ones a user may employ for end-of-event analysis or for persistency. As mentioned above, the default classes which Geant4 provides, i.e. G4Trajectory and G4TrajectoryPoint, have only very primitive quantities. The user can customize his/her own trajectory and trajectory point classes by deriving directly from the respective base classes.

To use the customized trajectory, the user must construct a concrete trajectory class object in the G4UserTrackingAction::PreUserTrackingAction() method and make its pointer available to G4TrackingManager by using the SetTrajectory() method. The customized trajectory point class object must be constructed in the AppendStep() method of the user's implementation of the trajectory class. This AppendStep() method will be invoked by G4TrackingManager.

To customize trajectory drawing, the user can override the DrawTrajectory() method in his/her own trajectory class.

When a customized version of G4Trajectory declares any new class variables, operator new and operator delete must be provided. It is also useful to check that the allocation size in operator new is equal to sizeof(G4Trajectory). These two points do not apply to G4VTrajectory because it has no operator new or operator delete.


About the authors