34 : m_xData(xData), m_errorLevel(errorLevel), m_warn(warningLevel > 0), m_warningLevel(warningLevel),
59 const auto xSize = xData.size();
62 return "Input workspace must not be empty";
69 bool printWarning =
false;
70 for (
size_t bin = 0; bin < xSize - 2; bin++) {
73 std::stringstream errorStr;
74 errorStr <<
"X axis must be linear (all bins must have the same width) ";
75 errorStr <<
"dx=" << xData[bin + 1] - xData[bin] <<
" reference dx=" << dx <<
" bin number=" << bin;
76 return errorStr.str();
98 throw std::runtime_error(
"No bins in input X data");
103 const auto xSize =
m_xData.size();
104 return (
m_xData[xSize - 1] -
m_xData[0]) /
static_cast<double>(xSize - 1);
119 if (bin >
m_xData.size() - 2) {
120 throw std::invalid_argument(
"Not enough bins in input X data");
127 return std::fabs((
m_xData[bin + 1] -
m_xData[0] -
static_cast<double>(bin + 1) * dx) / dx);
virtual double getDifference(const size_t bin, const double dx) const
Returns the error (simple or cumulative) at the given point.
virtual double getReferenceDx() const
Returns the bin width to compare against: either the average or the first depending on options.
const double m_warningLevel
virtual std::string validate() const
Perform validation of the given X array.
const double m_errorLevel
virtual void setErrorType(const ErrorType &errorType)
Set whether to use cumulative errors or compare each in turn.
ErrorType
Type of errors to check.
ReferenceBin
Type of bin to compare others to.
std::span< double const > const m_xData
EqualBinsChecker(std::span< double const > xData, const double errorLevel, const double warningLevel=-1)
Constructor, setting data and thresholds for errors and warnings.
ReferenceBin m_refBinType
virtual void setReferenceBin(const ReferenceBin &refBinType)
Set whether to compare each bin to the first bin width or the average.
The Logger class is in charge of the publishing messages from the framework through various channels.
void warning(const std::string &msg)
Logs at warning level.
Kernel::Logger g_log("DetermineSpinStateOrder")
Logger g_log("DateAndTime")