Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:11:25

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 #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   // scale the recorded material to the equivalence contribution along the
0017   // surface normal
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   // Only use real tracks or if empty tracks are allowed.
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   // average only real tracks or if empty tracks are allowed.
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       // average such that each track contributes equally.
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   // reset track average
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 }