diff --git a/Sim/Scan/AlphaScan.cpp b/Sim/Scan/AlphaScan.cpp index cc55ad1afcac8f3013fe00e768c7dabfbd84867a..c2cb81e99acb9035882be55a5bed53d1dbb69637 100644 --- a/Sim/Scan/AlphaScan.cpp +++ b/Sim/Scan/AlphaScan.cpp @@ -58,6 +58,7 @@ AlphaScan* AlphaScan::clone() const auto* result = new AlphaScan(*m_axis); result->setIntensity(intensity()); result->setFootprint(m_footprint.get()); + result->setAlphaOffset(alphaOffset()); if (m_lambda_distrib) result->m_lambda_distrib.reset(m_lambda_distrib->clone()); diff --git a/Sim/Scan/AlphaScan.h b/Sim/Scan/AlphaScan.h index 002017a95a9fb35b43ab38fde515636c76656067..7721d41dadd221e5a141f1f1516943e5bd7e9715 100644 --- a/Sim/Scan/AlphaScan.h +++ b/Sim/Scan/AlphaScan.h @@ -56,6 +56,8 @@ public: return m_alpha_distrib.get(); } + double alphaOffset() const { return m_alpha_offset; } + private: void checkInitialization(); diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index a053413461f6782926e0dc96406410249a4e3d45..b64af793abaa38f6ca14f1cb3eaab0b9a676b34e 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -28,6 +28,7 @@ #include "Resample/Element/DepthprobeElement.h" #include "Sim/Computation/DepthprobeComputation.h" #include "Sim/Scan/AlphaScan.h" +#include <iostream> DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample) : ISimulation(sample) @@ -69,9 +70,15 @@ void DepthprobeSimulation::initDistributionHandler() switch (distribution.whichParameter()) { case ParameterDistribution::BeamInclinationAngle: + { + auto* s = dynamic_cast<AlphaScan*>(m_scan.get()); + if (!s) + throw std::runtime_error("Alpha distribution not compatible with non-alpha scan"); distributionHandler().defineCallbackForDistribution( - &distribution, [&](double d) { m_beam->setInclination(d); }); + &distribution, [&](double d) { m_beam->setInclination(d);s->setAlphaOffset(d); + ASSERT( s->alphaOffset() == m_beam->alpha_i());}); break; + } case ParameterDistribution::BeamWavelength: distributionHandler().defineCallbackForDistribution( &distribution, [&](double d) { m_scan->setWavelength(d); }); @@ -84,7 +91,12 @@ void DepthprobeSimulation::initDistributionHandler() void DepthprobeSimulation::runComputation(const ReSample& re_sample, size_t i, double weight) { - const double result_angle = m_alpha_axis->bin(i).center() + m_beam->alpha_i(); + const auto* s = dynamic_cast<AlphaScan*>(m_scan.get()); + if (!s) + throw std::runtime_error("Alpha distribution not compatible with non-alpha scan"); + std::cout << s->alphaOffset() << " vs " << m_beam->alpha_i() << std::endl; + ASSERT( s->alphaOffset() == m_beam->alpha_i()); + const double result_angle = m_alpha_axis->bin(i).center() + s->alphaOffset(); DepthprobeElement ele(m_scan->wavelength(), -result_angle, m_z_axis.get(), 0 < result_angle && result_angle < M_PI_2);