ATLAS Offline Software
MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MdtReadoutElement.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONREADOUTGEOMETRY_MDTREADOUTELEMENT_ICC
6 #define MUONREADOUTGEOMETRY_MDTREADOUTELEMENT_ICC
7 
8 #ifndef NDEBUG
9 #define CHECK_IDVALID(ID) \
10  {if (idHelperSvc()->detElId(ID) != identify()) {\
11  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- The detector element "<<idHelperSvc()->toStringDetEl(identify())<<" is not suited for measurement " \
12  <<idHelperSvc()->toString(ID)); \
13  throw std::runtime_error("Wrong detector element"); \
14  } \
15  const int tube{m_idHelper.tube(ID)}, layer{m_idHelper.tubeLayer(ID)}; \
16  if (tube < 1 || tube > m_ntubesperlayer) { \
17  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- Invalid tube "<<tube<<" was given. Allowed 1-"<<m_ntubesperlayer); \
18  throw std::runtime_error("Tube is out of range"); \
19  } \
20  if (layer <1 || layer > m_nlayers) { \
21  ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<"() -- Invalid layer "<<layer<<" was given. Allowed 1-"<<m_ntubesperlayer); \
22  throw std::runtime_error("Layer is out of range"); \
23  }}
24 #else
25 #define CHECK_IDVALID(ID) \
26  {}
27 #endif
28 namespace MuonGM {
29  inline const Amg::Transform3D& MdtReadoutElement::transform() const { return absTransform(); }
30  inline const Amg::Vector3D& MdtReadoutElement::normal(const Identifier&) const {return normal();}
31  inline bool MdtReadoutElement::barrel() const { return m_inBarrel;}
32  inline bool MdtReadoutElement::endcap() const { return !barrel(); }
33  inline double MdtReadoutElement::innerTubeRadius() const { return m_innerRadius; }
34  inline double MdtReadoutElement::outerTubeRadius() const { return m_innerRadius + m_tubeWallThickness; }
35 
36 
37  inline int MdtReadoutElement::getMultilayer() const { return m_multilayer; }
38  inline int MdtReadoutElement::getNLayers() const { return m_nlayers; }
39  inline int MdtReadoutElement::getNtubesperlayer() const { return m_ntubesperlayer; }
40  inline int MdtReadoutElement::getNtubesinastep() const { return m_ntubesinastep; }
41  inline double MdtReadoutElement::tubePitch() const { return m_tubepitch; }
42  inline double MdtReadoutElement::getWireLength(const int tubeLayer, const int tube) const {
43  return tubeLength(tubeLayer, tube) - 2. * m_endpluglength;
44  }
45  inline double MdtReadoutElement::tubeLength(const int tubeLayer, const int tube) const {
46  return getActiveTubeLength(tubeLayer, tube) + 2. * m_deadlength;
47  }
48  inline double MdtReadoutElement::getActiveTubeLength(const int tubeLayer, const int tube) const {
49  return 2. * (bounds(tubeLayer, tube).halflengthZ());
50  }
51  inline const Amg::Transform3D& MdtReadoutElement::transform(const Identifier& id) const {
52  CHECK_IDVALID(id);
53  return transform(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
54  }
55  inline Amg::Transform3D MdtReadoutElement::globalToLocalTransf(const Identifier& id) const {
56  return transform(id).inverse();
57  }
58 
59  //// <Global <--> Local transformation without deformations
60  inline Amg::Transform3D MdtReadoutElement::nodeform_localToGlobalTransf(const Identifier& id) const {
61  CHECK_IDVALID(id);
62  return nodeform_localToGlobalTransf(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
63  }
64  inline Amg::Transform3D MdtReadoutElement::nodeform_globalToLocalTransf(const Identifier& id) const {
65  return nodeform_localToGlobalTransf(id).inverse();
66  }
67  inline const Amg::Transform3D& MdtReadoutElement::localToGlobalTransf(const Identifier&id) const {
68  CHECK_IDVALID(id);
69  return localToGlobalTransf(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
70  }
71  inline const Amg::Transform3D& MdtReadoutElement::localToGlobalTransf(int tubeLayer, int tube) const {
72  return transform(tubeLayer, tube);
73  }
74 
75 
76 
77  inline Amg::Transform3D MdtReadoutElement::tubeToMultilayerTransf(const Identifier& id) const {
78  CHECK_IDVALID(id);
79  return tubeToMultilayerTransf(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
80  }
81  inline double MdtReadoutElement::tubeLength(const Identifier& id) const {
82  CHECK_IDVALID(id);
83  return tubeLength(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
84  }
85  inline double MdtReadoutElement::RODistanceFromTubeCentre(const Identifier& id) const {
86  CHECK_IDVALID(id);
87  return RODistanceFromTubeCentre(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
88  }
89  inline double MdtReadoutElement::signedRODistanceFromTubeCentre(const Identifier& id) const {
90  CHECK_IDVALID(id);
91  return signedRODistanceFromTubeCentre(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
92  }
93  inline Amg::Vector3D MdtReadoutElement::tubeFrame_localROPos(const Identifier& id) const {
94  CHECK_IDVALID(id);
95  return tubeFrame_localROPos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
96  }
97  inline Amg::Vector3D MdtReadoutElement::localROPos(const Identifier& id) const {
98  CHECK_IDVALID(id);
99  const int tubeLayer = m_idHelper.tubeLayer(id);
100  const int tube = m_idHelper.tube(id);
101  return tubeToMultilayerTransf(tubeLayer, tube) * tubeFrame_localROPos(tubeLayer, tube);
102  }
103  inline Amg::Vector3D MdtReadoutElement::ROPos(const Identifier& id) const {
104  CHECK_IDVALID(id);
105  return ROPos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
106  }
107  inline Amg::Vector3D MdtReadoutElement::localTubePos(const Identifier& id) const {
108  CHECK_IDVALID(id);
109  return localTubePos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
110  }
111  inline Amg::Vector3D MdtReadoutElement::nodeform_localTubePos(const Identifier& id) const {
112  CHECK_IDVALID(id);
113  return nodeform_localTubePos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
114  }
115  inline Amg::Vector3D MdtReadoutElement::nodeform_tubePos(const Identifier& id) const {
116  CHECK_IDVALID(id);
117  return nodeform_tubePos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
118  }
119  inline Amg::Vector3D MdtReadoutElement::tubePos(const Identifier& id) const {
120  CHECK_IDVALID(id);
121  return tubePos(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
122  }
123  inline double MdtReadoutElement::distanceFromRO(const Amg::Vector3D& x, const Identifier& id) const {
124  CHECK_IDVALID(id);
125  return distanceFromRO(x, m_idHelper.tubeLayer(id), m_idHelper.tube(id));
126  }
127  inline int MdtReadoutElement::isAtReadoutSide(const Amg::Vector3D& GlobalHitPosition, const Identifier& id) const {
128  CHECK_IDVALID(id);
129  return isAtReadoutSide(GlobalHitPosition, m_idHelper.tubeLayer(id), m_idHelper.tube(id));
130  }
131  inline const Trk::SaggedLineSurface& MdtReadoutElement::surface(const Identifier& id) const {
132  CHECK_IDVALID(id);
133  return surface(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
134  }
135  inline const Trk::CylinderBounds& MdtReadoutElement::bounds(const Identifier& id) const {
136  CHECK_IDVALID(id);
137  return bounds(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
138  }
139  inline const Amg::Vector3D& MdtReadoutElement::center(const Identifier& id) const {
140  CHECK_IDVALID(id);
141  return center(m_idHelper.tubeLayer(id), m_idHelper.tube(id));
142  }
143 }
144 #undef CHECK_IDVALID
145 #endif // MUONREADOUTGEOMETRY_MDTREADOUTELEMENT_H