21 std::array<size_t, 2> nBinsRZ)>&
22 materialVectorToGridMapper,
23 std::vector<double> rPos, std::vector<double> zPos,
24 std::vector<Acts::Material>
material,
double lengthUnit)
26 detail::EquidistantAxis>> {
28 std::vector<ActsVectorF<5>> materialVector;
29 materialVector.reserve(
material.size());
32 materialVector.push_back(
mat.classificationNumbers());
37 std::sort(rPos.begin(), rPos.end());
38 std::sort(zPos.begin(), zPos.end());
40 rPos.erase(std::unique(rPos.begin(), rPos.end()), rPos.end());
41 zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end());
45 size_t nBinsR = rPos.size();
46 size_t nBinsZ = zPos.size();
49 auto minMaxR = std::minmax_element(rPos.begin(), rPos.end());
50 auto minMaxZ = std::minmax_element(zPos.begin(), zPos.end());
51 double rMin = *minMaxR.first;
52 double zMin = *minMaxZ.first;
53 double rMax = *minMaxR.second;
54 double zMax = *minMaxZ.second;
57 double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1);
58 double stepR = std::fabs(rMax - rMin) / (nBinsR - 1);
63 detail::EquidistantAxis rAxis(rMin * lengthUnit, rMax * lengthUnit, nBinsR);
64 detail::EquidistantAxis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ);
68 detail::EquidistantAxis>;
69 Grid_t grid(std::make_tuple(std::move(rAxis), std::move(zAxis)));
72 for (
size_t i = 1; i <=
nBinsR; ++i) {
73 for (
size_t j = 1; j <=
nBinsZ; ++j) {
74 std::array<size_t, 2> nIndices = {{rPos.size(), zPos.size()}};
75 Grid_t::index_t indices = {{i, j}};
79 grid.atLocalBins(indices) = materialVector.at(
80 materialVectorToGridMapper({{i - 1, j - 1}}, nIndices));
86 grid.setExteriorBins(vec);
97 detail::EquidistantAxis>>(transformPos,
103 std::array<size_t, 3> nBinsXYZ)>&
104 materialVectorToGridMapper,
105 std::vector<double> xPos, std::vector<double> yPos,
106 std::vector<double> zPos, std::vector<Material>
material,
double lengthUnit)
111 std::vector<ActsVectorF<5>> materialVector;
112 materialVector.reserve(
material.size());
115 materialVector.push_back(
mat.classificationNumbers());
120 std::sort(xPos.begin(), xPos.end());
121 std::sort(yPos.begin(), yPos.end());
122 std::sort(zPos.begin(), zPos.end());
124 xPos.erase(std::unique(xPos.begin(), xPos.end()), xPos.end());
125 yPos.erase(std::unique(yPos.begin(), yPos.end()), yPos.end());
126 zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end());
127 xPos.shrink_to_fit();
128 yPos.shrink_to_fit();
129 zPos.shrink_to_fit();
131 size_t nBinsX = xPos.size();
132 size_t nBinsY = yPos.size();
133 size_t nBinsZ = zPos.size();
136 auto minMaxX = std::minmax_element(xPos.begin(), xPos.end());
137 auto minMaxY = std::minmax_element(yPos.begin(), yPos.end());
138 auto minMaxZ = std::minmax_element(zPos.begin(), zPos.end());
141 double xMin = *minMaxX.first;
142 double yMin = *minMaxY.first;
143 double zMin = *minMaxZ.first;
145 double xMax = *minMaxX.second;
146 double yMax = *minMaxY.second;
147 double zMax = *minMaxZ.second;
150 double stepZ = std::fabs(zMax - zMin) / (nBinsZ - 1);
151 double stepY = std::fabs(yMax - yMin) / (nBinsY - 1);
152 double stepX = std::fabs(xMax - xMin) / (nBinsX - 1);
157 detail::EquidistantAxis xAxis(xMin * lengthUnit, xMax * lengthUnit, nBinsX);
158 detail::EquidistantAxis yAxis(yMin * lengthUnit, yMax * lengthUnit, nBinsY);
159 detail::EquidistantAxis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ);
164 std::make_tuple(std::move(xAxis), std::move(yAxis), std::move(zAxis)));
167 for (
size_t i = 1; i <= nBinsX; ++i) {
168 for (
size_t j = 1; j <= nBinsY; ++j) {
170 Grid_t::index_t indices = {{i, j,
k}};
171 std::array<size_t, 3> nIndices = {
172 {xPos.size(), yPos.size(), zPos.size()}};
176 grid.atLocalBins(indices) = materialVector.at(
177 materialVectorToGridMapper({{i - 1, j - 1,
k - 1}}, nIndices));
184 grid.setExteriorBins(vec);
195 transformPos, std::move(grid));