28 std::vector<std::vector<double>>
29 extractValues(std::vector<std::vector<ParameterSample>> samples,
32 std::vector<std::vector<double>> result;
33 result.resize(samples.size());
34 for (
size_t i = 0, size = result.size(); i < size; ++i) {
35 const auto& sample_row = samples[i];
36 auto& result_row = result[i];
37 result_row.reserve(sample_row.size());
38 std::for_each(sample_row.begin(), sample_row.end(),
40 result_row.push_back(extractor(sample));
50 , m_inc_angle(std::make_unique<
PointwiseAxis>(
"inc_angles", std::move(inc_angle)))
59 , m_inc_angle(inc_angle.clone())
68 , m_inc_angle(std::make_unique<
FixedBinAxis>(
"inc_angles", nbins, alpha_i_min, alpha_i_max))
97 std::vector<SpecularElement> result;
100 for (
size_t k = 0, size_incs = incs[i].size(); k < size_incs; ++k) {
101 const double alpha = incs[i][k];
102 for (
size_t j = 0, size_wls = wls[i].size(); j < size_wls; ++j) {
125 std::unique_ptr<ScanResolution> resolution(
131 const std::vector<double>& rel_dev)
133 std::unique_ptr<ScanResolution> resolution(
140 std::unique_ptr<ScanResolution> resolution(
146 const std::vector<double>& std_dev)
148 std::unique_ptr<ScanResolution> resolution(
160 std::unique_ptr<ScanResolution> resolution(
166 const std::vector<double>& rel_dev)
168 std::unique_ptr<ScanResolution> resolution(
175 std::unique_ptr<ScanResolution> resolution(
181 const std::vector<double>& std_dev)
183 std::unique_ptr<ScanResolution> resolution(
191 throw std::runtime_error(
"Error in AlphaScan::footprint: given index exceeds the "
192 "number of simulation elements");
194 std::vector<double> result(n_elements, 1.0);
201 const auto sample_values = extractValues(
204 const size_t pos_out = start / (n_wl_samples * n_inc_samples);
205 size_t pos_inc = (start - pos_out * n_wl_samples * n_inc_samples) / n_wl_samples;
206 size_t pos_wl = (start - pos_inc * n_wl_samples);
207 int left =
static_cast<int>(n_elements);
209 for (
size_t i = pos_out; left > 0; ++i)
210 for (
size_t k = pos_inc; k < n_inc_samples && left > 0; ++k) {
212 const double angle = sample_values[i][k];
215 for (
size_t j = pos_wl; j < n_wl_samples && left > 0; ++j) {
238 std::vector<double> result(axis_size, 0.0);
240 const auto wl_weights = extractValues(
242 const auto inc_weights = extractValues(
246 for (
size_t i = 0; i < axis_size; ++i) {
247 double& current = result[i];
248 for (
size_t k = 0, size_incs = inc_weights[i].size(); k < size_incs; ++k) {
249 const double inc_weight = inc_weights[i][k];
250 for (
size_t j = 0, size_wls = wl_weights[i].size(); j < size_wls; ++j) {
251 current += eles[elem_pos].intensity() * inc_weight * wl_weights[i][j];
262 throw std::runtime_error(
263 "Error in AlphaScan::checkInitialization: wavelength shell be positive");
265 const std::vector<double> axis_values =
m_inc_angle->binCenters();
266 if (!std::is_sorted(axis_values.begin(), axis_values.end()))
267 throw std::runtime_error(
"Error in AlphaScan::checkInitialization: q-vector values "
268 "shall be sorted in ascending order.");
Declares AlphaScan class.
Defines CoordSystem1D class and derived classes.
Defines class FixedBinAxis.
Defines class PointwiseAxis.
Defines class DetectionProperties.
Defines classes representing ranged one-dimensional distributions.
Defines scan resolution class.
Declares the class SpecularElement.
Scan type with inclination angles as coordinate values and a unique wavelength. Features footprint co...
CoordSystem1D * createCoordSystem() const override
std::unique_ptr< IFootprintFactor > m_footprint
std::unique_ptr< ScanResolution > m_wl_resolution
void setAbsoluteAngularResolution(const IRangedDistribution &distr, double std_dev)
DistrOutput applyIncResolution() const
void setAngleResolution(const ScanResolution &resolution)
Sets angle resolution values via ScanResolution object.
AlphaScan * clone() const override
void checkInitialization()
const IAxis * coordinateAxis() const override
Returns coordinate axis assigned to the data holder.
std::vector< double > footprint(size_t start, size_t n_elements) const override
Returns footprint correction factor for a range of simulation elements of size n_elements and startin...
void setFootprintFactor(const IFootprintFactor *f_factor)
Sets footprint correction factor.
std::unique_ptr< ScanResolution > m_inc_resolution
void setWavelengthResolution(const ScanResolution &resolution)
Sets wavelength resolution values via ScanResolution object.
double wavelength() const override
void setRelativeAngularResolution(const IRangedDistribution &distr, double rel_dev)
std::vector< std::vector< ParameterSample > > DistrOutput
std::vector< double > createIntensities(const std::vector< SpecularElement > &eles) const override
Returns intensity vector corresponding to convolution of given simulation elements.
DistrOutput applyWlResolution() const
AlphaScan(double wl, std::vector< double > inc_angle)
void setRelativeWavelengthResolution(const IRangedDistribution &distr, double rel_dev)
void setAbsoluteWavelengthResolution(const IRangedDistribution &distr, double std_dev)
std::vector< SpecularElement > generateElements() const override
Generates simulation elements for specular simulations.
const std::unique_ptr< IAxis > m_inc_angle
size_t numberOfElements() const override
Returns the number of simulation elements.
Conversion of axis units for the case of conventional (angle-based) reflectometry.
Abstract base class to support coordinate transforms and axis labels for 1D scans....
Axis with fixed bin size.
Abstract base class for one-dimensional axes.
Interface for one-dimensional ranged distributions. All derived distributions allow for generating sa...
std::unique_ptr< R3 > m_beamPolarization
Bloch vector encoding the beam's polarization.
PolMatrices polMatrices() const
std::unique_ptr< PolFilter > m_polAnalyzer
A parameter value with a weight, as obtained when sampling from a distribution.
Axis containing arbitrary (non-equidistant) coordinate values. Lower boundary of the first bin and up...
Detector properties (efficiency, transmission).
Container for reflectivity resolution data.
static ScanResolution * scanAbsoluteResolution(const IRangedDistribution &distr, double stddev)
ScanResolution * clone() const override=0
static ScanResolution * scanRelativeResolution(const IRangedDistribution &distr, double stddev)
static SpecularElement FromAlphaScan(double wavelength, double alpha, const PolMatrices &polMatrices, bool computable)