Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-03 08:57:01

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/ProtoLayer.hpp"
0012 #include "Acts/Geometry/StaticBlueprintNode.hpp"
0013 
0014 #include <memory>
0015 #include <ostream>
0016 
0017 namespace Acts::Experimental {
0018 
0019 namespace detail {
0020 struct LayerBlueprintNodeImpl;
0021 }
0022 
0023 /// The layer node is essentially an auto-sizing wrapper around a set of
0024 /// surfaces.
0025 /// @note This implementation is **preliminary** and will likely change
0026 ///       in the future.
0027 /// It defers most of the functionality to @ref Acts::Experimental::StaticBlueprintNode,
0028 /// after the initial volume creation is completed.
0029 ///
0030 /// The layer volume is created to wrap around the surfaces registered with
0031 /// this node. The orientation of the resulting volume defaults to the identity
0032 /// matrix. If another orientation is desired, this can be set with the
0033 /// @ref setTransform method. See @ref Acts::ProtoLayer for details on the auto-sizing from surfaces.
0034 ///
0035 class LayerBlueprintNode final : public StaticBlueprintNode {
0036  public:
0037   /// Enum that lists out the supported layer types.
0038   enum class LayerType {
0039     /// A cylinder layer
0040     Cylinder,
0041 
0042     /// A disc layer
0043     Disc,
0044 
0045     /// A plane layer
0046     /// @note This is not yet implemented
0047     Plane
0048   };
0049 
0050   /// Constructor for a layer node.
0051   /// @param name The name of the layer
0052   explicit LayerBlueprintNode(std::string_view name);
0053 
0054   ~LayerBlueprintNode() override;
0055 
0056   /// @copydoc BlueprintNode::name
0057   const std::string& name() const override;
0058 
0059   /// This function participates in the geometry construction.
0060   /// It will:
0061   /// -# Analyze the surfaces provided and produce a wrapping volume
0062   /// -# Register the surfaces with the volume
0063   /// -# Return the volume
0064   /// @param options Blueprint options for construction
0065   /// @param gctx Geometry context for construction
0066   /// @param logger Logger for debug output
0067   /// @return Reference to constructed Volume
0068   /// @note At least one surfaces needs to be registered via
0069   ///       @ref Acts::Experimental::LayerBlueprintNode::setSurfaces before
0070   ///       geometry construction.
0071   Volume& build(const BlueprintOptions& options, const GeometryContext& gctx,
0072                 const Logger& logger = Acts::getDummyLogger()) override;
0073 
0074   /// Register a set of surfaces with the layer node.
0075   /// @param surfaces The surfaces to register
0076   /// @note This will clear any previously registered proto layer
0077   /// @return Reference to this node for chaining
0078   LayerBlueprintNode& setSurfaces(
0079       std::vector<std::shared_ptr<Surface>> surfaces);
0080 
0081   /// Access the registered surfaces.
0082   /// @return The registered surfaces
0083   const std::vector<std::shared_ptr<Surface>>& surfaces() const;
0084 
0085   /// Register a proto layer with the layer node.
0086   /// @param protoLayer The proto layer to register
0087   /// @note This will clear any previously registered surfaces
0088   /// @return Reference to this node for chaining
0089   LayerBlueprintNode& setProtoLayer(
0090       std::optional<MutableProtoLayer> protoLayer);
0091 
0092   /// Access the registered proto layer.
0093   /// @note This will return nullptr if no proto layer is registered or built yet
0094   /// @return The registered proto layer
0095   const MutableProtoLayer* protoLayer() const;
0096 
0097   /// Set the transformation of the layer node.
0098   /// This can be used to specifically orient the resulting layer volume.
0099   /// @param transform The transformation to set
0100   /// @return Reference to this node for chaining
0101   LayerBlueprintNode& setTransform(const Transform3& transform);
0102 
0103   /// Access the transformation of the layer node.
0104   /// @return The transformation
0105   const Transform3& transform() const;
0106 
0107   /// Set the envelope of the layer node. This configures the amount of space to
0108   /// add around the contained surfaces.
0109   /// @param envelope The envelope to set
0110   /// @return Reference to this node for chaining
0111   LayerBlueprintNode& setEnvelope(const ExtentEnvelope& envelope);
0112 
0113   /// Access the envelope of the layer node.
0114   /// @return The envelope
0115   const ExtentEnvelope& envelope() const;
0116 
0117   /// Set the layer type of the layer node.
0118   /// @param layerType The layer type to set
0119   /// @return Reference to this node for chaining
0120   LayerBlueprintNode& setLayerType(LayerType layerType);
0121 
0122   /// Set the layer volume to be centered on the center of gravity of the
0123   /// surfaces.
0124   /// @param x Whether to center the layer volume on the x-axis
0125   /// @param y Whether to center the layer volume on the y-axis
0126   /// @param z Whether to center the layer volume on the z-axis
0127   /// @return Reference to this node for chaining
0128   LayerBlueprintNode& setUseCenterOfGravity(bool x, bool y, bool z);
0129 
0130   /// Access the layer type of the layer node.
0131   /// @return The layer type
0132   const LayerType& layerType() const;
0133 
0134   /// Output operator for the layer type enum.
0135   /// @param os The output stream
0136   /// @param type The layer type
0137   friend std::ostream& operator<<(std::ostream& os,
0138                                   LayerBlueprintNode::LayerType type) {
0139     switch (type) {
0140       using enum LayerBlueprintNode::LayerType;
0141       case Cylinder:
0142         os << "Cylinder";
0143         break;
0144       case Disc:
0145         os << "Disc";
0146         break;
0147       case Plane:
0148         os << "Plane";
0149         break;
0150     }
0151     return os;
0152   }
0153 
0154  private:
0155   /// @copydoc Acts::Experimental::BlueprintNode::addToGraphviz
0156   void addToGraphviz(std::ostream& os) const override;
0157 
0158   /// Helper method that performs the volume creation from the configured
0159   /// surfaces. It converts from an @p extent object to an instance of @ref
0160   /// Acts::VolumeBounds.
0161   /// @param extent The extent to use for the volume creation
0162   /// @param logger The logger to use
0163   void buildVolume(const Extent& extent, const Logger& logger);
0164 
0165   detail::LayerBlueprintNodeImpl& impl();
0166   const detail::LayerBlueprintNodeImpl& impl() const;
0167 
0168   std::unique_ptr<detail::LayerBlueprintNodeImpl> m_impl;
0169 };
0170 
0171 }  // namespace Acts::Experimental