Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-24 07:33:47

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