Celeritas 0.7-develop+980877a
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
celeritas::GeantTrackReconstruction Class Reference

Manage track information for reconstruction. More...

#include <GeantTrackReconstruction.hh>

Public Types

Type aliases
using VecParticle = std::vector< G4ParticleDefinition const * >
 
using SPStep = std::shared_ptr< G4Step >
 
using EventIdGetter = int(*)()
 

Public Member Functions

 GeantTrackReconstruction (VecParticle const &, SPStep)
 Construct with particle definitions for track reconstruction.
 
 ~GeantTrackReconstruction ()
 Unset the user information for all tracks.
 
 GeantTrackReconstruction (GeantTrackReconstruction const &)=delete
 
GeantTrackReconstruction & operator= (GeantTrackReconstruction const &)=delete
 
 GeantTrackReconstruction (GeantTrackReconstruction &&)=default
 
GeantTrackReconstruction & operator= (GeantTrackReconstruction &&)=default
 
void clear ()
 Clear G4Track reconstruction data.
 
PrimaryId acquire (G4Track &)
 Register mapping from Celeritas PrimaryID to Geant4 TrackID.
 
void init_event ()
 At the start of an event, reset the primary ID counter.
 
G4Track & view (ParticleId particle, PrimaryId primary, TrackId track, TrackId parent, size_type generation) const
 Restore the Geant4 identity of any Celeritas track.
 
G4VProcess const & placeholder_process () const
 Creator process reported for tracks created by Celeritas.
 

Static Public Member Functions

static SPStep make_g4step ()
 Allocate and initialize a valid Geant4 step object.
 
static int geant_track_id (TrackId)
 Geant4 track ID of a track created by Celeritas.
 

Static Public Attributes

static EventIdGetter get_current_event_id {nullptr}
 Event ID function pointer for unit testing when CELERITAS_DEBUG.
 

Detailed Description

Manage track information for reconstruction.

This class handles the bookkeeping of Geant4 track information needed to reconstruct tracks during hit processing. It maintains mappings between Celeritas PrimaryID and Geant4 track data.

Usage
  • init_event
  • acquire (multiple times)
  • view (may be interleaved with acquire)
  • clear (once all active tracks are used up)
  • then it can be initialized with a new event, or new primaries can be added to the current event.
Track identity
A Celeritas primary (generation 0) is the Geant4 track that was offloaded: it is reconstructed with the Geant4 track ID, parent ID, creator process, and user information saved by acquire , whatever their values. A track created by Celeritas has its own Geant4 identity, which never refers to the information of its offloaded ancestor:
  • its track ID is geant_track_id of its Celeritas track ID,
  • its parent ID is the saved Geant4 ID of the offloaded track if it is in generation 1 (see SimTrackView::generation ), and otherwise the mapped ID of its Celeritas parent,
  • its creator process is an inert placeholder named "celeritas", and
  • it has no user information.

A track that Geant4 offloads again after Celeritas handed it back is a new primary: it keeps the Geant4 ID it had, and its secondaries refer to it.

Note
Tracks created by Celeritas are never seen by Geant4: no user tracking action is called for them and they have no trajectory. User code that looks up information by track ID (e.g., recorded in a user tracking action) will not find them or, beyond generation 1, their parents, and sensitive detectors must not assume that user track information is set.
User information
The user information of an offloaded track is owned by this class from acquire until clear .

Constructor & Destructor Documentation

◆ GeantTrackReconstruction()

celeritas::GeantTrackReconstruction::GeantTrackReconstruction ( VecParticle const &  particles,
SPStep  step 
)

Construct with particle definitions for track reconstruction.

This must be constructed on the thread that uses it. The placeholder creator process registers itself with that thread's Geant4 process table, which owns it and deletes it when Geant4 clears its thread-local state.

Member Function Documentation

◆ acquire()

PrimaryId celeritas::GeantTrackReconstruction::acquire ( G4Track &  primary)

Register mapping from Celeritas PrimaryID to Geant4 TrackID.

This will take ownership of the G4VUserTrackInformation and unset it in the primary track.

◆ clear()

void celeritas::GeantTrackReconstruction::clear ( )

Clear G4Track reconstruction data.

This should be done when all Celeritas tracks have been completed, since afterward it will be impossible to reconstruct them.

The primary ID offset is saved to ensure consistency when flushing before an event is complete.

◆ geant_track_id()

int celeritas::GeantTrackReconstruction::geant_track_id ( TrackId  track)
static

Geant4 track ID of a track created by Celeritas.

Celeritas track IDs are unique within an event and start at zero for each event. Like AdePT, they are mapped to Geant4 IDs counting down from the largest integer, so that they never collide with the IDs that Geant4 assigns in increasing order.

◆ init_event()

void celeritas::GeantTrackReconstruction::init_event ( )

At the start of an event, reset the primary ID counter.

Precondition
The track data must have been previously flushed with the clear command.

◆ make_g4step()

auto celeritas::GeantTrackReconstruction::make_g4step ( )
static

Allocate and initialize a valid Geant4 step object.

The allocation is done like G4SteppingManager constructor but we reset values to invalid ones.

◆ view()

G4Track & celeritas::GeantTrackReconstruction::view ( ParticleId  particle_id,
PrimaryId  primary_id,
TrackId  track_id,
TrackId  parent_id,
size_type  generation 
) const

Restore the Geant4 identity of any Celeritas track.

A primary (generation 0) is the offloaded Geant4 track and is restored with its saved information. A track created by Celeritas is given its own identity (see the class documentation).

Member Data Documentation

◆ get_current_event_id

GeantTrackReconstruction::EventIdGetter celeritas::GeantTrackReconstruction::get_current_event_id {nullptr}
static

Event ID function pointer for unit testing when CELERITAS_DEBUG.

When constructing a class instance, if the function pointer is null, it will be set to a function that gets the Geant4 event manager's active event.


The documentation for this class was generated from the following files: