![]() |
|
|||
File indexing completed on 2025-09-16 08:27:19
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 accel/TrackingManagerConstructor.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <functional> 0010 #include <G4ParticleDefinition.hh> 0011 #include <G4VPhysicsConstructor.hh> 0012 0013 #include "corecel/cont/Span.hh" 0014 0015 namespace celeritas 0016 { 0017 class LocalTransporter; 0018 class SharedParams; 0019 class TrackingManagerIntegration; 0020 0021 //---------------------------------------------------------------------------// 0022 /*! 0023 * Construct a Celeritas tracking manager that offloads EM tracks. 0024 * 0025 * This should be composed with your physics list after it is constructed, 0026 * before the simulation begins. By default this uses the \c 0027 * celeritas::TrackingManagerIntegration helper: 0028 * \code 0029 auto* physics_list = new FTFP_BERT; 0030 physics_list->RegisterPhysics(new TrackingManagerConstructor{ 0031 &TrackingManagerIntegration::Instance()}); 0032 \endcode 0033 * 0034 * but for manual integration it can be constructed with a function to get a 0035 * reference to the thread-local \c LocalTransporter from the Geant4 thread ID: 0036 * \code 0037 auto* physics_list = new FTFP_BERT; 0038 physics_list->RegisterPhysics(new TrackingManagerConstructor{ 0039 shared_params, [](int){ return &local_transporter; }); 0040 \endcode 0041 * 0042 * \note If Celeritas is globally disabled, it will not add the track manager. 0043 * If Celeritas is configured to "kill offload" mode (for testing maximum 0044 * theoretical performance) then the tracking manager will be added but will 0045 * not send the tracks to Celeritas: it will simply kill them. 0046 */ 0047 class TrackingManagerConstructor final : public G4VPhysicsConstructor 0048 { 0049 public: 0050 //!@{ 0051 //! \name Type aliases 0052 using LocalTransporterFromThread = std::function<LocalTransporter*(int)>; 0053 //!@} 0054 0055 public: 0056 // Get a list of supported particles 0057 static Span<G4ParticleDefinition* const> OffloadParticles(); 0058 0059 // Construct name and mode 0060 TrackingManagerConstructor(SharedParams const* shared, 0061 LocalTransporterFromThread get_local); 0062 0063 // Construct from tracking manager integration 0064 explicit TrackingManagerConstructor(TrackingManagerIntegration* tmi); 0065 0066 //! Null-op: particles are constructed elsewhere 0067 void ConstructParticle() override {} 0068 0069 // Build and attach tracking manager 0070 void ConstructProcess() override; 0071 0072 //// ACCESSORS //// 0073 0074 //! Get the shared params associated with this TM 0075 SharedParams const* shared_params() const { return shared_; } 0076 0077 // Get the local transporter associated with the current thread ID 0078 LocalTransporter* get_local_transporter() const; 0079 0080 private: 0081 SharedParams const* shared_{nullptr}; 0082 LocalTransporterFromThread get_local_{}; 0083 }; 0084 0085 //---------------------------------------------------------------------------// 0086 } // 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 |
![]() ![]() |