File indexing completed on 2025-01-18 09:11:44
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/DD4hepDetector/DDG4DetectorConstruction.hpp"
0010
0011 #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp"
0012 #include "ActsExamples/Geant4/RegionCreator.hpp"
0013
0014 #include <DD4hep/DetElement.h>
0015 #include <DD4hep/Detector.h>
0016 #include <DDG4/Geant4Converter.h>
0017 #include <DDG4/Geant4GeometryInfo.h>
0018 #include <DDG4/Geant4Mapping.h>
0019
0020 class G4VPhysicalVolume;
0021
0022 namespace ActsExamples {
0023
0024 DDG4DetectorConstruction::DDG4DetectorConstruction(
0025 std::shared_ptr<dd4hep::Detector> detector,
0026 const Geant4ConstructionOptions& options)
0027 : m_detector(std::move(detector)), m_options(options) {}
0028
0029
0030 G4VPhysicalVolume* DDG4DetectorConstruction::Construct() {
0031 if (m_world == nullptr) {
0032 dd4hep::sim::Geant4Mapping g4map(*m_detector);
0033 dd4hep::sim::Geant4Converter g4conv(*m_detector,
0034 dd4hep::PrintLevel::VERBOSE);
0035 dd4hep::sim::Geant4GeometryInfo* geoInfo =
0036 g4conv.create(m_detector->world()).detach();
0037 g4map.attach(geoInfo);
0038
0039 m_world = geoInfo->world();
0040
0041 g4map.volumeManager();
0042
0043
0044 for (const auto& regionCreator : m_options.regionCreators) {
0045 regionCreator->buildRegion();
0046 }
0047 }
0048
0049 return m_world;
0050 }
0051
0052 }