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