diff --git a/Sim/Scan/AlphaScan.h b/Sim/Scan/AlphaScan.h index 7721d41dadd221e5a141f1f1516943e5bd7e9715..c1c384b89229c0a726fb74c1ee07643093915fb3 100644 --- a/Sim/Scan/AlphaScan.h +++ b/Sim/Scan/AlphaScan.h @@ -56,7 +56,10 @@ public: return m_alpha_distrib.get(); } - double alphaOffset() const { return m_alpha_offset; } + double alphaOffset() const + { + return m_alpha_offset; + } private: void checkInitialization(); diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index b64af793abaa38f6ca14f1cb3eaab0b9a676b34e..b20620ed45c5c5ca6ee09ea9c89dfce538555fa9 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -32,10 +32,12 @@ DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample) : ISimulation(sample) - , m_scan(scan.clone()) + , m_scan(dynamic_cast<AlphaScan*>(scan.clone())) , m_beam(InBeam(1., scan.wavelength(), 0., 0.).clone()) , m_alpha_axis(scan.coordinateAxis()->clone()) { + if (!m_scan) + throw std::runtime_error("DepthprobeSimulation not implemented for non-alpha scan"); } DepthprobeSimulation::~DepthprobeSimulation() = default; @@ -69,14 +71,12 @@ void DepthprobeSimulation::initDistributionHandler() for (const auto& distribution : distributionHandler().paramDistributions()) { 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);s->setAlphaOffset(d); - ASSERT( s->alphaOffset() == m_beam->alpha_i());}); + case ParameterDistribution::BeamInclinationAngle: { + distributionHandler().defineCallbackForDistribution(&distribution, [&](double d) { + m_beam->setInclination(d); + m_scan->setAlphaOffset(d); + ASSERT(m_scan->alphaOffset() == m_beam->alpha_i()); + }); break; } case ParameterDistribution::BeamWavelength: @@ -91,12 +91,9 @@ void DepthprobeSimulation::initDistributionHandler() void DepthprobeSimulation::runComputation(const ReSample& re_sample, size_t i, double weight) { - 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(); + std::cout << m_scan->alphaOffset() << " vs " << m_beam->alpha_i() << std::endl; + ASSERT(m_scan->alphaOffset() == m_beam->alpha_i()); + const double result_angle = m_alpha_axis->bin(i).center() + m_scan->alphaOffset(); DepthprobeElement ele(m_scan->wavelength(), -result_angle, m_z_axis.get(), 0 < result_angle && result_angle < M_PI_2); diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h index a8d833a0097c623da7f7341c9c269a9782d54027..5825a333d0068a66360bcb1e67657610a6923a2e 100644 --- a/Sim/Simulation/DepthprobeSimulation.h +++ b/Sim/Simulation/DepthprobeSimulation.h @@ -17,6 +17,7 @@ #include "Sim/Simulation/ISimulation.h" +class AlphaScan; class Beam; class DepthprobeElement; class IAxis; @@ -43,7 +44,7 @@ public: #ifndef SWIG - const IBeamScan& scan() const + const AlphaScan& scan() const { return *m_scan; } @@ -74,7 +75,7 @@ private: SimulationResult packResult() override; //... Model components: - std::unique_ptr<IBeamScan> m_scan; + std::unique_ptr<AlphaScan> m_scan; std::unique_ptr<Beam> m_beam; //... Caches: