void SaveDiffFittingAscii::writeData(const API::ITableWorkspace_sptr workspace, std::ofstream &file, const size_t columnSize) { for (size_t rowIndex = 0; rowIndex < workspace->rowCount(); ++rowIndex) { TableRow row = workspace->getRow(rowIndex); for (size_t columnIndex = 0; columnIndex < columnSize; columnIndex++) { const auto row_str = boost::lexical_cast<std::string>(row.Double(columnIndex)); g_log.debug() << row_str << std::endl; if (columnIndex == columnSize - 1) writeVal(row_str, file, true); else writeVal(row_str, file, false); } } }
int PoldiFitPeaks1D2::getBestChebyshevPolynomialDegree( const Workspace2D_sptr &dataWorkspace, const RefinedRange_sptr &range) { double chiSquareMin = 1e10; int nMin = -1; try { int n = 0; while ((n < 3)) { IAlgorithm_sptr fit = getFitAlgorithm(dataWorkspace, range, n); bool fitSuccess = fit->execute(); if (fitSuccess) { ITableWorkspace_sptr fitCharacteristics = fit->getProperty("OutputParameters"); TableRow row = fitCharacteristics->getRow(fitCharacteristics->rowCount() - 1); double chiSquare = row.Double(1); if (fabs(chiSquare - 1) < fabs(chiSquareMin - 1)) { chiSquareMin = chiSquare; nMin = n; } } ++n; } } catch (std::runtime_error) { nMin = -1; } if (nMin == -1) { g_log.information() << "Range [" << range->getXStart() << " - " << range->getXEnd() << "] is excluded."; } else { g_log.information() << "Chi^2 for range [" << range->getXStart() << " - " << range->getXEnd() << "] is minimal at n = " << nMin << " with Chi^2 = " << chiSquareMin << std::endl; } return nMin; }