Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-16 08:02:07

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