EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Material.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Material.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-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 
9 #pragma once
10 
12 
13 #include <iosfwd>
14 #include <limits>
15 
16 namespace Acts {
17 
38 class Material {
39  public:
41 
42  // Both mass and molar density are stored as a float and can thus not be
43  // distinguished by their types. Just changing the last element in the
44  // previously existing constructor that took five floats as input to represent
45  // molar density instead of mass density could have lead to significant
46  // confusion compared to the previous behaviour. To avoid any ambiguity,
47  // construction from separate material parameters must happen through the
48  // following named constructors.
49 
57  static Material fromMolarDensity(float x0, float l0, float ar, float z,
58  float molarRho);
70  static Material fromMassDensity(float x0, float l0, float ar, float z,
71  float massRho);
73  Material() = default;
76 
77  Material(Material&& mat) = default;
78  Material(const Material& mat) = default;
79  ~Material() = default;
80  Material& operator=(Material&& mat) = default;
81  Material& operator=(const Material& mat) = default;
82 
84  constexpr operator bool() const { return 0.0f < m_ar; }
85 
87  constexpr float X0() const { return m_x0; }
89  constexpr float L0() const { return m_l0; }
91  constexpr float Ar() const { return m_ar; }
93  constexpr float Z() const { return m_z; }
95  constexpr float molarDensity() const { return m_molarRho; }
97  constexpr float molarElectronDensity() const { return m_z * m_molarRho; }
99  float massDensity() const;
101  float meanExcitationEnergy() const;
102 
105 
106  private:
107  float m_x0 = std::numeric_limits<float>::infinity();
108  float m_l0 = std::numeric_limits<float>::infinity();
109  float m_ar = 0.0f;
110  float m_z = 0.0f;
111  float m_molarRho = 0.0f;
112 
113  friend constexpr bool operator==(const Material& lhs, const Material& rhs) {
114  return (lhs.m_x0 == rhs.m_x0) and (lhs.m_l0 == rhs.m_l0) and
115  (lhs.m_ar == rhs.m_ar) and (lhs.m_z == rhs.m_z) and
116  (lhs.m_molarRho == rhs.m_molarRho);
117  }
118  friend constexpr bool operator!=(const Material& lhs, const Material& rhs) {
119  return !(lhs == rhs);
120  }
121 };
122 
123 std::ostream& operator<<(std::ostream& os, const Material& material);
124 
125 } // namespace Acts