![]() |
|
|||
File indexing completed on 2025-10-18 08:20:33
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 /// @param ranges Vector of magnetic field ranges to use 0041 /// @warning These ranges are listed in increasing order of precedence, 0042 /// i.e. ranges further along the vector have higher priority. 0043 explicit MultiRangeBField(const std::vector<BFieldRange>& ranges); 0044 0045 /// Construct from a vector of magnetic field ranges (move version). 0046 /// @param ranges Vector of magnetic field ranges to use (moved) 0047 /// @warning These ranges are listed in increasing order of precedence, 0048 /// i.e. ranges further along the vector have higher priority. 0049 explicit MultiRangeBField(std::vector<BFieldRange>&& ranges); 0050 0051 /// @brief Construct a cache object. 0052 /// @param mctx Magnetic field context for cache creation 0053 /// @return Cache object for magnetic field computations 0054 MagneticFieldProvider::Cache makeCache( 0055 const MagneticFieldContext& mctx) const override; 0056 0057 /// @brief Request the value of the magnetic field at a given position. 0058 /// 0059 /// @param [in] position Global 3D position for the lookup. 0060 /// @param [in, out] cache Cache object. 0061 /// @returns A successful value containing a field vector if the given 0062 /// location is contained inside any of the regions, or a failure value 0063 /// otherwise. 0064 Result<Vector3> getField(const Vector3& position, 0065 MagneticFieldProvider::Cache& cache) const override; 0066 }; 0067 0068 } // 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 |
![]() ![]() |