Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-15 07:35:57

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/Portal.hpp"
0014 #include "Acts/Geometry/PortalShell.hpp"
0015 #include "Acts/Geometry/TrackingVolume.hpp"
0016 #include "Acts/Utilities/AxisDefinitions.hpp"
0017 #include "Acts/Utilities/Logger.hpp"
0018 
0019 #include <array>
0020 #include <memory>
0021 #include <vector>
0022 
0023 namespace Acts {
0024 
0025 /// @class CuboidPortalShell
0026 /// Base class for cuboid shaped portal shells, e.g. shells for cuboid
0027 /// volumes
0028 class CuboidPortalShell : public PortalShellBase {
0029  public:
0030   /// Type alias for cuboid volume bounds face enumeration
0031   using Face = CuboidVolumeBounds::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   /// @brief Get the transformation matrix for this cuboid portal shell
0048   /// @param gctx The geometry context
0049   /// @return Reference to the transformation matrix
0050   virtual const Transform3& localToGlobalTransform(
0051       const GeometryContext& gctx) const = 0;
0052 };
0053 
0054 /// Output stream operator for the CuboidPortalShell::Face enum
0055 /// @param os The output stream
0056 /// @param face The face to output
0057 /// @return The output stream
0058 std::ostream& operator<<(std::ostream& os, CuboidPortalShell::Face face);
0059 
0060 /// @class SingleCuboidPortalShell
0061 /// This class describes a cuboid shell containing a single volume.
0062 class SingleCuboidPortalShell : public CuboidPortalShell {
0063  public:
0064   /// Construct a single cuboid portal shell for the given volume
0065   /// @param gctx The current geometry context object, e.g. alignment
0066   /// @param volume The volume to create the shell for
0067   explicit SingleCuboidPortalShell(const GeometryContext& gctx,
0068                                    TrackingVolume& volume);
0069 
0070   /// @copydoc PortalShellBase::size
0071   std::size_t size() const final;
0072 
0073   /// @copydoc CuboidPortalShell::portal
0074   std::shared_ptr<Portal> portal(Face face) final;
0075 
0076   /// @copydoc CuboidPortalShell::setPortal
0077   void setPortal(std::shared_ptr<Portal> portal, Face face) final;
0078 
0079   /// @copydoc PortalShellBase::applyToVolume
0080   void applyToVolume() override;
0081 
0082   /// @copydoc PortalShellBase::isValid
0083   bool isValid() const override;
0084 
0085   /// @copydoc PortalShellBase::label
0086   std::string label() const override;
0087 
0088   const Transform3& localToGlobalTransform(
0089       const GeometryContext& gctx) const override {
0090     return m_volume->localToGlobalTransform(gctx);
0091   };
0092 
0093  private:
0094   std::array<std::shared_ptr<Portal>, 6> m_portals{};
0095 
0096   TrackingVolume* m_volume;
0097 };
0098 
0099 /// @class CuboidStackPortalShell
0100 /// This class describes a cuboid shell containing multiple volumes.
0101 class CuboidStackPortalShell final : public CuboidPortalShell {
0102  public:
0103   /// Construct the portal shell stack from the given shells
0104   /// @param gctx The geometry context
0105   /// @param shells The shells to stack
0106   /// @note The shells must be ordered in the given direction
0107   /// @param direction The stacking direction (along x/y/z axis) in local stack coordinates
0108   /// @param logger A logging instance for debugging
0109   /// @param materialPolicy How to treat material designated on faces that are
0110   ///        merged during stacking. By default this is a fatal error; in
0111   ///        @ref PortalMaterialMergePolicy::eDiscardAndMark mode the material is
0112   ///        discarded and the merged surface is tagged with a marker.
0113   CuboidStackPortalShell(const GeometryContext& gctx,
0114                          std::vector<CuboidPortalShell*> shells,
0115                          AxisDirection direction,
0116                          const Logger& logger = getDummyLogger(),
0117                          PortalMaterialMergePolicy materialPolicy =
0118                              PortalMaterialMergePolicy::eThrow);
0119 
0120   /// Return the faces that are *merged* (as opposed to fused) when stacking in
0121   /// the given direction. Material designated on these faces of a child shell
0122   /// cannot survive the stacking and will cause a merge failure.
0123   /// @param direction The stacking direction
0124   /// @return The faces that get merged for the given direction
0125   static std::vector<Face> mergedFaces(AxisDirection direction);
0126 
0127   /// @copydoc PortalShellBase::size
0128   std::size_t size() const override;
0129 
0130   /// @copydoc CuboidPortalShell::portal
0131   std::shared_ptr<Portal> portal(Face face) override;
0132 
0133   /// @copydoc CuboidPortalShell::setPortal
0134   void setPortal(std::shared_ptr<Portal> portal, Face face) override;
0135 
0136   void applyToVolume() override {
0137     // No-op, because it's a composite portal shell
0138   }
0139 
0140   /// @copydoc PortalShellBase::isValid
0141   bool isValid() const override;
0142 
0143   /// @copydoc PortalShellBase::label
0144   std::string label() const override;
0145 
0146   /// Return the stack's group transform
0147   /// @param gctx The geometry context
0148   /// @return Reference to the transform of the cuboid stack
0149   const Transform3& localToGlobalTransform(
0150       const GeometryContext& gctx) const override;
0151 
0152  private:
0153   /// Shell stacking direction in local stack coordinates
0154   AxisDirection m_direction;
0155 
0156   /// The cuboid face positioned first along the stacking direction
0157   CuboidVolumeBounds::Face m_frontFace = Face::NegativeXFace;
0158   /// The cuboid face positioned last along the stacking direction
0159   CuboidVolumeBounds::Face m_backFace = Face::PositiveXFace;
0160   /// The cuboid faces parallel to the stacking direction
0161   std::array<CuboidVolumeBounds::Face, 4> m_sideFaces{
0162       Face::NegativeZFace, Face::PositiveZFace, Face::NegativeYFace,
0163       Face::PositiveYFace};
0164 
0165   std::vector<CuboidPortalShell*> m_shells;
0166 };
0167 
0168 }  // namespace Acts