EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackingVolume.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackingVolume.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 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 
14 #include "Acts/Geometry/Layer.hpp"
15 #include "Acts/Geometry/Volume.hpp"
24 #include "Acts/Utilities/Ray.hpp"
25 
26 #include <functional>
27 #include <map>
28 #include <string>
29 
30 namespace Acts {
31 
32 class GlueVolumesDescriptor;
33 class VolumeBounds;
34 
35 template <typename object_t>
37 
38 // master typedefs
39 using TrackingVolumePtr = std::shared_ptr<const TrackingVolume>;
40 using MutableTrackingVolumePtr = std::shared_ptr<TrackingVolume>;
41 
43  std::shared_ptr<const BoundarySurfaceT<TrackingVolume>>;
44 using TrackingVolumeBoundaries = std::vector<TrackingVolumeBoundaryPtr>;
45 
46 // possible contained
48 using TrackingVolumeVector = std::vector<TrackingVolumePtr>;
49 using MutableTrackingVolumeVector = std::vector<MutableTrackingVolumePtr>;
51 using LayerVector = std::vector<LayerPtr>;
52 
53 // Intersection with Layer
55 
56 // Full intersection with surface
59 
81 class TrackingVolume : public Volume {
82  friend class TrackingGeometry;
83 
84  public:
85  TrackingVolume() = delete;
86  ~TrackingVolume() override;
87  TrackingVolume(const TrackingVolume&) = delete;
88  TrackingVolume& operator=(const TrackingVolume&) = delete;
89 
102  const std::shared_ptr<const TrackingVolumeArray>& containedVolumes =
103  nullptr,
104  const std::string& volumeName = "undefined") {
106  transform, std::move(volumeBounds), containedVolumes, volumeName));
107  }
108 
122  const Transform3D& transform, VolumeBoundsPtr volbounds,
123  std::vector<std::unique_ptr<Volume::BoundingBox>> boxStore,
124  std::vector<std::unique_ptr<const Volume>> descendants,
125  const Volume::BoundingBox* top,
126  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
127  const std::string& volumeName = "undefined") {
129  transform, std::move(volbounds), std::move(boxStore),
130  std::move(descendants), top, std::move(volumeMaterial), volumeName));
131  }
132 
147  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
148  std::unique_ptr<const LayerArray> containedLayers = nullptr,
149  std::shared_ptr<const TrackingVolumeArray> containedVolumes = nullptr,
151  const std::string& volumeName = "undefined") {
153  transform, std::move(volumeBounds), std::move(volumeMaterial),
154  std::move(containedLayers), std::move(containedVolumes),
155  std::move(denseVolumes), volumeName));
156  }
157 
164  const Layer* associatedLayer(const GeometryContext& gctx,
165  const Vector3D& position) const;
166 
178  std::vector<LayerIntersection> compatibleLayers(
179  const GeometryContext& gctx, const Vector3D& position,
180  const Vector3D& direction, const NavigationOptions<Layer>& options) const;
181 
194  std::vector<BoundaryIntersection> compatibleBoundaries(
195  const GeometryContext& gctx, const Vector3D& position,
196  const Vector3D& direction, const NavigationOptions<Surface>& options,
197  LoggerWrapper logger = getDummyLogger()) const;
198 
209  std::vector<SurfaceIntersection> compatibleSurfacesFromHierarchy(
210  const GeometryContext& gctx, const Vector3D& position,
211  const Vector3D& direction, double angle,
212  const NavigationOptions<Surface>& options) const;
213 
222  const Vector3D& position,
223  const double tol = 0.) const;
224 
227  const LayerArray* confinedLayers() const;
228 
230  std::shared_ptr<const TrackingVolumeArray> confinedVolumes() const;
231 
234 
242  void visitSurfaces(
243  const std::function<void(const Acts::Surface*)>& visitor) const;
244 
246  const std::string& volumeName() const;
247 
250 
252  const IVolumeMaterial* volumeMaterial() const;
253 
255  const std::shared_ptr<const IVolumeMaterial>& volumeMaterialSharedPtr() const;
256 
265  std::shared_ptr<const ISurfaceMaterial> surfaceMaterial,
266  BoundarySurfaceFace bsFace);
267 
275  void assignVolumeMaterial(std::shared_ptr<const IVolumeMaterial> material);
276 
285  void glueTrackingVolume(const GeometryContext& gctx,
286  BoundarySurfaceFace bsfMine, TrackingVolume* neighbor,
287  BoundarySurfaceFace bsfNeighbor);
288 
297  void glueTrackingVolumes(
298  const GeometryContext& gctx, BoundarySurfaceFace bsfMine,
299  const std::shared_ptr<TrackingVolumeArray>& neighbors,
300  BoundarySurfaceFace bsfNeighbor);
301 
312  std::shared_ptr<const BoundarySurfaceT<TrackingVolume>> bs,
313  bool checkmaterial = true);
314 
323  void registerGlueVolumeDescriptor(GlueVolumesDescriptor* gvd);
324 
330  GlueVolumesDescriptor& glueVolumesDescriptor();
331 
335  bool hasBoundingVolumeHierarchy() const;
336 
340  void registerColorCode(unsigned int icolor);
341 
343  unsigned int colorCode() const;
344 
346  const TrackingVolume* motherVolume() const;
347 
351  void setMotherVolume(const TrackingVolume* mvol);
352 
353  protected:
362  TrackingVolume(const Transform3D& transform, VolumeBoundsPtr volbounds,
363  const std::shared_ptr<const TrackingVolumeArray>&
364  containedVolumeArray = nullptr,
365  const std::string& volumeName = "undefined");
366 
367  TrackingVolume(const Transform3D& transform, VolumeBoundsPtr volbounds,
368  std::vector<std::unique_ptr<Volume::BoundingBox>> boxStore,
369  std::vector<std::unique_ptr<const Volume>> descendants,
370  const Volume::BoundingBox* top,
371  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
372  const std::string& volumeName = "undefined");
373 
386  const Transform3D& transform, VolumeBoundsPtr volumeBounds,
387  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
388  std::unique_ptr<const LayerArray> staticLayerArray = nullptr,
389  std::shared_ptr<const TrackingVolumeArray> containedVolumeArray = nullptr,
390  MutableTrackingVolumeVector denseVolumeVector = {},
391  const std::string& volumeName = "undefined");
392 
393  private:
395  MutableTrackingVolumeVector& confinedDenseVolumes);
396 
398  void createBoundarySurfaces();
399 
404  void synchronizeLayers(double envelope = 1.) const;
405 
415  void closeGeometry(const IMaterialDecorator* materialDecorator,
416  std::map<std::string, const TrackingVolume*>& volumeMap,
417  size_t& vol);
418 
420  void interlinkLayers();
421 
423  std::shared_ptr<const IVolumeMaterial> m_volumeMaterial{nullptr};
424 
427 
428  // the boundary surfaces
429  std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces;
430 
433  std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;
434 
436  std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;
437 
440 
443 
445  std::string m_name;
446 
448  unsigned int m_colorCode{20};
449 
451  std::vector<std::unique_ptr<const Volume::BoundingBox>> m_boundingBoxes;
452  std::vector<std::unique_ptr<const Volume>> m_descendantVolumes;
453  const Volume::BoundingBox* m_bvhTop{nullptr};
454 };
455 
456 inline const std::string& TrackingVolume::volumeName() const {
457  return m_name;
458 }
459 
461  return m_volumeMaterial.get();
462 }
463 
464 inline const std::shared_ptr<const IVolumeMaterial>&
466  return m_volumeMaterial;
467 }
468 
470  std::shared_ptr<const IVolumeMaterial> material) {
471  m_volumeMaterial = std::move(material);
472 }
473 
475  return m_confinedLayers.get();
476 }
477 
479  return m_confinedDenseVolumes;
480 }
481 
482 inline std::shared_ptr<const TrackingVolumeArray>
484  return m_confinedVolumes;
485 }
486 
487 inline void TrackingVolume::registerColorCode(unsigned int icolor) {
488  m_colorCode = icolor;
489 }
490 
491 inline unsigned int TrackingVolume::colorCode() const {
492  return m_colorCode;
493 }
494 
496  return m_motherVolume;
497 }
498 
500  m_motherVolume = mvol;
501 }
502 
504  return m_bvhTop != nullptr;
505 }
506 
507 #include "detail/TrackingVolume.ipp"
508 
509 } // namespace Acts