diff --git a/Framework/Algorithms/src/FitPeaks.cpp b/Framework/Algorithms/src/FitPeaks.cpp index dca990c27a39b28a6e0192e7d221c9b23aa28751..2132aa96e187b2aa343ac28e92b791a30ee4b99f 100644 --- a/Framework/Algorithms/src/FitPeaks.cpp +++ b/Framework/Algorithms/src/FitPeaks.cpp @@ -956,14 +956,20 @@ void FitPeaks::fitSpectrumPeaks( std::pair<double, double> peak_window_i = getPeakFitWindow(wi, peak_index); - bool observe_peak_width = + bool observe_peak_width_flag = decideToEstimatePeakWidth(!foundAnyPeak, peakfunction); + if (observe_peak_width && + m_peakWidthEstimateApproach == EstimatePeakWidth::NoEstimation) { + g_log.warning( + "Peak width can be estimated as ZERO. The result can be wrong"); + } + // do fitting with peak and background function (no analysis at this // point) - cost = - fitIndividualPeak(wi, peak_fitter, expected_peak_pos, peak_window_i, - observe_peak_width, peakfunction, bkgdfunction); + cost = fitIndividualPeak(wi, peak_fitter, expected_peak_pos, + peak_window_i, observe_peak_width_flag, + peakfunction, bkgdfunction); if (cost < 1e7) { // assume it worked and save out the result foundAnyPeak = true; for (size_t i = 0; i < lastGoodPeakParameters.size(); ++i) @@ -1282,6 +1288,7 @@ int FitPeaks::estimatePeakParameters( const Histogram &histogram, const std::pair<double, double> &peak_window, API::IPeakFunction_sptr peakfunction, API::IBackgroundFunction_sptr bkgdfunction, bool observe_peak_width) { + // get the range of start and stop to construct a function domain const auto &vector_x = histogram.points(); std::vector<double>::const_iterator start_iter = @@ -1307,6 +1314,7 @@ int FitPeaks::estimatePeakParameters( observePeakCenter(histogram, bkgd_values, start_index, stop_index, peak_center, peak_center_index, peak_height); + // return if failing to 'observe' peak center if (result != GOOD) return result; @@ -1318,12 +1326,10 @@ int FitPeaks::estimatePeakParameters( peakfunction->setCentre(peak_center); // Estimate FHWM (peak width) - // if (result == GOOD && if (observe_peak_width && m_peakWidthEstimateApproach != EstimatePeakWidth::NoEstimation) { double peak_width = observePeakWidth( histogram, bkgd_values, peak_center_index, start_index, stop_index); - const auto vec_x = histogram.points(); // proper factor for gaussian const double CONVERSION = 1.; // 2. * std::sqrt(2.); @@ -1344,7 +1350,7 @@ int FitPeaks::estimatePeakParameters( bool FitPeaks::isObservablePeakProfile(const std::string &peakprofile) { return (std::find(supported_peak_profiles.begin(), supported_peak_profiles.end(), - peakprofile) == supported_peak_profiles.end()); + peakprofile) != supported_peak_profiles.end()); } //----------------------------------------------------------------------------------------------