File indexing completed on 2025-01-18 09:55:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <Acts/Definitions/Algebra.hpp>
0012 #include <Acts/MagneticField/MagneticFieldContext.hpp>
0013 #include <Acts/MagneticField/MagneticFieldProvider.hpp>
0014 #include <Acts/Utilities/Result.hpp>
0015 #include <DD4hep/Detector.h>
0016 #include <gsl/pointers>
0017 #include <memory>
0018 #include <variant>
0019
0020
0021
0022
0023 namespace eicrecon::BField {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class DD4hepBField final : public Acts::MagneticFieldProvider {
0036 public:
0037 gsl::not_null<const dd4hep::Detector*> m_det;
0038
0039 public:
0040 struct Cache {
0041 Cache(const Acts::MagneticFieldContext& ) { }
0042 };
0043
0044 Acts::MagneticFieldProvider::Cache makeCache(const Acts::MagneticFieldContext& mctx) const override
0045 {
0046 #if Acts_VERSION_MAJOR >= 32
0047 return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx);
0048 #else
0049 return Acts::MagneticFieldProvider::Cache::make<Cache>(mctx);
0050 #endif
0051 }
0052
0053
0054
0055
0056
0057 explicit DD4hepBField(gsl::not_null<const dd4hep::Detector*> det) : m_det(det) {}
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 Acts::Result<Acts::Vector3> getField(const Acts::Vector3& position, Acts::MagneticFieldProvider::Cache& cache) const override;
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 Acts::Result<Acts::Vector3> getFieldGradient(const Acts::Vector3& position, Acts::ActsMatrix<3, 3>& ,
0084 Acts::MagneticFieldProvider::Cache& cache) const override;
0085 };
0086
0087 using BFieldVariant = std::variant<std::shared_ptr<const DD4hepBField>>;
0088
0089
0090
0091 }