36 for (
auto& val : angles)
42 return std::unique_ptr<AngularSpecScan>(result);
45 std::vector<SpecularSimulationElement> generateSimulationElements(
const Instrument& instrument,
50 return mangledScan(*aScan, instrument.
beam())->generateSimulationElements(instrument);
70 , m_scan(other.m_scan ? other.m_scan->clone() : nullptr)
71 , m_sim_elements(other.m_sim_elements)
72 , m_cache(other.m_cache)
87 throw std::runtime_error(
"Error in SpecularSimulation::prepareSimulation: the detector was "
88 "not properly configured.");
95 return m_scan->numberOfSimulationElements();
115 throw std::runtime_error(
"Error in SpecularSimulation::setScan: Scan cannot be set twice");
119 throw std::runtime_error(
120 "Error in SpecularSimulation::setScan: minimum value on coordinate axis is negative.");
125 throw std::runtime_error(
"Error in SpecularSimulation::setScan: Axis already set");
137 throw std::runtime_error(
138 "Error in SpecularSimulation::getAlphaAxis: coordinate axis was not initialized.");
139 return m_scan->coordinateAxis();
144 return m_scan->footprintFactor();
149 return m_scan->coordinateAxis()->size();
155 throw std::runtime_error(
"Error in SpecularSimulation: beam parameters were not set.");
163 std::unique_ptr<IComputation>
167 const auto& begin =
m_sim_elements.begin() +
static_cast<long>(start);
171 begin +
static_cast<long>(n_elements),
polarized);
177 throw std::runtime_error(
"Error in SpecularSimulation: the sizes of simulation element "
178 "vector and of its cache are different");
188 const std::vector<RealParameter*> names =
190 for (
const auto par : names)
191 if (par->getName().find(
"InclinationAngle") != std::string::npos && !zero_mean)
192 throw std::runtime_error(
"Error in SpecularSimulation: parameter distribution of "
193 "beam inclination angle should have zero mean.");
212 std::vector<double> footprints;
215 footprints = mangledScan(*aScan,
beam())->footprint(start_ind, n_elements);
217 footprints =
m_scan->footprint(start_ind, n_elements);
219 for (
size_t i = start_ind, k = 0; i < start_ind + n_elements; ++i, ++k) {
221 element.setIntensity(element.intensity() * beam_intensity * footprints[k]);
229 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
231 element.setIntensity(
background()->addBackground(element.intensity()));
253 std::vector<double>
result;
264 throw std::runtime_error(
"SpecularSimulation::setRawResults: size of vector passed as "
265 "argument doesn't match number of elements in this simulation");
266 for (
unsigned i = 0; i < raw_data.size(); i++)
Declares AngularSpecScan class.
#define ASSERT(condition)
Defines classes representing one-dimensional distributions.
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.
An incident neutron or x-ray beam.
Direction direction() const
double intensity() const
Returns the beam intensity in neutrons/sec.
double wavelength() const
kvector_t analyzerDirection() const
Retrieve the analyzer characteristics.
Interface for one-dimensional axes.
virtual std::vector< double > binCenters() const
virtual double lowerBound() const =0
Returns value of first point of axis.
void addAxis(const IAxis &axis)
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)
Abstract base class of OffSpecularSimulation, GISASSimulation and SpecularSimulation.
const IBackground * background() const
const MultiLayer * sample() const
const Instrument & instrument() const
ProgressHandler & progress()
const SimulationOptions & options() const
virtual void prepareSimulation()
Put into a clean state for running a simulation.
virtual void transferResultsToIntensityMap()
Creates the appropriate data structure (e.g.
Abstract base class for all types of specular scans.
virtual const IAxis * coordinateAxis() const =0
Returns coordinate axis assigned to the data holder.
virtual std::vector< SpecularSimulationElement > generateSimulationElements(const Instrument &instrument) const =0
Generates simulation elements for specular simulations.
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.
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 ISimulation 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.