Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-23 08:19:20

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