ATLAS Offline Software
MmReadoutElement.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_MMREADOUTELEMENT_ICC
5 #define MUONREADOUTGEOMETRYR4_MMREADOUTELEMENT_ICC
6 
7 namespace ActsTrk{
8  template <> inline Amg::Transform3D
9  TransformCacheDetEle<MuonGMR4::MmReadoutElement>::fetchTransform(const DetectorAlignStore* store) const {
10  return m_parent->toStation(store) * m_parent->fromGapToChamOrigin(hash());
11  }
12 
13 }
14 namespace MuonGMR4 {
15 
16 inline double MmReadoutElement::thickness() const { return 2.* m_pars.halfThickness; }
17 inline int MmReadoutElement::multilayer() const{ return m_multilayer; }
18 inline double MmReadoutElement::moduleHeight() const { return 2.*m_pars.halfHeight; }
19 inline double MmReadoutElement::moduleWidthS() const { return 2.*m_pars.halfShortWidth; }
20 inline double MmReadoutElement::moduleWidthL() const { return 2.*m_pars.halfLongWidth; }
21 inline double MmReadoutElement::moduleThickness() const { return 2.*m_pars.halfThickness; }
22 inline double MmReadoutElement::gapLengthS(const IdentifierHash& hash) const { return 2.*stripLayer(hash).design().shortHalfHeight(); }
23 inline double MmReadoutElement::gapLengthL(const IdentifierHash& hash) const { return 2.*stripLayer(hash).design().longHalfHeight();}
24 inline double MmReadoutElement::gapHeight(const IdentifierHash& hash) const { return 2.*stripLayer(hash).design().halfWidth();}
25 inline int MmReadoutElement::readoutSide(const IdentifierHash& measHash) const {
26  return m_pars.readoutSide[static_cast<unsigned>(layerHash(measHash))];
27 }
28 inline unsigned int MmReadoutElement::nGasGaps() const { return m_pars.layers.size(); }
29 inline unsigned int MmReadoutElement::numStrips(const IdentifierHash& hash) const {
30  return stripLayer(hash).design().numStrips();
31  }
32 inline unsigned int MmReadoutElement::firstStrip(const IdentifierHash& hash) const {
33  return stripLayer(hash).design().firstStripNumber();
34  }
35 inline double MmReadoutElement::stripLength(const IdentifierHash& hash) const {
36  return stripLayer(hash).design().stripLength(stripNumber(hash));
37 }
38 
39 
40 inline IdentifierHash MmReadoutElement::createHash(const int gasGap, const int strip) {
41  /*gasGap can be 1 to 4. So we make sure it contributes to the lower 4 bits. (Bit shifting begins from left to right).
42  Then we shift the bit position to the left by 4 positions and allocate the strip binary expression.
43  (gasGap-1) --> is the binary representation of the gasGap.
44  strip --> is the binary representation of the strip.
45  */
46  IdentifierHash hash = strip << 4 | (gasGap - 1);
47  return hash;
48 }
49 
50 inline IdentifierHash MmReadoutElement::measurementHash(const Identifier& measId) const {
51  if (m_idHelper.elementID(measId) != m_idHelper.elementID(identify()) ) {
52  ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
53  << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
54  }
55  return createHash(m_idHelper.gasGap(measId), m_idHelper.channel(measId));
56 }
57 
58 inline IdentifierHash MmReadoutElement::layerHash(const Identifier& measId) const {
59  if (m_idHelper.elementID(measId) != m_idHelper.elementID(identify()) ) {
60  ATH_MSG_WARNING("The measurement " << idHelperSvc()->toString(measId)
61  << " picks the wrong readout element " << idHelperSvc()->toStringDetEl(identify()));
62  }
63  return createHash(m_idHelper.gasGap(measId), 0);
64 }
65 
66 inline IdentifierHash MmReadoutElement::layerHash(const IdentifierHash& measHash) const {
67  //measHash & 0xF will extract the gasGap number from 0 to 3, which is what you need based on
68  // the fact that you createHash through :
69  //IdentifierHash hash = (gasGap - 1) | strip << 4;
70  return IdentifierHash{static_cast<unsigned int>((measHash & 0xF))};
71 }
72 
73 
74 inline Identifier MmReadoutElement::measurementId(const IdentifierHash& measHash) const {
75  return m_idHelper.channelID(identify(),multilayer(), gasGapNumber(measHash), stripNumber(measHash));
76 }
77 
78 // Extract the gas gap number from the lower 4 bits of the hash
79 inline unsigned int MmReadoutElement::gasGapNumber(const IdentifierHash& measHash) {
80  return (measHash & 0xF) + 1;
81 }
82 
83 // Extract the strip number from the remaining bits after removing the gas gap bits
84 inline unsigned int MmReadoutElement::stripNumber(const IdentifierHash& measHash) {
85  // Right shift by 4 to get rid of the lower 4 bits (gas gap bits).
86  return (measHash >> 4);
87 }
88 
89 inline const StripLayer& MmReadoutElement::stripLayer(const IdentifierHash& measHash) const {
90  return *m_pars.layers.at(static_cast<unsigned int>(layerHash(measHash)));
91 }
92 
93 inline const StripLayer& MmReadoutElement::stripLayer(const Identifier& measId) const {
94  return stripLayer(measurementHash(measId));
95 }
96 
97 
98 
99 inline Amg::Vector3D MmReadoutElement::stripPosition(const ActsGeometryContext& ctx, const Identifier& measId) const {
100  return stripPosition(ctx, measurementHash(measId));
101 }
102 
103 inline Amg::Vector3D MmReadoutElement::leftStripEdge(const ActsGeometryContext& ctx, const Identifier& measId) const{
104  return leftStripEdge(ctx, measurementHash(measId));
105 }
106 
107 inline Amg::Vector3D MmReadoutElement::rightStripEdge(const ActsGeometryContext& ctx, const Identifier& measId) const{
108  return rightStripEdge(ctx, measurementHash(measId));
109 }
110 
111 
112 } // namespace MuonGMR4
113 #endif