ATLAS Offline Software
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 
17 namespace MuonGM {
18 
19  class MuonDetectorManager;
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 
119 
120  std::unique_ptr<SurfaceData> m_surfaceData{};
121  };
122 
123  inline const Trk::PlaneSurface& MuonClusterReadoutElement::surface() const { return surface(0); }
125  inline const Amg::Vector3D& MuonClusterReadoutElement::center() const { return center(0); }
126  inline const Amg::Vector3D& MuonClusterReadoutElement::normal() const { return normal(0); }
127  inline const Trk::SurfaceBounds& MuonClusterReadoutElement::bounds() const { return bounds(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 
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 
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
MuonGM::MuonClusterReadoutElement::SurfaceData::m_layerNormals
std::vector< Amg::Vector3D > m_layerNormals
all surfaces on the muon strip detectors have the same normal vector
Definition: MuonClusterReadoutElement.h:26
MuonGM::MuonClusterReadoutElement::transform
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
Definition: MuonClusterReadoutElement.h:124
MuonGM::MuonClusterReadoutElement::~MuonClusterReadoutElement
~MuonClusterReadoutElement()
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
MuonGM::MuonClusterReadoutElement::normal
virtual const Amg::Vector3D & normal() const override
Return the normal of the element.
Definition: MuonClusterReadoutElement.h:126
MuonGM::MuonClusterReadoutElement::center
virtual const Amg::Vector3D & center() const override
Return the center of the element.
Definition: MuonClusterReadoutElement.h:125
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::SurfaceBounds
Definition: SurfaceBounds.h:47
MuonGM::MuonClusterReadoutElement::clearCache
virtual void clearCache() override final
clear the cache of the readout elememt
Definition: MuonClusterReadoutElement.cxx:13
Surface
Definition: Trigger/TrigAccel/TrigCudaFitter/src/Surface.h:8
MuonGM::MuonClusterReadoutElement::surfaces
virtual std::vector< const Trk::Surface * > surfaces() const
returns all the surfaces contained in this detector element
Definition: MuonClusterReadoutElement.h:197
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
MuonGM::MuonClusterReadoutElement::boundaryHash
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
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
MuonGM::MuonClusterReadoutElement::spacePointPosition
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 ...
protected
#define protected
Definition: DetDescrConditionsDict_dict_fixes.cxx:14
MuonGM::MuonClusterReadoutElement::stripPosition
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...
MuonGM::MuonClusterReadoutElement::spacePointPosition
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...
MuonGM::MuonReadoutElement
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:40
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
MuonGM::MuonClusterReadoutElement::measuresPhi
virtual bool measuresPhi(const Identifier &id) const =0
returns whether the given identifier measures phi or not
SurfaceBounds.h
MuonGM::MuonClusterReadoutElement::m_surfaceData
std::unique_ptr< SurfaceData > m_surfaceData
Definition: MuonClusterReadoutElement.h:120
MuonGM::MuonClusterReadoutElement::distanceToReadout
virtual double distanceToReadout(const Amg::Vector2D &pos, const Identifier &id) const =0
distance to readout.
MuonGM::MuonClusterReadoutElement::SurfaceData
struct to hold information needed for TrkDetElementBase, takes owership of all pointers
Definition: MuonClusterReadoutElement.h:24
vector
Definition: MultiHisto.h:13
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGM::MuonClusterReadoutElement::numberOfStrips
virtual int numberOfStrips(const Identifier &layerId) const =0
number of strips per layer
Trk::DetectorElemType
DetectorElemType
Definition: TrkDetElementBase.h:39
MuonGM::MuonClusterReadoutElement::SurfaceData::m_layerTransforms
std::vector< Amg::Transform3D > m_layerTransforms
there are two transformation per layer as the eta/phi surfaces are rotated by 90 degrees wrt eachothe...
Definition: MuonClusterReadoutElement.h:33
MuonReadoutElement.h
MuonGM::MuonClusterReadoutElement::SurfaceData::~SurfaceData
~SurfaceData()=default
MuonGM::MuonClusterReadoutElement::numberOfLayers
virtual int numberOfLayers(bool measuresPhi) const =0
number of layers in phi/eta projection
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
MuonGM::MuonClusterReadoutElement::layerHash
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...
MuonGM::MuonClusterReadoutElement::stripNumber
virtual int stripNumber(const Amg::Vector2D &pos, const Identifier &id) const =0
strip number corresponding to local position.
MuonGM::MuonClusterReadoutElement::numberOfStrips
virtual int numberOfStrips(int layer, bool measuresPhi) const =0
MuonGM::MuonClusterReadoutElement::SurfaceData::SurfaceData
SurfaceData()=default
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonGM::MuonClusterReadoutElement::SurfaceData::m_layerCenters
std::vector< Amg::Vector3D > m_layerCenters
the eta and phi surfaces for a given layer share the same center: Total number = number of layers
Definition: MuonClusterReadoutElement.h:40
MuonGM::MuonClusterReadoutElement::SurfaceData::m_layerSurfaces
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...
Definition: MuonClusterReadoutElement.h:37
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonGM::MuonClusterReadoutElement
Definition: MuonClusterReadoutElement.h:21
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
PlaneSurface.h
python.changerun.pv
pv
Definition: changerun.py:81
MuonGM::MuonClusterReadoutElement::SurfaceData::m_surfBounds
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...
Definition: MuonClusterReadoutElement.h:29
MuonGM::MuonClusterReadoutElement::bounds
virtual const Trk::SurfaceBounds & bounds() const override
Return the boundaries of the element.
Definition: MuonClusterReadoutElement.h:127
MuonGM::MuonClusterReadoutElement::surfaceHash
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...
Identifier
Definition: IdentifierFieldParser.cxx:14