File indexing completed on 2024-09-28 07:03:49
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/Plugins/DD4hep/DD4hepDetectorElement.hpp"
0025 #include <Acts/Material/IMaterialDecorator.hpp>
0026
0027
0028 #include "GaudiKernel/MsgStream.h"
0029 #include "GaudiKernel/Service.h"
0030 #include "GaudiKernel/ServiceHandle.h"
0031
0032
0033 #include "DD4hep/Detector.h"
0034 #include "DDRec/CellIDPositionConverter.h"
0035 #include "DDRec/SurfaceManager.h"
0036 #include "DDRec/Surface.h"
0037 #include "DD4hep/DD4hepUnits.h"
0038
0039 #include "JugTrack/DD4hepBField.h"
0040
0041
0042 namespace Jug::Reco {
0043
0044 class ActsGeoSvc : public extends<Service, IActsGeoSvc> {
0045 public:
0046 using VolumeSurfaceMap = std::unordered_map<uint64_t, const Acts::Surface*>;
0047
0048 private:
0049
0050
0051
0052
0053
0054 dd4hep::Detector* m_dd4hepGeo = nullptr;
0055
0056
0057 Acts::Logging::Level m_actsLoggingLevel = Acts::Logging::INFO;
0058
0059
0060 Acts::GeometryContext m_trackingGeoCtx;
0061
0062
0063 std::shared_ptr<const Acts::TrackingGeometry> m_trackingGeo{nullptr};
0064
0065
0066 std::shared_ptr<const Acts::IMaterialDecorator> m_materialDeco{nullptr};
0067
0068
0069 VolumeSurfaceMap m_surfaces;
0070
0071
0072 std::shared_ptr<const Jug::BField::DD4hepBField> m_magneticField = nullptr;
0073
0074
0075 Gaudi::Property<std::vector<std::string>> m_xmlFileNames{
0076 this, "detectors", {}, "Detector descriptions XML-files"};
0077
0078
0079 Gaudi::Property<std::string> m_jsonFileName{
0080 this, "materials", "", "Material map JSON-file"};
0081
0082
0083 MsgStream m_log;
0084
0085 public:
0086 ActsGeoSvc(const std::string& name, ISvcLocator* svc);
0087
0088 virtual ~ActsGeoSvc();
0089
0090 virtual StatusCode initialize() final;
0091
0092 virtual StatusCode finalize() final;
0093
0094
0095
0096
0097 StatusCode buildDD4HepGeo();
0098
0099
0100
0101 virtual std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry() const;
0102
0103 virtual std::shared_ptr<const Acts::MagneticFieldProvider> getFieldProvider() const { return m_magneticField; }
0104
0105 virtual double centralMagneticField() const
0106 {
0107 return m_dd4hepGeo->field().magneticField({0, 0, 0}).z() * (Acts::UnitConstants::T / dd4hep::tesla);
0108 }
0109
0110 virtual const VolumeSurfaceMap& surfaceMap() const { return m_surfaces; }
0111 };
0112
0113 inline std::shared_ptr<const Acts::TrackingGeometry> ActsGeoSvc::trackingGeometry() const
0114 {
0115 return m_trackingGeo;
0116 }
0117
0118 }
0119
0120 #endif