26 ss <<
"Error in SimDataPair::" << method <<
": Trying access non-initialized data\n";
27 throw std::runtime_error(ss.str());
32 auto result = std::make_unique<OutputData<double>>();
33 result->copyShapeFrom(shape);
34 result->setAllTo(value);
41 : m_simulation_builder(builder), m_raw_data(data.clone()),
42 m_raw_uncertainties(std::move(uncertainties))
51 : m_simulation_builder(builder), m_raw_data(data.clone()),
52 m_raw_uncertainties(std::move(uncertainties)), m_raw_user_weights(std::move(user_weights))
60 : m_simulation_builder(std::move(other.m_simulation_builder)),
61 m_simulation(std::move(other.m_simulation)), m_sim_data(std::move(other.m_sim_data)),
62 m_exp_data(std::move(other.m_exp_data)), m_uncertainties(std::move(other.m_uncertainties)),
63 m_user_weights(std::move(other.m_user_weights)), m_raw_data(std::move(other.m_raw_data)),
64 m_raw_uncertainties(std::move(other.m_raw_uncertainties)),
65 m_raw_user_weights(std::move(other.m_raw_user_weights))
128 for (
size_t i = 0, size = result.
size(); i < size; ++i)
140 for (
size_t i = 0, size = result.
size(); i < size; ++i)
188 std::unique_ptr<OutputData<double>> dummy_array =
199 throw std::runtime_error(
"Error in SimDataPair: simulation builder is empty");
202 throw std::runtime_error(
"Error in SimDataPair: passed experimental data array is empty");
205 throw std::runtime_error(
206 "Error in SimDataPair: experimental data and uncertainties have different shape.");
209 throw std::runtime_error(
210 "Error in SimDataPair: user weights are not initialized or have invalid shape");
std::function< std::unique_ptr< Simulation >(const Fit::Parameters &)> simulation_builder_t
Defines class IntensityDataFunctions.
Defines constants and "almost equal" in namespace Numeric.
Defines class SimDataPair.
Defines class Simulation.
Declares utilities for unit converters.
A collection of fit parameters.
Interface to provide axis translations to different units for simulation output.
virtual Axes::Units defaultUnits() const =0
Holds pair of simulation/experimental data to fit.
SimulationResult userWeights() const
Returns the user uncertainties cut to the ROI area.
SimulationResult m_sim_data
Current simulation results. Masked areas are nullified.
std::vector< double > experimental_array() const
Returns the flattened experimental data cut to the ROI area.
SimulationResult absoluteDifference() const
Returns the absolute difference between simulated and experimental data cut to the ROI area.
std::unique_ptr< OutputData< double > > m_raw_user_weights
User-defined weights.
std::vector< double > user_weights_array() const
Returns a flat array of user weights cut to the ROI area.
std::vector< double > uncertainties_array() const
Returns the flattened experimental uncertainties cut to the ROI area.
std::vector< double > simulation_array() const
Returns the flattened simulated intensities cut to the ROI area.
SimDataPair(simulation_builder_t builder, const OutputData< double > &data, std::unique_ptr< OutputData< double >> uncertainties, double user_weight=1.0)
SimulationResult uncertainties() const
Returns the data uncertainties cut to the ROI area If no uncertainties present, returns zero-filled S...
SimulationResult experimentalData() const
Returns the experimental data cut to the ROI area.
bool containsUncertainties() const
std::unique_ptr< OutputData< double > > m_raw_data
Raw experimental data as obtained from the user.
void runSimulation(const Fit::Parameters ¶ms)
std::unique_ptr< Simulation > m_simulation
Current simulation for given set of parameters.
size_t numberOfFitElements() const
Returns the number of elements in the fit area.
SimulationResult relativeDifference() const
Returns the relative difference between simulated and experimental data cut to the ROI area.
SimulationResult simulationResult() const
Returns the result of last computed simulation.
SimulationResult m_uncertainties
Weights from experimental data uncertainties. Masked areas are nullified.
SimulationResult m_exp_data
Experimental data cut to the ROI. Masked areas are nullified.
SimulationResult m_user_weights
Manually defined (user) weights. Masked areas are nullified.
std::unique_ptr< OutputData< double > > m_raw_uncertainties
Data uncertainties as provided by the user.
simulation_builder_t m_simulation_builder
Simulation builder from the user to construct simulation for given set of parameters.
Wrapper around OutputData<double> that also provides unit conversions.
const IUnitConverter & converter() const
Returns underlying unit converter.
std::unique_ptr< OutputData< double > > data(Axes::Units units=Axes::Units::DEFAULT) const
double GetRelativeDifference(double a, double b)
Returns the safe relative difference, which is 2(|a-b|)/(|a|+|b|) except in special cases.
double GetAbsoluteDifference(double a, double b)
Returns the absolute value of the difference between a and b.
std::unique_ptr< OutputData< double > > createOutputData(const IUnitConverter &converter, Axes::Units units)
Returns zero-valued output data array in specified units.
std::unique_ptr< OutputData< double > > initUserWeights(const OutputData< double > &shape, double value)
void throwInitializationException(std::string method)