ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONNSWASBUILT_IDENTIFIER_H
6#define MUONNSWASBUILT_IDENTIFIER_H
7
8#include <functional>
9
10namespace NswAsBuilt {
11
12 // This file defines structs with the list of indices needed to address a
13 // quadruplet, a PCB or a strip. (Probably something similar already exists
14 // somewhere in the code)
15
27 MMS=55,
28 MML=56,
29 STS=57,
30 STL=58
31 };
32
34 int stationEta{0};
35 int stationPhi{0};
36 int multilayer{0};
37
38 std::string stationNameStr() const {
39 if (stationName > 56) return (stationName==STS) ? "STS" : "STL";
40 else return (stationName==MMS) ? "MMS" : "MML";
41 }
42
43 bool operator<(const quadrupletIdentifier_t& o) const {
45 }
46
47 bool operator==(const quadrupletIdentifier_t& o) const {
49 }
50
51 };
52
61 int ilayer{0};
62 int ipcb{0};
63
64 bool operator<(const pcbIdentifier_t& o) const {
65 return std::tie(quadruplet, ilayer, ipcb) < std::tie(o.quadruplet, o.ilayer, o.ipcb);
66 }
67
68 bool operator==(const pcbIdentifier_t& o) const {
69 return std::tie(quadruplet, ilayer, ipcb) == std::tie(o.quadruplet, o.ilayer, o.ipcb);
70 }
71 };
72
83 int ilayer{0};
84 int istrip{0};
85
86 bool operator<(const stripIdentifier_t& o) const {
87 return std::tie(quadruplet, ilayer, istrip) < std::tie(o.quadruplet, o.ilayer, o.istrip);
88 }
89 bool operator==(const stripIdentifier_t& o) const {
90 return std::tie(quadruplet, ilayer, istrip) == std::tie(o.quadruplet, o.ilayer, o.istrip);
91 }
92 };
93
94}
95
96
97// Define std::hash for the types above, to be able to use them is std::unordered_map
98// the hex value (0x9e3779b9) is just a trick to combine hash values
99namespace std {
100 template<> struct hash<NswAsBuilt::quadrupletIdentifier_t> {
101 std::size_t operator()(const NswAsBuilt::quadrupletIdentifier_t& v) const noexcept {
102 // Computing hash directly (avoid dependency to boost::hash_combine)
103 std::hash<int> hasher;
104 std::size_t h1 = hasher(v.stationName);
105 std::size_t h2 = hasher(v.stationEta);
106 std::size_t h3 = hasher(v.stationPhi);
107 std::size_t h4 = hasher(v.multilayer);
108 std::size_t ret = h1;
109 ret ^= h2 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
110 ret ^= h3 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
111 ret ^= h4 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
112 return ret;
113 }
114 };
115
116 template<> struct hash<NswAsBuilt::pcbIdentifier_t> {
117 std::size_t operator()(const NswAsBuilt::pcbIdentifier_t& v) const noexcept {
118 // Computing hash directly (avoid dependency to boost::hash_combine)
119 std::size_t h1 = std::hash<NswAsBuilt::quadrupletIdentifier_t>{}(v.quadruplet);
120 std::size_t h2 = std::hash<int>{}(v.ilayer);
121 std::size_t h3 = std::hash<int>{}(v.ipcb);
122 std::size_t ret = h1;
123 ret ^= h2 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
124 ret ^= h3 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
125 return ret;
126 }
127 };
128
129 template<> struct hash<NswAsBuilt::stripIdentifier_t> {
130 std::size_t operator()(const NswAsBuilt::stripIdentifier_t& v) const noexcept {
131 // Computing hash directly (avoid dependency to boost::hash_combine)
132 std::size_t h1 = std::hash<NswAsBuilt::quadrupletIdentifier_t>{}(v.quadruplet);
133 std::size_t h2 = std::hash<int>{}(v.ilayer);
134 std::size_t h3 = std::hash<int>{}(v.istrip);
135 std::size_t ret = h1;
136 ret ^= h2 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
137 ret ^= h3 + 0x9e3779b9 + (ret << 6) + (ret >> 2);
138 return ret;
139 }
140 };
141}
142
143#endif
144
STL namespace.
std::size_t operator()(const NswAsBuilt::pcbIdentifier_t &v) const noexcept
std::size_t operator()(const NswAsBuilt::quadrupletIdentifier_t &v) const noexcept
std::size_t operator()(const NswAsBuilt::stripIdentifier_t &v) const noexcept