Skip to content
Snippets Groups Projects
Commit 440abb9d authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

repaired - don't understand why previous version was not threadsafe

parent 541f3d48
No related branches found
No related tags found
1 merge request!1454rm Beam from Dp|Offsp-Sim
......@@ -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();
......
......@@ -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);
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment