File indexing completed on 2025-01-18 09:11:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "ActsExamples/GeoModelDetector/GeoModelGeant4DetectorConstruction.hpp"
0010
0011 #include "ActsExamples/Geant4/Geant4ConstructionOptions.hpp"
0012 #include "ActsExamples/Geant4/RegionCreator.hpp"
0013
0014 #include <G4LogicalVolume.hh>
0015 #include <G4PVPlacement.hh>
0016 #include <G4ThreeVector.hh>
0017 #include <G4VPhysicalVolume.hh>
0018 #include <GeoModel2G4/ExtParameterisedVolumeBuilder.h>
0019 #include <GeoModelKernel/GeoFullPhysVol.h>
0020
0021 namespace ActsExamples {
0022
0023 GeoModelGeant4DetectorConstruction::GeoModelGeant4DetectorConstruction(
0024 const Acts::GeoModelTree& geoModelTree,
0025 const Geant4ConstructionOptions& options)
0026 : G4VUserDetectorConstruction(),
0027 m_geoModelTree(geoModelTree),
0028 m_options(options) {
0029 if (geoModelTree.worldVolume == nullptr) {
0030 throw std::invalid_argument(
0031 "GeoModelGeant4DetectorConstruction: "
0032 "GeoModel world volume is nullptr");
0033 }
0034 }
0035
0036 G4VPhysicalVolume* GeoModelGeant4DetectorConstruction::Construct() {
0037 if (m_g4World == nullptr) {
0038 ExtParameterisedVolumeBuilder builder(m_geoModelTree.worldVolumeName);
0039 G4LogicalVolume* g4WorldLog = builder.Build(m_geoModelTree.worldVolume);
0040 m_g4World =
0041 new G4PVPlacement(nullptr, G4ThreeVector(), g4WorldLog,
0042 m_geoModelTree.worldVolumeName, nullptr, false, 0);
0043
0044
0045 for (const auto& regionCreator : m_options.regionCreators) {
0046 regionCreator->buildRegion();
0047 }
0048 }
0049 return m_g4World;
0050 }
0051
0052 }