27 , m_beam(beam.clone())
28 , m_detector(detector.clone())
35 , m_beam(
Beam::horizontalBeam().clone())
45 result.push_back(
m_beam.get());
74 throw std::runtime_error(
"Error in numberOfElements(): no detector context");
79 size_t start,
size_t n_elements)
82 const auto& begin =
m_eles.begin() +
static_cast<long>(start);
83 return std::make_unique<DWBAComputation>(re_sample,
options(),
progress(), begin,
84 begin +
static_cast<long>(n_elements));
99 std::vector<std::unique_ptr<DiffuseElement>> result;
101 for (
size_t element_index = 0; element_index <
N; ++element_index)
102 result.emplace_back(std::make_unique<DiffuseElement>(
104 beam_polMatrices, analyzer_operator,
112 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
114 double sin_alpha_i = std::abs(std::sin(element.
alphaI()));
115 if (sin_alpha_i == 0.0) {
119 const double solid_angle = element.
solidAngle();
128 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
137 throw std::runtime_error(
"Error in ISimulation2D::addDataToCache(double): cache size"
138 " not the same as element size");
139 for (
unsigned i = 0; i <
m_eles.size(); i++)
147 for (
unsigned i = 0; i <
m_eles.size(); i++)
164 switch (dc->whichParameter()) {
Defines the macro ASSERT.
#define ASSERT(condition)
Defines class DWBAComputation.
Define DetectorContext class.
Defines class DiffuseElement.
Defines interface IBackground.
Defines common detector interface.
Defines interface ISimulation2D.
Defines class SphericalDetector.
An incident neutron or x-ray beam.
Direction direction() const
void setAzimuthalAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
void setInclinationAngleGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
double intensity() const
Returns the beam intensity in neutrons/sec.
double wavelength() const
void setWavelengthGuarded(double value)
Check for limits, set the value if within limits. Throws if limits are violated.
SpinMatrix polMatrix() const
Returns the polarization density matrix (in spin basis along z-axis)
Data stucture containing both input and output of a single detector cell.
double solidAngle() const
void setIntensity(double intensity)
const std::vector< ParameterDistribution > & getDistributions() const
void defineCallbackForDistribution(const ParameterDistribution *distribution, std::function< void(double)> fn)
Abstract detector interface.
virtual size_t indexOfSpecular(const Beam &beam) const =0
Returns index of pixel that contains the specular wavevector. If no pixel contains this specular wave...
void setRegionOfInterest(double xlow, double ylow, double xup, double yup)
Sets rectangular region of interest with lower left and upper right corners defined.
const PolFilter & analyzer() const
Returns detection properties.
void maskAll()
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks. The mask value 'true' means that the channel...
std::unique_ptr< DetectorContext > createContext() const
Basic class for all shapes in 2D.
std::unique_ptr< DetectorContext > m_detector_context
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.
std::unique_ptr< IComputation > createComputation(const reSample &re_sample, size_t start, size_t n_elements) override
Generate a single threaded computation for a given range of simulation elements.
void setRegionOfInterest(double xlow, double ylow, double xup, double yup)
Sets rectangular region of interest with lower left and upper right corners defined.
std::vector< const INode * > nodeChildren() const override
Returns all children.
bool force_polarized() const override
Force polarized computation even in absence of sample magnetization or external fields.
std::vector< std::unique_ptr< DiffuseElement > > generateElements(const Beam &beam)
Generate simulation elements for given beam.
~ISimulation2D() override
std::unique_ptr< IDetector > m_detector
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::unique_ptr< Beam > m_beam
std::vector< double > m_cache
size_t numberOfElements() const override
Gets the number of elements this simulation needs to calculate.
std::vector< std::unique_ptr< DiffuseElement > > m_eles
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. The mask value 'true' means that the channel...
ISimulation2D(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
void initDistributionHandler() override
init callbacks for setting the parameter values
Abstract base class, holds the infrastructure to run a simulation.
ProgressHandler & progress()
const IBackground * background() const
std::vector< const INode * > nodeChildren() const override
Returns all children.
const SimulationOptions & options() const
DistributionHandler m_distribution_handler
Our sample model: a stack of layers one below the other.
A parametric distribution function, for use with any model parameter.
R3 analyzerDirection() const
Retrieve the analyzer characteristics.
SpinMatrix matrix() const
Return the polarization density matrix (in spin basis along z-axis)
A detector with coordinate axes along angles phi and alpha.
Data structure that contains all the necessary data for scattering calculations.