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

sort SpecSim.cpp

parent 59f5169c
No related branches found
No related tags found
1 merge request!1270Sort members in simulation classes; privatize some.
Pipeline #85674 failed
...@@ -38,23 +38,13 @@ SpecularSimulation::SpecularSimulation(const ISpecularScan& scan, const MultiLay ...@@ -38,23 +38,13 @@ SpecularSimulation::SpecularSimulation(const ISpecularScan& scan, const MultiLay
SpecularSimulation::~SpecularSimulation() = default; SpecularSimulation::~SpecularSimulation() = default;
size_t SpecularSimulation::numberOfElements() const
{
return m_scan->numberOfElements();
}
SimulationResult SpecularSimulation::packResult() const
{
ASSERT(!m_eles.empty());
Datafield data({m_scan->coordinateAxis()->clone()}, m_scan->createIntensities(m_eles));
return {data, simCoordSystem()};
}
const ICoordSystem* SpecularSimulation::simCoordSystem() const const ICoordSystem* SpecularSimulation::simCoordSystem() const
{ {
return m_scan->scanCoordSystem(); return m_scan->scanCoordSystem();
} }
//... Overridden executors:
void SpecularSimulation::initElementVector() void SpecularSimulation::initElementVector()
{ {
m_eles = m_scan->generateElements(); m_eles = m_scan->generateElements();
...@@ -73,33 +63,21 @@ std::unique_ptr<IComputation> SpecularSimulation::createComputation(const ReSamp ...@@ -73,33 +63,21 @@ std::unique_ptr<IComputation> SpecularSimulation::createComputation(const ReSamp
begin + static_cast<long>(n_elements)); begin + static_cast<long>(n_elements));
} }
void SpecularSimulation::validateParametrization(const ParameterDistribution& par_distr) const void SpecularSimulation::normalize(size_t start, size_t n_elements)
{
const bool zero_mean = par_distr.getDistribution()->mean() == 0.0;
if (zero_mean)
return;
/* TODO come back to this after refactoring of distribution handling
if (par_distr.whichParameter() == ParameterDistribution::BeamInclinationAngle)
throw std::runtime_error("Error in SpecularSimulation: parameter distribution of "
"beam inclination angle should have zero mean.");
*/
}
void SpecularSimulation::normalize(size_t start_ind, size_t n_elements)
{ {
std::vector<double> footprints = m_scan->footprint(start_ind, n_elements); std::vector<double> footprints = m_scan->footprint(start, n_elements);
for (size_t i = start_ind, k = 0; i < start_ind + n_elements; ++i, ++k) { for (size_t i = start, k = 0; i < start + n_elements; ++i, ++k) {
auto& element = m_eles[i]; auto& element = m_eles[i];
element.setIntensity(element.intensity() * footprints[k]); element.setIntensity(element.intensity() * footprints[k]);
} }
} }
void SpecularSimulation::addBackgroundIntensity(size_t start_ind, size_t n_elements) void SpecularSimulation::addBackgroundIntensity(size_t start, size_t n_elements)
{ {
if (!background()) if (!background())
return; return;
for (size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) { for (size_t i = start, stop_point = start + n_elements; i < stop_point; ++i) {
auto& element = m_eles[i]; auto& element = m_eles[i];
element.setIntensity(background()->addBackground(element.intensity())); element.setIntensity(background()->addBackground(element.intensity()));
} }
...@@ -121,7 +99,33 @@ void SpecularSimulation::moveDataFromCache() ...@@ -121,7 +99,33 @@ void SpecularSimulation::moveDataFromCache()
m_cache.shrink_to_fit(); m_cache.shrink_to_fit();
} }
//... Overridden getters:
bool SpecularSimulation::force_polarized() const bool SpecularSimulation::force_polarized() const
{ {
return m_scan->polarized(); return m_scan->polarized();
} }
size_t SpecularSimulation::numberOfElements() const
{
return m_scan->numberOfElements();
}
SimulationResult SpecularSimulation::packResult() const
{
ASSERT(!m_eles.empty());
Datafield data({m_scan->coordinateAxis()->clone()}, m_scan->createIntensities(m_eles));
return {data, simCoordSystem()};
}
void SpecularSimulation::validateParametrization(const ParameterDistribution& par_distr) const
{
const bool zero_mean = par_distr.getDistribution()->mean() == 0.0;
if (zero_mean)
return;
/* TODO come back to this after refactoring of distribution handling
if (par_distr.whichParameter() == ParameterDistribution::BeamInclinationAngle)
throw std::runtime_error("Error in SpecularSimulation: parameter distribution of "
"beam inclination angle should have zero mean.");
*/
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment