Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-12 09:39:35

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 increasing local stack coordinates
0107   ///       along the given direction. The supplied order is preserved.
0108   /// @throws AssertionFailureException If the supplied shells are empty or
0109   ///         are not ordered along the local stacking axis.
0110   /// @param direction The stacking direction (along x/y/z axis) in local stack coordinates
0111   /// @param logger A logging instance for debugging
0112   /// @param materialPolicy How to treat material designated on faces that are
0113   ///        merged during stacking. By default this is a fatal error; in
0114   ///        @ref PortalMaterialMergePolicy::eDiscardAndMark mode the material is
0115   ///        discarded and the merged surface is tagged with a marker.
0116   CuboidStackPortalShell(const GeometryContext& gctx,
0117                          std::vector<CuboidPortalShell*> shells,
0118                          AxisDirection direction,
0119                          const Logger& logger = getDummyLogger(),
0120                          PortalMaterialMergePolicy materialPolicy =
0121                              PortalMaterialMergePolicy::eThrow);
0122 
0123   /// Return the faces that are *merged* (as opposed to fused) when stacking in
0124   /// the given direction. Material designated on these faces of a child shell
0125   /// cannot survive the stacking and will cause a merge failure.
0126   /// @param direction The stacking direction
0127   /// @return The faces that get merged for the given direction
0128   static std::vector<Face> mergedFaces(AxisDirection direction);
0129 
0130   /// @copydoc PortalShellBase::size
0131   std::size_t size() const override;
0132 
0133   /// @copydoc CuboidPortalShell::portal
0134   std::shared_ptr<Portal> portal(Face face) override;
0135 
0136   /// @copydoc CuboidPortalShell::setPortal
0137   void setPortal(std::shared_ptr<Portal> portal, Face face) override;
0138 
0139   void applyToVolume() override {
0140     // No-op, because it's a composite portal shell
0141   }
0142 
0143   /// @copydoc PortalShellBase::isValid
0144   bool isValid() const override;
0145 
0146   /// @copydoc PortalShellBase::label
0147   std::string label() const override;
0148 
0149   /// Return the stack's group transform
0150   /// @param gctx The geometry context
0151   /// @return Reference to the transform of the cuboid stack
0152   const Transform3& localToGlobalTransform(
0153       const GeometryContext& gctx) const override;
0154 
0155  private:
0156   /// Shell stacking direction in local stack coordinates
0157   AxisDirection m_direction;
0158 
0159   /// The cuboid face positioned first along the stacking direction
0160   CuboidVolumeBounds::Face m_frontFace = Face::NegativeXFace;
0161   /// The cuboid face positioned last along the stacking direction
0162   CuboidVolumeBounds::Face m_backFace = Face::PositiveXFace;
0163   /// The cuboid faces parallel to the stacking direction
0164   std::array<CuboidVolumeBounds::Face, 4> m_sideFaces{
0165       Face::NegativeZFace, Face::PositiveZFace, Face::NegativeYFace,
0166       Face::PositiveYFace};
0167 
0168   std::vector<CuboidPortalShell*> m_shells;
0169 };
0170 
0171 }  // namespace Acts