Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:15:41

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/InterpolatedBFieldMap.hpp"
0013 #include "Acts/Utilities/AxisDefinitions.hpp"
0014 #include "Acts/Utilities/Grid.hpp"
0015 
0016 #include <array>
0017 #include <cstddef>
0018 #include <functional>
0019 #include <string>
0020 
0021 namespace Acts {
0022 
0023 /// Method to setup the FieldMapper
0024 /// @param localToGlobalBin Function mapping the local bins of r,z to the
0025 /// global
0026 /// bin of the map magnetic field value e.g.: we have small grid with the
0027 /// values: r={2,3}, z ={4,5}, the corresponding indices are i(r) and j(z),
0028 /// the
0029 /// globalIndex is M and the field map is:
0030 ///|| r | i || z | j || |B(r,z)| ||  M ||
0031 ///  -----------------------------------
0032 ///|| 2 | 0 || 4 | 0 ||  2.323   ||  0 ||
0033 ///|| 2 | 0 || 5 | 1 ||  2.334   ||  1 ||
0034 ///|| 3 | 1 || 4 | 0 ||  2.325   ||  2 ||
0035 ///|| 3 | 1 || 5 | 1 ||  2.331   ||  3 ||
0036 ///
0037 /// @code
0038 /// In this case the function would look like:
0039 /// [](std::array<std::size_t, 2> binsRZ, std::array<std::size_t, 2> nBinsRZ) {
0040 ///    return (binsRZ.at(0) * nBinsRZ.at(1) + binsRZ.at(1));
0041 /// }
0042 /// @endcode
0043 /// @param[in] fieldMapFile Path to file containing field map in txt format
0044 /// @param[in] lengthUnit The unit of the grid points
0045 /// @param[in] BFieldUnit The unit of the magnetic field
0046 /// @note This information is only used as a hint for the required size of
0047 ///       the internal vectors. A correct value is not needed, but will help
0048 ///       to speed up the field map initialization process.
0049 /// @param[in] firstQuadrant Flag if set to true indicating that only the
0050 /// first quadrant of the grid points and the BField values has been given and
0051 /// that the BFieldMap should be created symmetrically for all quadrants.
0052 /// e.g. we have the grid values r={0,1} with BFieldValues={2,3} on the r
0053 /// axis.
0054 /// If the flag is set to true the r-axis grid values will be set to
0055 /// {-1,0,1} and the BFieldValues will be set to {3,2,3}.
0056 /// @param delimiter The delimiter used in the text file to separate values
0057 InterpolatedBFieldMap<
0058     Grid<Vector2, Axis<AxisType::Equidistant>, Axis<AxisType::Equidistant>>>
0059 makeMagneticFieldMapRzFromText(
0060     const std::function<std::size_t(std::array<std::size_t, 2> binsRZ,
0061                                     std::array<std::size_t, 2> nBinsRZ)>&
0062         localToGlobalBin,
0063     const std::string& fieldMapFile, double lengthUnit, double BFieldUnit,
0064     bool firstQuadrant = false, const std::string& delimiter = "");
0065 
0066 /// Method to setup the FieldMapper
0067 /// @param localToGlobalBin Function mapping the local bins of x,y,z to the
0068 /// global bin of the map magnetic field value e.g.: we have small grid with
0069 /// the  values: x={2,3}, y={3,4}, z ={4,5}, the corresponding indices are i(x),
0070 /// j(y) and z(k), the globalIndex is M and the field map is:
0071 ///|| x | i || y | j || z | k || |B(x,y,z)| ||  M ||
0072 ///  --------------------------------------------
0073 ///|| 2 | 0 || 3 | 0 || 4 | 0 ||  2.323   ||  0 ||
0074 ///|| 2 | 0 || 3 | 0 || 5 | 1 ||  2.334   ||  1 ||
0075 ///|| 2 | 0 || 4 | 1 || 4 | 0 ||  2.325   ||  2 ||
0076 ///|| 2 | 0 || 4 | 1 || 5 | 1 ||  2.331   ||  3 ||
0077 ///|| 3 | 1 || 3 | 0 || 4 | 0 ||  2.323   ||  4 ||
0078 ///|| 3 | 1 || 3 | 0 || 5 | 1 ||  2.334   ||  5 ||
0079 ///|| 3 | 1 || 4 | 1 || 4 | 0 ||  2.325   ||  6 ||
0080 ///|| 3 | 1 || 4 | 1 || 5 | 1 ||  2.331   ||  7 ||
0081 ///
0082 /// @code
0083 /// In this case the function would look like:
0084 /// [](std::array<std::size_t, 3> binsXYZ, std::array<std::size_t, 3> nBinsXYZ)
0085 /// {
0086 ///   return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2))
0087 ///        + binsXYZ.at(1) * nBinsXYZ.at(2)
0088 ///        + binsXYZ.at(2));
0089 /// }
0090 /// @endcode
0091 /// @param[in] fieldMapFile Path to file containing field map in txt format
0092 /// @param[in] lengthUnit The unit of the grid points
0093 /// @param[in] BFieldUnit The unit of the magnetic field
0094 /// @note This information is only used as a hint for the required size of
0095 ///       the internal vectors. A correct value is not needed, but will help
0096 ///       to speed up the field map initialization process.
0097 /// @param[in] firstOctant Flag if set to true indicating that only the
0098 /// first
0099 /// octant of the grid points and the BField values has been given and that
0100 /// the BFieldMap should be created symmetrically for all quadrants.
0101 /// e.g. we have the grid values z={0,1} with BFieldValues={2,3} on the r
0102 /// axis.
0103 /// If the flag is set to true the z-axis grid values will be set to
0104 /// {-1,0,1} and the BFieldValues will be set to {3,2,3}.
0105 /// @param delimiter The delimiter used in the text file to separate values
0106 InterpolatedBFieldMap<
0107     Grid<Vector3, Axis<AxisType::Equidistant>, Axis<AxisType::Equidistant>,
0108          Axis<AxisType::Equidistant>>>
0109 makeMagneticFieldMapXyzFromText(
0110     const std::function<std::size_t(std::array<std::size_t, 3> binsXYZ,
0111                                     std::array<std::size_t, 3> nBinsXYZ)>&
0112         localToGlobalBin,
0113     const std::string& fieldMapFile, double lengthUnit, double BFieldUnit,
0114     bool firstOctant = false, const std::string& delimiter = "");
0115 
0116 }  // namespace Acts