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