diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index 9f096583c4d1781ec3102362a7abc198a76ef6ee..0c929cb94f17e9b8cbf4e7fbd43b50ee8d2cf3ce 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -53,7 +53,7 @@ void sortXAxis(MatrixWorkspace_sptr &ws) { x_value = ws->x(i)[k]; sorter.insert(std::pair<double, double>(x_value, ws->y(i)[k])); sorter.insert(std::pair<double, double>(x_value, ws->e(i)[k])); - if (ws->hasDx(i)) + if (ws->hasDx(i) && !ws->isHistogramData()) sorter.insert(std::pair<double, double>(x_value, ws->dx(i)[k])); } size_t ws_size = ws->size(); @@ -67,7 +67,7 @@ void sortXAxis(MatrixWorkspace_sptr &ws) { vecx[l] = it->first; vecy[l] = it->second; vece[l] = (++it)->second; - if (ws->hasDx(i)) + if (ws->hasDx(i) && !ws->isHistogramData()) vecdx[l] = (++it)->second; ++l; ++it; @@ -78,7 +78,7 @@ void sortXAxis(MatrixWorkspace_sptr &ws) { ws->setSharedX(i, x); ws->setSharedY(i, y); ws->setSharedE(i, e); - if (ws->hasDx(i)) { + if (ws->hasDx(i) && !ws->isHistogramData()) { auto dx = make_cow<HistogramDx>(std::move(vecdx)); ws->setSharedDx(i, dx); } @@ -221,9 +221,12 @@ std::map<std::string, std::string> Stitch1D::validateInputs(void) { RunCombinationHelper combHelper; combHelper.setReferenceProperties(lhs); std::string compatible = combHelper.checkCompatibility(rhs, true); - if (!compatible.empty()) - issues["RHSWorkspace"] = "Workspace " + rhs->getName() + - " is not compatible: " + compatible + "\n"; + if (!compatible.empty()) { + if (!(compatible == "spectra must have either Dx values or not; ") || + (rhs->isHistogramData())) // Issue only for point data + issues["RHSWorkspace"] = "Workspace " + rhs->getName() + + " is not compatible: " + compatible + "\n"; + } return issues; } @@ -535,7 +538,7 @@ void Stitch1D::scaleWorkspace(MatrixWorkspace_sptr &ws, // We lost Dx values (Multiply) and need to get them back for point data if (ws->size() == dxWS->size()) { for (size_t i = 0; i < ws->getNumberHistograms(); ++i) { - if (dxWS->hasDx(i) && !ws->hasDx(i)) { + if (dxWS->hasDx(i) && !ws->hasDx(i) && !ws->isHistogramData()) { ws->setSharedDx(i, dxWS->sharedDx(i)); } } diff --git a/Framework/Algorithms/src/Stitch1DMany.cpp b/Framework/Algorithms/src/Stitch1DMany.cpp index d2a330570be1e24919dd50cc746598ea0a37c404..8dfb17fee782298498da2952ee339f884542e2df 100644 --- a/Framework/Algorithms/src/Stitch1DMany.cpp +++ b/Framework/Algorithms/src/Stitch1DMany.cpp @@ -141,10 +141,14 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() { for (const auto &ws : column) { // check if all the others are compatible with the reference std::string compatible = combHelper.checkCompatibility(ws, true); - if (!compatible.empty()) - issues["InputWorkspaces"] = "Workspace " + ws->getName() + - " is not compatible: " + compatible + - "\n"; + if (!compatible.empty()) { + if (!(compatible == + "spectra must have either Dx values or not; ") || + (ws->isHistogramData())) // Issue only for point data + issues["RHSWorkspace"] = "Workspace " + ws->getName() + + " is not compatible: " + compatible + + "\n"; + } } m_inputWSMatrix.emplace_back(column); } else if (m_inputWSMatrix.size() != @@ -173,7 +177,8 @@ std::map<std::string, std::string> Stitch1DMany::validateInputs() { int scaleFactorFromPeriod = this->getProperty("ScaleFactorFromPeriod"); m_scaleFactorFromPeriod = static_cast<size_t>(scaleFactorFromPeriod); - m_scaleFactorFromPeriod--; // To account for period being indexed from 1 + m_scaleFactorFromPeriod--; // To account for period being indexed from + // 1 if (m_scaleFactorFromPeriod >= m_inputWSMatrix.size()) { std::stringstream expectedRange; expectedRange << m_inputWSMatrix.size(); @@ -231,7 +236,8 @@ void Stitch1DMany::exec() { std::string groupName = this->getProperty("OutputWorkspace"); std::string outName; - // Determine whether or not we are scaling workspaces using scale factors + // Determine whether or not we are scaling workspaces using scale + // factors // from a specific period Property *manualSF = this->getProperty("ManualScaleFactors"); bool usingScaleFromPeriod = m_useManualScaleFactors && @@ -347,7 +353,8 @@ void Stitch1DMany::doStitch1D(std::vector<MatrixWorkspace_sptr> &toStitch, /** Performs the Stitch1DMany algorithm at a specific period * @param period :: The period index we are stitching at - * @param useManualScaleFactors :: True to use provided values for scale factors + * @param useManualScaleFactors :: True to use provided values for scale + * factors * @param outName :: Output stitched workspace name * @param outScaleFactors :: Actual values used for scale factors */ diff --git a/docs/source/algorithms/Stitch1D-v3.rst b/docs/source/algorithms/Stitch1D-v3.rst index fb8e2ba453167e7af58c6a302c040b7bf9677860..f7a2ef375ba3d0ca3a5c8b23c3dd411d6b0beefc 100644 --- a/docs/source/algorithms/Stitch1D-v3.rst +++ b/docs/source/algorithms/Stitch1D-v3.rst @@ -10,16 +10,16 @@ Description ----------- Stitches single histogram :ref:`Matrix Workspaces <MatrixWorkspace>` -together outputting a stitched Matrix Workspace. Note that workspaces must be histogrammed, you may -want to use :ref:`algm-ConvertToHistogram` on workspaces prior to passing them to this algorithm. +together outputting a stitched Matrix Workspace. +The type of the input workspaces (histogram or point data) determines the stitch procedure. +The x-error values Dx will always be ignored in case of histogram workspaces. +Point data workspaces must be consistent, i.e. must have Dx defined or not. Either the right-hand-side or left-hand-side workspace can be chosen to be scaled. Users can optionally provide :ref:`algm-Rebin` :literal:`Params`, otherwise they are calculated from the input workspaces. Likewise, :literal:`StartOverlap` and :literal:`EndOverlap` are optional. If not provided, then these are taken to be the region of X-axis intersection. -The type of the input workspaces (histogram or point data) determines the x values in the overlap range of the output workspace. - The algorithm workflow for histograms is as follows: #. The workspaces are initially rebinned, as prescribed by the rebin :literal:`Params`. Note that