Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-31 08:19:15

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