diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ConvFit.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ConvFit.h index 105c01735989e775177ad8dcd39d08140f84cd96..d349967ab549f4ceb895d62d1e0a54cc69df5d95 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ConvFit.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/ConvFit.h @@ -47,6 +47,7 @@ namespace IDA private: boost::shared_ptr<Mantid::API::CompositeFunction> createFunction(bool tieCentres=false); + double getInstrumentResolution(std::string workspaceName); QtProperty* createLorentzian(const QString &); void createTemperatureCorrection(Mantid::API::CompositeFunction_sptr product); void populateFunction(Mantid::API::IFunction_sptr func, Mantid::API::IFunction_sptr comp, QtProperty* group, const std::string & pref, bool tie); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp index 169601acfb8d8102fc4e88310ffd07b829ca406b..574a21684cba2a653a0bf79e1851a3d7a7c655d7 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp @@ -472,6 +472,26 @@ namespace IDA product->applyTies(); } + double ConvFit::getInstrumentResolution(std::string workspaceName) + { + using namespace Mantid::API; + + double resolution = 0.0; + try + { + MatrixWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(workspaceName); + Mantid::Geometry::Instrument_const_sptr inst = ws->getInstrument(); + std::string analyser = inst->getStringParameter("analyser")[0]; + resolution = inst->getComponentByName(analyser)->getNumberParameter("resolution")[0]; + } + catch(Mantid::Kernel::Exception::NotFoundError &e) + { + resolution = 0; + } + + return resolution; + } + QtProperty* ConvFit::createLorentzian(const QString & name) { QtProperty* lorentzGroup = m_cfGrpMng->addProperty(name); @@ -653,6 +673,14 @@ namespace IDA { showInformationBox(exc.what()); } + + // Default FWHM to resolution of instrument + double resolution = getInstrumentResolution(m_cfInputWSName.toStdString()); + if(resolution > 0) + { + m_cfDblMng->setValue(m_cfProp["Lorentzian 1.FWHM"], resolution); + m_cfDblMng->setValue(m_cfProp["Lorentzian 2.FWHM"], resolution); + } } void ConvFit::plotGuess(QtProperty*)