36 const double angle_shift = beam.
getAlpha();
38 for (
auto& val : angles)
44 return std::unique_ptr<AngularSpecScan>(result);
50 std::vector<SpecularSimulationElement> result;
62 for (
auto& elem : result)
63 elem.setPolarizationHandler({polarization, analyzer});
80 :
Simulation(other), m_scan(other.m_scan ? other.m_scan->clone() : nullptr),
81 m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
96 throw std::runtime_error(
"Error in SpecularSimulation::prepareSimulation: the detector was "
97 "not properly configured.");
104 return m_scan->numberOfSimulationElements();
125 throw std::runtime_error(
126 "Error in SpecularSimulation::setScan: minimum value on coordinate axis is negative.");
141 throw std::runtime_error(
142 "Error in SpecularSimulation::getAlphaAxis: coordinate axis was not initialized.");
143 return m_scan->coordinateAxis();
148 return m_scan->footprintFactor();
153 return m_scan->coordinateAxis()->size();
159 throw std::runtime_error(
"Error in SpecularSimulation: beam parameters were not set.");
167 std::unique_ptr<IComputation>
171 const auto& begin =
m_sim_elements.begin() +
static_cast<long>(start);
173 begin +
static_cast<long>(n_elements));
179 throw std::runtime_error(
"Error in SpecularSimulation: the sizes of simulation element "
180 "vector and of its cache are different");
190 const std::vector<RealParameter*> names =
192 for (
const auto par : names)
193 if (par->getName().find(
"InclinationAngle") != std::string::npos && !zero_mean)
194 throw std::runtime_error(
"Error in SpecularSimulation: parameter distribution of "
195 "beam inclination angle should have zero mean.");
213 if (beam_intensity == 0.0)
216 std::vector<double> footprints;
221 footprints =
m_scan->footprint(start_ind, n_elements);
223 for (
size_t i = start_ind, k = 0; i < start_ind + n_elements; ++i, ++k) {
225 element.setIntensity(element.getIntensity() * beam_intensity * footprints[k]);
233 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
235 element.setIntensity(
background()->addBackground(element.getIntensity()));
257 std::vector<double>
result;
268 throw std::runtime_error(
"SpecularSimulation::setRawResults: size of vector passed as "
269 "argument doesn't match number of elements in this simulation");
270 for (
unsigned i = 0; i < raw_data.size(); i++)
Declares AngularSpecScan class.
#define ASSERT(condition)
Defines classes representing one-dimensional distributions.
Defines class Histogram1D.
Defines interface IBackground.
Defines class ParameterPool.
Defines class PointwiseAxis.
Defines class RealParameter.
Defines class SpecularComputation.
Defines a detector for specular simulations.
Declares the class SpecularSimulationElement.
Defines class SpecularSimulation.
Defines UnitConverter1D class and derived classes.
Scan type with inclination angles as coordinate values and a unique wavelength.
virtual const IFootprintFactor * footprintFactor() const override
Returns IFootprintFactor object pointer.
const ScanResolution * wavelengthResolution() const
const ScanResolution * angleResolution() const
virtual const IAxis * coordinateAxis() const override
Returns coordinate axis assigned to the data holder.
Beam defined by wavelength, direction and intensity.
double getWavelength() const
Eigen::Matrix2cd getPolarization() const
Returns the polarization density matrix (in spin basis along z-axis)
Eigen::Matrix2cd analyzerOperator() const
Return the polarization density matrix (in spin basis along z-axis)
Interface for one-dimensional axes.
virtual double getMin() const =0
Returns value of first point of axis.
virtual std::vector< double > getBinCenters() const
const DetectionProperties & detectionProperties() const
Returns detection properties.
virtual double getMean() const =0
Returns the distribution-specific mean.
ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.
RealParameter * parameter(const std::string &name) const
Returns parameter with given 'name'.
void setName(const std::string &name)
Pure virtual base class for all types of specular scans.
virtual std::vector< SpecularSimulationElement > generateSimulationElements() const =0
Generates simulation elements for specular simulations.
virtual const IAxis * coordinateAxis() const =0
Returns coordinate axis assigned to the data holder.
ISpecularScan * clone() const override=0
Assembles beam, detector and their relative positions with respect to the sample.
void setBeamParameters(double wavelength, double alpha_i, double phi_i)
Sets the beam wavelength and incoming angles.
void setDetector(const IDetector &detector)
Sets the detector (axes can be overwritten later)
void initDetector()
init detector with beam settings
void setAllTo(const T &value)
Sets content of output data to specific value.
void addAxis(const IAxis &new_axis)
void setRawDataVector(const std::vector< T > &data_vector)
Sets new values to raw data vector.
A parametric distribution function, for use with any model parameter.
const IDistribution1D * getDistribution() const
std::string getMainParameterName() const
get the main parameter's name
Axis containing arbitrary (non-equidistant) coordinate values.
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
RealParameter & setLimits(const RealLimits &limits)
Wrapper around OutputData<double> that also provides unit conversions.
Pure virtual base class of OffSpecularSimulation, GISASSimulation and SpecularSimulation.
const Instrument & instrument() const
ProgressHandler & progress()
const IBackground * background() const
virtual void prepareSimulation()
Put into a clean state for running a simulation.
virtual void transferResultsToIntensityMap()
Creates the appropriate data structure (e.g.
const MultiLayer * sample() const
double getBeamIntensity() const
const SimulationOptions & options() const
1D detector for specular simulations.
Main class to run a specular simulation.
std::vector< double > rawResults() const override
const IAxis * coordinateAxis() const
Returns a pointer to coordinate axis.
void initialize()
Initializes simulation.
SimulationResult result() const override
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
void setRawResults(const std::vector< double > &raw_data) override
SpecularSimulation * clone() const override
std::vector< double > m_cache
void addDataToCache(double weight) override
std::vector< SpecularSimulationElement > m_sim_elements
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
std::unique_ptr< ISpecularScan > m_scan
~SpecularSimulation() override
void initSimulationElementVector() override
Initializes the vector of Simulation elements.
void setScan(const ISpecularScan &scan)
Sets chosen specular scan to the simulation.
void addBackgroundIntensity(size_t start_ind, size_t n_elements) override
void prepareSimulation() override
Put into a clean state for running a simulation.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
void moveDataFromCache() override
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
const IFootprintFactor * footprintFactor() const
Returns a pointer to footprint factor holder.
void normalize(size_t start_ind, size_t n_elements) override
Normalize the detector counts to beam intensity, to solid angle, and to exposure angle.
std::unique_ptr< IComputation > generateSingleThreadedComputation(size_t start, size_t n_elements) override
Generate a single threaded computation for a given range of simulation elements.
static std::unique_ptr< UnitConverter1D > createUnitConverter(const ISpecularScan &handler)
Factory function to create unit converter for particular type of specular data.
std::unique_ptr< AngularSpecScan > mangledScan(const AngularSpecScan &scan, const Beam &beam)
std::vector< SpecularSimulationElement > generateSimulationElements(const Instrument &instrument, const ISpecularScan &scan)