Skip to content

Commit

Permalink
ConvFit FWHM default to instrument resolution
Browse files Browse the repository at this point in the history
Refs #9338
  • Loading branch information
DanNixon committed Sep 19, 2014
1 parent c66cdfc commit 8cac916
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Expand Up @@ -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);
Expand Down
28 changes: 28 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ConvFit.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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*)
Expand Down

0 comments on commit 8cac916

Please sign in to comment.