Hits
Table of Contents
What a hit represents
In Geant4, a hit is a record of what happened inside a specific sensitive volume during particle transport. It is not a physical volume or a particle. Instead, it is an object in memory that stores information about an interaction that your detector would be able to measure.
Each sensitive detector class defines its own hit type, usually by creating a class that inherits from G4VHit. This custom hit class decides which quantities to store. For example, a calorimeter hit might store the total energy deposited in one cell, while a tracking detector hit might store position, time, and track ID for a single crossing of a sensor.
A hit is typically created inside the ProcessHits() method of your sensitive detector. When Geant4 steps a particle through a sensitive logical volume, it calls ProcessHits() with the current G4Step. Your code examines the step, extracts the information you care about, fills a new hit object, and adds it to a hit collection.
Hits are grouped into hit collections, one collection per sensitive detector per event. During an event, you accumulate hits. At the end of the event, Geant4 stores all the hit collections in the event object, and your event or run actions can retrieve them for analysis. Hits are therefore the main bridge between the detailed Geant4 tracking and the higher level detector response that you want to analyze.
It is important to understand that hits are a modeling choice. You decide when to create a hit and how many hits to create. For example, you might create one hit per step, one hit per track crossing a volume, or one hit that sums all energy in a detector element during an event. The design of your hit class and your hit creation logic should reflect how your real detector behaves and how you plan to analyze the data.
A hit is an abstract measurement in your simulation. You control:
- When a hit is created.
- What data the hit stores.
- How multiple physical interactions are combined into one hit.
Energy
For many detectors, the most important quantity stored in a hit is energy deposition. In Geant4, the energy lost by a particle in a step is available through the G4Step object, for example with step->GetTotalEnergyDeposit(). Your hit class commonly has a data member such as G4double fEdep, and you fill or accumulate this value when you process each relevant step.
You can choose between two common patterns. In a sampling or tracking detector, you might create a separate hit for each step or each crossing, with fEdep equal to the step energy deposit. In a calorimeter cell, you often create or find one hit per cell and per event, then add the step energy to the existing hit, so that at the end of the event the hit holds the total energy deposited in that cell.
Energy should normally be stored using Geant4 units, for example in MeV, by including the appropriate headers and writing values as value * MeV. Keeping all internal values in a consistent unit system avoids confusion and mistakes later during analysis and when printing results.
Always:
- Use
GetTotalEnergyDeposit()to obtain step energy for hits. - Store energy with explicit Geant4 units (for example
MeV). - Decide clearly whether one hit represents one step or a sum over many steps.
Time
Time information in hits allows you to simulate detector timing, coincidences, and time of flight. Geant4 provides several time variables for each step. The most commonly used is the global time, which you can access from the pre step point. A typical call is step->GetPreStepPoint()->GetGlobalTime(). This gives the time since the beginning of the event when the particle reached that point.
Your hit class can have a member such as G4double fTime. How you set this value depends on how your detector behaves. For a time resolving detector, you may set fTime to the arrival time of the first energy deposit above some threshold. For detectors that integrate over an event, you may not need time at all, or you might store an average or weighted time.
You should also be aware that Geant4 can provide local times and proper times, but for basic detector hits the global time is usually the correct choice. As with energy, store time in Geant4 units, for example ns or ps, to keep consistency throughout your code and analysis.
Hit timing should be:
- Taken from the appropriate step time, usually the global time.
- Stored in consistent Geant4 time units (for example
ns). - Defined according to the detector concept, such as first hit time or energy weighted time.
Position
Position information makes hits useful for reconstructing where in the detector an interaction occurred. In Geant4, you can obtain positions from the step points, for example with step->GetPreStepPoint()->GetPosition() or GetPostStepPoint()->GetPosition(). These positions are given in global coordinates by default.
Your hit class typically stores position as a G4ThreeVector, for example G4ThreeVector fPos. Again, the meaning you give to this position depends on your detector model. In a pixel or strip detector, you might store the exact global position of the energy deposit. In a calorimeter, you might store the center of the cell and let that represent the whole cell, even if the step occurred somewhere inside it.
Sometimes you also need local coordinates, for example when you want the hit position relative to a specific detector element. In that case, you can use the touchable history attached to the step points to transform from global to local coordinates. For a beginner course, it is usually sufficient to start by using global coordinates and only introduce local transformations when needed.
As with other quantities, always attach explicit length units when setting or printing positions. Internally, Geant4 uses millimeters as the base unit, but you can work with mm, cm, or m as long as you are consistent.
When storing hit positions:
- Decide whether the position represents the exact step point or a detector element center.
- Know whether you are using global or local coordinates.
- Keep all positions in consistent Geant4 units (for example
mm).
Views: 6
KAHIBARO