File indexing completed on 2025-01-18 09:12:42
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Material/AccumulatedMaterialSlab.hpp"
0013 #include "Acts/Material/AccumulatedSurfaceMaterial.hpp"
0014 #include "Acts/Material/Material.hpp"
0015 #include "Acts/Material/MaterialSlab.hpp"
0016 #include "Acts/Utilities/BinUtility.hpp"
0017 #include "Acts/Utilities/BinningType.hpp"
0018
0019 #include <array>
0020 #include <cstddef>
0021 #include <memory>
0022 #include <vector>
0023
0024 namespace Acts::Test {
0025
0026
0027 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_construction_test) {
0028
0029
0030 AccumulatedSurfaceMaterial material0D{};
0031 auto accMat0D = material0D.accumulatedMaterial();
0032 BOOST_CHECK_EQUAL(accMat0D.size(), 1u);
0033 BOOST_CHECK_EQUAL(accMat0D[0].size(), 1u);
0034 BOOST_CHECK_EQUAL(material0D.splitFactor(), 0.);
0035
0036
0037
0038 BinUtility binUtility1D(10, -5., 5., open, AxisDirection::AxisX);
0039 AccumulatedSurfaceMaterial material1D{binUtility1D};
0040 auto accMat1D = material1D.accumulatedMaterial();
0041 BOOST_CHECK_EQUAL(accMat1D.size(), 1u);
0042 BOOST_CHECK_EQUAL(accMat1D[0].size(), 10u);
0043
0044
0045
0046 BinUtility binUtility2D(10, -5., 5., open, AxisDirection::AxisX);
0047 binUtility2D += BinUtility(20, -10., 10., open, AxisDirection::AxisY);
0048 AccumulatedSurfaceMaterial material2D{binUtility2D};
0049 auto accMat2D = material2D.accumulatedMaterial();
0050 BOOST_CHECK_EQUAL(accMat2D.size(), 20u);
0051 for (std::size_t ib = 0; ib < accMat2D.size(); ++ib) {
0052 BOOST_CHECK_EQUAL(accMat2D[ib].size(), 10u);
0053 }
0054 }
0055
0056
0057 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_0D) {
0058 Material mat = Material::fromMolarDensity(1., 1., 1., 1., 1.);
0059 MaterialSlab one(mat, 1.);
0060 MaterialSlab two(mat, 2.);
0061
0062 AccumulatedSurfaceMaterial material0D{};
0063 const std::vector<std::array<std::size_t, 3>> bin;
0064
0065 material0D.accumulate(Vector2{0., 0.}, one);
0066 material0D.accumulate(Vector2{0., 0.}, one);
0067 material0D.trackVariance(bin, one);
0068 material0D.trackAverage();
0069
0070 material0D.accumulate(Vector3(0., 0., 0.), two);
0071 material0D.trackVariance(bin, one);
0072 material0D.trackAverage();
0073
0074 auto accMat0D = material0D.accumulatedMaterial();
0075 auto accMatProp0D = accMat0D[0][0];
0076 auto [matProp0D, trackCount] = accMatProp0D.totalAverage();
0077 auto [matVar0D, trackCount2] = accMatProp0D.totalVariance();
0078
0079 BOOST_CHECK_EQUAL(matVar0D, 0.0);
0080 BOOST_CHECK_EQUAL(matProp0D.thicknessInX0(), two.thicknessInX0());
0081 BOOST_CHECK_EQUAL(trackCount, trackCount2);
0082 BOOST_CHECK_EQUAL(trackCount, 2u);
0083 }
0084
0085
0086 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_1D) {
0087 Material mat = Material::fromMolarDensity(1., 1., 1., 1., 1.);
0088 MaterialSlab one(mat, 1.);
0089 MaterialSlab two(mat, 2.);
0090 MaterialSlab three(mat, 3.);
0091 MaterialSlab four(mat, 4.);
0092
0093
0094 BinUtility binUtility2D(2, -1., 1., open, AxisDirection::AxisX);
0095 binUtility2D += BinUtility(2, -1., 1., open, AxisDirection::AxisY);
0096 AccumulatedSurfaceMaterial material2D{binUtility2D};
0097 const std::vector<std::array<std::size_t, 3>> bin;
0098
0099
0100
0101 material2D.accumulate(Vector2{-0.5, -0.5}, one);
0102 material2D.accumulate(Vector2{0.5, -0.5}, two);
0103 material2D.accumulate(Vector2{-0.5, 0.5}, three);
0104 material2D.accumulate(Vector2{0.5, 0.5}, four);
0105 material2D.trackVariance(bin, one);
0106 material2D.trackAverage();
0107
0108 material2D.accumulate(Vector2{0.5, -0.5}, two);
0109 material2D.accumulate(Vector2{-0.5, 0.5}, three);
0110 material2D.accumulate(Vector2{0.5, 0.5}, four);
0111 material2D.trackVariance(bin, one);
0112 material2D.trackAverage();
0113
0114 material2D.accumulate(Vector2{-0.5, 0.5}, three);
0115 material2D.accumulate(Vector2{0.5, 0.5}, four);
0116 material2D.trackVariance(bin, one);
0117 material2D.trackAverage();
0118
0119 material2D.accumulate(Vector2{0.5, 0.5}, four);
0120 material2D.trackVariance(bin, one);
0121 material2D.trackAverage();
0122
0123 auto accMat2D = material2D.accumulatedMaterial();
0124
0125 auto [accMatProp00, trackCount00] = accMat2D[0][0].totalAverage();
0126 auto [accMatProp01, trackCount01] = accMat2D[0][1].totalAverage();
0127 auto [accMatProp10, trackCount10] = accMat2D[1][0].totalAverage();
0128 auto [accMatProp11, trackCount11] = accMat2D[1][1].totalAverage();
0129
0130 auto [matVar00, trackCount200] = accMat2D[0][0].totalVariance();
0131 auto [matVar01, trackCount201] = accMat2D[0][1].totalVariance();
0132 auto [matVar10, trackCount210] = accMat2D[1][0].totalVariance();
0133 auto [matVar11, trackCount211] = accMat2D[1][1].totalVariance();
0134
0135 BOOST_CHECK_EQUAL(accMatProp00.thicknessInX0(), one.thicknessInX0());
0136 BOOST_CHECK_EQUAL(accMatProp01.thicknessInX0(), two.thicknessInX0());
0137 BOOST_CHECK_EQUAL(accMatProp10.thicknessInX0(), three.thicknessInX0());
0138 BOOST_CHECK_EQUAL(accMatProp11.thicknessInX0(), four.thicknessInX0());
0139
0140 BOOST_CHECK_EQUAL(matVar11, 0.0);
0141 BOOST_CHECK_EQUAL(matVar11, 0.0);
0142 BOOST_CHECK_EQUAL(matVar11, 0.0);
0143 BOOST_CHECK_EQUAL(matVar11, 0.0);
0144
0145 BOOST_CHECK_EQUAL(trackCount00, trackCount200);
0146 BOOST_CHECK_EQUAL(trackCount01, trackCount201);
0147 BOOST_CHECK_EQUAL(trackCount10, trackCount210);
0148 BOOST_CHECK_EQUAL(trackCount11, trackCount211);
0149
0150 BOOST_CHECK_EQUAL(trackCount00, 1u);
0151 BOOST_CHECK_EQUAL(trackCount01, 2u);
0152 BOOST_CHECK_EQUAL(trackCount10, 3u);
0153 BOOST_CHECK_EQUAL(trackCount11, 4u);
0154 }
0155
0156
0157 BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_variance_0D) {
0158 Material mat1 = Material::fromMolarDensity(1.0 / 3, 1., 1., 1., 1.);
0159 Material mat2 = Material::fromMolarDensity(1, 1., 1., 1., 1.);
0160 Material matAvg = Material::fromMolarDensity(0.5, 1., 1., 1., 1.);
0161
0162 MaterialSlab one(mat1, 1.);
0163 MaterialSlab two(mat2, 1.);
0164 MaterialSlab avg(matAvg, 1.);
0165
0166 AccumulatedSurfaceMaterial material0D{};
0167 const std::vector<std::array<std::size_t, 3>> bin;
0168
0169 material0D.accumulate(Vector2{0., 0.}, one);
0170 material0D.trackVariance(bin, avg);
0171 material0D.trackAverage();
0172
0173 material0D.accumulate(Vector3(0., 0., 0.), two);
0174 material0D.trackVariance(bin, avg);
0175 material0D.trackAverage();
0176
0177 auto accMat0D = material0D.accumulatedMaterial();
0178 auto accMatProp0D = accMat0D[0][0];
0179 auto [matProp0D, trackCount] = accMatProp0D.totalAverage();
0180 auto [matVar0D, trackCount2] = accMatProp0D.totalVariance();
0181
0182 BOOST_CHECK_EQUAL(matVar0D, 1.0);
0183 BOOST_CHECK_EQUAL(matProp0D.thicknessInX0(), avg.thicknessInX0());
0184 BOOST_CHECK_EQUAL(trackCount, trackCount2);
0185 BOOST_CHECK_EQUAL(trackCount, 2u);
0186 }
0187
0188 }