File indexing completed on 2025-12-11 09:40:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/Surface.hpp"
0013 #include "ActsPlugins/Geant4/Geant4DetectorElement.hpp"
0014 #include "ActsPlugins/Geant4/Geant4PhysicalVolumeSelectors.hpp"
0015
0016 #include <cstddef>
0017 #include <memory>
0018 #include <tuple>
0019 #include <vector>
0020
0021 namespace HepGeom {
0022 class Transform3D;
0023 }
0024
0025 class G4VPhysicalVolume;
0026 using G4Transform3D = HepGeom::Transform3D;
0027
0028 namespace ActsPlugins {
0029
0030 class Geant4DetectorElement;
0031 class IGeant4PhysicalVolumeSelector;
0032
0033
0034
0035
0036 class Geant4DetectorSurfaceFactory {
0037 public:
0038
0039 using ElementFactory = std::function<std::shared_ptr<Geant4DetectorElement>(
0040 std::shared_ptr<Acts::Surface>, const G4VPhysicalVolume&,
0041 const Acts::Transform3&, double)>;
0042
0043
0044
0045 struct Config {
0046
0047
0048 ElementFactory detectorElementFactory =
0049 [](std::shared_ptr<Acts::Surface> surface,
0050 const G4VPhysicalVolume& g4physVol, const Acts::Transform3& toGlobal,
0051 double thickness) {
0052 return std::make_shared<Geant4DetectorElement>(
0053 std::move(surface), g4physVol, toGlobal, thickness);
0054 };
0055
0056 };
0057
0058
0059 using Geant4SensitiveSurface =
0060 std::tuple<std::shared_ptr<Geant4DetectorElement>,
0061 std::shared_ptr<Acts::Surface>>;
0062
0063 using Geant4PassiveSurface = std::shared_ptr<Acts::Surface>;
0064
0065
0066
0067 struct Cache {
0068
0069 std::vector<Geant4SensitiveSurface> sensitiveSurfaces;
0070
0071 std::vector<Geant4PassiveSurface> passiveSurfaces;
0072
0073 std::size_t matchedG4Volumes = 0;
0074
0075 std::size_t convertedSurfaces = 0;
0076
0077 std::size_t convertedMaterials = 0;
0078 };
0079
0080
0081 struct Options {
0082
0083 double scaleConversion = 1.;
0084
0085 bool convertMaterial = false;
0086
0087 double convertedMaterialThickness = -1;
0088
0089 std::shared_ptr<IGeant4PhysicalVolumeSelector> sensitiveSurfaceSelector =
0090 nullptr;
0091
0092 std::shared_ptr<IGeant4PhysicalVolumeSelector> passiveSurfaceSelector =
0093 nullptr;
0094 };
0095
0096
0097 Geant4DetectorSurfaceFactory() = delete;
0098
0099
0100
0101
0102
0103 explicit Geant4DetectorSurfaceFactory(
0104 const Config& config,
0105 std::unique_ptr<const Acts::Logger> mlogger = Acts::getDefaultLogger(
0106 "Geant4DetectorSurfaceFactory", Acts::Logging::INFO))
0107 : m_config(config), m_logger(std::move(mlogger)) {}
0108
0109
0110
0111
0112
0113
0114
0115
0116 void construct(Cache& cache, const G4Transform3D& g4ToGlobal,
0117 const G4VPhysicalVolume& g4PhysVol, const Options& option);
0118
0119 private:
0120
0121 Config m_config = Config{};
0122
0123
0124 std::unique_ptr<const Acts::Logger> m_logger;
0125
0126
0127 const Acts::Logger& logger() const { return *m_logger; }
0128 };
0129
0130 }