Analysis Software
Documentation for sPHENIX simulation 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 #include <utility>
16 
17 namespace Acts {
18 
39 class Material {
40  public:
41  using ParametersVector = Eigen::Matrix<float, 5, 1>;
42 
43  // Both mass and molar density are stored as a float and can thus not be
44  // distinguished by their types. Just changing the last element in the
45  // previously existing constructor that took five floats as input to represent
46  // molar density instead of mass density could have lead to significant
47  // confusion compared to the previous behaviour. To avoid any ambiguity,
48  // construction from separate material parameters must happen through the
49  // following named constructors.
50 
58  static Material fromMolarDensity(float x0, float l0, float ar, float z,
59  float molarRho);
71  static Material fromMassDensity(float x0, float l0, float ar, float z,
72  float massRho);
74  Material() = default;
77 
78  Material(Material&& mat) = default;
79  Material(const Material& mat) = default;
80  ~Material() = default;
81  Material& operator=(Material&& mat) = default;
82  Material& operator=(const Material& mat) = default;
83 
85  constexpr operator bool() const { return 0.0f < m_ar; }
86 
88  constexpr float X0() const { return m_x0; }
90  constexpr float L0() const { return m_l0; }
92  constexpr float Ar() const { return m_ar; }
94  constexpr float Z() const { return m_z; }
96  constexpr float molarDensity() const { return m_molarRho; }
98  constexpr float molarElectronDensity() const { return m_z * m_molarRho; }
100  float massDensity() const;
102  float meanExcitationEnergy() const;
103 
106 
107  private:
108  float m_x0 = std::numeric_limits<float>::infinity();
109  float m_l0 = std::numeric_limits<float>::infinity();
110  float m_ar = 0.0f;
111  float m_z = 0.0f;
112  float m_molarRho = 0.0f;
113 
114  friend constexpr bool operator==(const Material& lhs, const Material& rhs) {
115  return (lhs.m_x0 == rhs.m_x0) and (lhs.m_l0 == rhs.m_l0) and
116  (lhs.m_ar == rhs.m_ar) and (lhs.m_z == rhs.m_z) and
117  (lhs.m_molarRho == rhs.m_molarRho);
118  }
119  friend constexpr bool operator!=(const Material& lhs, const Material& rhs) {
120  return !(lhs == rhs);
121  }
122 };
123 
124 std::ostream& operator<<(std::ostream& os, const Material& material);
125 
126 } // namespace Acts