53 :
Simulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
60 throw std::runtime_error(
"Error in numberOfSimulationElements(): no detector context");
65 double y_min,
double y_max)
81 const auto& begin =
m_sim_elements.begin() +
static_cast<long>(start);
83 begin +
static_cast<long>(n_elements));
89 const double alpha_i = -beam.
getAlpha();
90 const double phi_i = beam.
getPhi();
99 std::vector<SimulationElement>
result;
101 for (
size_t element_index = 0; element_index < N; ++element_index) {
108 result.emplace_back(std::move(element));
116 if (beam_intensity == 0.0)
118 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
120 double sin_alpha_i = std::abs(std::sin(element.
getAlphaI()));
121 if (sin_alpha_i == 0.0)
132 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
141 throw std::runtime_error(
"Error in Simulation2D::addDataToCache(double): cache size"
142 " not the same as element size");
159 std::vector<double>
result;
170 throw std::runtime_error(
"Simulation2D::setRawResults: size of vector passed as "
171 "argument doesn't match number of elements in this simulation");
172 for (
unsigned i = 0; i < raw_data.size(); i++)
#define ASSERT(condition)
Defines class DWBAComputation.
Define DetectorContext class.
Defines class Histogram2D.
Defines interface IBackground.
Defines class Simulation2D.
Defines class SimulationElement.
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)
Abstract 2D detector interface.
std::unique_ptr< DetectorContext > createContext() const
void setRegionOfInterest(double xlow, double ylow, double xup, double yup)
Sets rectangular region of interest with lower left and upper right corners defined.
virtual size_t indexOfSpecular(const Beam &beam) const =0
Returns index of pixel that contains the specular wavevector.
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
void setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, double y_min, double y_max)
Sets detector parameters using angle ranges.
void removeMasks()
Removes all masks from the detector.
void maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
const DetectionProperties & detectionProperties() const
Returns detection properties.
Basic class for all shapes in 2D.
void setDetector(const IDetector &detector)
Sets the detector (axes can be overwritten later)
IDetector2D & detector2D()
Pure virtual base class of OffSpecularSimulation and GISASSimulation.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
void setDetector(const IDetector2D &detector)
Sets the detector (axes can be overwritten later)
std::vector< double > m_cache
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.
std::vector< SimulationElement > m_sim_elements
void moveDataFromCache() override
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.
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
void addBackgroundIntensity(size_t start_ind, size_t n_elements) override
void setDetectorParameters(size_t n_phi, double phi_min, double phi_max, size_t n_alpha, double alpha_min, double alpha_max)
Sets spherical detector parameters using angle ranges.
std::vector< SimulationElement > generateSimulationElements(const Beam &beam)
Generate simulation elements for given beam.
void setRawResults(const std::vector< double > &raw_data) override
std::unique_ptr< DetectorContext > m_detector_context
void maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
void removeMasks()
removes all masks from the detector
virtual void initUnitConverter()
void prepareSimulation() override
Put into a clean state for running a simulation.
std::vector< double > rawResults() const override
void setRegionOfInterest(double xlow, double ylow, double xup, double yup)
Sets rectangular region of interest with lower left and upper right corners defined.
void addDataToCache(double weight) override
Data stucture containing both input and output of a single detector cell.
void setSpecular(bool is_specular)
Set specularity indication on/off.
double getIntensity() const
double getSolidAngle() const
void setIntensity(double intensity)
void setPolarization(const Eigen::Matrix2cd &polarization)
Sets the polarization density matrix (in spin basis along z-axis)
void setAnalyzerOperator(const Eigen::Matrix2cd &polarization_operator)
Sets the polarization analyzer operator (in spin basis along z-axis)
Pure virtual base class of OffSpecularSimulation, GISASSimulation and SpecularSimulation.
const Instrument & instrument() const
virtual void updateIntensityMap()
ProgressHandler & progress()
const IBackground * background() const
virtual void initSimulationElementVector()=0
Initializes the vector of Simulation elements.
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
virtual SimulationResult result() const =0
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
const SimulationOptions & options() const
const double wavelength(0.154)