Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Core/include/Acts/Material/MaterialMapUtils.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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/Material/InterpolatedMaterialMap.hpp"
0014 #include "Acts/Material/Material.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 #include "Acts/Utilities/Grid.hpp"
0017 
0018 #include <array>
0019 #include <cstddef>
0020 #include <functional>
0021 #include <vector>
0022 
0023 // Convenience functions to ease creation of and Acts::InterpolatedMaterialMap
0024 // and to avoid code duplication. Currently implemented for the two most common
0025 // formats: rz and xyz.
0026 
0027 namespace Acts {
0028 
0029 /// @addtogroup material
0030 /// @{
0031 
0032 class Material;
0033 
0034 /// Method to set up the MaterialMapper
0035 /// @param [in] materialVectorToGridMapper Function mapping the vector of
0036 /// material to the map of material values
0037 ///
0038 /// e.g.: we have small grid with the values: r={2,3}, z ={4,5}, the
0039 /// corresponding indices are i (belonging to r) and j (belonging to z), the
0040 /// globalIndex is M (belonging to the values of the Material) and the map is:
0041 ///|   r |    i |    z |    j |   M |
0042 ///|----:|:----:|:----:|:----:|:----|
0043 ///|   2 |    0 |    4 |    0 |   0 |
0044 ///|   2 |    0 |    5 |    1 |   1 |
0045 ///|   3 |    1 |    4 |    0 |   2 |
0046 ///|   3 |    1 |    5 |    1 |   3 |
0047 ///
0048 /// In this case the function would look like:
0049 /// @code
0050 /// [](std::array<std::size_t, 2> binsRZ, std::array<std::size_t, 2> nBinsRZ) {
0051 ///    return (binsRZ.at(0) * nBinsRZ.at(1) + binsRZ.at(1));
0052 /// }
0053 /// @endcode
0054 /// @param [in] rPos Values of the grid points in r
0055 /// @note The values do not need to be sorted or unique (this will be done
0056 /// inside the function)
0057 /// @param [in] zPos Values of the grid points in z
0058 /// @note The values do not need to be sorted or unique (this will be done
0059 /// inside the function)
0060 /// @param [in] material The material classification values in r and z for all
0061 /// given grid points stored in a vector
0062 /// @note The function localToGlobalBin determines how the material was
0063 /// stored in the vector in respect to the grid values
0064 /// @param [in] lengthUnit The unit of the grid points
0065 /// @return A material mapper for RZ coordinate system with equidistant grid
0066 MaterialMapLookup<
0067     Grid<Material::ParametersVector, Axis<Acts::AxisType::Equidistant>,
0068          Axis<Acts::AxisType::Equidistant>>>
0069 materialMapperRZ(
0070     const std::function<std::size_t(std::array<std::size_t, 2> binsRZ,
0071                                     std::array<std::size_t, 2> nBinsRZ)>&
0072         materialVectorToGridMapper,
0073     std::vector<double> rPos, std::vector<double> zPos,
0074     const std::vector<Acts::Material>& material,
0075     double lengthUnit = UnitConstants::mm);
0076 
0077 /// Method to set up the MaterialLookup
0078 /// @param [in] materialVectorToGridMapper Function mapping the vector of
0079 /// material to the map of material values
0080 ///
0081 /// e.g.: we have small grid with the values: x={2,3}, y={3,4}, z ={4,5}, the
0082 /// corresponding indices are i (belonging to x), j (belonging to y) and k
0083 /// (belonging to z), the globalIndex is M (belonging to the values of the
0084 /// Material) and the map is:
0085 ///| x   |    i |    y |    j |    z |    k |   M |
0086 ///|----:|:----:|:----:|:----:|:----:|:----:|:----|
0087 ///|   2 |    0 |    3 |    0 |    4 |    0 |   0 |
0088 ///|   2 |    0 |    3 |    0 |    5 |    1 |   1 |
0089 ///|   2 |    0 |    4 |    1 |    4 |    0 |   2 |
0090 ///|   2 |    0 |    4 |    1 |    5 |    1 |   3 |
0091 ///|   3 |    1 |    3 |    0 |    4 |    0 |   4 |
0092 ///|   3 |    1 |    3 |    0 |    5 |    1 |   5 |
0093 ///|   3 |    1 |    4 |    1 |    4 |    0 |   6 |
0094 ///|   3 |    1 |    4 |    1 |    5 |    1 |   7 |
0095 ///
0096 /// In this case the function would look like:
0097 /// @code
0098 /// [](std::array<std::size_t, 3> binsXYZ, std::array<std::size_t, 3> nBinsXYZ)
0099 /// {
0100 ///   return (binsXYZ.at(0) * (nBinsXYZ.at(1) * nBinsXYZ.at(2))
0101 ///        + binsXYZ.at(1) * nBinsXYZ.at(2)
0102 ///        + binsXYZ.at(2));
0103 /// }
0104 /// @endcode
0105 /// @param[in] xPos Values of the grid points in x
0106 /// @note The values do not need to be sorted or unique (this will be done
0107 /// inside the function)
0108 /// @param[in] yPos Values of the grid points in y
0109 /// @note The values do not need to be sorted or unique (this will be done
0110 /// inside the function)
0111 /// @param[in] zPos Values of the grid points in z
0112 /// @note The values do not need to be sorted or unique (this will be done
0113 /// inside the function)
0114 /// @param [in] material The material classification values in x, y and z for
0115 /// all given grid points stored in a vector
0116 /// @note The function localToGlobalBin determines how the material was
0117 /// stored in the vector in respect to the grid values
0118 /// @param [in] lengthUnit The unit of the grid points
0119 /// @return A material mapper for XYZ coordinate system with equidistant grid
0120 MaterialMapLookup<
0121     Grid<Material::ParametersVector, Axis<Acts::AxisType::Equidistant>,
0122          Axis<Acts::AxisType::Equidistant>, Axis<Acts::AxisType::Equidistant>>>
0123 materialMapperXYZ(
0124     const std::function<std::size_t(std::array<std::size_t, 3> binsXYZ,
0125                                     std::array<std::size_t, 3> nBinsXYZ)>&
0126         materialVectorToGridMapper,
0127     std::vector<double> xPos, std::vector<double> yPos,
0128     std::vector<double> zPos, const std::vector<Material>& material,
0129     double lengthUnit = UnitConstants::mm);
0130 
0131 /// @}
0132 
0133 }  // namespace Acts