ECCE @ 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 
10 // TrackingVolume.h, Acts project
12 
13 #pragma once
14 #include <functional>
15 #include <map>
16 #include <string>
20 #include "Acts/Geometry/Layer.hpp"
21 #include "Acts/Geometry/Volume.hpp"
29 #include "Acts/Utilities/Ray.hpp"
30 
31 namespace Acts {
32 
34 class VolumeBounds;
35 
36 // master typedefs
37 using TrackingVolumePtr = std::shared_ptr<const TrackingVolume>;
38 using MutableTrackingVolumePtr = std::shared_ptr<TrackingVolume>;
39 
41  std::shared_ptr<const BoundarySurfaceT<TrackingVolume>>;
42 using TrackingVolumeBoundaries = std::vector<TrackingVolumeBoundaryPtr>;
43 
44 // possible contained
46 using TrackingVolumeVector = std::vector<TrackingVolumePtr>;
47 using MutableTrackingVolumeVector = std::vector<MutableTrackingVolumePtr>;
49 using LayerVector = std::vector<LayerPtr>;
50 
51 // Intersection with Layer
53 
54 // full intersection with surface
57 
79 class TrackingVolume : public Volume {
80  friend class TrackingGeometry;
81 
82  public:
84  ~TrackingVolume() override;
85 
87  TrackingVolume(const TrackingVolume&) = delete;
88 
90  TrackingVolume& operator=(const TrackingVolume&) = delete;
91 
102  std::shared_ptr<const Transform3D> htrans, VolumeBoundsPtr volumeBounds,
103  const std::shared_ptr<const TrackingVolumeArray>& containedVolumes =
104  nullptr,
105  const std::string& volumeName = "undefined") {
107  new TrackingVolume(std::move(htrans), std::move(volumeBounds),
108  containedVolumes, volumeName));
109  }
110 
123  std::shared_ptr<const Transform3D> htrans, VolumeBoundsPtr volbounds,
124  std::vector<std::unique_ptr<Volume::BoundingBox>> boxStore,
125  std::vector<std::unique_ptr<const Volume>> descendants,
126  const Volume::BoundingBox* top,
127  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
128  const std::string& volumeName = "undefined") {
130  std::move(htrans), std::move(volbounds), std::move(boxStore),
131  std::move(descendants), top, std::move(volumeMaterial), volumeName));
132  }
133 
146  std::shared_ptr<const Transform3D> htrans, VolumeBoundsPtr volumeBounds,
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  std::move(htrans), 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  template <typename options_t>
179  std::vector<LayerIntersection> compatibleLayers(
180  const GeometryContext& gctx, const Vector3D& position,
181  const Vector3D& direction, const options_t& options) const;
182 
195  template <typename options_t>
196  std::vector<BoundaryIntersection> compatibleBoundaries(
197  const GeometryContext& gctx, const Vector3D& position,
198  const Vector3D& direction, const options_t& options) const;
199 
210  template <typename options_t>
211  std::vector<SurfaceIntersection> compatibleSurfacesFromHierarchy(
212  const GeometryContext& gctx, const Vector3D& position,
213  const Vector3D& direction, double angle, const options_t& options) const;
214 
223  const Vector3D& position,
224  const double tol = 0.) const;
225 
228  const LayerArray* confinedLayers() const;
229 
231  std::shared_ptr<const TrackingVolumeArray> confinedVolumes() const;
232 
235 
243  void visitSurfaces(
244  const std::function<void(const Acts::Surface*)>& visitor) const;
245 
247  const std::string& volumeName() const;
248 
251 
253  const IVolumeMaterial* volumeMaterial() const;
254 
256  const std::shared_ptr<const IVolumeMaterial>& volumeMaterialSharedPtr() const;
257 
266  std::shared_ptr<const ISurfaceMaterial> surfaceMaterial,
267  BoundarySurfaceFace bsFace);
268 
276  void assignVolumeMaterial(std::shared_ptr<const IVolumeMaterial> material);
277 
287  BoundarySurfaceFace bsfMine, TrackingVolume* neighbor,
288  BoundarySurfaceFace bsfNeighbor);
289 
298  void glueTrackingVolumes(
299  const GeometryContext& gctx, BoundarySurfaceFace bsfMine,
300  const std::shared_ptr<TrackingVolumeArray>& neighbors,
301  BoundarySurfaceFace bsfNeighbor);
302 
313  std::shared_ptr<const BoundarySurfaceT<TrackingVolume>> bs,
314  bool checkmaterial = true);
315 
324  void registerGlueVolumeDescriptor(GlueVolumesDescriptor* gvd);
325 
331  GlueVolumesDescriptor& glueVolumesDescriptor();
332 
336  bool hasBoundingVolumeHierarchy() const;
337 
341  void registerColorCode(unsigned int icolor);
342 
344  unsigned int colorCode() const;
345 
347  const TrackingVolume* motherVolume() const;
348 
352  void setMotherVolume(const TrackingVolume* mvol);
353 
354  protected:
356  TrackingVolume();
357 
365  TrackingVolume(std::shared_ptr<const Transform3D> htrans,
366  VolumeBoundsPtr volbounds,
367  const std::shared_ptr<const TrackingVolumeArray>&
368  containedVolumeArray = nullptr,
369  const std::string& volumeName = "undefined");
370 
371  TrackingVolume(std::shared_ptr<const Transform3D> htrans,
372  VolumeBoundsPtr volbounds,
373  std::vector<std::unique_ptr<Volume::BoundingBox>> boxStore,
374  std::vector<std::unique_ptr<const Volume>> descendants,
375  const Volume::BoundingBox* top,
376  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
377  const std::string& volumeName = "undefined");
378 
390  std::shared_ptr<const Transform3D> htrans, VolumeBoundsPtr volumeBounds,
391  std::shared_ptr<const IVolumeMaterial> volumeMaterial,
392  std::unique_ptr<const LayerArray> staticLayerArray = nullptr,
393  std::shared_ptr<const TrackingVolumeArray> containedVolumeArray = nullptr,
394  MutableTrackingVolumeVector denseVolumeVector = {},
395  const std::string& volumeName = "undefined");
396 
397  private:
399  MutableTrackingVolumeVector& confinedDenseVolumes);
400 
402  void createBoundarySurfaces();
403 
408  void synchronizeLayers(double envelope = 1.) const;
409 
419  void closeGeometry(const IMaterialDecorator* materialDecorator,
420  std::map<std::string, const TrackingVolume*>& volumeMap,
421  size_t& vol);
422 
424  void interlinkLayers();
425 
426  template <typename T>
427  static std::vector<const Volume*> intersectSearchHierarchy(
428  const T obj, const Volume::BoundingBox* lnode);
429 
431  std::shared_ptr<const IVolumeMaterial> m_volumeMaterial{nullptr};
432 
435 
436  // the boundary surfaces
437  std::vector<TrackingVolumeBoundaryPtr> m_boundarySurfaces;
438 
441  std::unique_ptr<const LayerArray> m_confinedLayers = nullptr;
442 
444  std::shared_ptr<const TrackingVolumeArray> m_confinedVolumes = nullptr;
445 
448 
451 
453  std::string m_name;
454 
456  unsigned int m_colorCode{20};
457 
459  std::vector<std::unique_ptr<const Volume::BoundingBox>> m_boundingBoxes;
460  std::vector<std::unique_ptr<const Volume>> m_descendantVolumes;
461  const Volume::BoundingBox* m_bvhTop{nullptr};
462 };
463 
464 inline const std::string& TrackingVolume::volumeName() const {
465  return m_name;
466 }
467 
469  return m_volumeMaterial.get();
470 }
471 
472 inline const std::shared_ptr<const IVolumeMaterial>&
474  return m_volumeMaterial;
475 }
476 
478  std::shared_ptr<const IVolumeMaterial> material) {
479  m_volumeMaterial = std::move(material);
480 }
481 
483  return m_confinedLayers.get();
484 }
485 
487  return m_confinedDenseVolumes;
488 }
489 
490 inline std::shared_ptr<const TrackingVolumeArray>
492  return m_confinedVolumes;
493 }
494 
495 inline void TrackingVolume::registerColorCode(unsigned int icolor) {
496  m_colorCode = icolor;
497 }
498 
499 inline unsigned int TrackingVolume::colorCode() const {
500  return m_colorCode;
501 }
502 
504  return m_motherVolume;
505 }
506 
508  m_motherVolume = mvol;
509 }
510 
512  return m_bvhTop != nullptr;
513 }
514 
515 #include "detail/TrackingVolume.ipp"
516 
517 } // namespace Acts