![]() |
|
|||
File indexing completed on 2025-02-22 10:31:21
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file celeritas/ext/GeantSetup.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <memory> 0011 #include <string> 0012 0013 #include "corecel/Config.hh" 0014 0015 #include "corecel/Assert.hh" 0016 0017 #include "GeantPhysicsOptions.hh" 0018 0019 // Geant4 forward declarations 0020 class G4VPhysicalVolume; 0021 class G4RunManager; 0022 0023 namespace celeritas 0024 { 0025 0026 //---------------------------------------------------------------------------// 0027 /*! 0028 * Construct a Geant 4 run manager and populate internal Geant4 physics. 0029 * 0030 * This is usually passed directly into \c GeantImporter . It hides Geant4 0031 * implementation details (including header files) from the rest of the code. 0032 * It is safe to include even when Geant4 is unavailable! 0033 * 0034 * The setup is targeted specifically for physics that Celeritas supports. 0035 */ 0036 class GeantSetup 0037 { 0038 public: 0039 //!@{ 0040 //! \name Type aliases 0041 using Options = GeantPhysicsOptions; 0042 //!@} 0043 0044 public: 0045 // Construct from a GDML file and physics options 0046 GeantSetup(std::string const& gdml_filename, Options options); 0047 0048 // Default constructor 0049 GeantSetup() = default; 0050 0051 // Terminate run on destruction 0052 ~GeantSetup(); 0053 0054 //! Prevent copying but allow moving 0055 CELER_DEFAULT_MOVE_DELETE_COPY(GeantSetup); 0056 0057 // Get the world detector volume 0058 inline G4VPhysicalVolume const* world() const; 0059 0060 //! True if we own a run manager 0061 explicit operator bool() const { return static_cast<bool>(run_manager_); } 0062 0063 private: 0064 struct RMDeleter 0065 { 0066 void operator()(G4RunManager*) const; 0067 }; 0068 using RMUniquePtr = std::unique_ptr<G4RunManager, RMDeleter>; 0069 0070 RMUniquePtr run_manager_{nullptr}; 0071 G4VPhysicalVolume* world_{nullptr}; 0072 }; 0073 0074 //---------------------------------------------------------------------------// 0075 // FREE FUNCTIONS 0076 0077 //---------------------------------------------------------------------------// 0078 // INLINE DEFINITIONS 0079 //---------------------------------------------------------------------------// 0080 /*! 0081 * Get the world detector volume. 0082 */ 0083 G4VPhysicalVolume const* GeantSetup::world() const 0084 { 0085 CELER_EXPECT(*this); 0086 return world_; 0087 } 0088 0089 #if !CELERITAS_USE_GEANT4 0090 inline GeantSetup::GeantSetup(std::string const&, Options) 0091 { 0092 CELER_NOT_CONFIGURED("Geant4"); 0093 } 0094 0095 inline GeantSetup::~GeantSetup() = default; 0096 0097 inline void GeantSetup::RMDeleter::operator()(G4RunManager*) const 0098 { 0099 CELER_ASSERT_UNREACHABLE(); 0100 } 0101 #endif 0102 0103 //---------------------------------------------------------------------------// 0104 } // 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 |
![]() ![]() |