File indexing completed on 2025-12-22 10:35:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef GEOSVC_H
0013 #define GEOSVC_H
0014
0015
0016 #include "JugTrack/IActsGeoSvc.h"
0017
0018
0019 #include "Acts/Utilities/Logger.hpp"
0020 #include "Acts/Definitions/Units.hpp"
0021 #include "Acts/Surfaces/Surface.hpp"
0022 #include "Acts/Definitions/Common.hpp"
0023 #include "Acts/Geometry/TrackingGeometry.hpp"
0024 #include <Acts/Material/IMaterialDecorator.hpp>
0025
0026 #if Acts_VERSION_MAJOR >= 44
0027 #include "ActsPlugins/DD4hep/DD4hepDetectorElement.hpp"
0028 #else
0029 #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp"
0030 #endif
0031
0032
0033 #include "GaudiKernel/MsgStream.h"
0034 #include "GaudiKernel/Service.h"
0035 #include "GaudiKernel/ServiceHandle.h"
0036
0037
0038 #include "DD4hep/Detector.h"
0039 #include "DDRec/CellIDPositionConverter.h"
0040 #include "DDRec/SurfaceManager.h"
0041 #include "DDRec/Surface.h"
0042 #include "DD4hep/DD4hepUnits.h"
0043
0044 #include "JugTrack/DD4hepBField.h"
0045
0046
0047 namespace Jug::Reco {
0048
0049 class ActsGeoSvc : public extends<Service, IActsGeoSvc> {
0050 public:
0051 using VolumeSurfaceMap = std::unordered_map<uint64_t, const Acts::Surface*>;
0052
0053 private:
0054
0055
0056
0057
0058
0059 dd4hep::Detector* m_dd4hepGeo = nullptr;
0060
0061
0062 Acts::Logging::Level m_actsLoggingLevel = Acts::Logging::INFO;
0063
0064
0065 Acts::GeometryContext m_trackingGeoCtx;
0066
0067
0068 std::shared_ptr<const Acts::TrackingGeometry> m_trackingGeo{nullptr};
0069
0070
0071 std::shared_ptr<const Acts::IMaterialDecorator> m_materialDeco{nullptr};
0072
0073
0074 VolumeSurfaceMap m_surfaces;
0075
0076
0077 std::shared_ptr<const Jug::BField::DD4hepBField> m_magneticField = nullptr;
0078
0079
0080 Gaudi::Property<std::vector<std::string>> m_xmlFileNames{
0081 this, "detectors", {}, "Detector descriptions XML-files"};
0082
0083
0084 Gaudi::Property<std::string> m_jsonFileName{
0085 this, "materials", "", "Material map JSON-file"};
0086
0087
0088 MsgStream m_log;
0089
0090 public:
0091 ActsGeoSvc(const std::string& name, ISvcLocator* svc);
0092
0093 virtual ~ActsGeoSvc();
0094
0095 virtual StatusCode initialize() final;
0096
0097 virtual StatusCode finalize() final;
0098
0099
0100
0101
0102 StatusCode buildDD4HepGeo();
0103
0104
0105
0106 virtual std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry() const;
0107
0108 virtual std::shared_ptr<const Acts::MagneticFieldProvider> getFieldProvider() const { return m_magneticField; }
0109
0110 virtual double centralMagneticField() const
0111 {
0112 return m_dd4hepGeo->field().magneticField({0, 0, 0}).z() * (Acts::UnitConstants::T / dd4hep::tesla);
0113 }
0114
0115 virtual const VolumeSurfaceMap& surfaceMap() const { return m_surfaces; }
0116 };
0117
0118 inline std::shared_ptr<const Acts::TrackingGeometry> ActsGeoSvc::trackingGeometry() const
0119 {
0120 return m_trackingGeo;
0121 }
0122
0123 }
0124
0125 #endif