Analysis Software
Documentation for sPHENIX simulation 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 
28 
29 #include <array>
30 #include <cstddef>
31 #include <memory>
32 #include <ostream>
33 #include <string>
34 #include <tuple>
35 #include <utility>
36 
37 namespace Acts {
38 
39 class DetectorElementBase;
40 class SurfaceBounds;
41 class ISurfaceMaterial;
42 class Layer;
43 class TrackingVolume;
44 class IVisualization3D;
45 class Surface;
46 
48 using SurfaceIntersection = ObjectIntersection<Surface>;
51 
63 class Surface : public virtual GeometryObject,
64  public std::enable_shared_from_this<Surface> {
65  public:
70  enum SurfaceType {
71  Cone = 0,
72  Cylinder = 1,
73  Disc = 2,
74  Perigee = 3,
75  Plane = 4,
76  Straw = 5,
78  Other = 7
79  };
80 
82  static std::array<std::string, SurfaceType::Other> s_surfaceTypeNames;
83 
84  protected:
89  Surface(const Transform3& transform = Transform3::Identity());
90 
97  Surface(const Surface& other);
98 
102  Surface(const DetectorElementBase& detelement);
103 
112  Surface(const GeometryContext& gctx, const Surface& other,
113  const Transform3& shift);
114 
115  public:
116  virtual ~Surface();
117 
121  template <class T, typename... Args>
122  static std::shared_ptr<T> makeShared(Args&&... args) {
123  return std::shared_ptr<T>(new T(std::forward<Args>(args)...));
124  }
125 
135  std::shared_ptr<Surface> getSharedPtr();
136 
146  std::shared_ptr<const Surface> getSharedPtr() const;
147 
153  Surface& operator=(const Surface& other);
154 
163  virtual bool operator==(const Surface& other) const;
164 
168  virtual bool operator!=(const Surface& sf) const;
169 
170  public:
172  virtual SurfaceType type() const = 0;
173 
182  virtual const Transform3& transform(const GeometryContext& gctx) const;
183 
190  virtual Vector3 center(const GeometryContext& gctx) const;
191 
201  virtual Vector3 normal(const GeometryContext& gctx,
202  const Vector2& lposition) const = 0;
203 
211 
214  virtual Vector3 normal(const GeometryContext& gctx,
215  const Vector3& position) const;
216 
222  //
224  virtual Vector3 normal(const GeometryContext& gctx) const {
225  return normal(gctx, center(gctx));
226  }
227 
230  virtual const SurfaceBounds& bounds() const = 0;
231 
235 
238  const Layer* associatedLayer() const;
239 
245  void associateLayer(const Layer& lay);
246 
249  const ISurfaceMaterial* surfaceMaterial() const;
250 
253  const std::shared_ptr<const ISurfaceMaterial>& surfaceMaterialSharedPtr()
254  const;
255 
259  void assignDetectorElement(const DetectorElementBase& detelement);
260 
268  void assignSurfaceMaterial(std::shared_ptr<const ISurfaceMaterial> material);
269 
280  bool isOnSurface(const GeometryContext& gctx, const Vector3& position,
281  const Vector3& direction,
282  const BoundaryCheck& bcheck = true) const;
283 
289  virtual bool insideBounds(const Vector2& lposition,
290  const BoundaryCheck& bcheck = true) const;
291 
302  virtual Vector3 localToGlobal(const GeometryContext& gctx,
303  const Vector2& lposition,
304  const Vector3& direction) const = 0;
305 
320  const GeometryContext& gctx, const Vector3& position,
321  const Vector3& direction,
322  double tolerance = s_onSurfaceTolerance) const = 0;
323 
336  const Vector3& position,
337  const Vector3& direction) const;
338 
357  const GeometryContext& gctx, const BoundVector& boundParams) const;
358 
374  const GeometryContext& gctx, const FreeVector& parameters) const;
375 
390  const GeometryContext& gctx, const FreeVector& parameters) const;
391 
400  virtual double pathCorrection(const GeometryContext& gctx,
401  const Vector3& position,
402  const Vector3& direction) const = 0;
403 
414  const GeometryContext& gctx, const Vector3& position,
415  const Vector3& direction, const BoundaryCheck& bcheck = false,
417 
422  virtual std::ostream& toStream(const GeometryContext& gctx,
423  std::ostream& sl) const;
424 
429 
431  virtual std::string name() const = 0;
432 
446  size_t lseg) const = 0;
447 
462  const GeometryContext& gctx, const FreeVector& parameters,
463  const FreeVector& pathDerivative) const;
464 
479  const GeometryContext& gctx, const FreeVector& parameters) const;
480 
490  const GeometryContext& gctx, const Vector3& position) const = 0;
491 
492  protected:
495  Transform3 m_transform = Transform3::Identity();
496 
499 
502  const Layer* m_associatedLayer{nullptr};
503 
507 
509  std::shared_ptr<const ISurfaceMaterial> m_surfaceMaterial;
510 
511  private:
526  const GeometryContext& gctx, const FreeVector& parameters) const;
527 };
528 
532 inline std::ostream& operator<<(
533  std::ostream& os,
534  const std::tuple<const Surface&, const GeometryContext&>& tup) {
535  const auto [surface, gctx] = tup;
536  surface.toStream(gctx, os);
537  return os;
538 }
539 
540 } // namespace Acts