File indexing completed on 2025-01-18 09:11:25
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "Acts/Material/AccumulatedMaterialSlab.hpp"
0010
0011 #include "Acts/Material/Material.hpp"
0012 #include "Acts/Material/detail/AverageMaterials.hpp"
0013
0014 void Acts::AccumulatedMaterialSlab::accumulate(MaterialSlab slab,
0015 float pathCorrection) {
0016
0017
0018 slab.scaleThickness(1 / pathCorrection);
0019 m_trackAverage = detail::combineSlabs(m_trackAverage, slab);
0020 }
0021
0022 void Acts::AccumulatedMaterialSlab::trackVariance(MaterialSlab slabReference,
0023 bool useEmptyTrack) {
0024
0025 if (useEmptyTrack || (0 < m_trackAverage.thickness())) {
0026 float variance = ((1 / m_trackAverage.material().X0()) -
0027 (1 / slabReference.material().X0())) *
0028 ((1 / m_trackAverage.material().X0()) -
0029 (1 / slabReference.material().X0()));
0030 if (m_totalCount == 0u) {
0031 m_totalVariance = variance;
0032 } else {
0033 double weightTotal = m_totalCount / (m_totalCount + 1.0);
0034 double weightTrack = 1 / (m_totalCount + 1.0);
0035 m_totalVariance = weightTotal * m_totalVariance + weightTrack * variance;
0036 }
0037 }
0038 }
0039
0040 void Acts::AccumulatedMaterialSlab::trackAverage(bool useEmptyTrack) {
0041
0042 if (useEmptyTrack || (0 < m_trackAverage.thickness())) {
0043 if (m_totalCount == 0u) {
0044 m_totalAverage = m_trackAverage;
0045 } else {
0046 double weightTotal = m_totalCount / (m_totalCount + 1.0);
0047 double weightTrack = 1 / (m_totalCount + 1.0);
0048
0049 MaterialSlab fromTotal(m_totalAverage.material(),
0050 weightTotal * m_totalAverage.thickness());
0051 MaterialSlab fromTrack(m_trackAverage.material(),
0052 weightTrack * m_trackAverage.thickness());
0053 m_totalAverage = detail::combineSlabs(fromTotal, fromTrack);
0054 }
0055 m_totalCount += 1;
0056 }
0057
0058 m_trackAverage = MaterialSlab();
0059 }
0060
0061 std::pair<Acts::MaterialSlab, unsigned int>
0062 Acts::AccumulatedMaterialSlab::totalAverage() const {
0063 return {m_totalAverage, m_totalCount};
0064 }
0065
0066 std::pair<float, unsigned int> Acts::AccumulatedMaterialSlab::totalVariance()
0067 const {
0068 return {m_totalVariance, m_totalCount};
0069 }