Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:53

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Geometry/TrackingVolume.hpp"
0015 #include "Acts/Geometry/TrackingVolumeVisitorConcept.hpp"
0016 #include "Acts/Surfaces/SurfaceVisitorConcept.hpp"
0017 #include "Acts/Utilities/Logger.hpp"
0018 
0019 #include <memory>
0020 #include <unordered_map>
0021 #include <utility>
0022 
0023 namespace Acts {
0024 
0025 class Layer;
0026 class Surface;
0027 class PerigeeSurface;
0028 class IMaterialDecorator;
0029 class TrackingVolume;
0030 
0031 ///  @class TrackingGeometry
0032 ///
0033 ///  The TrackingGeometry class is the owner of the constructed TrackingVolumes.
0034 ///
0035 ///  It enables both, a global search for an asociatedVolume
0036 ///  (respectively, if existing, a global search of an associated Layer or the
0037 ///  next associated Layer), such as a continuous navigation by BoundarySurfaces
0038 ///  between the confined TrackingVolumes.
0039 class TrackingGeometry {
0040   /// Give the GeometryBuilder friend rights
0041   friend class TrackingGeometryBuilder;
0042 
0043  public:
0044   /// Constructor
0045   ///
0046   /// @param highestVolume is the world volume
0047   /// @param materialDecorator is a dediated decorator that can assign
0048   ///        surface or volume based material to the TrackingVolume
0049   /// @param hook Identifier hook to be applied to surfaces
0050   /// @param logger instance of a logger (defaulting to the "silent" one)
0051   TrackingGeometry(const std::shared_ptr<TrackingVolume>& highestVolume,
0052                    const IMaterialDecorator* materialDecorator = nullptr,
0053                    const GeometryIdentifierHook& hook = {},
0054                    const Logger& logger = getDummyLogger());
0055 
0056   /// Destructor
0057   ~TrackingGeometry();
0058 
0059   /// Access to the world volume
0060   /// @return plain pointer to the world volume
0061   const TrackingVolume* highestTrackingVolume() const;
0062 
0063   /// Access to the world volume
0064   /// @return shared pointer to the world volume
0065   std::shared_ptr<const TrackingVolume> highestTrackingVolumePtr() const;
0066 
0067   /// return the lowest tracking Volume
0068   ///
0069   /// @param gctx The current geometry context object, e.g. alignment
0070   /// @param gp is the global position of the call
0071   ///
0072   /// @return plain pointer to the lowest TrackingVolume
0073   const TrackingVolume* lowestTrackingVolume(const GeometryContext& gctx,
0074                                              const Vector3& gp) const;
0075 
0076   /// Forward the associated Layer information
0077   ///
0078   /// @param gctx is the context for this request (e.g. alignment)
0079   /// @param gp is the global position of the call
0080   ///
0081   /// @return plain pointer to assocaiated layer
0082   const Layer* associatedLayer(const GeometryContext& gctx,
0083                                const Vector3& gp) const;
0084 
0085   /// @brief Visit all reachable surfaces
0086   ///
0087   /// @tparam visitor_t Type of the callable visitor
0088   ///
0089   /// @param visitor The callable. Will be called for each reachable surface
0090   /// that is found, a selection of the surfaces can be done in the visitor
0091   /// @param restrictToSensitives If true, only sensitive surfaces are visited
0092   ///
0093   /// @note If a context is needed for the visit, the visitor has to provide
0094   /// this, e.g. as a private member
0095   template <SurfaceVisitor visitor_t>
0096   void visitSurfaces(visitor_t&& visitor, bool restrictToSensitives) const {
0097     highestTrackingVolume()->template visitSurfaces<visitor_t>(
0098         std::forward<visitor_t>(visitor), restrictToSensitives);
0099   }
0100 
0101   /// @brief Visit all sensitive surfaces
0102   ///
0103   /// @tparam visitor_t Type of the callable visitor
0104   ///
0105   /// @param visitor The callable. Will be called for each sensitive surface
0106   /// that is found, a selection of the surfaces can be done in the visitor
0107   ///
0108   /// @note If a context is needed for the visit, the visitor has to provide
0109   /// this, e.g. as a private member
0110   template <SurfaceVisitor visitor_t>
0111   void visitSurfaces(visitor_t&& visitor) const {
0112     visitSurfaces(std::forward<visitor_t>(visitor), true);
0113   }
0114 
0115   /// @brief Visit all reachable tracking volumes
0116   ///
0117   /// @tparam visitor_t Type of the callable visitor
0118   ///
0119   /// @param visitor The callable. Will be called for each reachable volume
0120   /// that is found, a selection of the volumes can be done in the visitor
0121   ///
0122   /// @note If a context is needed for the visit, the visitor has to provide
0123   /// this, e.g. as a private member
0124   template <TrackingVolumeVisitor visitor_t>
0125   void visitVolumes(visitor_t&& visitor) const {
0126     highestTrackingVolume()->template visitVolumes<visitor_t>(
0127         std::forward<visitor_t>(visitor));
0128   }
0129 
0130   /// Search for a volume with the given identifier.
0131   ///
0132   /// @param id is the geometry identifier of the volume
0133   /// @retval nullptr if no such volume exists
0134   /// @retval pointer to the found volume otherwise.
0135   const TrackingVolume* findVolume(GeometryIdentifier id) const;
0136 
0137   /// Search for a surface with the given identifier.
0138   ///
0139   /// @param id is the geometry identifier of the surface
0140   /// @retval nullptr if no such surface exists
0141   /// @retval pointer to the found surface otherwise.
0142   const Surface* findSurface(GeometryIdentifier id) const;
0143 
0144   /// Access to the GeometryIdentifier - Surface association map
0145   const std::unordered_map<GeometryIdentifier, const Surface*>&
0146   geoIdSurfaceMap() const;
0147 
0148   /// Visualize a tracking geometry including substructure
0149   /// @param helper The visualization helper that implement the output
0150   /// @param gctx The geometry context
0151   /// @param viewConfig Global view config
0152   /// @param portalViewConfig View config for portals
0153   /// @param sensitiveViewConfig View configuration for sensitive surfaces
0154   void visualize(IVisualization3D& helper, const GeometryContext& gctx,
0155                  const ViewConfig& viewConfig = s_viewVolume,
0156                  const ViewConfig& portalViewConfig = s_viewPortal,
0157                  const ViewConfig& sensitiveViewConfig = s_viewSensitive) const;
0158 
0159  private:
0160   // the known world
0161   std::shared_ptr<TrackingVolume> m_world;
0162   // lookup containers
0163   std::unordered_map<GeometryIdentifier, const TrackingVolume*> m_volumesById;
0164   std::unordered_map<GeometryIdentifier, const Surface*> m_surfacesById;
0165 };
0166 
0167 }  // namespace Acts