Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 44 additions & 7 deletions Core/include/Acts/Material/BinnedSurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,68 @@
#include "Acts/Material/ISurfaceMaterial.hpp"
#include "Acts/Material/MaterialSlab.hpp"
#include "Acts/Utilities/BinUtility.hpp"
#include "Acts/Utilities/ProtoAxis.hpp"

#include <array>
#include <iosfwd>

namespace Acts {

/// @ingroup material
///
/// It extends the @ref ISurfaceMaterial base class and is an array pf
/// It extends the @ref ISurfaceMaterial base class and is an array of
/// MaterialSlab. This is not memory optimised as every bin
/// holds one material property object.
///
/// The binning is described by two @ref DirectedProtoAxis objects. A
/// conceptually 1D surface uses a second axis with a single bin.
///
/// The split factors:
/// - 1. : oppositePre
/// - 0. : alongPre
class BinnedSurfaceMaterial : public ISurfaceMaterial {
public:
/// Primary constructor using two directed proto axes (always 2D).
///
/// @param axes defines the 2D binning structure on the surface; for a
/// conceptually 1D surface use a second axis with a single bin
/// @param materialMatrix is the matrix of material slabs (moved)
/// @param splitFactor is the pre/post splitting directive
/// @param mappingType is the type of surface mapping associated to the surface
BinnedSurfaceMaterial(std::array<DirectedProtoAxis, 2> axes,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we strictly need DirectedProtoAxis here? the two things I know of it provides additionally to an IAxis is the direction, which I want to add with #5540, and the auto sizing from ProtoAxis. I imagine this cannot rely on auto sizing since the material matrix is already generated with some given binning.

ultimately we could use IMultiAxisND<N> from here #5531. what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, I think we should use IMultiAxisND<2> here, shall we wait until we are through with the IAxis reordering?

MaterialSlabMatrix materialMatrix,
double splitFactor = 0.,
MappingType mappingType = MappingType::Default);

/// @deprecated Use the DirectedProtoAxis-based constructor instead.
///
/// Explicit constructor with only full MaterialSlab,
/// for one-dimensional binning.
///
/// @param binUtility defines the binning structure on the surface (copied)
/// @param materialVector is the vector of material slabs as recorded (moved)
/// @param splitFactor is the pre/post splitting directive
/// @param mappingType is the type of surface mapping associated to the surface
[[deprecated(
"Use BinnedSurfaceMaterial(std::array<DirectedProtoAxis, 2>, "
"MaterialSlabMatrix) instead")]]
BinnedSurfaceMaterial(const BinUtility& binUtility,
MaterialSlabVector materialVector,
double splitFactor = 0.,
MappingType mappingType = MappingType::Default);

/// @deprecated Use the DirectedProtoAxis-based constructor instead.
///
/// Explicit constructor with only full MaterialSlab,
/// for two-dimensional binning.
///
/// @param binUtility defines the binning structure on the surface (copied)
/// @param materialMatrix is the matrix of material slabs as recorded (moved)
/// @param splitFactor is the pre/post splitting directive
/// @param mappingType is the type of surface mapping associated to the surface
[[deprecated(
"Use BinnedSurfaceMaterial(std::array<DirectedProtoAxis, 2>, "
"MaterialSlabMatrix) instead")]]
BinnedSurfaceMaterial(const BinUtility& binUtility,
MaterialSlabMatrix materialMatrix,
double splitFactor = 0.,
Expand All @@ -58,9 +85,18 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial {
/// @return Reference to this object after scaling
BinnedSurfaceMaterial& scale(double factor) final;

/// Return the BinUtility
/// @return Reference to the bin utility used for material binning
const BinUtility& binUtility() const { return m_binUtility; }
/// Return the two directed proto axes describing the binning.
/// @return const reference to the axes array
const std::array<DirectedProtoAxis, 2>& axes() const { return m_axes; }

/// @deprecated Use axes() instead.
///
/// Return a BinUtility reconstructed from the internal axes.
/// Single-bin dummy axes are omitted so the result matches what was
/// originally provided to the deprecated BinUtility constructors.
///
/// @return reconstructed BinUtility
[[deprecated("Use axes() instead")]] BinUtility binUtility() const;

/// @brief Retrieve the entire material slab matrix
/// @return Reference to the complete matrix of material slabs
Expand All @@ -86,10 +122,11 @@ class BinnedSurfaceMaterial : public ISurfaceMaterial {
std::ostream& toStream(std::ostream& sl) const final;

private:
/// The helper for the bin finding
BinUtility m_binUtility;
/// The two directed axes defining the binning (axis 0 → lp[0], axis 1 →
/// lp[1])
std::array<DirectedProtoAxis, 2> m_axes;

/// The five different MaterialSlab
/// The MaterialSlab matrix (row = axis-1 bin, col = axis-0 bin)
MaterialSlabMatrix m_fullMaterial;
};

Expand Down
153 changes: 73 additions & 80 deletions Core/include/Acts/Material/ProtoSurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "Acts/Utilities/BinUtility.hpp"
#include "Acts/Utilities/ProtoAxis.hpp"

#include <array>
#include <iosfwd>
#include <vector>

Expand All @@ -22,118 +23,110 @@ namespace Acts {
/// @addtogroup material
/// @{

/// Convert a BinUtility to a pair of two DirectedProtoAxis.
/// For a 1D BinUtility a single-bin dummy axis is appended as the second axis.
/// This helper is intended for migration code that still works with BinUtility.
std::array<DirectedProtoAxis, 2> protoAxesFromBinUtility(const BinUtility& bu);
Comment on lines +26 to +29

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we elevate this to an utility?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, actually something that can disappear with the BinUtility.


///
/// @brief proxy to SurfaceMaterial hand over BinUtility or other suitable
/// binning description
/// @brief Prototype surface material described by two @ref DirectedProtoAxis
/// objects.
///
/// The ProtoSurfaceMaterial class acts as a proxy to the SurfaceMaterial
/// to mark the layers and surfaces on which the material should be mapped on
/// at construction time of the geometry and to hand over the granularity of
/// of the material map with the bin Utility.
template <typename BinningType>
class ProtoSurfaceMaterialT : public ISurfaceMaterial {
/// to mark surfaces on which the material should be mapped at geometry
/// construction time. It carries the binning description with two directed
/// proto axes. A conceptually 1D surface uses a second axis with a single bin.
///
class ProtoSurfaceMaterial : public ISurfaceMaterial {
public:
/// Constructor without binningType - homogeneous material
ProtoSurfaceMaterialT() = default;
/// Default constructor — creates a homogeneous (single-bin) placeholder.
ProtoSurfaceMaterial();

/// Constructor with BinningType
/// @param binning a binning description for the material map binning
/// Constructor with two directed proto axes.
///
/// @param axes the 2D binning description
/// @param mappingType is the type of surface mapping associated to the surface
explicit ProtoSurfaceMaterialT(const BinningType& binning,
MappingType mappingType = MappingType::Default)
: ISurfaceMaterial(1., mappingType), m_binning(binning) {}
explicit ProtoSurfaceMaterial(std::array<DirectedProtoAxis, 2> axes,
MappingType mappingType = MappingType::Default);

/// Copy constructor
/// @deprecated Use the std::array<DirectedProtoAxis, 2> constructor instead.
///
/// @param smproxy The source proxy
ProtoSurfaceMaterialT(const ProtoSurfaceMaterialT<BinningType>& smproxy) =
default;

/// Copy move constructor
/// Constructor from a BinUtility.
///
/// @param smproxy The source proxy
ProtoSurfaceMaterialT(ProtoSurfaceMaterialT<BinningType>&& smproxy) noexcept =
default;

/// Destructor
~ProtoSurfaceMaterialT() override = default;
/// @param binUtil the binning utility (converted to two DirectedProtoAxis)
/// @param mappingType is the type of surface mapping associated to the surface
[[deprecated(
"Use ProtoSurfaceMaterial(std::array<DirectedProtoAxis, 2>) "
"instead")]]
explicit ProtoSurfaceMaterial(const BinUtility& binUtil,
MappingType mappingType = MappingType::Default);

/// Assignment operator
/// @deprecated Use the std::array<DirectedProtoAxis, 2> constructor instead.
///
/// @param smproxy The source proxy
/// @return Reference to this object
ProtoSurfaceMaterialT<BinningType>& operator=(
const ProtoSurfaceMaterialT<BinningType>& smproxy) = default;

/// Assignment move operator
/// Constructor from a vector of DirectedProtoAxis objects (was the
/// ProtoGridSurfaceMaterial path). Only the first two axes are used; if only
/// one is provided a single-bin dummy axis is added.
///
/// @param smproxy The source proxy
/// @return Reference to this object
ProtoSurfaceMaterialT<BinningType>& operator=(
ProtoSurfaceMaterialT<BinningType>&& smproxy) noexcept = default;

/// Scale operation - dummy implementation
/// @param axes vector of directed proto axes
/// @param mappingType is the type of surface mapping associated to the surface
[[deprecated(
"Use ProtoSurfaceMaterial(std::array<DirectedProtoAxis, 2>) "
"instead")]]
explicit ProtoSurfaceMaterial(const std::vector<DirectedProtoAxis>& axes,
MappingType mappingType = MappingType::Default);

/// Copy / move / destructor — all defaulted.
ProtoSurfaceMaterial(const ProtoSurfaceMaterial&) = default;
ProtoSurfaceMaterial(ProtoSurfaceMaterial&&) noexcept = default;
~ProtoSurfaceMaterial() override = default;
ProtoSurfaceMaterial& operator=(const ProtoSurfaceMaterial&) = default;
ProtoSurfaceMaterial& operator=(ProtoSurfaceMaterial&&) noexcept = default;

/// Scale operation — no-op for proto material.
ProtoSurfaceMaterial& scale(double /*factor*/) final { return *this; }

/// Return the two directed proto axes.
/// @return const reference to the axes array
const std::array<DirectedProtoAxis, 2>& axes() const { return m_axes; }

/// @deprecated Use axes() instead.
///
/// @return Reference to this object
ProtoSurfaceMaterialT<BinningType>& scale(double /*factor*/) final {
return (*this);
}

/// Return the BinUtility
/// @return Reference to the binning
const BinningType& binning() const { return (m_binning); }

/// Return method for full material description of the Surface - from local
/// coordinates
/// Reconstruct a BinUtility from the internal axes.
/// Single-bin dummy axes are omitted so the result matches what was
/// originally provided to the deprecated BinUtility constructor.
///
/// @return will return dummy material
/// @return reconstructed BinUtility
[[deprecated("Use axes() instead")]] BinUtility binning() const;

/// Return method for full material description — returns dummy material.
const MaterialSlab& materialSlab(const Vector2& /*lp*/) const final {
return (m_materialSlab);
return m_materialSlab;
}

/// @copydoc ISurfaceMaterial::localAxisDirections() const
std::vector<AxisDirection> localAxisDirections() const final { return {}; }
std::vector<AxisDirection> localAxisDirections() const final;

/// Return method for full material description of the Surface - from the
/// global coordinates
///
/// @return will return dummy material
/// @copydoc ISurfaceMaterial::materialSlab(const Vector3&) const
[[deprecated(
"Use materialSlab(const Vector2& lp) with a prior "
"Surface::globalToLocal() call instead")]] const MaterialSlab&
materialSlab(const Vector3& /*gp*/) const final {
return (m_materialSlab);
return m_materialSlab;
}

using ISurfaceMaterial::materialSlab;

/// Output Method for std::ostream, to be overloaded by child classes
///
/// @param sl is the output stream
/// @return The output stream
std::ostream& toStream(std::ostream& sl) const final {
sl << "Acts::ProtoSurfaceMaterial : " << std::endl;
sl << m_binning << std::endl;
return sl;
}
/// Output Method for std::ostream.
std::ostream& toStream(std::ostream& sl) const final;

private:
/// A binning description
BinningType m_binning;

/// Dummy material properties
std::array<DirectedProtoAxis, 2> m_axes;
MaterialSlab m_materialSlab = MaterialSlab::Nothing();
};

/// @brief Type alias for a prototype surface material using BinUtility
/// A surface material implementation that uses BinUtility for binning
using ProtoSurfaceMaterial = ProtoSurfaceMaterialT<Acts::BinUtility>;

/// @brief Type alias for a prototype surface material using a grid of ProtoAxis
/// A surface material implementation that uses a vector of ProtoAxis for
/// grid-based binning
using ProtoGridSurfaceMaterial =
ProtoSurfaceMaterialT<std::vector<DirectedProtoAxis>>;
/// @deprecated Use ProtoSurfaceMaterial instead. Will be removed in a future release.
using ProtoGridSurfaceMaterial
[[deprecated("Use ProtoSurfaceMaterial instead")]] = ProtoSurfaceMaterial;

/// @}

Expand Down
2 changes: 1 addition & 1 deletion Core/src/Geometry/MaterialDesignator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ProtoDesignator {
<< loc1 << " to face " << face);

portal->surface().assignSurfaceMaterial(
std::make_shared<ProtoGridSurfaceMaterial>(std::vector{loc0, loc1}));
std::make_shared<ProtoSurfaceMaterial>(std::array{loc0, loc1}));
}
}

Expand Down
Loading
Loading