Skip to content
Snippets Groups Projects
Commit aa9548da authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Implement SpecularSimulation::setBeamParameters overloads for TOF and q-defined reflectometry

parent 1d969ec9
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,10 @@ namespace
std::unique_ptr<ISpecularDataHandler> mangledDataHandler(const ISpecularDataHandler& data_handler,
const Beam& beam);
// compute qz values for given wavelengths and inclination angle. Sorts
// wavelengths in descending order if it was not done before.
std::vector<double> computeQzValues(std::vector<double> wls, double inc_angle);
const RealLimits alpha_limits = RealLimits::limited(0.0, M_PI_2);
const double zero_phi_i = 0.0;
const double zero_alpha_i = 0.0;
......@@ -85,8 +89,8 @@ size_t SpecularSimulation::numberOfSimulationElements() const
SimulationResult SpecularSimulation::result() const
{
auto data = createIntensityData();
UnitConverterConvSpec converter(m_instrument.getBeam(), *coordinateAxis());
return SimulationResult(*data, converter);
auto converter = UnitConverter1D::createUnitConverter(*m_data_handler);
return SimulationResult(*data, *converter);
}
void SpecularSimulation::setBeamParameters(double lambda, const IAxis& alpha_axis,
......@@ -130,6 +134,26 @@ void SpecularSimulation::setBeamParameters(double lambda, std::vector<double> in
setBeamParameters(lambda, axis, beam_shape);
}
void SpecularSimulation::setBeamParameters(std::vector<double> wavelength_values,
double incident_angle,
const IFootprintFactor* beam_shape)
{
auto qzs = computeQzValues(wavelength_values, incident_angle);
auto q_axis = std::make_unique<PointwiseAxis>("qzs", std::move(qzs));
SpecularDetector1D detector(*q_axis);
m_instrument.setDetector(detector);
m_data_handler =
std::make_unique<SpecularDataHandlerTOF>(incident_angle, std::move(q_axis), beam_shape);
}
void SpecularSimulation::setBeamParameters(std::vector<double> qz_values)
{
auto q_axis = std::make_unique<PointwiseAxis>("qz", std::move(qz_values));
SpecularDetector1D detector(*q_axis);
m_instrument.setDetector(detector);
m_data_handler = std::make_unique<SpecularDataHandlerQ>(std::move(q_axis));
}
const IAxis* SpecularSimulation::coordinateAxis() const
{
if (!m_data_handler || !m_data_handler->coordinateAxis())
......@@ -323,4 +347,23 @@ std::unique_ptr<ISpecularDataHandler> mangledDataHandler(const ISpecularDataHand
data_handler.footprintFactor());
return std::move(result);
}
std::vector<double> computeQzValues(std::vector<double> wls, double inc_angle)
{
std::vector<double> result;
result.reserve(wls.size());
const auto begin = wls.begin();
const auto end = wls.end();
if (!std::is_sorted(begin, end, std::greater<double>()))
std::sort(begin, end, std::greater<double>());
if (wls.back() <= 0.0)
throw std::runtime_error("Error in computeQzValues: passed vector of wavelengths contains "
"negative or zero values");
std::transform(
begin, end, std::back_inserter(result),
[sin_inc = std::sin(inc_angle)](double value) { return 4.0 * M_PI * sin_inc / value; });
return result;
}
}
......@@ -58,6 +58,9 @@ public:
const IFootprintFactor* beam_shape = nullptr);
void setBeamParameters(double lambda, std::vector<double> incident_angle_values,
const IFootprintFactor* beam_shape = nullptr);
void setBeamParameters(std::vector<double> wavelength_values, double incident_angle,
const IFootprintFactor* beam_shape = nullptr);
void setBeamParameters(std::vector<double> qz_values);
//! Sets beam parameters for specular simulation. _lambda_ defines the wavelength of incoming
//! beam (in nm), _alpha_axis_ defines the range of incident angles, while _beam_shape_
//! (optional parameter) is required to take footprint effects into account.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment