ATLAS Offline Software
Loading...
Searching...
No Matches
ATLASMagneticFieldWrapper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ACTSGEOMETRY_ATLASMAGNETICFIELDWRAPPER_H
6#define ACTSGEOMETRY_ATLASMAGNETICFIELDWRAPPER_H
7
10#include "Acts/Definitions/Algebra.hpp"
11#include "Acts/Definitions/Units.hpp"
12#include "Acts/MagneticField/MagneticFieldContext.hpp"
13#include "Acts/MagneticField/MagneticFieldProvider.hpp"
14
15class ATLASMagneticFieldWrapper final : public Acts::MagneticFieldProvider {
16
17public:
18
19 struct Cache {
20
21 Cache(const Acts::MagneticFieldContext mctx) {
22 const auto* atlasField = mctx.get<const AtlasFieldCacheCondObj*>();
24
25 }
26
28 };
29
31
32
33 MagneticFieldProvider::Cache
34 makeCache(const Acts::MagneticFieldContext& mctx) const override {
35 return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx);
36 }
37
38 Acts::Result<Acts::Vector3>
39 getField(const Acts::Vector3& position, Acts::MagneticFieldProvider::Cache& gcache) const override {
40 Cache& cache = gcache.as<Cache>();
41 double posXYZ[3];
42 posXYZ[0] = position.x();
43 posXYZ[1] = position.y();
44 posXYZ[2] = position.z();
45 double BField[3];
46
47 cache.fieldCache.getField(posXYZ, BField);
48
49 // Magnetic field
50 Acts::Vector3 bfield{BField[0],BField[1],BField[2]};
51
52 bfield *= m_bFieldUnit; // kT -> T;
53
54 return Acts::Result<Acts::Vector3>::success(bfield);
55 }
56
57private:
58 const double m_bFieldUnit = 1000.*Acts::UnitConstants::T;
59};
60
61
62#endif
Acts::Result< Acts::Vector3 > getField(const Acts::Vector3 &position, Acts::MagneticFieldProvider::Cache &gcache) const override
ATLASMagneticFieldWrapper()=default
MagneticFieldProvider::Cache makeCache(const Acts::MagneticFieldContext &mctx) const override
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
Cache(const Acts::MagneticFieldContext mctx)