Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-16 07:35:12

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/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/CuboidVolumeBounds.hpp"
0013 #include "Acts/Geometry/PortalShell.hpp"
0014 #include "Acts/Geometry/TrackingVolume.hpp"
0015 #include "Acts/Utilities/AxisDefinitions.hpp"
0016 #include "Acts/Utilities/Logger.hpp"
0017 
0018 #include <array>
0019 #include <memory>
0020 #include <vector>
0021 
0022 namespace Acts {
0023 
0024 /// @class CuboidPortalShell
0025 /// Base class for cuboid shaped portal shells, e.g. shells for cuboid
0026 /// volumes
0027 class CuboidPortalShell : public PortalShellBase {
0028  public:
0029   /// Type alias for cuboid volume bounds face enumeration
0030   using Face = CuboidVolumeBounds::Face;
0031 
0032   /// Retrieve a shared_ptr for the portal associated to the given face. Can be
0033   /// nullptr if unset.
0034   /// @param face The face to retrieve the portal for
0035   /// @return The portal associated to the face
0036   virtual std::shared_ptr<Portal> portal(Face face) = 0;
0037 
0038   /// Set the portal associated to the given face.
0039   /// @param portal The portal to set
0040   /// @param face The face to set the portal
0041   virtual void setPortal(std::shared_ptr<Portal> portal, Face face) = 0;
0042 
0043   /// @copydoc PortalShellBase::fill
0044   void fill(TrackingVolume& volume) override;
0045 
0046   /// @brief Get the transformation matrix for this cuboid portal shell
0047   /// @param gctx The geometry context
0048   /// @return Reference to the transformation matrix
0049   virtual const Transform3& localToGlobalTransform(
0050       const GeometryContext& gctx) const = 0;
0051 };
0052 
0053 /// Output stream operator for the CuboidPortalShell::Face enum
0054 /// @param os The output stream
0055 /// @param face The face to output
0056 /// @return The output stream
0057 std::ostream& operator<<(std::ostream& os, CuboidPortalShell::Face face);
0058 
0059 /// @class SingleCuboidPortalShell
0060 /// This class describes a cuboid shell containing a single volume.
0061 class SingleCuboidPortalShell : public CuboidPortalShell {
0062  public:
0063   /// Construct a single cuboid 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 SingleCuboidPortalShell(const GeometryContext& gctx,
0067                                    TrackingVolume& volume);
0068 
0069   /// @copydoc PortalShellBase::size
0070   std::size_t size() const final;
0071 
0072   /// @copydoc CuboidPortalShell::portal
0073   std::shared_ptr<Portal> portal(Face face) final;
0074 
0075   /// @copydoc CuboidPortalShell::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   const Transform3& localToGlobalTransform(
0088       const GeometryContext& gctx) const override {
0089     return m_volume->localToGlobalTransform(gctx);
0090   };
0091 
0092  private:
0093   std::array<std::shared_ptr<Portal>, 6> m_portals{};
0094 
0095   TrackingVolume* m_volume;
0096 };
0097 
0098 /// @class CuboidStackPortalShell
0099 /// This class describes a cuboid shell containing multiple volumes.
0100 class CuboidStackPortalShell final : public CuboidPortalShell {
0101  public:
0102   /// Construct the portal shell stack from the given shells
0103   /// @param gctx The geometry context
0104   /// @param shells The shells to stack
0105   /// @note The shells must be ordered in the given direction
0106   /// @param direction The stacking direction (along x/y/z axis) in local stack coordinates
0107   /// @param logger A logging instance for debugging
0108   CuboidStackPortalShell(const GeometryContext& gctx,
0109                          std::vector<CuboidPortalShell*> shells,
0110                          AxisDirection direction,
0111                          const Logger& logger = getDummyLogger());
0112 
0113   /// @copydoc PortalShellBase::size
0114   std::size_t size() const override;
0115 
0116   /// @copydoc CuboidPortalShell::portal
0117   std::shared_ptr<Portal> portal(Face face) override;
0118 
0119   /// @copydoc CuboidPortalShell::setPortal
0120   void setPortal(std::shared_ptr<Portal> portal, Face face) override;
0121 
0122   void applyToVolume() override {
0123     // No-op, because it's a composite portal shell
0124   }
0125 
0126   /// @copydoc PortalShellBase::isValid
0127   bool isValid() const override;
0128 
0129   /// @copydoc PortalShellBase::label
0130   std::string label() const override;
0131 
0132   /// Return the stack's group transform
0133   /// @param gctx The geometry context
0134   /// @return Reference to the transform of the cuboid stack
0135   const Transform3& localToGlobalTransform(
0136       const GeometryContext& gctx) const override;
0137 
0138  private:
0139   /// Shell stacking direction in local stack coordinates
0140   AxisDirection m_direction;
0141 
0142   /// The cuboid face positioned first along the stacking direction
0143   CuboidVolumeBounds::Face m_frontFace = Face::NegativeXFace;
0144   /// The cuboid face positioned last along the stacking direction
0145   CuboidVolumeBounds::Face m_backFace = Face::PositiveXFace;
0146   /// The cuboid faces parallel to the stacking direction
0147   std::array<CuboidVolumeBounds::Face, 4> m_sideFaces{
0148       Face::NegativeZFace, Face::PositiveZFace, Face::NegativeYFace,
0149       Face::PositiveYFace};
0150 
0151   std::vector<CuboidPortalShell*> m_shells;
0152 };
0153 
0154 }  // namespace Acts