File indexing completed on 2025-07-02 08:32:53
0001
0002
0003
0004 #pragma once
0005
0006
0007 #include <Acts/Definitions/Units.hpp>
0008 #include <Acts/Geometry/GeometryContext.hpp>
0009 #include <Acts/Geometry/TrackingGeometry.hpp>
0010 #include <Acts/MagneticField/MagneticFieldProvider.hpp>
0011 #include <Acts/Surfaces/Surface.hpp>
0012 #include <Acts/Visualization/ViewConfig.hpp>
0013 #include <DD4hep/Detector.h>
0014 #include <DD4hep/Fields.h>
0015 #include <Evaluator/DD4hepUnits.h>
0016 #include <Math/GenVector/Cartesian3D.h>
0017 #include <Math/GenVector/DisplacementVector3D.h>
0018 #include <spdlog/logger.h>
0019 #include <array>
0020 #include <cstdint>
0021 #include <map>
0022 #include <memory>
0023 #include <string>
0024 #include <unordered_map>
0025
0026 namespace dd4hep::rec {
0027 class Surface;
0028 }
0029 namespace eicrecon::BField {
0030 class DD4hepBField;
0031 }
0032
0033
0034
0035
0036
0037 void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo,
0038 std::shared_ptr<spdlog::logger> init_log, const std::string& fname);
0039
0040 class ActsGeometryProvider {
0041 public:
0042 ActsGeometryProvider(){};
0043 virtual ~ActsGeometryProvider() = default;
0044
0045 using VolumeSurfaceMap = std::unordered_map<uint64_t, const Acts::Surface*>;
0046
0047 virtual void initialize(const dd4hep::Detector* dd4hep_geo, std::string material_file,
0048 std::shared_ptr<spdlog::logger> log,
0049 std::shared_ptr<spdlog::logger> init_log) final;
0050
0051 const dd4hep::Detector* dd4hepDetector() const { return m_dd4hepDetector; }
0052
0053
0054
0055 std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry() const { return m_trackingGeo; }
0056
0057 std::shared_ptr<const Acts::MagneticFieldProvider> getFieldProvider() const;
0058
0059 double centralMagneticField() const {
0060 return m_dd4hepDetector->field().magneticField({0, 0, 0}).z() *
0061 (Acts::UnitConstants::T / dd4hep::tesla);
0062 }
0063
0064 const VolumeSurfaceMap& surfaceMap() const { return m_surfaces; }
0065
0066 std::map<int64_t, dd4hep::rec::Surface*> getDD4hepSurfaceMap() const { return m_surfaceMap; }
0067
0068 const Acts::GeometryContext& getActsGeometryContext() const { return m_trackingGeoCtx; }
0069
0070
0071 std::shared_ptr<spdlog::logger> getActsRelatedLogger() const { return m_log; }
0072
0073
0074
0075
0076 std::shared_ptr<spdlog::logger> getActsInitRelatedLogger() const { return m_init_log; }
0077
0078 private:
0079
0080
0081
0082
0083 const dd4hep::Detector* m_dd4hepDetector = nullptr;
0084
0085
0086 std::map<int64_t, dd4hep::rec::Surface*> m_surfaceMap;
0087
0088
0089 Acts::GeometryContext m_trackingGeoCtx;
0090
0091
0092 std::shared_ptr<const Acts::TrackingGeometry> m_trackingGeo{nullptr};
0093
0094
0095 VolumeSurfaceMap m_surfaces;
0096
0097
0098 std::shared_ptr<const eicrecon::BField::DD4hepBField> m_magneticField = nullptr;
0099
0100
0101 std::shared_ptr<spdlog::logger> m_log;
0102
0103
0104
0105
0106 std::shared_ptr<spdlog::logger> m_init_log;
0107
0108
0109 #if Acts_VERSION_MAJOR >= 37
0110 Acts::ViewConfig m_containerView{.color = {220, 220, 220}};
0111 Acts::ViewConfig m_volumeView{.color = {220, 220, 0}};
0112 Acts::ViewConfig m_sensitiveView{.color = {0, 180, 240}};
0113 Acts::ViewConfig m_passiveView{.color = {240, 180, 0}};
0114 Acts::ViewConfig m_gridView{.color = {220, 0, 0}};
0115 #else
0116 Acts::ViewConfig m_containerView{{220, 220, 220}};
0117 Acts::ViewConfig m_volumeView{{220, 220, 0}};
0118 Acts::ViewConfig m_sensitiveView{{0, 180, 240}};
0119 Acts::ViewConfig m_passiveView{{240, 180, 0}};
0120 Acts::ViewConfig m_gridView{{220, 0, 0}};
0121 #endif
0122 bool m_objWriteIt{false};
0123 bool m_plyWriteIt{false};
0124 std::string m_outputTag{""};
0125 std::string m_outputDir{""};
0126
0127 public:
0128 void setObjWriteIt(bool writeit) { m_objWriteIt = writeit; }
0129 bool getObjWriteIt() const { return m_objWriteIt; }
0130 void setPlyWriteIt(bool writeit) { m_plyWriteIt = writeit; }
0131 bool getPlyWriteIt() const { return m_plyWriteIt; }
0132
0133 void setOutputTag(std::string tag) { m_outputTag = tag; }
0134 std::string getOutputTag() const { return m_outputTag; }
0135 void setOutputDir(std::string dir) { m_outputDir = dir; }
0136 std::string getOutputDir() const { return m_outputDir; }
0137
0138 #if Acts_VERSION_MAJOR >= 37
0139 using Color = Acts::Color;
0140 #else
0141 using Color = Acts::ColorRGB;
0142 #endif
0143 void setContainerView(std::array<int, 3> c) { m_containerView.color = Color(c); }
0144 const Acts::ViewConfig& getContainerView() const { return m_containerView; }
0145 void setVolumeView(std::array<int, 3> c) { m_volumeView.color = Color(c); }
0146 const Acts::ViewConfig& getVolumeView() const { return m_volumeView; }
0147 void setSensitiveView(std::array<int, 3> c) { m_sensitiveView.color = Color(c); }
0148 const Acts::ViewConfig& getSensitiveView() const { return m_sensitiveView; }
0149 void setPassiveView(std::array<int, 3> c) { m_passiveView.color = Color(c); }
0150 const Acts::ViewConfig& getPassiveView() const { return m_passiveView; }
0151 void setGridView(std::array<int, 3> c) { m_gridView.color = Color(c); }
0152 const Acts::ViewConfig& getGridView() const { return m_gridView; }
0153 };