ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Material.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Material.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019-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 
11 #include <cmath>
12 #include <ostream>
13 
14 #include "Acts/Utilities/Units.hpp"
15 
17  : Material(parameters[eX0], parameters[eL0], parameters[eAr],
18  parameters[eZ], parameters[eRho]) {}
19 
21  using namespace Acts::UnitLiterals;
22 
23  // no material, no electron density
24  if (!(*this)) {
25  return 0.0f;
26  }
27 
28  // Avogadro constant
29  constexpr double Na = 6.02214076e23;
30  // perform computations in double precision. due to the native units we might
31  // and up with ratios of large numbers and need to keep precision.
32  // convert relativ atomic mass Ar to atom mass in native units
33  const double atomicMass = m_ar * 1_u;
34  // compute molar atomic density
35  // [mass density / atom mass / Avogadro constant]
36  // [mass density / (atom mass * Avogadro constant)]
37  // = (mass / volume) / (mass * (1/mol))
38  // = (mass * mol) / (mass * volume)
39  const double molarAtomicDensity =
40  static_cast<double>(m_rho) / atomicMass / Na;
41  // each atom has Z electrons
42  return static_cast<float>(m_z * molarAtomicDensity);
43 }
44 
46  using namespace Acts::UnitLiterals;
47 
48  // use approximative computation as defined in ATL-SOFT-PUB-2008-003
49  return 16_eV * std::pow(m_z, 0.9f);
50 }
51 
54  parameters[eX0] = m_x0;
55  parameters[eL0] = m_l0;
56  parameters[eAr] = m_ar;
57  parameters[eZ] = m_z;
58  parameters[eRho] = m_rho;
59  return parameters;
60 }
61 
62 std::ostream& Acts::operator<<(std::ostream& os, const Material& material) {
63  if (!material) {
64  os << "vacuum";
65  } else {
66  os << "X0=" << material.X0();
67  os << "|L0=" << material.L0();
68  os << "|Ar=" << material.Ar();
69  os << "|Z=" << material.Z();
70  os << "|rho=" << material.massDensity();
71  }
72  return os;
73 }