Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AccumulatedMaterialSlab.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AccumulatedMaterialSlab.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
13 
15  float pathCorrection) {
16  // scale the recorded material to the equivalence contribution along the
17  // surface normal
18  slab.scaleThickness(1 / pathCorrection);
20 }
21 
23  bool useEmptyTrack) {
24  // Only use real tracks or if empty tracks are allowed.
25  if (useEmptyTrack or (0 < m_trackAverage.thickness())) {
26  float variance = ((1 / m_trackAverage.material().X0()) -
27  (1 / slabReference.material().X0())) *
28  ((1 / m_trackAverage.material().X0()) -
29  (1 / slabReference.material().X0()));
30  if (m_totalCount == 0u) {
31  m_totalVariance = variance;
32  } else {
33  double weightTotal = m_totalCount / (m_totalCount + 1.0);
34  double weightTrack = 1 / (m_totalCount + 1.0);
35  m_totalVariance = weightTotal * m_totalVariance + weightTrack * variance;
36  }
37  }
38 }
39 
41  // average only real tracks or if empty tracks are allowed.
42  if (useEmptyTrack or (0 < m_trackAverage.thickness())) {
43  if (m_totalCount == 0u) {
44  m_totalAverage = m_trackAverage;
45  } else {
46  double weightTotal = m_totalCount / (m_totalCount + 1.0);
47  double weightTrack = 1 / (m_totalCount + 1.0);
48  // average such that each track contributes equally.
49  MaterialSlab fromTotal(m_totalAverage.material(),
50  weightTotal * m_totalAverage.thickness());
51  MaterialSlab fromTrack(m_trackAverage.material(),
52  weightTrack * m_trackAverage.thickness());
53  m_totalAverage = detail::combineSlabs(fromTotal, fromTrack);
54  }
55  m_totalCount += 1;
56  }
57  // reset track average
58  m_trackAverage = MaterialSlab();
59 }
60 
61 std::pair<Acts::MaterialSlab, unsigned int>
63  return {m_totalAverage, m_totalCount};
64 }
65 
66 std::pair<float, unsigned int> Acts::AccumulatedMaterialSlab::totalVariance()
67  const {
68  return {m_totalVariance, m_totalCount};
69 }