ATLAS Offline Software
Loading...
Searching...
No Matches
MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONREADOUTGEOMETRYR4_MDTREADOUTELEMENT_ICC
5#define MUONREADOUTGEOMETRYR4_MDTREADOUTELEMENT_ICC
6
7#include <GaudiKernel/SystemOfUnits.h>
8namespace ActsTrk{
9 template <> inline Amg::Transform3D
10 TransformCacheDetEle<MuonGMR4::MdtReadoutElement>::fetchTransform(const DetectorAlignStore* store) const {
11 using RE = MuonGMR4::MdtReadoutElement;
12 static const unsigned int layerTube = RE::tubeNumber(RE::measurementHash(1, 0));
13 /// Check whether the hash represents a tube or the central layer
14 const unsigned int tubeNum = m_parent->tubeNumber(hash());
15 if (tubeNum == layerTube) {
16 const Amg::Translation3D toCenter{0.5*m_parent->moduleHeight() * Amg::Vector3D::UnitY()};
17 return m_parent->toStation(store) * m_parent->toChamberLayer(hash()) *
18 toCenter * Amg::getRotateY3D(90*Gaudi::Units::deg);
19 }
20 return m_parent->toStation(store) *
21 m_parent->fromIdealToDeformed(hash(), store) * m_parent->toTubeFrame(hash());
22 }
23 template <> inline Identifier
24 TransformCacheDetEle<MuonGMR4::MdtReadoutElement>::identify() const {
25 using RE = MuonGMR4::MdtReadoutElement;
26 static const unsigned int layerTube = RE::tubeNumber(RE::measurementHash(0,0));
27 /// Check whether the hash represents a tube or the central layer
28 const unsigned int tubeNum = m_parent->tubeNumber(hash());
29 if (tubeNum == layerTube) {
30 return m_parent->measurementId(RE::measurementHash(RE::layerNumber(hash()) +1,
31 m_parent->numTubesInLay() +1));
32 }
33 return m_parent->measurementId(hash());
34 }
35}
36
37namespace MuonGMR4 {
38inline unsigned int MdtReadoutElement::multilayer() const { return m_stML; }
39inline unsigned int MdtReadoutElement::numLayers() const { return m_pars.tubeLayers.size(); }
40inline unsigned int MdtReadoutElement::numTubesInLay() const { return m_pars.tubeLayers.empty() ? 0 : m_pars.tubeLayers[0]->nTubes(); }
41inline double MdtReadoutElement::innerTubeRadius() const {return m_pars.tubeInnerRad;}
42inline double MdtReadoutElement::tubeRadius() const {return innerTubeRadius() + m_pars.tubeWall;}
43inline double MdtReadoutElement::tubePitch() const { return m_pars.tubePitch;}
44inline double MdtReadoutElement::thickness() const {return 2.* m_pars.halfHeight;}
45inline double MdtReadoutElement::moduleWidthS() const{ return 2.*m_pars.shortHalfX; }
46inline double MdtReadoutElement::moduleWidthL() const{ return 2.*m_pars.longHalfX; }
47inline double MdtReadoutElement::moduleHeight() const{ return 2.*m_pars.halfY; }
48inline double MdtReadoutElement::moduleThickness() const{ return 2.*m_pars.halfHeight; }
49inline const MdtReadoutElement* MdtReadoutElement::complementaryRE() const { return m_reOtherMl; }
50inline bool MdtReadoutElement::isValid(const IdentifierHash& measHash) const {
51 return layerNumber(measHash) < numLayers() &&
52 tubeNumber(measHash) < numTubesInLay() &&
53 !m_pars.removedTubes.count(measHash);
54}
55inline IdentifierHash MdtReadoutElement::measurementHash(const Identifier& measId) const {
56 if (idHelperSvc()->detElId(measId) != identify()) {
57 ATH_MSG_WARNING("The measurement "
58 << idHelperSvc()->toString(measId)
59 << " picks the wrong readout element "
60 << idHelperSvc()->toStringDetEl(identify()));
61 }
62 IdentifierHash hash = measurementHash(m_idHelper.tubeLayer(measId),
63 m_idHelper.tube(measId));
64 ATH_MSG_VERBOSE("Translate measurement identifier "
65 << idHelperSvc()->toString(measId)
66 << " to measurement hash " << static_cast<int>(hash));
67 return hash;
68}
69inline IdentifierHash MdtReadoutElement::layerHash(const Identifier& measId) const {
70 if (idHelperSvc()->detElId(measId) != identify()) {
71 ATH_MSG_WARNING("The measurement "
72 << idHelperSvc()->toString(measId)
73 << " picks the wrong readout element "
74 << idHelperSvc()->toStringDetEl(identify()));
75 }
76 IdentifierHash hash = measurementHash(m_idHelper.tubeLayer(measId), 0);
77 ATH_MSG_VERBOSE("Translate measurement identifier "
78 << idHelperSvc()->toString(measId)
79 << " to layer hash hash " << static_cast<int>(hash));
80 return hash;
81}
82inline unsigned int MdtReadoutElement::tubeNumber(const IdentifierHash& hash) {
83 return (static_cast<unsigned int>(hash) >> 16);
84}
85/// Transforms the identifier hash into a layer number ranging from
86/// (0-numLayers()-1)
87inline unsigned int MdtReadoutElement::layerNumber(const IdentifierHash& hash) {
88 constexpr uint16_t layMask = (~0);
89 return static_cast<unsigned int>(hash) & layMask;
90}
91inline IdentifierHash MdtReadoutElement::measurementHash(unsigned int layer, unsigned int tube) {
92 return IdentifierHash{( (tube-1) << 16) | (layer-1)};
93}
94inline IdentifierHash MdtReadoutElement::layerHash(const IdentifierHash& measHash) {
95 return measurementHash(layerNumber(measHash) + 1 , 0);
96}
97inline bool MdtReadoutElement::isBarrel() const { return m_isBarrel; }
98
99
100inline Amg::Vector3D MdtReadoutElement::globalTubePos(const ActsTrk::GeometryContext& ctx,
101 const Identifier& measId) const {
102 return globalTubePos(ctx, measurementHash(measId));
103}
104inline Amg::Vector3D MdtReadoutElement::readOutPos(const ActsTrk::GeometryContext& ctx,
105 const Identifier& measId) const{
106 return readOutPos(ctx, measurementHash(measId));
107}
108inline Amg::Vector3D MdtReadoutElement::highVoltPos(const ActsTrk::GeometryContext& ctx,
109 const Identifier& measId) const {
110 return highVoltPos(ctx, measurementHash(measId));
111}
112inline double MdtReadoutElement::distanceToReadout(const ActsTrk::GeometryContext& ctx,
113 const Identifier& measId,
114 const Amg::Vector3D& globPoint) const {
115 return distanceToReadout(ctx,measurementHash(measId), globPoint);
116}
117
118
119} // namespace MuonGMR4
120#endif