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