KAHIBARO
Discord Login Register

Recording Detector Hits

Understanding Detector Hits in a PET Simulation

In a PET scanner simulation, the main observable is not the detailed particle tracks but the signals produced in each detector crystal. In Geant4 this response is represented by hits. For PET, you use hits to record which crystal fired, how much energy it received, and at what time. Later chapters use these hits to build coincidences and lines of response, so here the focus is on how to define, create, and store them.

Designing a PET Hit

A hit should represent the response of a single detector element for one event. For a PET detector crystal, this usually includes at least the deposited energy and a time stamp. You also need to know which detector fired, so you can later pair hits in opposite crystals.

A typical PET hit class derives from G4VHit and stores, for example, the following information.

Energy deposited in the crystal, often in units of keV or MeV. In PET you usually sum all energy deposits in a given crystal during one event. The total deposited energy $E_{\text{dep}}$ is the sum of all step deposits in that crystal:
$$
E_{\text{dep}} = \sum_{i} \Delta E_i
$$

Detector identity. You need an integer that uniquely identifies each crystal. This can be a single ID or a combination that describes the detector ring, module, and crystal index. In later steps you will use this ID to group hits by detector element and to map them to physical positions.

Timing information. PET relies on coincidence timing between two detector hits. You usually store the time of the interaction taken from the global time of the step. You may choose to store the earliest time, the energy weighted time, or simply overwrite with the last time depending on your timing model.

Optional position information. In some simulations you also store the hit position, for example the energy weighted average interaction point inside the crystal. For basic PET energy windowing and coincidence building this is not strictly required, because you know the detector position from its ID and geometry, but it can be useful for studies of depth of interaction or position resolution.

Once you decide what your hit should contain, you implement the corresponding data members and access methods in your G4VHit derived class and provide an allocator, as in any Geant4 hit implementation.

A PET hit should represent one detector element in one event, and must store at least detector ID, total deposited energy, and a time stamp.

Connecting Hits to the PET Geometry

In PET, you typically have many identical detector crystals arranged in a ring. Hits must tell you which crystal was involved. You achieve this by combining two ingredients: a sensitive detector class and a way to obtain a unique ID for each crystal.

The sensitive detector is attached to the logical volume that represents a single detector crystal. This means that every step occurring in any crystal volume will be processed by the same sensitive detector code. Inside this code you must distinguish one crystal from another.

You can identify a crystal in several ways. A common approach is to use the copy number of the physical volume. Each placement of the crystal logical volume in the PET ring is given a unique copy number when you build the geometry, using G4PVPlacement, replicas, or parameterized volumes. In the sensitive detector, you can retrieve this copy number from the touchable history.

If your PET ring uses a hierarchical structure, for example rings, modules, and crystals, you can build a compound ID from several copy numbers. For instance, you might extract ring index, module index, and crystal index from different levels in the touchable and then combine them into a single integer or store them separately in the hit. This makes it simple later to reconstruct the exact position of each detected gamma in the scanner.

Every PET detector crystal must have a unique and reproducible ID, often taken from the copy number of the physical volume, so that recorded hits can be mapped back to specific crystals.

Implementing the PET Sensitive Detector

The core of recording hits is the implementation of a G4VSensitiveDetector derived class, for example PetDetectorSD. This class converts energy deposition steps inside PET crystals into hits and hit collections.

In the constructor of your sensitive detector class, you declare the name of the hits collection that this detector will produce. In Initialize(const G4Event*) you create a new hit collection for each event and obtain its collection ID from the G4SDManager. You then store this collection pointer so that ProcessHits can add hits to it during the event.

The main work is done in ProcessHits(G4Step step, G4TouchableHistory). This method is called by Geant4 for each step inside a volume that has this sensitive detector assigned. In a PET crystal, you generally proceed as follows.

You first get the energy deposited in this step using step->GetTotalEnergyDeposit(). If this is zero you can usually ignore the step, because it did not contribute to the detectable energy. For nonzero energy deposits, you then obtain the global time of the step from the pre step point using step->GetPreStepPoint()->GetGlobalTime(). This gives the physical time since the start of the event when the interaction took place.

Next, you determine which detector crystal is involved. From the pre step point you get the G4TouchableHandle and then retrieve the copy number of the crystal volume. This copy number is used as the detector ID for the hit.

You now have the key pieces of information: energy deposited, time, and detector ID. You must decide how to handle multiple steps in the same crystal. In PET, you usually want one hit per crystal per event with the total energy in that crystal. To achieve this, you search the current hit collection for an existing hit with the same detector ID. If one exists, you update it by adding the new energy deposit and possibly updating the time according to your model. If no hit exists, you create a new hit object, set its detector ID, energy, and time, and insert it in the collection.

This accumulation turns many microscopic energy deposition steps into a single macroscopic detector signal that better represents what a real PET detector would measure.

In PET, always accumulate all step energy deposits for the same crystal into a single hit per event, instead of creating one hit per step.

Storing and Accessing PET Hit Collections

At the end of each event, you want the set of detector hits to be available for analysis steps such as energy windowing and coincidence finding. Geant4 handles storage and retrieval of hits through hit collections attached to the event.

When the event begins, your sensitive detector creates a new hit collection object and registers it with the event through the hit collection of event. As ProcessHits is called, each new or updated PetHit is stored in this collection. From your EventAction you can then access the hits at the end of the event.

In EndOfEventAction(const G4Event* event) you retrieve the G4HCofThisEvent pointer and then get the specific PET hit collection using the collection ID you obtained earlier from the G4SDManager. Once you have the collection, you can iterate over all hits, read the energy, time, and detector ID from each, and pass them to your analysis code or to later PET specific logic such as energy windows and coincidences.

You should check that the hit collection exists before using it. If no hits were produced in the event, the pointer can be null. You also need to be aware of units. Stored energy is in internal Geant4 units, for example MeV. When you export data or compare with physical expectations, you often convert to keV or MeV explicitly.

The hits from the PET detector volumes should be kept separate from any other sensitive detectors in the same simulation, such as trigger counters or calibration devices. Using clear collection names and consistent indexing makes it easier to manage complex simulations and to connect each hit to the correct detector component.

At the end of each event, always retrieve the correct hit collection by its collection ID, check for null pointers, and convert values to explicit units before analysis or output.

By defining a clear hit structure, assigning a sensitive detector to each crystal, and carefully accumulating and storing hits, you create the bridge between microscopic particle transport and the macroscopic detector signals that PET data analysis uses. Subsequent steps in the PET example, such as applying an energy window and finding coincidence events, operate entirely on these recorded detector hits.

Views: 9

Comments

Please login to add a comment.

Don't have an account? Register now!