![]() |
|
|||
File indexing completed on 2025-08-05 08:09:16
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project 0004 // 0005 // This Source Code Form is subject to the terms of the Mozilla Public 0006 // License, v. 2.0. If a copy of the MPL was not distributed with this 0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 #include "Acts/Definitions/Algebra.hpp" 0011 #include "Acts/MagneticField/MagneticFieldContext.hpp" 0012 #include "Acts/MagneticField/MagneticFieldProvider.hpp" 0013 0014 namespace Acts { 0015 0016 /// @ingroup MagneticField 0017 /// 0018 /// This class implements a simple constant magnetic field. The 0019 /// magnetic field value has to be set at creation time, but can 0020 /// be updated later on. 0021 class ConstantBField final : public MagneticFieldProvider { 0022 public: 0023 struct Cache { 0024 /// @brief constructor with context 0025 Cache(const MagneticFieldContext& /*mcfg*/) {} 0026 }; 0027 0028 /// Construct constant magnetic field from field vector. 0029 /// 0030 /// @param [in] B magnetic field vector in global coordinate system 0031 explicit ConstantBField(Vector3 B) : m_BField(std::move(B)) {} 0032 0033 /// @brief Get the B field at a position 0034 Vector3 getField() const { return m_BField; } 0035 0036 /// @copydoc MagneticFieldProvider::getField(const Vector3&,MagneticFieldProvider::Cache&) const 0037 /// 0038 /// @note The @p position is ignored and only kept as argument to provide 0039 /// a consistent interface with other magnetic field services. 0040 Result<Vector3> getField(const Vector3& position, 0041 MagneticFieldProvider::Cache& cache) const override { 0042 (void)position; 0043 (void)cache; 0044 return Result<Vector3>::success(m_BField); 0045 } 0046 0047 /// @copydoc MagneticFieldProvider::getFieldGradient(const Vector3&,ActsMatrix<3,3>&,MagneticFieldProvider::Cache&) const 0048 /// 0049 /// @note The @p position is ignored and only kept as argument to provide 0050 /// a consistent interface with other magnetic field services. 0051 /// @note currently the derivative is not calculated 0052 /// @todo return derivative 0053 Result<Vector3> getFieldGradient( 0054 const Vector3& position, ActsMatrix<3, 3>& derivative, 0055 MagneticFieldProvider::Cache& cache) const override { 0056 (void)position; 0057 (void)derivative; 0058 (void)cache; 0059 return Result<Vector3>::success(m_BField); 0060 } 0061 0062 /// @copydoc MagneticFieldProvider::makeCache(const MagneticFieldContext&) const 0063 Acts::MagneticFieldProvider::Cache makeCache( 0064 const Acts::MagneticFieldContext& mctx) const override { 0065 return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx); 0066 } 0067 0068 /// @brief check whether given 3D position is inside look-up domain 0069 /// 0070 /// @return Always true for constant magnetic field 0071 bool isInside(const Vector3& /*position*/) const { return true; } 0072 0073 /// @brief update magnetic field vector 0074 /// 0075 /// @param [in] B magnetic field vector in global coordinate system 0076 void setField(const Vector3& B) { m_BField = B; } 0077 0078 private: 0079 /// magnetic field vector 0080 Vector3 m_BField; 0081 }; 0082 } // namespace Acts
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |