|
||||
File indexing completed on 2025-01-18 09:27:39
0001 // This file is part of the Acts project. 0002 // 0003 // Copyright (C) 2017-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/Definitions/Units.hpp" 0012 #include "Acts/MagneticField/InterpolatedBFieldMap.hpp" 0013 #include "Acts/Utilities/Grid.hpp" 0014 #include "Acts/Utilities/detail/AxisFwd.hpp" 0015 0016 #include <array> 0017 #include <cstddef> 0018 #include <functional> 0019 #include <utility> 0020 #include <vector> 0021 0022 // Convenience functions to ease creation of and Acts::InterpolatedBFieldMap 0023 // and to avoid code duplication. Currently implemented for the two most common 0024 // formats: rz and xyz. 0025 0026 namespace Acts { 0027 0028 class SolenoidBField; 0029 0030 /// Method to setup the FieldMap 0031 /// @param localToGlobalBin Function mapping the local bins of r,z to the global 0032 /// bin of the map magnetic field value 0033 /// 0034 /// e.g.: we have small grid with the 0035 /// values: r={2,3}, z ={4,5}, the corresponding indices are i (belonging to r) 0036 /// and j (belonging to z), the 0037 /// globalIndex is M (belonging to the value of the magnetic field B(r,z)) and 0038 /// the field map is: 0039 ///| r | i | z | j | B(r,z) | M | 0040 ///|----:|:----:|:----:|:----:|:--------:|:----| 0041 ///| 2 | 0 | 4 | 0 | 2.323 | 0 | 0042 ///| 2 | 0 | 5 | 1 | 2.334 | 1 | 0043 ///| 3 | 1 | 4 | 0 | 2.325 | 2 | 0044 ///| 3 | 1 | 5 | 1 | 2.331 | 3 | 0045 /// 0046 /// In this case the function would look like: 0047 /// @code 0048 /// [](std::array<std::size_t, 2> binsRZ, std::array<std::size_t, 2> nBinsRZ) { 0049 /// return (binsRZ.at(0) * nBinsRZ.at(1) + binsRZ.at(1)); 0050 /// } 0051 /// @endcode 0052 /// @param[in] rPos Values of the grid points in r 0053 /// @note The values do not need to be sorted or unique (this will be done 0054 /// inside the function) 0055 /// @param[in] zPos Values of the grid points in z 0056 /// @note The values do not need to be sorted or unique (this will be done 0057 /// inside the function) 0058 /// @param[in] bField The magnetic field values inr r and z for all given grid 0059 /// points stored in a vector 0060 /// @note The function localToGlobalBin determines how the magnetic field was 0061 /// stored in the vector in respect to the grid values 0062 /// @param[in] lengthUnit The unit of the grid points 0063 /// @param[in] BFieldUnit The unit of the magnetic field 0064 /// @param[in] firstQuadrant Flag if set to true indicating that only the first 0065 /// quadrant of the grid points and the BField values has been given. 0066 /// @note If @p firstQuadrant is true will create a field that is symmetric for all quadrants. 0067 /// e.g. we have the grid values r={0,1} with BFieldValues={2,3} on the r 0068 /// axis. If the flag is set to true the r-axis grid values will be set to 0069 /// {-1,0,1} and the BFieldValues will be set to {3,2,3}. 0070 /// @return A field map instance for use in interpolation. 0071 Acts::InterpolatedBFieldMap< 0072 Acts::Grid<Acts::Vector2, Acts::detail::EquidistantAxis, 0073 Acts::detail::EquidistantAxis>> 0074 fieldMapRZ(const std::function<std::size_t(std::array<std::size_t, 2> binsRZ, 0075 std::array<std::size_t, 2> nBinsRZ)>& 0076 localToGlobalBin, 0077 std::vector<double> rPos, std::vector<double> zPos, 0078 std::vector<Acts::Vector2> bField, 0079 double lengthUnit = UnitConstants::mm, 0080 double BFieldUnit = UnitConstants::T, bool firstQuadrant = false); 0081 0082 /// Method to setup the FieldMap 0083 /// @param localToGlobalBin Function mapping the local bins of x,y,z to the 0084 /// global bin of the map magnetic field value 0085 /// 0086 /// e.g.: we have small grid with the 0087 /// values: x={2,3}, y={3,4}, z ={4,5}, the corresponding indices are i 0088 /// (belonging to x), j (belonging to y) 0089 /// and k (belonging to z), the globalIndex is M (belonging to the value of the 0090 /// magnetic field B(x,y,z)) and the field map is: 0091 /// 0092 ///| x | i | y | j | z | k | B(x,y,z) | M | 0093 ///|----:|:----:|:----:|:----:|:----:|:----:|:--------:|:----| 0094 ///| 2 | 0 | 3 | 0 | 4 | 0 | 2.323 | 0 | 0095 ///| 2 | 0 | 3 | 0 | 5 | 1 | 2.334 | 1 | 0096 ///| 2 | 0 | 4 | 1 | 4 | 0 | 2.325 | 2 | 0097 ///| 2 | 0 | 4 | 1 | 5 | 1 | 2.331 | 3 | 0098 ///| 3 | 1 | 3 | 0 | 4 | 0 | 2.323 | 4 | 0099 ///| 3 | 1 | 3 | 0 | 5 | 1 | 2.334 | 5 | 0100 ///| 3 | 1 | 4 | 1 | 4 | 0 | 2.325 | 6 | 0101 ///| 3 | 1 | 4 | 1 | 5 | 1 | 2.331 | 7 | 0102 /// 0103 /// In this case the function would look like: 0104 /// @code 0105 /// [](std::array<std::size_t, 3> binsXYZ, std::array<std::size_t, 3> nBinsXYZ) 0106 /// { 0107 /// return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2)) 0108 /// + binsXYZ.at(1) * nBinsXYZ.at(2) 0109 /// + binsXYZ.at(2)); 0110 /// } 0111 /// @endcode 0112 /// @note The grid point values @p xPos, @p yPos and @p zPos do not need to be 0113 /// sorted or unique (this will be done inside the function) 0114 /// @param[in] xPos Values of the grid points in x 0115 /// @param[in] yPos Values of the grid points in y 0116 /// @param[in] zPos Values of the grid points in z 0117 /// @param[in] bField The magnetic field values inr r and z for all given grid 0118 /// points stored in a vector 0119 /// @note The function @p localToGlobalBin determines how the magnetic field was 0120 /// stored in the vector in respect to the grid values 0121 /// @param[in] lengthUnit The unit of the grid points 0122 /// @param[in] BFieldUnit The unit of the magnetic field 0123 /// @param[in] firstOctant Flag if set to true indicating that only the first 0124 /// octant of the grid points and the BField values has been given. 0125 /// @note If @p firstOctant is true, the function will assume a symmetrical 0126 /// field for all quadrants. e.g. we have the grid values z={0,1} with 0127 /// BFieldValues={2,3} on the r axis. If the flag is set to true the 0128 /// z-axis grid values will be set to {-1,0,1} and the BFieldValues will 0129 /// be set to {3,2,3}. 0130 /// @return A field map instance for use in interpolation. 0131 Acts::InterpolatedBFieldMap< 0132 Acts::Grid<Acts::Vector3, Acts::detail::EquidistantAxis, 0133 Acts::detail::EquidistantAxis, Acts::detail::EquidistantAxis>> 0134 fieldMapXYZ( 0135 const std::function<std::size_t(std::array<std::size_t, 3> binsXYZ, 0136 std::array<std::size_t, 3> nBinsXYZ)>& 0137 localToGlobalBin, 0138 std::vector<double> xPos, std::vector<double> yPos, 0139 std::vector<double> zPos, std::vector<Acts::Vector3> bField, 0140 double lengthUnit = UnitConstants::mm, double BFieldUnit = UnitConstants::T, 0141 bool firstOctant = false); 0142 0143 /// Function which takes an existing SolenoidBField instance and 0144 /// creates a field mapper by sampling grid points from the analytical 0145 /// solenoid field. 0146 /// 0147 /// @param rlim pair of r bounds 0148 /// @param zlim pair of z bounds 0149 /// @param nbins pair of bin counts 0150 /// @param field the solenoid field instance 0151 /// 0152 /// @return A field map instance for use in interpolation. 0153 Acts::InterpolatedBFieldMap< 0154 Acts::Grid<Acts::Vector2, Acts::detail::EquidistantAxis, 0155 Acts::detail::EquidistantAxis>> 0156 solenoidFieldMap(std::pair<double, double> rlim, std::pair<double, double> zlim, 0157 std::pair<std::size_t, std::size_t> nbins, 0158 const SolenoidBField& field); 0159 0160 } // 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 |