File indexing completed on 2025-01-30 09:14:59
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <cstdint>
0012 #include <iosfwd>
0013
0014 namespace Acts {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 class GeometryIdentifier {
0028 public:
0029 using Value = std::uint64_t;
0030
0031
0032 constexpr GeometryIdentifier(Value encoded) : m_value(encoded) {}
0033
0034 GeometryIdentifier() = default;
0035 GeometryIdentifier(GeometryIdentifier&&) = default;
0036 GeometryIdentifier(const GeometryIdentifier&) = default;
0037 ~GeometryIdentifier() = default;
0038 GeometryIdentifier& operator=(GeometryIdentifier&&) = default;
0039 GeometryIdentifier& operator=(const GeometryIdentifier&) = default;
0040
0041
0042 constexpr Value value() const { return m_value; }
0043
0044
0045 constexpr Value volume() const { return getBits(volume_mask); }
0046
0047 constexpr Value boundary() const { return getBits(boundary_mask); }
0048
0049 constexpr Value layer() const { return getBits(layer_mask); }
0050
0051 constexpr Value approach() const { return getBits(approach_mask); }
0052
0053 constexpr Value sensitive() const { return getBits(sensitive_mask); }
0054
0055 private:
0056
0057 static constexpr Value volume_mask = 0xff00000000000000;
0058 static constexpr Value boundary_mask = 0x00ff000000000000;
0059 static constexpr Value layer_mask = 0x0000fff000000000;
0060 static constexpr Value approach_mask = 0x0000000ff0000000;
0061 static constexpr Value sensitive_mask = 0x000000000fffffff;
0062
0063
0064 Value m_value = 0;
0065
0066
0067 static constexpr int extractShift(Value mask) {
0068
0069
0070
0071
0072
0073 return __builtin_ctzll(mask);
0074 }
0075
0076 constexpr Value getBits(Value mask) const {
0077 return (m_value & mask) >> extractShift(mask);
0078 }
0079
0080 friend constexpr bool operator==(GeometryIdentifier lhs,
0081 GeometryIdentifier rhs) {
0082 return lhs.m_value == rhs.m_value;
0083 }
0084 friend constexpr bool operator<(GeometryIdentifier lhs,
0085 GeometryIdentifier rhs) {
0086 return lhs.m_value < rhs.m_value;
0087 }
0088 };
0089
0090 std::ostream& operator<<(std::ostream& os, GeometryIdentifier id);
0091
0092 }