Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-04 07:57:30

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/Geometry/CylinderVolumeBounds.hpp"
0012 #include "Acts/Geometry/PortalShell.hpp"
0013 #include "Acts/Utilities/AxisDefinitions.hpp"
0014 #include "Acts/Utilities/Logger.hpp"
0015 
0016 #include <array>
0017 #include <memory>
0018 
0019 namespace Acts {
0020 
0021 /// @class CylinderPortalShell
0022 /// Base class for cylinder shaped portal shells, e.g. shells for cylinder
0023 /// volumes
0024 class CylinderPortalShell : public PortalShellBase {
0025  public:
0026   using Face = CylinderVolumeBounds::Face;
0027 
0028   using enum CylinderVolumeBounds::Face;
0029 
0030   /// Retrieve the portal associated to the given face. Can be nullptr if unset.
0031   /// @param face The face to retrieve the portal for
0032   /// @return The portal associated to the face
0033   virtual Portal* portal(Face face) = 0;
0034 
0035   /// Retrieve a shared_ptr for the portal associated to the given face. Can be
0036   /// nullptr if unset.
0037   /// @param face The face to retrieve the portal for
0038   /// @return The portal associated to the face
0039   virtual std::shared_ptr<Portal> portalPtr(Face face) = 0;
0040 
0041   /// Set the portal associated to the given face.
0042   /// @param portal The portal to set
0043   /// @param face The face to set the portal
0044   virtual void setPortal(std::shared_ptr<Portal> portal, Face face) = 0;
0045 
0046   /// @copydoc PortalShellBase::fill
0047   void fill(TrackingVolume& volume) override;
0048 };
0049 
0050 /// Output stream operator for the CylinderPortalShell::Face enum
0051 /// @param os The output stream
0052 /// @param face The face to output
0053 /// @return The output stream
0054 std::ostream& operator<<(std::ostream& os, CylinderPortalShell::Face face);
0055 
0056 /// @class SingleCylinderPortalShell
0057 /// This class describes a cylinder shell containing a single volume. The
0058 /// available faces depend on the configuration of the cylinder volume bounds.
0059 /// If a phi sector is configured, the shell will have corresponding portal
0060 /// slots. If the inner radius is non-zero, the shell will have an inner
0061 /// cylinder portal slot.
0062 class SingleCylinderPortalShell : public CylinderPortalShell {
0063  public:
0064   using Base = CylinderPortalShell;
0065 
0066   /// Construct a single cylinder portal shell for the given volume
0067   /// @param volume The volume to create the shell for
0068   explicit SingleCylinderPortalShell(TrackingVolume& volume);
0069 
0070   /// @copydoc PortalShellBase::size
0071   std::size_t size() const final;
0072 
0073   /// @copydoc CylinderPortalShell::portal
0074   Portal* portal(Face face) final;
0075 
0076   /// @copydoc CylinderPortalShell::portalPtr
0077   std::shared_ptr<Portal> portalPtr(Face face) final;
0078 
0079   /// @copydoc CylinderPortalShell::setPortal
0080   void setPortal(std::shared_ptr<Portal> portal, Face face) final;
0081 
0082   /// @copydoc PortalShellBase::applyToVolume
0083   void applyToVolume() override;
0084 
0085   /// @copydoc PortalShellBase::isValid
0086   bool isValid() const override;
0087 
0088   /// @copydoc PortalShellBase::label
0089   std::string label() const override;
0090 
0091  private:
0092   std::array<std::shared_ptr<Portal>, 6> m_portals{};
0093 
0094   TrackingVolume* m_volume;
0095 };
0096 
0097 /// @class CylinderStackPortalShell
0098 /// This class describes a cylinder shell containing multiple volumes. The
0099 /// available faces depend on the configuration of the cylinder volume bounds.
0100 /// @note The stack shell currently does not support phi sectors
0101 /// The stack can be oriented along the (local) z or r direction, which drives
0102 /// the stacking. Depending on the direction, portals on the shells of children
0103 /// are merged or fused. Subsequently, portal access respects shared portals
0104 /// between shells. Below is an illustration of a stack in the r direction:
0105 ///
0106 ///  Fused         +-----------------+
0107 /// portals ----+  |                 |
0108 ///   |         |  v           OuterCylinder
0109 ///   |  +------+------+
0110 ///   |  |      |      |
0111 ///   |  |      |      |<--+
0112 ///   +--+---+  v      |   |
0113 ///      +---+---------+   |
0114 ///      |   |         |   |      Shared portal
0115 ///      |   |         |<--+---      (grid)
0116 ///      |   v         |   |      PositiveDisc
0117 ///      +-------------+   |
0118 /// r ^  |             |   |
0119 ///   |  |             |<--+
0120 ///   |  |             |
0121 ///   |  +-------------+       InnerCylinder
0122 ///   +----->      ^            (if rMin>0)
0123 ///          z     |                 |
0124 ///                +-----------------+
0125 ///
0126 /// @note The shells must be ordered in the given direction
0127 /// Depending on the stack direction, the portal lookup will return different
0128 /// portals. In the illustration above, the `PositiveDisc` portal is shared
0129 /// among all shells, while the `OuterCylinder` and `InnerCylinder` portals are
0130 /// looked up from the innermost and outermost shell in the r direction.
0131 class CylinderStackPortalShell : public CylinderPortalShell {
0132  public:
0133   using SingleShell = SingleCylinderPortalShell;
0134 
0135   /// Construct the portal shell stack from the given shells
0136   /// @param gctx The geometry context
0137   /// @param shells The shells to stack
0138   /// @note The shells must be ordered in the given direction
0139   /// @param direction The stacking direction
0140   /// @param logger A logging instance for debugging
0141   CylinderStackPortalShell(const GeometryContext& gctx,
0142                            std::vector<CylinderPortalShell*> shells,
0143                            AxisDirection direction,
0144                            const Logger& logger = getDummyLogger());
0145 
0146   /// @copydoc PortalShellBase::size
0147   std::size_t size() const final;
0148 
0149   /// @copydoc CylinderPortalShell::portal
0150   Portal* portal(Face face) final;
0151 
0152   /// @copydoc CylinderPortalShell::portalPtr
0153   std::shared_ptr<Portal> portalPtr(Face face) final;
0154 
0155   /// @copydoc CylinderPortalShell::setPortal
0156   void setPortal(std::shared_ptr<Portal> portal, Face face) final;
0157 
0158   void applyToVolume() override {
0159     // No-op, because it's a composite portal shell
0160   }
0161 
0162   /// @copydoc PortalShellBase::isValid
0163   bool isValid() const override;
0164 
0165   /// @copydoc PortalShellBase::label
0166   std::string label() const override;
0167 
0168  private:
0169   AxisDirection m_direction;
0170   std::vector<CylinderPortalShell*> m_shells;
0171   bool m_hasInnerCylinder{true};
0172 };
0173 
0174 }  // namespace Acts