Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:07:31

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