ATLAS Offline Software
Loading...
Searching...
No Matches
MuonClusterReadoutElement.h
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_MUONCLUSTERREADOUTELEMENT_H
6#define MUONREADOUTGEOMETRY_MUONCLUSTERREADOUTELEMENT_H
7
8
9#include <stdexcept>
10#include <string>
11#include <vector>
12
16
17namespace MuonGM {
18
20
22 public:
24 struct SurfaceData {
26 std::vector<Amg::Vector3D> m_layerNormals{};
27
29 std::vector<std::unique_ptr<Trk::SurfaceBounds>> m_surfBounds{};
30
33 std::vector<Amg::Transform3D> m_layerTransforms{};
34
37 std::vector<std::unique_ptr<Trk::PlaneSurface>> m_layerSurfaces{};
38
40 std::vector<Amg::Vector3D> m_layerCenters{};
41
42 SurfaceData() = default;
43 ~SurfaceData() = default;
44 };
45
46
48
51 virtual double distanceToReadout(const Amg::Vector2D& pos, const Identifier& id) const = 0;
52
55 virtual int stripNumber(const Amg::Vector2D& pos, const Identifier& id) const = 0;
56
59 virtual bool stripPosition(const Identifier& id, Amg::Vector2D& pos) const = 0;
60
64 virtual bool spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector2D& pos) const = 0;
65
68 virtual bool spacePointPosition(const Identifier& phiId, const Identifier& etaId, Amg::Vector3D& pos) const = 0;
69
71 virtual int numberOfLayers(bool measuresPhi) const = 0;
72
74 virtual int numberOfStrips(const Identifier& layerId) const = 0;
75 virtual int numberOfStrips(int layer, bool measuresPhi) const = 0;
76
78 virtual void clearCache() override final;
79
81 virtual const Trk::PlaneSurface& surface() const override;
82 virtual const Trk::SurfaceBounds& bounds() const override;
83 virtual const Amg::Vector3D& center() const override;
84 virtual const Amg::Vector3D& normal() const override;
85 virtual const Amg::Transform3D& transform() const override;
86
88 virtual const Trk::PlaneSurface& surface(const Identifier& id) const override;
89 virtual const Trk::SurfaceBounds& bounds(const Identifier& id) const override;
90 virtual const Amg::Vector3D& center(const Identifier& id) const override;
91 virtual const Amg::Vector3D& normal(const Identifier& id) const override;
92 virtual const Amg::Transform3D& transform(const Identifier& id) const override;
93
95 const Trk::PlaneSurface& surface(int surfHash) const;
96 const Trk::SurfaceBounds& bounds(int boundHash) const;
97 const Amg::Vector3D& center(int layHash) const;
98 const Amg::Vector3D& normal(int layHash) const;
99 const Amg::Transform3D& transform(int surfHash) const;
100
102 virtual std::vector<const Trk::Surface*> surfaces() const;
103
105 virtual int layerHash(const Identifier& id) const = 0;
106
108 virtual int surfaceHash(const Identifier& id) const = 0;
109
111 virtual int boundaryHash(const Identifier& id) const = 0;
112
114 virtual bool measuresPhi(const Identifier& id) const = 0;
115
116 protected:
117
118 MuonClusterReadoutElement(GeoVFullPhysVol* pv, MuonDetectorManager* mgr, Trk::DetectorElemType detType);
119
121 };
122
125 inline const Amg::Vector3D& MuonClusterReadoutElement::center() const { return center(0); }
126 inline const Amg::Vector3D& MuonClusterReadoutElement::normal() const { return normal(0); }
128
131 inline const Amg::Vector3D& MuonClusterReadoutElement::center(const Identifier& id) const { return center(layerHash(id)); }
132 inline const Amg::Vector3D& MuonClusterReadoutElement::normal(const Identifier& id) const { return normal(layerHash(id)); }
134
136 if (!m_surfaceData) {
137 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Requesting surface but cache is empty");
138 throw std::runtime_error("Empty surface cache");
139 }
140 if (hash == -1 || hash >= (int)m_surfaceData->m_layerSurfaces.size()) {
141 ATH_MSG_WARNING(" surface hash out of range: " << hash << " elements "
142 << m_surfaceData->m_layerSurfaces.size());
143 return *m_surfaceData->m_layerSurfaces.front();
144 }
145 return *m_surfaceData->m_layerSurfaces[hash];
146 }
147
149 if (!m_surfaceData) {
150 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Requesting transform but cache is empty");
151 throw std::runtime_error("Empty transform cache");
152 }
153 if (hash == -1 || hash >= (int)m_surfaceData->m_layerTransforms.size()) {
154 ATH_MSG_WARNING("transform hash out of range: " << hash << " elements "
155 << m_surfaceData->m_layerTransforms.size());
156 return m_surfaceData->m_layerTransforms.front();
157 }
158 return m_surfaceData->m_layerTransforms[hash];
159 }
160
161 inline const Amg::Vector3D& MuonClusterReadoutElement::center(int hash) const {
162 if (!m_surfaceData) {
163 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Requesting center but cache is empty");
164 throw std::runtime_error("Empty center cache");
165 }
166 if (hash == -1 || hash >= (int)m_surfaceData->m_layerCenters.size()) {
167 ATH_MSG_WARNING("center hash out of range: " << hash << " elements " << m_surfaceData->m_layerCenters.size());
168 return m_surfaceData->m_layerCenters.front();
169 }
170 return m_surfaceData->m_layerCenters[hash];
171 }
172
173 inline const Amg::Vector3D& MuonClusterReadoutElement::normal(int hash) const {
174 if (!m_surfaceData) {
175 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Requesting normal but cache is empty");
176 throw std::runtime_error("Empty normal cache");
177 }
178 if (hash == -1 || hash >= (int)m_surfaceData->m_layerNormals.size()) {
179 ATH_MSG_WARNING("normal hash out of range: " << hash << " elements " << m_surfaceData->m_layerNormals.size());
180 return m_surfaceData->m_layerNormals.front();
181 }
182 return m_surfaceData->m_layerNormals[hash];
183 }
184
186 if (!m_surfaceData) {
187 ATH_MSG_FATAL(__FILE__<<":"<<__LINE__<<" "<<__func__<<" Requesting bounds but cache is empty");
188 throw std::runtime_error("Empty bounds cache");
189 }
190 if (hash == -1 || hash >= (int)m_surfaceData->m_surfBounds.size()) {
191 ATH_MSG_WARNING("normal hash out of range: " << hash << " elements " << m_surfaceData->m_surfBounds.size());
192 return *m_surfaceData->m_surfBounds.front();
193 }
194 return *m_surfaceData->m_surfBounds[hash];
195 }
196
197 inline std::vector<const Trk::Surface*> MuonClusterReadoutElement::surfaces() const {
198 std::vector<const Trk::Surface*> elementSurfaces;
199
200 // create when first time requested and when possible
201 if (m_surfaceData) {
202 elementSurfaces.reserve(m_surfaceData->m_layerSurfaces.size());
203 for (const std::unique_ptr<Trk::PlaneSurface>& ptr : m_surfaceData->m_layerSurfaces) {
204 elementSurfaces.emplace_back(ptr.get());
205 }
206 }
207 // return the element surfaces
208 return elementSurfaces;
209 }
210
211} // namespace MuonGM
212#endif // MUONREADOUTGEOMETRY_MUONCLUSTERREADOUTELEMENT_H
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
Eigen::Affine3d Transform3D
#define protected
Eigen::Matrix< double, 3, 1 > Vector3D
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
virtual int stripNumber(const Amg::Vector2D &pos, const Identifier &id) const =0
strip number corresponding to local position.
virtual std::vector< const Trk::Surface * > surfaces() const
returns all the surfaces contained in this detector element
virtual bool spacePointPosition(const Identifier &phiId, const Identifier &etaId, Amg::Vector3D &pos) const =0
Global space point position for a given pair of phi and eta identifiers If one of the identifiers is ...
virtual bool spacePointPosition(const Identifier &phiId, const Identifier &etaId, Amg::Vector2D &pos) const =0
space point position for a given pair of phi and eta identifiers The LocalPosition is expressed in th...
virtual void clearCache() override final
clear the cache of the readout elememt
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const =0
strip position If the strip number is outside the range of valid strips, the function will return fal...
virtual int numberOfLayers(bool measuresPhi) const =0
number of layers in phi/eta projection
virtual bool measuresPhi(const Identifier &id) const =0
returns whether the given identifier measures phi or not
virtual const Amg::Vector3D & center() const override
Return the center of the element.
virtual double distanceToReadout(const Amg::Vector2D &pos, const Identifier &id) const =0
distance to readout.
virtual int surfaceHash(const Identifier &id) const =0
returns the hash function to be used to look up the surface and surface transform for a given identif...
virtual int layerHash(const Identifier &id) const =0
returns the hash function to be used to look up the center and the normal of the tracking surface for...
std::unique_ptr< SurfaceData > m_surfaceData
virtual int boundaryHash(const Identifier &id) const =0
returns the hash function to be used to look up the surface boundary for a given identifier
MuonClusterReadoutElement(GeoVFullPhysVol *pv, MuonDetectorManager *mgr, Trk::DetectorElemType detType)
virtual const Amg::Vector3D & normal() const override
Return the normal of the element.
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries of the element.
virtual int numberOfStrips(int layer, bool measuresPhi) const =0
virtual int numberOfStrips(const Identifier &layerId) const =0
number of strips per layer
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
MuonReadoutElement(GeoVFullPhysVol *pv, MuonDetectorManager *mgr, Trk::DetectorElemType detType)
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Abstract base class for surface bounds to be specified.
STL class.
Definition of ATLAS Math & Geometry primitives (Amg)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27
Ensure that the ATLAS eigen extensions are properly loaded.
STL namespace.
struct to hold information needed for TrkDetElementBase, takes owership of all pointers
std::vector< std::unique_ptr< Trk::PlaneSurface > > m_layerSurfaces
there are two surfaces per layer as the eta/phi surfaces are rotated by 90 degrees wrt eachother: Tot...
std::vector< Amg::Vector3D > m_layerNormals
all surfaces on the muon strip detectors have the same normal vector
std::vector< std::unique_ptr< Trk::SurfaceBounds > > m_surfBounds
the eta and phi bounds of the individual layers are not all identical in the muon system (sTGC stairc...
std::vector< Amg::Transform3D > m_layerTransforms
there are two transformation per layer as the eta/phi surfaces are rotated by 90 degrees wrt eachothe...
std::vector< Amg::Vector3D > m_layerCenters
the eta and phi surfaces for a given layer share the same center: Total number = number of layers