ATLAS Offline Software
MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MdtReadoutElement.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_MDTREADOUTELEMENT_ICC
5 #define MUONREADOUTGEOMETRYR4_MDTREADOUTELEMENT_ICC
6 
7 #include <GaudiKernel/SystemOfUnits.h>
8 namespace 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(0,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) * m_parent->toTubeFrame(hash());
21  }
22 }
23 
24 namespace MuonGMR4 {
25 inline unsigned int MdtReadoutElement::multilayer() const { return m_stML; }
26 inline unsigned int MdtReadoutElement::numLayers() const { return m_pars.tubeLayers.size(); }
27 inline unsigned int MdtReadoutElement::numTubesInLay() const { return m_pars.tubeLayers.empty() ? 0 : m_pars.tubeLayers[0]->nTubes(); }
28 inline double MdtReadoutElement::innerTubeRadius() const {return m_pars.tubeInnerRad;}
29 inline double MdtReadoutElement::tubeRadius() const {return innerTubeRadius() + m_pars.tubeWall;}
30 inline double MdtReadoutElement::tubePitch() const { return m_pars.tubePitch;}
31 inline double MdtReadoutElement::thickness() const {return 2.* m_pars.halfHeight;}
32 inline double MdtReadoutElement::moduleWidthS() const{ return 2.*m_pars.shortHalfX; }
33 inline double MdtReadoutElement::moduleWidthL() const{ return 2.*m_pars.longHalfX; }
34 inline double MdtReadoutElement::moduleHeight() const{ return 2.*m_pars.halfY; }
35 inline double MdtReadoutElement::moduleThickness() const{ return 2.*m_pars.halfHeight; }
36 
37 inline bool MdtReadoutElement::isValid(const IdentifierHash& measHash) const {
38  return layerNumber(measHash) < numLayers() &&
39  tubeNumber(measHash) < numTubesInLay() &&
40  !m_pars.removedTubes.count(measHash);
41 }
42 inline IdentifierHash MdtReadoutElement::measurementHash(const Identifier& measId) const {
43  if (idHelperSvc()->detElId(measId) != identify()) {
44  ATH_MSG_WARNING("The measurement "
45  << idHelperSvc()->toString(measId)
46  << " picks the wrong readout element "
47  << idHelperSvc()->toStringDetEl(identify()));
48  }
49  IdentifierHash hash = measurementHash(m_idHelper.tubeLayer(measId),
50  m_idHelper.tube(measId));
51  ATH_MSG_VERBOSE("Translate measurement identifier "
52  << idHelperSvc()->toString(measId)
53  << " to measurement hash " << static_cast<int>(hash));
54  return hash;
55 }
56 inline IdentifierHash MdtReadoutElement::layerHash(const Identifier& measId) const {
57  if (idHelperSvc()->detElId(measId) != identify()) {
58  ATH_MSG_WARNING("The measurement "
59  << idHelperSvc()->toString(measId)
60  << " picks the wrong readout element "
61  << idHelperSvc()->toStringDetEl(identify()));
62  }
63  IdentifierHash hash = measurementHash(m_idHelper.tubeLayer(measId), 0);
64  ATH_MSG_VERBOSE("Translate measurement identifier "
65  << idHelperSvc()->toString(measId)
66  << " to layer hash hash " << static_cast<int>(hash));
67  return hash;
68 }
69 inline unsigned int MdtReadoutElement::tubeNumber(const IdentifierHash& hash) {
70  return (static_cast<unsigned int>(hash) >> 16);
71 }
72 /// Transforms the identifier hash into a layer number ranging from
73 /// (0-numLayers()-1)
74 inline unsigned int MdtReadoutElement::layerNumber(const IdentifierHash& hash) {
75  constexpr uint16_t layMask = (~0);
76  return static_cast<unsigned int>(hash) & layMask;
77 }
78 inline IdentifierHash MdtReadoutElement::measurementHash(unsigned int layer, unsigned int tube) {
79  return IdentifierHash{( (tube-1) << 16) | (layer-1)};
80 }
81 inline IdentifierHash MdtReadoutElement::layerHash(const IdentifierHash& measHash) {
82  return measurementHash(layerNumber(measHash) + 1 , 0);
83 }
84 inline bool MdtReadoutElement::isBarrel() const { return m_isBarrel; }
85 
86 
87 inline Amg::Vector3D MdtReadoutElement::globalTubePos(const ActsGeometryContext& ctx,
88  const Identifier& measId) const {
89  return globalTubePos(ctx, measurementHash(measId));
90 }
91 inline Amg::Vector3D MdtReadoutElement::readOutPos(const ActsGeometryContext& ctx,
92  const Identifier& measId) const{
93  return readOutPos(ctx, measurementHash(measId));
94 }
95 inline Amg::Vector3D MdtReadoutElement::highVoltPos(const ActsGeometryContext& ctx,
96  const Identifier& measId) const {
97  return highVoltPos(ctx, measurementHash(measId));
98 }
99 inline double MdtReadoutElement::distanceToReadout(const ActsGeometryContext& ctx,
100  const Identifier& measId,
101  const Amg::Vector3D& globPoint) const {
102  return distanceToReadout(ctx,measurementHash(measId), globPoint);
103 }
104 
105 
106 } // namespace MuonGMR4
107 #endif