ATLAS Offline Software
sTgcReadoutElement.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONREADOUTGEOMETRYR4_STGCREADOUTELEMENT_ICC
5 #define MUONREADOUTGEOMETRYR4_STGCREADOUTELEMENT_ICC
6 
7 
8 namespace ActsTrk{
9  template <> inline Amg::Transform3D
10  TransformCacheDetEle<MuonGMR4::sTgcReadoutElement>::fetchTransform(const DetectorAlignStore* store) const{
11  return m_parent->toStation(store) * m_parent->fromGapToChamOrigin(hash());
12  }
13 }
14 
15 
16 namespace MuonGMR4 {
17  namespace sTgcIdMeasHashFields {
18  constexpr unsigned int minusOne = -1;
19  /// Hash field layout
20  //// (wireInGrp) | (channel) [1-512] | IsWireInGrp (0,1) | (sTgcChannelType) [0-2] | (gasGap -1) [1-4]
21  constexpr unsigned int gasGapShift = 0;
22  constexpr unsigned int chTypeShift = 2;
23  constexpr unsigned int wireInGrpBit = chTypeShift+ 2;
24  constexpr unsigned int chanShift = chTypeShift + 3;
25  constexpr unsigned int wireInGrpShift = chanShift + 9;
26  }
27 
28 inline double sTgcReadoutElement::chamberHeight() const { return 2.* m_pars.halfChamberHeight; }
29 inline double sTgcReadoutElement::sChamberLength() const { return 2.* m_pars.sHalfChamberLength; }
30 inline double sTgcReadoutElement::lChamberLength() const { return 2.* m_pars.lHalfChamberLength; }
31 inline double sTgcReadoutElement::thickness() const { return 2.* m_pars.halfChamberTck; }
32 inline double sTgcReadoutElement::sFrameWidth() const { return m_pars.sFrameWidth; }
33 inline double sTgcReadoutElement::lFrameWidth() const { return m_pars.lFrameWidth; }
34 inline int sTgcReadoutElement::multilayer() const { return m_multiLayer; }
35 
36 inline unsigned int sTgcReadoutElement::numLayers() const { return m_pars.numLayers; }
37 inline unsigned int sTgcReadoutElement::nChTypes() const { return m_pars.nChTypes; }
38 inline double sTgcReadoutElement::gasGapThickness() const { return m_pars.gasTck; }
39 inline double sTgcReadoutElement::gasGapPitch() const { return m_gasGapPitch; }
40 
41 inline double sTgcReadoutElement::firstStripPitch(const IdentifierHash& measHash) const { return m_pars.firstStripPitch[gasGapNumber(measHash)]; }
42 inline double sTgcReadoutElement::firstStripPitch(const Identifier& measId) const { return firstStripPitch(measurementHash(measId)); }
43 
44 inline double sTgcReadoutElement::sGapLength(const Identifier& measId) const { return 2*stripDesign(measId).shortHalfHeight(); }
45 inline double sTgcReadoutElement::sGapLength(const IdentifierHash& measHash) const { return 2*stripDesign(measHash).shortHalfHeight(); }
46 inline double sTgcReadoutElement::lGapLength(const Identifier& measId) const { return 2*stripDesign(measId).longHalfHeight(); }
47 inline double sTgcReadoutElement::lGapLength(const IdentifierHash& measHash) const { return 2*stripDesign(measHash).longHalfHeight(); }
48 inline double sTgcReadoutElement::sPadLength(const Identifier& measId) const { return 2*padDesign(measId).shortHalfHeight(); }
49 inline double sTgcReadoutElement::sPadLength(const IdentifierHash& measHash) const { return 2*padDesign(measHash).shortHalfHeight(); }
50 inline double sTgcReadoutElement::lPadLength(const Identifier& measId) const { return 2*padDesign(measId).longHalfHeight(); }
51 inline double sTgcReadoutElement::lPadLength(const IdentifierHash& measHash) const { return 2*padDesign(measHash).longHalfHeight(); }
52 inline double sTgcReadoutElement::gapHeight(const Identifier& measId) const { return 2*stripDesign(measId).halfWidth(); }
53 inline double sTgcReadoutElement::gapHeight(const IdentifierHash& measHash) const { return 2*stripDesign(measHash).halfWidth(); }
54 inline double sTgcReadoutElement::yCutout(const Identifier& measId) const { return stripDesign(measId).yCutout(); }
55 inline double sTgcReadoutElement::yCutout(const IdentifierHash& measHash) const { return stripDesign(measHash).yCutout(); }
56 
57 inline unsigned int sTgcReadoutElement::numStrips(const Identifier& measId) const { return stripDesign(measId).numStrips(); }
58 inline unsigned int sTgcReadoutElement::numStrips(const IdentifierHash& measHash) const { return stripDesign(measHash).numStrips(); }
59 inline double sTgcReadoutElement::stripPitch(const Identifier& measId) const { return stripDesign(measId).stripPitch(); }
60 inline double sTgcReadoutElement::stripPitch(const IdentifierHash& measHash) const { return stripDesign(measHash).stripPitch(); }
61 inline double sTgcReadoutElement::stripWidth(const Identifier& measId) const { return stripDesign(measId).stripWidth(); }
62 inline double sTgcReadoutElement::stripWidth(const IdentifierHash& measHash) const { return stripDesign(measHash).stripWidth(); }
63 inline double sTgcReadoutElement::stripLength(const Identifier& measId) const { unsigned int channel = m_idHelper.channel(measId);
64  return stripDesign(measId).stripLength(channel); }
65 inline double sTgcReadoutElement::stripLength(const IdentifierHash& measHash) const { unsigned int channel = m_idHelper.channel(measurementId(measHash));
66  return stripDesign(measHash).stripLength(channel); }
67 
68 inline double sTgcReadoutElement::wirePitch(const Identifier& measId) const { return wireDesign(measId).stripPitch(); }
69 inline double sTgcReadoutElement::wirePitch(const IdentifierHash& measHash) const { return wireDesign(measHash).stripPitch(); }
70 inline double sTgcReadoutElement::wireWidth(const Identifier& measId) const { return wireDesign(measId).stripWidth(); }
71 inline double sTgcReadoutElement::wireWidth(const IdentifierHash& measHash) const { return wireDesign(measHash).stripWidth(); }
72 inline unsigned int sTgcReadoutElement::wireGroupWidth(unsigned int gasGap) const { return wireDesign(gasGap).numWiresInGroup(2); }
73 inline unsigned int sTgcReadoutElement::numWires(unsigned int gasGap) const {return wireDesign(gasGap).nAllWires();}
74 inline unsigned int sTgcReadoutElement::numWireGroups(unsigned int gasGap) const { return wireDesign(gasGap).numStrips();}
75 inline unsigned int sTgcReadoutElement::firstWireGroupWidth(unsigned int gasGap) const { return wireDesign(gasGap).numWiresInGroup(1); }
76 inline double sTgcReadoutElement::wireCutout(unsigned int gasGap) const { return wireDesign(gasGap).wireCutout(); }
77 
78 inline unsigned int sTgcReadoutElement::numPads(const Identifier& measId) const { return padDesign(measId).numPads(); }
79 inline unsigned int sTgcReadoutElement::numPads(const IdentifierHash& measHash) const { return padDesign(measHash).numPads(); }
80 inline unsigned int sTgcReadoutElement::numPadEta(const Identifier& measId) const { return padDesign(measId).numPadEta(); }
81 inline unsigned int sTgcReadoutElement::numPadEta(const IdentifierHash& measHash) const { return padDesign(measHash).numPadEta(); }
82 inline unsigned int sTgcReadoutElement::numPadPhi(const Identifier& measId) const { return padDesign(measId).numPadPhi(); }
83 inline unsigned int sTgcReadoutElement::numPadPhi(const IdentifierHash& measHash) const { return padDesign(measHash).numPadPhi(); }
84 inline double sTgcReadoutElement::firstPadHeight(const Identifier& measId) const { return padDesign(measId).firstPadHeight(); }
85 inline double sTgcReadoutElement::firstPadHeight(const IdentifierHash& measHash) const { return padDesign(measHash).firstPadHeight(); }
86 inline double sTgcReadoutElement::padHeight(const Identifier& measId) const { return padDesign(measId).padHeight(); }
87 inline double sTgcReadoutElement::padHeight(const IdentifierHash& measHash) const { return padDesign(measHash).padHeight(); }
88 inline double sTgcReadoutElement::padPhiShift(const Identifier& measId) const { return padDesign(measId).padPhiShift(); }
89 inline double sTgcReadoutElement::padPhiShift(const IdentifierHash& measHash) const { return padDesign(measHash).padPhiShift(); }
90 inline double sTgcReadoutElement::firstPadPhiDiv(const Identifier& measId) const { return padDesign(measId).firstPadPhiDiv(); }
91 inline double sTgcReadoutElement::firstPadPhiDiv(const IdentifierHash& measHash) const { return padDesign(measHash).firstPadPhiDiv(); }
92 inline double sTgcReadoutElement::anglePadPhi(const Identifier& measId) const { return padDesign(measId).anglePadPhi(); }
93 inline double sTgcReadoutElement::anglePadPhi(const IdentifierHash& measHash) const { return padDesign(measHash).anglePadPhi(); }
94 inline unsigned int sTgcReadoutElement::maxPadEta(const Identifier& measId) const { return padDesign(measId).anglePadPhi(); }
95 inline unsigned int sTgcReadoutElement::maxPadEta(const IdentifierHash& measHash) const { return padDesign(measHash).anglePadPhi(); }
96 inline unsigned int sTgcReadoutElement::padNumber(const Identifier& measId) const { return padNumber(measurementHash(measId)); }
97 inline unsigned int sTgcReadoutElement::padNumber(const IdentifierHash& measHash) const { return padDesign(measHash).padNumber(channelNumber(measHash)); }
98 inline std::pair<uint, uint> sTgcReadoutElement::padEtaPhi(const Identifier& measId) const { return padEtaPhi(measurementHash(measId)); }
99 inline std::pair<uint, uint> sTgcReadoutElement::padEtaPhi(const IdentifierHash& measHash) const { return padDesign(measHash).padEtaPhi(channelNumber(measHash)); }
100 inline unsigned int sTgcReadoutElement::padEta(const Identifier& measId) const { return padEta(measurementHash(measId)); }
101 inline unsigned int sTgcReadoutElement::padEta(const IdentifierHash& measHash) const { return padDesign(measHash).padEta(channelNumber(measHash)); }
102 inline unsigned int sTgcReadoutElement::padPhi(const Identifier& measId) const { return padPhi(measurementHash(measId)); }
103 inline unsigned int sTgcReadoutElement::padPhi(const IdentifierHash& measHash) const { return padDesign(measHash).padPhi(channelNumber(measHash)); }
104 inline double sTgcReadoutElement::beamlineRadius(const Identifier& measId) const { return padDesign(measId).beamlineRadius(); }
105 inline double sTgcReadoutElement::beamlineRadius(const IdentifierHash& measHash) const { return padDesign(measHash).beamlineRadius(); }
106 using localCornerArray = std::array<Amg::Vector2D, 4>;
107 inline localCornerArray sTgcReadoutElement::localPadCorners(const Identifier& measId) const { return localPadCorners(measurementHash(measId)); }
108 inline localCornerArray sTgcReadoutElement::localPadCorners(const IdentifierHash& measHash) const { return padDesign(measHash).padCorners(channelNumber(measHash)); }
109 using globalCornerArray = std::array<Amg::Vector3D, 4>;
110 inline globalCornerArray sTgcReadoutElement::globalPadCorners(const ActsGeometryContext& ctx, const Identifier& measId) const {
111  return globalPadCorners(ctx, measurementHash(measId));
112 }
113 
114 inline const StripDesign& sTgcReadoutElement::stripDesign(const Identifier& measId) const {
115  unsigned int gasGap = m_idHelper.gasGap(measId);
116  return m_pars.stripLayers[gasGap-1].design();
117  }
118 inline const StripDesign& sTgcReadoutElement::stripDesign(const IdentifierHash& measHash) const {
119  return stripDesign(measurementId(measHash));
120  }
121 inline const StripDesign& sTgcReadoutElement::stripDesign(unsigned int gasGap) const {
122  return m_pars.stripLayers[gasGap-1].design();
123  }
124 
125 inline const WireGroupDesign& sTgcReadoutElement::wireDesign(const Identifier& measId) const {
126  unsigned int gasGap = m_idHelper.gasGap(measId);
127  return static_cast<const WireGroupDesign&>(m_pars.wireGroupLayers[gasGap-1].design());
128  }
129 inline const WireGroupDesign& sTgcReadoutElement::wireDesign(const IdentifierHash& measHash) const {
130  return wireDesign(measurementId(measHash));
131  }
132 inline const WireGroupDesign& sTgcReadoutElement::wireDesign(unsigned int gasGap) const {
133  return static_cast<const WireGroupDesign&>(m_pars.wireGroupLayers[gasGap-1].design());
134  }
135 
136 inline const PadDesign& sTgcReadoutElement::padDesign(const Identifier& measId) const {
137  unsigned int gasGap = m_idHelper.gasGap(measId);
138  return static_cast<const PadDesign&>(m_pars.padLayers[gasGap-1].design());
139  }
140 inline const PadDesign& sTgcReadoutElement::padDesign(const IdentifierHash& measHash) const {
141  return padDesign(measurementId(measHash));
142  }
143 inline const PadDesign& sTgcReadoutElement::padDesign(unsigned int gasGap) const {
144  return static_cast<const PadDesign&>(m_pars.padLayers[gasGap-1].design());
145  }
146 
147 inline IdentifierHash sTgcReadoutElement::measurementHash(const Identifier& measId) const {
148  if (idHelperSvc()->detElId(measId) != identify()) {
149  ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
150  << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
151  }
152  return createHash(m_idHelper.gasGap(measId),
153  m_idHelper.channelType(measId),
154  m_idHelper.channel(measId));
155 }
156 inline IdentifierHash sTgcReadoutElement::createHash(const unsigned int gasGap,
157  const unsigned int channelType,
158  const unsigned int channel,
159  const unsigned int wireInGrp) {
160  using namespace sTgcIdMeasHashFields;
161  /// Construct the Hash such that (channel) | WireInGrpBit (0,1) | (channelType) | (gasGap -1)
162  if (channelType == ReadoutChannelType::WireInGrp) {
163  const unsigned int readOutHash = static_cast<unsigned int>(createHash(gasGap, ReadoutChannelType::Wire, channel));
164  return IdentifierHash {wireInGrp << wireInGrpShift | (1<<wireInGrpBit) | readOutHash};
165  }
166  return IdentifierHash{ channel << chanShift | channelType << chTypeShift | (gasGap -1) };
167 }
168 
169 inline IdentifierHash sTgcReadoutElement::layerHash(const IdentifierHash& measHash) {
170  using namespace sTgcIdMeasHashFields;
171  constexpr unsigned int mask = (minusOne << chanShift) | (1<<wireInGrpBit);
172  return IdentifierHash{static_cast<unsigned int>(measHash) & (~mask)};
173 }
174 
175 inline unsigned int sTgcReadoutElement::channelNumber(const IdentifierHash& measHash) {
176  using namespace sTgcIdMeasHashFields;
177  constexpr unsigned int mask = (minusOne << wireInGrpShift);
178  const unsigned int stripedHash = (~mask) & static_cast<unsigned int>(measHash);
179  return stripedHash >> chanShift;
180 }
181 inline unsigned int sTgcReadoutElement::chType(const IdentifierHash& measHash) {
182  using namespace sTgcIdMeasHashFields;
183  constexpr unsigned int mask = (minusOne << chanShift);
184  const unsigned int stripedHash = (~mask) & static_cast<unsigned int>(measHash);
185  return stripedHash >> chTypeShift;
186 
187 }
188 inline unsigned int sTgcReadoutElement::gasGapNumber(const IdentifierHash& measHash) {
189  using namespace sTgcIdMeasHashFields;
190  constexpr unsigned int mask = (minusOne << chTypeShift);
191  return (static_cast<unsigned int>(measHash) &(~mask) );
192 }
193 inline Identifier sTgcReadoutElement::measurementId(const IdentifierHash& measHash) const {
194  return m_idHelper.channelID(identify(), multilayer(), gasGapNumber(measHash) + 1, chType(measHash), channelNumber(measHash));
195 }
196 inline IdentifierHash sTgcReadoutElement::layerHash(const Identifier& measId) const {
197  if (m_idHelper.elementID(measId) != m_idHelper.elementID(identify()) ) {
198  ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
199  << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
200  }
201  return createHash(m_idHelper.gasGap(measId), m_idHelper.channelType(measId), 0);
202 }
203 
204 inline Amg::Vector2D sTgcReadoutElement::localChannelPosition(const Identifier& measId) const {
205  return localChannelPosition(measurementHash(measId)); }
206 
207 inline Amg::Vector3D sTgcReadoutElement::globalChannelPosition(const ActsGeometryContext& ctx, const Identifier& measId) const {
208  return globalChannelPosition(ctx, measurementHash(measId));
209 }
210 
211 inline const StripLayer& sTgcReadoutElement::stripLayer(const IdentifierHash& measHash) const {
212  unsigned int gasGap = gasGapNumber(measHash);
213  return m_pars.stripLayers[gasGap];
214 }
215 inline const StripLayer& sTgcReadoutElement::stripLayer(const Identifier& measId) const {
216  return stripLayer(measurementHash(measId));
217 }
218 inline int sTgcReadoutElement::padNumber(const Amg::Vector2D& hitPos, const Identifier& measId) const {
219  return padNumber(hitPos, measurementHash(measId));
220 }
221 
222 } // namespace MuonGMR4
223 #endif