|
||||
File indexing completed on 2025-01-18 09:10:53
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 #include "Acts/Utilities/RangeXD.hpp" 0015 0016 namespace Acts { 0017 0018 /// @ingroup MagneticField 0019 /// 0020 /// @brief Magnetic field provider modelling a magnetic field consisting of 0021 /// several (potentially overlapping) regions of constant values. 0022 class MultiRangeBField final : public MagneticFieldProvider { 0023 private: 0024 struct Cache { 0025 explicit Cache(const MagneticFieldContext& /*unused*/); 0026 0027 std::optional<std::size_t> index = {}; 0028 }; 0029 0030 using BFieldRange = std::pair<RangeXD<3, double>, Vector3>; 0031 0032 // The different ranges and their corresponding field vectors. Note that 0033 // regions positioned _later_ in this vector take priority over earlier 0034 // regions. 0035 std::vector<BFieldRange> fieldRanges; 0036 0037 public: 0038 /// @brief Construct a magnetic field from a vector of ranges. 0039 /// 0040 /// @warning These ranges are listed in increasing order of precedence, 0041 /// i.e. ranges further along the vector have higher priority. 0042 explicit MultiRangeBField(const std::vector<BFieldRange>& ranges); 0043 0044 explicit MultiRangeBField(std::vector<BFieldRange>&& ranges); 0045 0046 /// @brief Construct a cache object. 0047 MagneticFieldProvider::Cache makeCache( 0048 const MagneticFieldContext& mctx) const override; 0049 0050 /// @brief Request the value of the magnetic field at a given position. 0051 /// 0052 /// @param [in] position Global 3D position for the lookup. 0053 /// @param [in, out] cache Cache object. 0054 /// @returns A successful value containing a field vector if the given 0055 /// location is contained inside any of the regions, or a failure value 0056 /// otherwise. 0057 Result<Vector3> getField(const Vector3& position, 0058 MagneticFieldProvider::Cache& cache) const override; 0059 }; 0060 0061 } // 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 |