EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MaterialSlab.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MaterialSlab.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 <vector>
15 
16 namespace Acts {
17 
23 class MaterialSlab {
24  public:
26  MaterialSlab() = default;
28  MaterialSlab(float thickness);
33  MaterialSlab(const Material& material, float thickness);
40  MaterialSlab(const std::vector<MaterialSlab>& layers);
41  ~MaterialSlab() = default;
42 
43  MaterialSlab(MaterialSlab&&) = default;
44  MaterialSlab(const MaterialSlab&) = default;
45  MaterialSlab& operator=(MaterialSlab&&) = default;
46  MaterialSlab& operator=(const MaterialSlab&) = default;
47 
49  void scaleThickness(float scale);
50 
52  constexpr operator bool() const {
53  return m_material and (0.0f < m_thickness);
54  }
55 
57  constexpr const Material& material() const { return m_material; }
59  constexpr float thickness() const { return m_thickness; }
61  constexpr float thicknessInX0() const { return m_thicknessInX0; }
63  constexpr float thicknessInL0() const { return m_thicknessInL0; }
64 
65  private:
67  float m_thickness = 0.0f;
68  float m_thicknessInX0 = 0.0f;
69  float m_thicknessInL0 = 0.0f;
70 
71  friend constexpr bool operator==(const MaterialSlab& lhs,
72  const MaterialSlab& rhs) {
73  // t/X0 and t/L0 are dependent variables and need not be checked
74  return (lhs.m_material == rhs.m_material) and
75  (lhs.m_thickness == rhs.m_thickness);
76  }
77  friend constexpr bool operator!=(const MaterialSlab& lhs,
78  const MaterialSlab& rhs) {
79  return !(lhs == rhs);
80  }
81 };
82 
83 std::ostream& operator<<(std::ostream& os, const MaterialSlab& materialSlab);
84 
85 // Useful typedefs
86 using MaterialSlabVector = std::vector<MaterialSlab>;
87 using MaterialSlabMatrix = std::vector<MaterialSlabVector>;
88 
89 } // namespace Acts