ATLAS Offline Software
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 
10 namespace 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 
26  enum StationName {
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 
59  struct pcbIdentifier_t {
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
99 namespace 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 
NswAsBuilt::stripIdentifier_t::operator<
bool operator<(const stripIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:86
NswAsBuilt::stripIdentifier_t::quadruplet
quadrupletIdentifier_t quadruplet
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:82
NswAsBuilt::quadrupletIdentifier_t::operator<
bool operator<(const quadrupletIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:43
NswAsBuilt::quadrupletIdentifier_t::stationEta
int stationEta
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:34
NswAsBuilt::quadrupletIdentifier_t::StationName
StationName
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:26
NswAsBuilt::quadrupletIdentifier_t::STS
@ STS
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:29
NswAsBuilt::quadrupletIdentifier_t::stationNameStr
std::string stationNameStr() const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:38
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
std::hash< NswAsBuilt::quadrupletIdentifier_t >
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:100
NswAsBuilt::pcbIdentifier_t
The indices of a MM PCB.
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:59
std::hash< NswAsBuilt::stripIdentifier_t >::operator()
std::size_t operator()(const NswAsBuilt::stripIdentifier_t &v) const noexcept
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:130
NswAsBuilt::quadrupletIdentifier_t::stationName
StationName stationName
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:33
NswAsBuilt::quadrupletIdentifier_t::multilayer
int multilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:36
NswAsBuilt::pcbIdentifier_t::quadruplet
quadrupletIdentifier_t quadruplet
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:60
NswAsBuilt::stripIdentifier_t
Athena indices of a MM strip.
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:81
NswAsBuilt::quadrupletIdentifier_t
Athena indices for a MM quadruplet:
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:25
NswAsBuilt::quadrupletIdentifier_t::MML
@ MML
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:28
NswAsBuilt::quadrupletIdentifier_t::operator==
bool operator==(const quadrupletIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:47
std::hash< NswAsBuilt::pcbIdentifier_t >::operator()
std::size_t operator()(const NswAsBuilt::pcbIdentifier_t &v) const noexcept
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:117
NswAsBuilt::pcbIdentifier_t::operator==
bool operator==(const pcbIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:68
NswAsBuilt::pcbIdentifier_t::ipcb
int ipcb
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:62
NswAsBuilt::stripIdentifier_t::operator==
bool operator==(const stripIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:89
python.PyAthena.v
v
Definition: PyAthena.py:154
NswAsBuilt::stripIdentifier_t::ilayer
int ilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:83
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
NswAsBuilt::quadrupletIdentifier_t::MMS
@ MMS
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:27
NswAsBuilt::stripIdentifier_t::istrip
int istrip
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:84
NswAsBuilt::quadrupletIdentifier_t::STL
@ STL
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:30
NswAsBuilt
Definition: CathodeBoardElement.h:12
NswAsBuilt::pcbIdentifier_t::ilayer
int ilayer
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:61
std::hash< NswAsBuilt::quadrupletIdentifier_t >::operator()
std::size_t operator()(const NswAsBuilt::quadrupletIdentifier_t &v) const noexcept
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:101
NswAsBuilt::quadrupletIdentifier_t::stationPhi
int stationPhi
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:35
NswAsBuilt::pcbIdentifier_t::operator<
bool operator<(const pcbIdentifier_t &o) const
Definition: MuonSpectrometer/MuonDetDescr/MuonNSWAsBuilt/MuonNSWAsBuilt/Identifier.h:64