Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:07:29

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 volume The volume to create the shell for
0065   explicit SingleCylinderPortalShell(TrackingVolume& volume);
0066 
0067   /// @copydoc PortalShellBase::size
0068   std::size_t size() const final;
0069 
0070   /// @copydoc CylinderPortalShell::portal
0071   std::shared_ptr<Portal> portal(Face face) final;
0072 
0073   /// @copydoc CylinderPortalShell::setPortal
0074   void setPortal(std::shared_ptr<Portal> portal, Face face) final;
0075 
0076   /// @copydoc PortalShellBase::applyToVolume
0077   void applyToVolume() override;
0078 
0079   /// @copydoc PortalShellBase::isValid
0080   bool isValid() const override;
0081 
0082   /// @copydoc PortalShellBase::label
0083   std::string label() const override;
0084 
0085  private:
0086   std::array<std::shared_ptr<Portal>, 6> m_portals{};
0087 
0088   TrackingVolume* m_volume;
0089 };
0090 
0091 /// @class CylinderStackPortalShell
0092 /// This class describes a cylinder shell containing multiple volumes. The
0093 /// available faces depend on the configuration of the cylinder volume bounds.
0094 /// @note The stack shell currently does not support phi sectors
0095 /// The stack can be oriented along the (local) z or r direction, which drives
0096 /// the stacking. Depending on the direction, portals on the shells of children
0097 /// are merged or fused. Subsequently, portal access respects shared portals
0098 /// between shells. Below is an illustration of a stack in the r direction:
0099 /// ```
0100 ///  Fused         +-----------------+
0101 /// portals ----+  |                 |
0102 ///   |         |  v           OuterCylinder
0103 ///   |  +------+------+
0104 ///   |  |      |      |
0105 ///   |  |      |      |<--+
0106 ///   +--+---+  v      |   |
0107 ///      +---+---------+   |
0108 ///      |   |         |   |      Shared portal
0109 ///      |   |         |<--+---      (grid)
0110 ///      |   v         |   |      PositiveDisc
0111 ///      +-------------+   |
0112 /// r ^  |             |   |
0113 ///   |  |             |<--+
0114 ///   |  |             |
0115 ///   |  +-------------+       InnerCylinder
0116 ///   +----->      ^            (if rMin>0)
0117 ///          z     |                 |
0118 ///                +-----------------+
0119 /// ```
0120 /// @note The shells must be ordered in the given direction
0121 /// Depending on the stack direction, the portal lookup will return different
0122 /// portals. In the illustration above, the `PositiveDisc` portal is shared
0123 /// among all shells, while the `OuterCylinder` and `InnerCylinder` portals are
0124 /// looked up from the innermost and outermost shell in the r direction.
0125 class CylinderStackPortalShell : public CylinderPortalShell {
0126  public:
0127   /// Type alias for single cylinder portal shell type used in stacks
0128   using SingleShell = SingleCylinderPortalShell;
0129 
0130   /// Construct the portal shell stack from the given shells
0131   /// @param gctx The geometry context
0132   /// @param shells The shells to stack
0133   /// @note The shells must be ordered in the given direction
0134   /// @param direction The stacking direction
0135   /// @param logger A logging instance for debugging
0136   CylinderStackPortalShell(const GeometryContext& gctx,
0137                            std::vector<CylinderPortalShell*> shells,
0138                            AxisDirection direction,
0139                            const Logger& logger = getDummyLogger());
0140 
0141   /// @copydoc PortalShellBase::size
0142   std::size_t size() const final;
0143 
0144   /// @copydoc CylinderPortalShell::portal
0145   std::shared_ptr<Portal> portal(Face face) final;
0146 
0147   /// @copydoc CylinderPortalShell::setPortal
0148   void setPortal(std::shared_ptr<Portal> portal, Face face) final;
0149 
0150   void applyToVolume() override {
0151     // No-op, because it's a composite portal shell
0152   }
0153 
0154   /// @copydoc PortalShellBase::isValid
0155   bool isValid() const override;
0156 
0157   /// @copydoc PortalShellBase::label
0158   std::string label() const override;
0159 
0160  private:
0161   AxisDirection m_direction;
0162   std::vector<CylinderPortalShell*> m_shells;
0163   bool m_hasInnerCylinder{true};
0164 };
0165 
0166 }  // namespace Acts