56 size_t phi_f_size = phi_axis.
size();
63 return {*data, *coordsSystem};
69 if (alpha_axis.
size() < 1)
70 throw std::runtime_error(
"OffspecSimulation::prepareSimulation() "
71 "-> Error. Incoming alpha range size < 1.");
72 const double alpha_zero = alpha_axis.
min();
103 std::vector<std::unique_ptr<DiffuseElement>> eles_i =
generateElements(beam2);
104 for (
auto&& ele : eles_i)
105 m_eles.emplace_back(std::move(ele));
137 std::unique_ptr<Datafield> detector_image;
146 size_t N = detector_image->size();
147 for (
size_t i = 0; i <
N; ++i)
148 (*detector_image)[i] =
m_eles[index *
N + i]->intensity();
151 for (
size_t i = 0; i <
N; ++i)
152 (*
m_intensity_map)[index * y_axis_size + i % y_axis_size] += (*detector_image)[i];
Defines the macro ASSERT.
#define ASSERT(condition)
Defines structs Bin1D, Bin1DCVector.
Defines interface CoordSystem2D and its subclasses.
Defines and implements templated class Datafield.
Defines class DiffuseElement.
Defines classes representing one-dimensional distributions.
Defines class OffspecSimulation.
Defines class RectangularDetector.
Defines class RectangularPixel.
Defines class SimulationResult.
Defines class SphericalDetector.
An incident neutron or x-ray beam.
void setDirection(const Direction &direction)
void setInclination(double alpha)
void setWavelength(double wavelength)
Stores radiation power per bin.
Abstract base class for one-dimensional axes.
virtual IAxis * clone() const =0
virtual double min() const =0
Returns value of first point of axis.
virtual size_t size() const =0
Returns the number of bins.
Interface to provide axis translations to different units for simulation output.
Abstract detector interface.
const IAxis & axis(size_t index) const
One axis of the complete detector. Any region of interest is not taken into account.
size_t rank() const
Returns number of defined axes.
void applyDetectorResolution(Datafield *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
virtual ICoordSystem * offspecCoords(IAxis *beamAxis, const Direction &beamDirection) const =0
virtual double mean() const =0
Returns the distribution-specific mean.
Abstract base class of simulations that generate 2D patterns.
std::vector< std::unique_ptr< DiffuseElement > > generateElements(const Beam &beam)
Generate simulation elements for given beam.
void prepareSimulation() override
Put into a clean state for running a simulation.
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
Our sample model: a stack of layers one below the other.
const IAxis * beamAxis() const
Returns axis of the beam.
std::unique_ptr< Datafield > m_intensity_map
void updateIntensityMap() override
Default implementation only adds the detector axes.
void transferDetectorImage(size_t index)
Normalize, apply detector resolution and transfer detector image corresponding to alpha_i = m_alpha_i...
OffspecSimulation(const Beam &beam, const MultiLayer &sample, const IDetector &detector)
size_t numberOfElements() const override
Gets the number of elements this simulation needs to calculate.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
SimulationResult pack_result() override
Sets m_result.
void prepareSimulation() override
Put into a clean state for running a simulation.
ICoordSystem * createCoordSystem() const override
void validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
std::unique_ptr< IAxis > m_alpha_i_axis
void setBeamParameters(double wavelength, const IAxis &alpha_axis, double phi_i)
Sets beam parameters from here (forwarded to Instrument)
void checkInitialization() const
Check correct number of axes.
void initElementVector() override
Initializes the vector of ISimulation elements.
A parametric distribution function, for use with any model parameter.
const IDistribution1D * getDistribution() const
Wrapper around Datafield that also provides unit conversions.