32 const double zero_phi_i = 0.0;
33 const double zero_alpha_i = 0.0;
63 FixedBinAxis axis(
"alpha_i",
static_cast<size_t>(nbins), alpha_i_min, alpha_i_max);
70 throw std::runtime_error(
"Error in DepthProbeSimulation::setZSpan: maximum on-axis value "
71 "is less or equal to the minimum one");
72 m_z_axis = std::make_unique<FixedBinAxis>(
"z", n_bins, z_min, z_max);
78 throw std::runtime_error(
"Error in DepthProbeSimulation::alphaAxis: incident angle axis "
79 "was not initialized.");
86 throw std::runtime_error(
"Error in DepthProbeSimulation::zAxis: position axis "
87 "was not initialized.");
94 throw std::runtime_error(
"Error in DepthProbeSimulation::intensityMapSize: attempt to "
95 "access non-initialized data.");
111 throw std::runtime_error(
112 "Error in DepthProbeSimulation::setBeamParameters: wavelength must be positive.");
113 if (alpha_axis.
min() < 0.0)
114 throw std::runtime_error(
115 "Error in DepthProbeSimulation::setBeamParameters: minimum value on "
116 "angle axis is negative.");
117 if (alpha_axis.
min() >= alpha_axis.
max())
118 throw std::runtime_error(
119 "Error in DepthProbeSimulation::setBeamParameters: alpha bounds are not sorted.");
120 if (alpha_axis.
size() == 0)
121 throw std::runtime_error(
122 "Error in DepthProbeSimulation::setBeamParameters: angle axis is empty");
147 std::vector<DepthProbeElement> result;
153 result.reserve(axis_size);
154 for (
size_t i = 0; i < axis_size; ++i) {
156 result.emplace_back(wavelength, -result_angle,
zAxis());
157 if (!alpha_limits.isInRange(result_angle))
158 result.back().setCalculationFlag(
false);
163 std::unique_ptr<IComputation>
167 const auto& begin =
m_eles.begin() +
static_cast<long>(start);
168 return std::make_unique<DepthProbeComputation>(re_sample,
options(),
progress(), begin,
169 begin +
static_cast<long>(n_elements));
176 throw std::runtime_error(
177 "Error in DepthProbeSimulation::validityCheck: no sample found in the simulation.");
179 const size_t data_size =
m_eles.size();
181 throw std::runtime_error(
182 "Error in DepthProbeSimulation::validityCheck: length of simulation "
183 "element vector is not equal to the number of inclination angles");
189 throw std::runtime_error(
"Error in DepthProbeSimulation: the sizes of simulation element "
190 "vector and of its cache are different");
208 for (
size_t i = start_ind, stop_point = start_ind + n_elements; i < stop_point; ++i) {
209 auto& element =
m_eles[i];
210 const double alpha_i = -element.alphaI();
212 double intensity_factor = beam_intensity;
213 if (footprint !=
nullptr)
214 intensity_factor = intensity_factor * footprint->
calculate(alpha_i);
215 element.setIntensities(element.getIntensities() * intensity_factor);
222 throw std::runtime_error(
223 "Error: nonzero background is not supported by DepthProbeSimulation");
229 for (
size_t i = 0, size =
m_eles.size(); i < size; ++i)
236 for (
size_t i = 0, size =
m_eles.size(); i < size; ++i)
251 std::vector<double> out(frame->size());
253 for (
size_t i = 0, size =
m_eles.size(); i < size; ++i)
254 for (
const double v:
m_eles[i].getIntensities())
257 return std::unique_ptr<Datafield>(
new Datafield(frame, out));
Defines the macro ASSERT.
#define ASSERT(condition)
Defines structs Bin1D, Bin1DCVector.
Defines interface CoordSystem2D and its subclasses.
Declares class DepthProbeComputation.
Defines class DepthProbeSimulation.
Defines classes representing one-dimensional distributions.
Defines class FixedBinAxis.
Defines and implements templated class Frame.
Defines interface IBackground.
Defines and implements class IFlux.
Defines class SimulationResult.
An incident neutron or x-ray beam.
Direction direction() const
void setDirection(const Direction &direction)
double intensity() const
Returns the beam intensity in neutrons/sec.
double wavelength() const
const IFootprintFactor * footprintFactor() const
Returns footprint factor.
void setFootprintFactor(const IFootprintFactor &shape_factor)
Sets footprint factor to the beam.
void setInclinationLimits(const RealLimits &limits)
void setWavelength(double wavelength)
Stores radiation power per bin.
DepthProbeCoordinates class handles the unit translations for depth probe simulations Its default uni...
std::vector< DepthProbeElement > m_eles
std::unique_ptr< IAxis > m_z_axis
void setBeamParameters(double lambda, int nbins, double alpha_i_min, double alpha_i_max, const IFootprintFactor *beam_shape=nullptr)
Sets beam parameters with alpha_i of the beam defined in the range.
void moveDataFromCache() override
void addDataToCache(double weight) override
void setZSpan(size_t n_bins, double z_min, double z_max)
Set z positions for intensity calculations. Negative z's correspond to the area under sample surface....
DepthProbeSimulation(const MultiLayer &sample)
void addBackgroundIntensity(size_t start_ind, size_t n_elements) override
std::unique_ptr< Datafield > createIntensityData() const
Creates intensity data from simulation elements.
~DepthProbeSimulation() override
double incidentAngle(size_t index) const
void initElementVector() override
Initializes the vector of ISimulation elements.
std::vector< DepthProbeElement > generateElements(const Beam &beam)
Generate simulation elements for given beam.
const IAxis * alphaAxis() const
Returns a pointer to incident angle axis.
ICoordSystem * createCoordSystem() const override
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 validateParametrization(const ParameterDistribution &par_distr) const override
Checks the distribution validity for simulation.
void validityCheck() const
Checks if simulation data is ready for retrieval.
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.
size_t numberOfElements() const override
Gets the number of elements this simulation needs to calculate.
std::vector< std::valarray< double > > m_cache
std::unique_ptr< IAxis > m_alpha_axis
const IAxis * zAxis() const
Returns a pointer to z-position axis.
SimulationResult pack_result() override
Sets m_result.
size_t intensityMapSize() const override
Returns the total number of the intensity values in the simulation result.
Axis with fixed bin size.
Abstract base class for one-dimensional axes.
virtual double max() const =0
Returns value of last point of axis.
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.
virtual double mean() const =0
Returns the distribution-specific mean.
Abstract base class of simulations that generate 2D patterns.
ProgressHandler & progress()
const IBackground * background() const
const MultiLayer * sample() const
const SimulationOptions & options() const
Our sample model: a stack of layers one below the other.
A parametric distribution function, for use with any model parameter.
const IDistribution1D * getDistribution() const
Limits for a real fit parameter.
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Wrapper around Datafield that also provides unit conversions.
Data structure that contains all the necessary data for scattering calculations.