![]() |
|
|||
File indexing completed on 2025-10-19 07:57:13
0001 // This file is part of the ACTS project. 0002 // 0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. 0008 0009 #pragma once 0010 0011 #include "Acts/Definitions/Algebra.hpp" 0012 #include "Acts/MagneticField/MagneticFieldContext.hpp" 0013 #include "Acts/MagneticField/MagneticFieldProvider.hpp" 0014 0015 namespace Acts { 0016 0017 /// @ingroup MagneticField 0018 /// 0019 /// This class implements a simple constant magnetic field. The 0020 /// magnetic field value has to be set at creation time, but can 0021 /// be updated later on. 0022 class ConstantBField final : public MagneticFieldProvider { 0023 public: 0024 struct Cache { 0025 /// @brief constructor with context 0026 explicit Cache(const MagneticFieldContext& /*mcfg*/) {} 0027 }; 0028 0029 /// Construct constant magnetic field from field vector. 0030 /// 0031 /// @param [in] B magnetic field vector in global coordinate system 0032 explicit ConstantBField(Vector3 B) : m_BField(std::move(B)) {} 0033 0034 /// @brief Get the B field at a position 0035 /// @return The constant magnetic field vector 0036 Vector3 getField() const { return m_BField; } 0037 0038 /// @copydoc MagneticFieldProvider::getField(const Vector3&,MagneticFieldProvider::Cache&) const 0039 /// 0040 /// @note The @p position is ignored and only kept as argument to provide 0041 /// a consistent interface with other magnetic field services. 0042 Result<Vector3> getField(const Vector3& position, 0043 MagneticFieldProvider::Cache& cache) const override { 0044 (void)position; 0045 (void)cache; 0046 return Result<Vector3>::success(m_BField); 0047 } 0048 0049 /// @copydoc MagneticFieldProvider::makeCache(const MagneticFieldContext&) const 0050 Acts::MagneticFieldProvider::Cache makeCache( 0051 const Acts::MagneticFieldContext& mctx) const override { 0052 return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx); 0053 } 0054 0055 /// @brief check whether given 3D position is inside look-up domain 0056 /// 0057 /// @return Always true for constant magnetic field 0058 bool isInside(const Vector3& /*position*/) const { return true; } 0059 0060 /// @brief update magnetic field vector 0061 /// 0062 /// @param [in] B magnetic field vector in global coordinate system 0063 void setField(const Vector3& B) { m_BField = B; } 0064 0065 private: 0066 /// magnetic field vector 0067 Vector3 m_BField; 0068 }; 0069 } // 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 |
![]() ![]() |