diff --git a/Core/src/Material/MaterialSlab.cpp b/Core/src/Material/MaterialSlab.cpp index a7ec8c98f4f..73d81133486 100644 --- a/Core/src/Material/MaterialSlab.cpp +++ b/Core/src/Material/MaterialSlab.cpp @@ -12,6 +12,7 @@ #include #include +#include static constexpr auto eps = 2 * std::numeric_limits::epsilon(); @@ -22,6 +23,9 @@ Acts::MaterialSlab::MaterialSlab(const Material& material, float thickness) m_thickness(thickness), m_thicknessInX0((eps < material.X0()) ? (thickness / material.X0()) : 0), m_thicknessInL0((eps < material.L0()) ? (thickness / material.L0()) : 0) { + if (thickness < 0) { + throw std::runtime_error("thickness < 0"); + } } Acts::MaterialSlab::MaterialSlab(const std::vector& layers) @@ -40,6 +44,10 @@ Acts::MaterialSlab::MaterialSlab(const std::vector& layers) } void Acts::MaterialSlab::scaleThickness(float scale) { + if (scale < 0) { + throw std::runtime_error("scale < 0"); + } + m_thickness *= scale; m_thicknessInX0 *= scale; m_thicknessInL0 *= scale; diff --git a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp index 32bf3f9d8ec..0c67db667f9 100644 --- a/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp +++ b/Fatras/include/ActsFatras/Kernel/detail/SimulationActor.hpp @@ -165,7 +165,8 @@ struct SimulationActor { // particle direction is normalized, not sure about surface normal auto cosIncidenceInv = normal.norm() / normal.dot(before.unitDirection()); - slab.scaleThickness(cosIncidenceInv); + // apply abs in case `normal` and `before` produce an angle > 90° + slab.scaleThickness(std::abs(cosIncidenceInv)); // run the interaction simulation interact(slab, result); }