diff --git a/Code/Mantid/Framework/Algorithms/src/FindPeakBackground.cpp b/Code/Mantid/Framework/Algorithms/src/FindPeakBackground.cpp index fdda95a8c531eca3277e0a6c46aee48a5f577fe8..5aa647cd5c9a521de6a10c7281e8bd6cd6ef0db0 100644 --- a/Code/Mantid/Framework/Algorithms/src/FindPeakBackground.cpp +++ b/Code/Mantid/Framework/Algorithms/src/FindPeakBackground.cpp @@ -106,24 +106,35 @@ namespace Algorithms */ void FindPeakBackground::exec() { - // 1. Get input and validate + // Get input and validate MatrixWorkspace_const_sptr inpWS = getProperty("InputWorkspace"); int inpwsindex = getProperty("WorkspaceIndex"); std::vector<double> m_vecFitWindows = getProperty("FitWindow"); m_backgroundType = getPropertyValue("BackgroundType"); double k = getProperty("SigmaConstant"); - if (inpwsindex < 0 || inpwsindex >= static_cast<int>(inpWS->getNumberHistograms())) + if (isEmpty(inpwsindex)) + { + // Default + if (inpWS->getNumberHistograms() == 1) + { + inpwsindex = 0; + } + else + { + throw runtime_error("WorkspaceIndex must be given. "); + } + } + else if (inpwsindex < 0 || inpwsindex >= static_cast<int>(inpWS->getNumberHistograms())) { stringstream errss; errss << "Input workspace " << inpWS->name() << " has " << inpWS->getNumberHistograms() << " spectra. Input workspace index " << inpwsindex << " is out of boundary. "; throw runtime_error(errss.str()); } - if (isEmpty(inpwsindex)) - throw runtime_error("WorkspaceIndex must be given. "); - // 2. Generate output + + // Generate output const MantidVec& inpX = inpWS->readX(inpwsindex); size_t sizex = inpWS->readX(inpwsindex).size(); size_t sizey = inpWS->readY(inpwsindex).size();