|
|
|||
File indexing completed on 2026-01-09 10:07:58
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file celeritas/ext/detail/TrackProcessor.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <memory> 0010 #include <vector> 0011 0012 #include "corecel/Macros.hh" 0013 #include "celeritas/Types.hh" 0014 0015 class G4ParticleDefinition; 0016 class G4Step; 0017 class G4Track; 0018 class G4VProcess; 0019 class G4VUserTrackInformation; 0020 0021 namespace celeritas 0022 { 0023 namespace detail 0024 { 0025 //---------------------------------------------------------------------------// 0026 /*! 0027 * Manage track information for reconstruction. 0028 * 0029 * This class handles the bookkeeping of Geant4 track information needed 0030 * to reconstruct tracks during hit processing. It maintains mappings between 0031 * Celeritas PrimaryID and Geant4 track data. 0032 * 0033 */ 0034 class TrackProcessor 0035 { 0036 public: 0037 //!@{ 0038 //! \name Type aliases 0039 using VecParticle = std::vector<G4ParticleDefinition const*>; 0040 //!@} 0041 0042 public: 0043 // Construct with particle definitions for track reconstruction 0044 explicit TrackProcessor(VecParticle const&); 0045 0046 ~TrackProcessor(); 0047 CELER_DEFAULT_MOVE_DELETE_COPY(TrackProcessor); 0048 0049 // Clear G4Track reconstruction data 0050 void end_event(); 0051 0052 // Register mapping from Celeritas PrimaryID to Geant4 TrackID 0053 [[nodiscard]] PrimaryId register_primary(G4Track&); 0054 0055 // Restore track information for given primary and particle IDs 0056 G4Track& restore_track(ParticleId, PrimaryId) const; 0057 0058 // Get the owned step 0059 G4Step& step() { return *step_; } 0060 0061 private: 0062 //! Data needed to reconstruct a G4Track from Celeritas transport 0063 class GeantTrackReconstructionData 0064 { 0065 public: 0066 //! Save the G4Track reconstruction data 0067 explicit GeantTrackReconstructionData(G4Track&); 0068 //! Whether the data is valid 0069 explicit operator bool() const { return track_id_ >= 0; } 0070 //! Restore the G4Track from the reconstruction data 0071 void restore_track(G4Track&) const; 0072 0073 private: 0074 //! Original Geant4 track ID 0075 int track_id_{-1}; 0076 //! Original Geant4 parent ID 0077 int parent_id_{0}; 0078 //! User track information 0079 std::unique_ptr<G4VUserTrackInformation> user_info_; 0080 //! Process that created the track 0081 G4VProcess const* creator_process_{nullptr}; 0082 }; 0083 0084 //! G4Track reconstruction data indexed by Celeritas PrimaryID 0085 std::vector<GeantTrackReconstructionData> g4_track_data_; 0086 //! Tracks for each particle type 0087 std::vector<std::unique_ptr<G4Track>> tracks_; 0088 //! Owned step object 0089 std::unique_ptr<G4Step> step_; 0090 }; 0091 0092 //---------------------------------------------------------------------------// 0093 } // namespace detail 0094 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|