File indexing completed on 2025-08-05 08:09:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/Geant4/GdmlDetectorConstruction.hpp"
0010
0011 #include <utility>
0012
0013 #include <G4GDMLParser.hh>
0014
0015 class G4VPhysicalVolume;
0016
0017 using namespace ActsExamples;
0018
0019 GdmlDetectorConstruction::GdmlDetectorConstruction(
0020 std::string path,
0021 std::vector<std::shared_ptr<RegionCreator>> regionCreators)
0022 : G4VUserDetectorConstruction(),
0023 m_path(std::move(path)),
0024 m_regionCreators(std::move(regionCreators)) {}
0025
0026 G4VPhysicalVolume* GdmlDetectorConstruction::Construct() {
0027 if (m_world == nullptr) {
0028 G4GDMLParser parser;
0029
0030 parser.Read(m_path);
0031 m_world = parser.GetWorldVolume();
0032
0033
0034 for (const auto& regionCreator : m_regionCreators) {
0035 regionCreator->Construct();
0036 }
0037 }
0038 return m_world;
0039 }
0040
0041 GdmlDetectorConstructionFactory::GdmlDetectorConstructionFactory(
0042 std::string path,
0043 std::vector<std::shared_ptr<RegionCreator>> regionCreators)
0044 : m_path(std::move(path)), m_regionCreators(std::move(regionCreators)) {}
0045
0046 std::unique_ptr<G4VUserDetectorConstruction>
0047 GdmlDetectorConstructionFactory::factorize() const {
0048 return std::make_unique<GdmlDetectorConstruction>(m_path, m_regionCreators);
0049 }