76 :
ISimulation(other), m_sim_elements(other.m_sim_elements), m_cache(other.m_cache)
83 throw std::runtime_error(
"Error in numberOfSimulationElements(): no detector context");
88 double y_min,
double y_max)
104 const auto& begin =
m_sim_elements.begin() +
static_cast<long>(start);
108 begin +
static_cast<long>(n_elements),
polarized);
120 const size_t spec_index =
detector.indexOfSpecular(
beam);
124 std::vector<SimulationElement>
result;
126 for (
size_t element_index = 0; element_index < N; ++element_index) {
131 result.emplace_back(std::move(element));
139 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
141 double sin_alpha_i = std::abs(std::sin(element.
getAlphaI()));
142 if (sin_alpha_i == 0.0) {
146 const double solid_angle = element.
solidAngle();
155 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
164 throw std::runtime_error(
"Error in ISimulation2D::addDataToCache(double): cache size"
165 " not the same as element size");
182 std::vector<double>
result;
193 throw std::runtime_error(
"ISimulation2D::setRawResults: size of vector passed as "
194 "argument doesn't match number of elements in this simulation");
195 for (
unsigned i = 0; i < raw_data.size(); i++)
Defines the macro ASSERT.
#define ASSERT(condition)
Defines class DWBAComputation.
Define DetectorContext class.
Defines interface IBackground.
Defines interface ISimulation2D.
Defines class SimulationElement.
An incident neutron or x-ray beam.
Direction direction() const
Eigen::Matrix2cd getPolarization() const
Returns the polarization density matrix (in spin basis along z-axis)
double intensity() const
Returns the beam intensity in neutrons/sec.
double wavelength() const
kvector_t analyzerDirection() const
Retrieve the analyzer characteristics.
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.
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 maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
Abstract detector interface.
const DetectionProperties & detectionProperties() const
Returns detection properties.
Basic class for all shapes in 2D.
Abstract base class of OffSpecularSimulation and GISASSimulation.
std::unique_ptr< DetectorContext > m_detector_context
void setDetector(const IDetector2D &detector)
Sets the detector (axes can be overwritten later)
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.
size_t numberOfSimulationElements() const override
Gets the number of elements this simulation needs to calculate.
void setRawResults(const std::vector< double > &raw_data) override
void moveDataFromCache() 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.
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::vector< SimulationElement > generateSimulationElements(const Beam &beam)
Generate simulation elements for given beam.
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.
IDetector2D & detector2D()
std::vector< SimulationElement > m_sim_elements
~ISimulation2D() override
virtual void initUnitConverter()
void maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
void prepareSimulation() override
Put into a clean state for running a simulation.
std::vector< double > m_cache
void addBackgroundIntensity(size_t start_ind, size_t n_elements) override
void addDataToCache(double weight) override
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
Abstract base class of OffSpecularSimulation, GISASSimulation and SpecularSimulation.
virtual void updateIntensityMap()
const IBackground * background() const
const MultiLayer * sample() const
const Instrument & instrument() const
ProgressHandler & progress()
virtual void initSimulationElementVector()=0
Initializes the vector of ISimulation elements.
const SimulationOptions & options() const
virtual void prepareSimulation()
Put into a clean state for running a simulation.
virtual SimulationResult result() const =0
Returns the results of the simulation in a format that supports unit conversion and export to numpy a...
IDetector * getDetector()
virtual void transferResultsToIntensityMap()
Creates the appropriate data structure (e.g.
void setDetector(const IDetector &detector)
Sets the detector (axes can be overwritten later)
Our sample model: a stack of layers one below the other.
Data stucture containing both input and output of a single detector cell.
double solidAngle() const
void setIntensity(double intensity)