Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Nov 24, 2024
1 parent d3fc378 commit 1938235
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 45 deletions.
15 changes: 10 additions & 5 deletions Core/include/Acts/Material/HomogeneousSurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ class HomogeneousSurfaceMaterial : public ISurfaceMaterial {
HomogeneousSurfaceMaterial& operator=(HomogeneousSurfaceMaterial&& hsm) =
default;

/// Equality operator
///
/// @param hsm is the source material
bool operator==(const HomogeneousSurfaceMaterial& hsm) const;

/// Scale operator
/// - it is effectively a thickness scaling
///
Expand Down Expand Up @@ -94,6 +89,16 @@ class HomogeneousSurfaceMaterial : public ISurfaceMaterial {
private:
/// The five different MaterialSlab
MaterialSlab m_fullMaterial;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param other is the material to compare to
/// @return true if the materials are equal
friend constexpr bool operator==(const HomogeneousSurfaceMaterial& lhs,
const HomogeneousSurfaceMaterial& rhs) {
return lhs.m_fullMaterial == rhs.m_fullMaterial;
}
};

} // namespace Acts
17 changes: 11 additions & 6 deletions Core/include/Acts/Material/HomogeneousVolumeMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ class HomogeneousVolumeMaterial : public IVolumeMaterial {
HomogeneousVolumeMaterial& operator=(const HomogeneousVolumeMaterial& hvm) =
default;

/// Equality operator
///
/// @param hvm is the source material
bool operator==(const HomogeneousVolumeMaterial& hvm) const;

/// Access to actual material
///
/// @param position is the request position for the material call
Expand All @@ -64,7 +59,17 @@ class HomogeneousVolumeMaterial : public IVolumeMaterial {
std::ostream& toStream(std::ostream& sl) const final;

private:
Material m_material = Material();
Material m_material;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param other is the material to compare to
/// @return true if the materials are equal
friend constexpr bool operator==(const HomogeneousVolumeMaterial& lhs,
const HomogeneousVolumeMaterial& rhs) {
return lhs.m_material == rhs.m_material;
}
};

} // namespace Acts
1 change: 1 addition & 0 deletions Core/include/Acts/Material/ISurfaceMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class ISurfaceMaterial {
protected:
/// the split factor in favour of oppositePre
double m_splitFactor{1.};

/// Use the default mapping type by default
MappingType m_mappingType{Acts::MappingType::Default};
};
Expand Down
18 changes: 11 additions & 7 deletions Core/include/Acts/Material/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ class Material {
Material& operator=(Material&& mat) = default;
Material& operator=(const Material& mat) = default;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param mat is the material to compare to
/// @return true if the materials are equal
bool operator==(const Material& mat) const;

/// Check if the material is valid, i.e. it is not vacuum.
bool isValid() const { return 0.0f < m_ar; }

Expand Down Expand Up @@ -117,6 +110,17 @@ class Material {
float m_ar = 0.0f;
float m_z = 0.0f;
float m_molarRho = 0.0f;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param mat is the material to compare to
/// @return true if the materials are equal
friend constexpr bool operator==(const Material& lhs, const Material& rhs) {
return (lhs.m_x0 == rhs.m_x0) && (lhs.m_l0 == rhs.m_l0) &&
(lhs.m_ar == rhs.m_ar) && (lhs.m_z == rhs.m_z) &&
(lhs.m_molarRho == rhs.m_molarRho);
}
};

std::ostream& operator<<(std::ostream& os, const Material& material);
Expand Down
19 changes: 12 additions & 7 deletions Core/include/Acts/Material/MaterialSlab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ class MaterialSlab {
MaterialSlab& operator=(MaterialSlab&&) = default;
MaterialSlab& operator=(const MaterialSlab&) = default;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param other is the material to compare to
/// @return true if the materials are equal
bool operator==(const MaterialSlab& other) const;

/// Scale the material thickness by the given factor.
void scaleThickness(float scale);

Expand All @@ -85,6 +78,18 @@ class MaterialSlab {
float m_thickness = 0.0f;
float m_thicknessInX0 = 0.0f;
float m_thicknessInL0 = 0.0f;

/// Check if two materials are exactly equal.
/// @note This is a strict equality check, i.e. the materials must
/// have identical properties.
/// @param other is the material to compare to
/// @return true if the materials are equal
friend constexpr bool operator==(const MaterialSlab& lhs,
const MaterialSlab& rhs) {
// t/X0 and t/L0 are dependent variables and need not be checked
return (lhs.m_material == rhs.m_material) &&
(lhs.m_thickness == rhs.m_thickness);
}
};

std::ostream& operator<<(std::ostream& os, const MaterialSlab& materialSlab);
Expand Down
5 changes: 0 additions & 5 deletions Core/src/Material/HomogeneousSurfaceMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ HomogeneousSurfaceMaterial::HomogeneousSurfaceMaterial(const MaterialSlab& full,
MappingType mappingType)
: ISurfaceMaterial(splitFactor, mappingType), m_fullMaterial(full) {}

bool HomogeneousSurfaceMaterial::operator==(
const HomogeneousSurfaceMaterial& hsm) const {
return m_fullMaterial == hsm.m_fullMaterial;
}

HomogeneousSurfaceMaterial& HomogeneousSurfaceMaterial::scale(double factor) {
m_fullMaterial.scaleThickness(factor);
return *this;
Expand Down
5 changes: 0 additions & 5 deletions Core/src/Material/HomogeneousVolumeMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ namespace Acts {
HomogeneousVolumeMaterial::HomogeneousVolumeMaterial(const Material& material)
: m_material(material) {}

bool HomogeneousVolumeMaterial::operator==(
const HomogeneousVolumeMaterial& hvm) const {
return m_material == hvm.m_material;
}

const Material HomogeneousVolumeMaterial::material(
const Vector3& /*position*/) const {
return m_material;
Expand Down
5 changes: 0 additions & 5 deletions Core/src/Material/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ float Material::massDensity() const {
return atomicMass * numberDensity;
}

bool Material::operator==(const Material& mat) const {
return m_x0 == mat.m_x0 && m_l0 == mat.m_l0 && m_ar == mat.m_ar &&
m_z == mat.m_z && m_molarRho == mat.m_molarRho;
}

float Material::meanExcitationEnergy() const {
using namespace UnitLiterals;

Expand Down
5 changes: 0 additions & 5 deletions Core/src/Material/MaterialSlab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "Acts/Material/detail/AverageMaterials.hpp"

#include <limits>
#include <numeric>
#include <ostream>
#include <stdexcept>

Expand All @@ -33,10 +32,6 @@ MaterialSlab::MaterialSlab(const Material& material, float thickness)
}
}

bool MaterialSlab::operator==(const MaterialSlab& other) const {
return m_material == other.m_material && m_thickness == other.m_thickness;
}

MaterialSlab MaterialSlab::averageLayers(const MaterialSlab& layerA,
const MaterialSlab& layerB) {
return detail::combineSlabs(layerA, layerB);
Expand Down
2 changes: 2 additions & 0 deletions Tests/UnitTests/Core/Material/MaterialSlabTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ BOOST_AUTO_TEST_CASE(scale_thickness) {
Acts::MaterialSlab halfScaled = mat;
halfScaled.scaleThickness(0.5);

BOOST_CHECK_NE(mat, halfMat);
BOOST_CHECK_EQUAL(halfMat, halfScaled);
CHECK_CLOSE_REL(mat.thicknessInX0(), 2 * halfMat.thicknessInX0(), eps);
CHECK_CLOSE_REL(mat.thicknessInL0(), 2 * halfMat.thicknessInL0(), eps);
CHECK_CLOSE_REL(mat.thickness() * mat.material().massDensity(),
Expand Down

0 comments on commit 1938235

Please sign in to comment.