Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-25 07:55:10

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