File indexing completed on 2025-01-18 09:11:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Material/AccumulatedSurfaceMaterial.hpp"
0010
0011 #include "Acts/Material/BinnedSurfaceMaterial.hpp"
0012 #include "Acts/Material/HomogeneousSurfaceMaterial.hpp"
0013
0014 #include <utility>
0015
0016
0017 Acts::AccumulatedSurfaceMaterial::AccumulatedSurfaceMaterial(double splitFactor)
0018 : m_splitFactor(splitFactor) {
0019 AccumulatedVector accMat = {{AccumulatedMaterialSlab()}};
0020 m_accumulatedMaterial = {{accMat}};
0021 }
0022
0023
0024 Acts::AccumulatedSurfaceMaterial::AccumulatedSurfaceMaterial(
0025 const BinUtility& binUtility, double splitFactor)
0026 : m_binUtility(binUtility), m_splitFactor(splitFactor) {
0027 std::size_t bins0 = m_binUtility.bins(0);
0028 std::size_t bins1 = m_binUtility.bins(1);
0029 AccumulatedVector accVec(bins0, AccumulatedMaterialSlab());
0030 m_accumulatedMaterial = AccumulatedMatrix(bins1, accVec);
0031 }
0032
0033
0034 std::array<std::size_t, 3> Acts::AccumulatedSurfaceMaterial::accumulate(
0035 const Vector2& lp, const MaterialSlab& mp, double pathCorrection) {
0036 if (m_binUtility.dimensions() == 0) {
0037 m_accumulatedMaterial[0][0].accumulate(mp, pathCorrection);
0038 return {0, 0, 0};
0039 }
0040 std::size_t bin0 = m_binUtility.bin(lp, 0);
0041 std::size_t bin1 = m_binUtility.bin(lp, 1);
0042 m_accumulatedMaterial[bin1][bin0].accumulate(mp, pathCorrection);
0043 return {bin0, bin1, 0};
0044 }
0045
0046
0047 std::array<std::size_t, 3> Acts::AccumulatedSurfaceMaterial::accumulate(
0048 const Vector3& gp, const MaterialSlab& mp, double pathCorrection) {
0049 if (m_binUtility.dimensions() == 0) {
0050 m_accumulatedMaterial[0][0].accumulate(mp, pathCorrection);
0051 return {0, 0, 0};
0052 }
0053 std::array<std::size_t, 3> bTriple = m_binUtility.binTriple(gp);
0054 m_accumulatedMaterial[bTriple[1]][bTriple[0]].accumulate(mp, pathCorrection);
0055 return bTriple;
0056 }
0057
0058
0059 void Acts::AccumulatedSurfaceMaterial::trackVariance(const Vector3& gp,
0060 MaterialSlab slabReference,
0061 bool emptyHit) {
0062 if (m_binUtility.dimensions() == 0) {
0063 m_accumulatedMaterial[0][0].trackVariance(slabReference, emptyHit);
0064 return;
0065 }
0066 std::array<std::size_t, 3> bTriple = m_binUtility.binTriple(gp);
0067 std::vector<std::array<std::size_t, 3>> trackBins = {bTriple};
0068 trackVariance(trackBins, slabReference);
0069 }
0070
0071
0072 void Acts::AccumulatedSurfaceMaterial::trackVariance(
0073 const std::vector<std::array<std::size_t, 3>>& trackBins,
0074 MaterialSlab slabReference, bool emptyHit) {
0075
0076 if (m_binUtility.dimensions() == 0) {
0077 m_accumulatedMaterial[0][0].trackVariance(slabReference, emptyHit);
0078 return;
0079 }
0080
0081 if (!trackBins.empty()) {
0082 for (auto bin : trackBins) {
0083 m_accumulatedMaterial[bin[1]][bin[0]].trackVariance(slabReference);
0084 }
0085 } else {
0086
0087 for (auto& matVec : m_accumulatedMaterial) {
0088 for (auto& mat : matVec) {
0089 mat.trackVariance(slabReference);
0090 }
0091 }
0092 }
0093 }
0094
0095
0096 void Acts::AccumulatedSurfaceMaterial::trackAverage(const Vector3& gp,
0097 bool emptyHit) {
0098 if (m_binUtility.dimensions() == 0) {
0099 m_accumulatedMaterial[0][0].trackAverage(emptyHit);
0100 return;
0101 }
0102
0103 std::array<std::size_t, 3> bTriple = m_binUtility.binTriple(gp);
0104 std::vector<std::array<std::size_t, 3>> trackBins = {bTriple};
0105 trackAverage(trackBins, emptyHit);
0106 }
0107
0108
0109 void Acts::AccumulatedSurfaceMaterial::trackAverage(
0110 const std::vector<std::array<std::size_t, 3>>& trackBins, bool emptyHit) {
0111
0112 if (m_binUtility.dimensions() == 0) {
0113 m_accumulatedMaterial[0][0].trackAverage(emptyHit);
0114 return;
0115 }
0116
0117
0118 if (!trackBins.empty()) {
0119 for (auto bin : trackBins) {
0120 m_accumulatedMaterial[bin[1]][bin[0]].trackAverage(emptyHit);
0121 }
0122 } else {
0123
0124 for (auto& matVec : m_accumulatedMaterial) {
0125 for (auto& mat : matVec) {
0126 mat.trackAverage(emptyHit);
0127 }
0128 }
0129 }
0130 }
0131
0132
0133 std::unique_ptr<const Acts::ISurfaceMaterial>
0134 Acts::AccumulatedSurfaceMaterial::totalAverage() {
0135 if (m_binUtility.bins() == 1) {
0136
0137 return std::make_unique<HomogeneousSurfaceMaterial>(
0138 m_accumulatedMaterial[0][0].totalAverage().first, m_splitFactor);
0139 }
0140
0141 MaterialSlabMatrix mpMatrix(
0142 m_binUtility.bins(1),
0143 MaterialSlabVector(m_binUtility.bins(0), MaterialSlab()));
0144
0145 for (std::size_t ib1 = 0; ib1 < m_binUtility.bins(1); ++ib1) {
0146 for (std::size_t ib0 = 0; ib0 < m_binUtility.bins(0); ++ib0) {
0147 mpMatrix[ib1][ib0] = m_accumulatedMaterial[ib1][ib0].totalAverage().first;
0148 }
0149 }
0150
0151 return std::make_unique<const BinnedSurfaceMaterial>(
0152 m_binUtility, std::move(mpMatrix), m_splitFactor);
0153 }