File indexing completed on 2025-08-05 08:09:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <cstdint>
0012 #include <functional>
0013 #include <iosfwd>
0014 #include <utility>
0015
0016 namespace Acts {
0017
0018 class Surface;
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 class GeometryIdentifier {
0032 public:
0033 using Value = uint64_t;
0034
0035
0036 constexpr GeometryIdentifier(Value encoded) : m_value(encoded) {}
0037
0038 GeometryIdentifier() = default;
0039 GeometryIdentifier(GeometryIdentifier&&) = default;
0040 GeometryIdentifier(const GeometryIdentifier&) = default;
0041 ~GeometryIdentifier() = default;
0042 GeometryIdentifier& operator=(GeometryIdentifier&&) = default;
0043 GeometryIdentifier& operator=(const GeometryIdentifier&) = default;
0044
0045
0046 constexpr Value value() const { return m_value; }
0047
0048
0049 constexpr Value volume() const { return getBits(kVolumeMask); }
0050
0051 constexpr Value boundary() const { return getBits(kBoundaryMask); }
0052
0053 constexpr Value layer() const { return getBits(kLayerMask); }
0054
0055 constexpr Value approach() const { return getBits(kApproachMask); }
0056
0057 constexpr Value passive() const { return getBits(kApproachMask); }
0058
0059 constexpr Value sensitive() const { return getBits(kSensitiveMask); }
0060
0061
0062
0063 constexpr Value extra() const { return getBits(kExtraMask); }
0064
0065
0066 constexpr GeometryIdentifier& setVolume(Value volume) {
0067 return setBits(kVolumeMask, volume);
0068 }
0069
0070 constexpr GeometryIdentifier& setBoundary(Value boundary) {
0071 return setBits(kBoundaryMask, boundary);
0072 }
0073
0074 constexpr GeometryIdentifier& setLayer(Value layer) {
0075 return setBits(kLayerMask, layer);
0076 }
0077
0078 constexpr GeometryIdentifier& setApproach(Value approach) {
0079 return setBits(kApproachMask, approach);
0080 }
0081
0082 constexpr GeometryIdentifier& setPassive(Value approach) {
0083 return setBits(kApproachMask, approach);
0084 }
0085
0086 constexpr GeometryIdentifier& setSensitive(Value sensitive) {
0087 return setBits(kSensitiveMask, sensitive);
0088 }
0089
0090 constexpr GeometryIdentifier& setExtra(Value extra) {
0091 return setBits(kExtraMask, extra);
0092 }
0093
0094 private:
0095
0096
0097 static constexpr Value kVolumeMask = 0xff00000000000000;
0098
0099 static constexpr Value kBoundaryMask = 0x00ff000000000000;
0100
0101 static constexpr Value kLayerMask = 0x0000fff000000000;
0102
0103 static constexpr Value kApproachMask = 0x0000000ff0000000;
0104 static constexpr Value kPassiveMask = kApproachMask;
0105
0106 static constexpr Value kSensitiveMask = 0x000000000fffff00;
0107
0108 static constexpr Value kExtraMask = 0x00000000000000ff;
0109
0110
0111 Value m_value = 0;
0112
0113
0114 static constexpr int extractShift(Value mask) {
0115
0116
0117
0118
0119 return __builtin_ctzll(mask);
0120 }
0121
0122 constexpr Value getBits(Value mask) const {
0123 return (m_value & mask) >> extractShift(mask);
0124 }
0125
0126 constexpr GeometryIdentifier& setBits(Value mask, Value id) {
0127 m_value = (m_value & ~mask) | ((id << extractShift(mask)) & mask);
0128
0129 return *this;
0130 }
0131
0132 friend constexpr bool operator==(GeometryIdentifier lhs,
0133 GeometryIdentifier rhs) {
0134 return lhs.m_value == rhs.m_value;
0135 }
0136 friend constexpr bool operator!=(GeometryIdentifier lhs,
0137 GeometryIdentifier rhs) {
0138 return lhs.m_value != rhs.m_value;
0139 }
0140 friend constexpr bool operator<(GeometryIdentifier lhs,
0141 GeometryIdentifier rhs) {
0142 return lhs.m_value < rhs.m_value;
0143 }
0144 };
0145
0146 std::ostream& operator<<(std::ostream& os, GeometryIdentifier id);
0147
0148
0149
0150 struct GeometryIdentifierHook {
0151 virtual ~GeometryIdentifierHook() = default;
0152 virtual Acts::GeometryIdentifier decorateIdentifier(
0153 Acts::GeometryIdentifier identifier, const Acts::Surface& surface) const;
0154 };
0155
0156 }
0157
0158
0159
0160 namespace std {
0161 template <>
0162 struct hash<Acts::GeometryIdentifier> {
0163 auto operator()(Acts::GeometryIdentifier gid) const noexcept {
0164 return std::hash<Acts::GeometryIdentifier::Value>()(gid.value());
0165 }
0166 };
0167 }