ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Surface.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Surface.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
22 
23 #include <memory>
24 
25 namespace Acts {
26 
27 class DetectorElementBase;
28 class SurfaceBounds;
29 class ISurfaceMaterial;
30 class Layer;
31 class TrackingVolume;
32 class IVisualization;
33 
35 using SurfaceIntersection = ObjectIntersection<Surface>;
36 
48 class Surface : public virtual GeometryObject,
49  public std::enable_shared_from_this<Surface> {
50  public:
55  enum SurfaceType {
56  Cone = 0,
57  Cylinder = 1,
58  Disc = 2,
59  Perigee = 3,
60  Plane = 4,
61  Straw = 5,
63  Other = 7
64  };
65 
66  protected:
71  Surface(std::shared_ptr<const Transform3D> tform = nullptr);
72 
79  Surface(const Surface& other);
80 
84  Surface(const DetectorElementBase& detelement);
85 
94  Surface(const GeometryContext& gctx, const Surface& other,
95  const Transform3D& shift);
96 
97  public:
98  virtual ~Surface();
99 
103  template <class T, typename... Args>
104  static std::shared_ptr<T> makeShared(Args&&... args) {
105  return std::shared_ptr<T>(new T(std::forward<Args>(args)...));
106  }
107 
117  std::shared_ptr<Surface> getSharedPtr();
118 
128  std::shared_ptr<const Surface> getSharedPtr() const;
129 
135  Surface& operator=(const Surface& other);
136 
145  virtual bool operator==(const Surface& other) const;
146 
150  virtual bool operator!=(const Surface& sf) const;
151 
152  public:
154  virtual SurfaceType type() const = 0;
155 
164  virtual const Transform3D& transform(const GeometryContext& gctx) const;
165 
172  virtual const Vector3D center(const GeometryContext& gctx) const;
173 
183  virtual const Vector3D normal(const GeometryContext& gctx,
184  const Vector2D& lposition) const = 0;
185 
193 
196  virtual const Vector3D normal(const GeometryContext& gctx,
197  const Vector3D& position) const;
198 
204  //
206  virtual const Vector3D normal(const GeometryContext& gctx) const {
207  return normal(gctx, center(gctx));
208  }
209 
212  virtual const SurfaceBounds& bounds() const = 0;
213 
217 
220  const Layer* associatedLayer() const;
221 
227  void associateLayer(const Layer& lay);
228 
231  const ISurfaceMaterial* surfaceMaterial() const;
232 
235  const std::shared_ptr<const ISurfaceMaterial>& surfaceMaterialSharedPtr()
236  const;
237 
245  void assignSurfaceMaterial(std::shared_ptr<const ISurfaceMaterial> material);
246 
257  bool isOnSurface(const GeometryContext& gctx, const Vector3D& position,
258  const Vector3D& momentum,
259  const BoundaryCheck& bcheck = true) const;
260 
266  virtual bool insideBounds(const Vector2D& lposition,
267  const BoundaryCheck& bcheck = true) const;
268 
279  virtual void localToGlobal(const GeometryContext& gctx,
280  const Vector2D& lposition,
281  const Vector3D& momentum,
282  Vector3D& position) const = 0;
283 
298  virtual bool globalToLocal(const GeometryContext& gctx,
299  const Vector3D& position, const Vector3D& momentum,
300  Vector2D& lposition) const = 0;
301 
314  const GeometryContext& gctx, const Vector3D& position,
315  const Vector3D& momentum) const;
316 
331  virtual void initJacobianToGlobal(const GeometryContext& gctx,
332  BoundToFreeMatrix& jacobian,
333  const Vector3D& position,
334  const Vector3D& direction,
335  const BoundVector& pars) const;
336 
353  const GeometryContext& gctx, FreeToBoundMatrix& jacobian,
354  const Vector3D& position, const Vector3D& direction) const;
355 
372  virtual const BoundRowVector derivativeFactors(
373  const GeometryContext& gctx, const Vector3D& position,
374  const Vector3D& direction, const RotationMatrix3D& rft,
375  const BoundToFreeMatrix& jacobian) const;
376 
385  virtual double pathCorrection(const GeometryContext& gctx,
386  const Vector3D& position,
387  const Vector3D& direction) const = 0;
388 
398  const Vector3D& position,
399  const Vector3D& direction,
400  const BoundaryCheck& bcheck) const
401 
402  {
403  // Get the intersection with the surface
404  auto sIntersection =
405  intersectionEstimate(gctx, position, direction, bcheck);
406  // return a surface intersection with result direction
407  return SurfaceIntersection(sIntersection, this);
408  }
409 
421  const GeometryContext& gctx, const Vector3D& position,
422  const Vector3D& direction, const BoundaryCheck& bcheck) const = 0;
423 
428  virtual std::ostream& toStream(const GeometryContext& gctx,
429  std::ostream& sl) const;
430 
432  virtual std::string name() const = 0;
433 
447  size_t lseg) const = 0;
448 
449  protected:
452  std::shared_ptr<const Transform3D> m_transform;
453 
456 
459  const Layer* m_associatedLayer{nullptr};
460 
464 
466  std::shared_ptr<const ISurfaceMaterial> m_surfaceMaterial;
467 };
468 
470 
471 } // namespace Acts