Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-11 09:40:23

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 ActsPlugins {
0022 
0023 /// Method to setup the FieldMap
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] treeName The name of the root tree
0045 /// @param[in] lengthUnit The unit of the grid points
0046 /// @param[in] BFieldUnit The unit of the magnetic field
0047 /// @param[in] firstQuadrant Flag if set to true indicating that only the
0048 /// first
0049 /// quadrant of the grid points and the BField values has been given and
0050 /// that
0051 /// 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}
0056 /// and the BFieldValues will be set to {3,2,3}.
0057 Acts::InterpolatedBFieldMap<
0058     Acts::Grid<Acts::Vector2, Acts::Axis<Acts::AxisType::Equidistant>,
0059                Acts::Axis<Acts::AxisType::Equidistant>>>
0060 makeMagneticFieldMapRzFromRoot(
0061     const std::function<std::size_t(std::array<std::size_t, 2> binsRZ,
0062                                     std::array<std::size_t, 2> nBinsRZ)>&
0063         localToGlobalBin,
0064     const std::string& fieldMapFile, const std::string& treeName,
0065     double lengthUnit, double BFieldUnit, bool firstQuadrant = false);
0066 
0067 /// Method to setup the FieldMap
0068 /// @param localToGlobalBin Function mapping the local bins of x,y,z to the
0069 /// global bin of the map magnetic field value e.g.: we have small grid with
0070 /// the
0071 /// values: x={2,3}, y={3,4}, z ={4,5}, the corresponding indices are i(x),
0072 /// j(y)
0073 /// 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] treeName The name of the root tree
0096 /// @param[in] lengthUnit The unit of the grid points
0097 /// @param[in] BFieldUnit The unit of the magnetic field
0098 /// @param[in] firstOctant Flag if set to true indicating that only the
0099 /// first
0100 /// octant of the grid points and the BField values has been given and that
0101 /// the BFieldMap should be created symmetrically for all quadrants.
0102 /// e.g. we have the grid values z={0,1} with BFieldValues={2,3} on the r
0103 /// axis.
0104 /// If the flag is set to true the z-axis grid values will be set to
0105 /// {-1,0,1}
0106 /// and the BFieldValues will be set to {3,2,3}.
0107 Acts::InterpolatedBFieldMap<
0108     Acts::Grid<Acts::Vector3, Acts::Axis<Acts::AxisType::Equidistant>,
0109                Acts::Axis<Acts::AxisType::Equidistant>,
0110                Acts::Axis<Acts::AxisType::Equidistant>>>
0111 makeMagneticFieldMapXyzFromRoot(
0112     const std::function<std::size_t(std::array<std::size_t, 3> binsXYZ,
0113                                     std::array<std::size_t, 3> nBinsXYZ)>&
0114         localToGlobalBin,
0115     const std::string& fieldMapFile, const std::string& treeName,
0116     double lengthUnit, double BFieldUnit, bool firstOctant = false);
0117 
0118 }  // namespace ActsPlugins