Beispiel #1
0
/**
 * @brief Copies the sorted inputworkspace into the output workspace without
 * using clone because of how histograms are supported, for the Y Axis and the E
 * Axis.
 *
 * @param workspaceIndicies the sorted vector of indicies
 * @param inputWorkspace the unsorted input workspaces
 * @param outputWorkspace the empty output workspace
 * @param specNum the spectrum number being copied into
 * @param isAProperHistogram whether or not it has been determined to be a valid
 * histogram earlier on.
 */
void SortXAxis::copyYandEToOutputWorkspace(
    std::vector<std::size_t> &workspaceIndicies,
    const Mantid::API::MatrixWorkspace &inputWorkspace,
    Mantid::API::MatrixWorkspace &outputWorkspace, unsigned int specNum,
    bool isAProperHistogram) {
  // If Histogram data find the biggest index value and remove it from
  // workspaceIndicies
  if (isAProperHistogram) {
    auto lastIndexIt =
        std::find(workspaceIndicies.begin(), workspaceIndicies.end(),
                  inputWorkspace.y(specNum).size());
    workspaceIndicies.erase(lastIndexIt);
  }

  auto &inSpaceY = inputWorkspace.y(specNum);
  for (auto workspaceIndex = 0u;
       workspaceIndex < inputWorkspace.y(specNum).size(); workspaceIndex++) {
    outputWorkspace.mutableY(specNum)[workspaceIndex] =
        inSpaceY[workspaceIndicies[workspaceIndex]];
  }

  auto &inSpaceE = inputWorkspace.e(specNum);
  for (auto workspaceIndex = 0u;
       workspaceIndex < inputWorkspace.e(specNum).size(); workspaceIndex++) {
    outputWorkspace.mutableE(specNum)[workspaceIndex] =
        inSpaceE[workspaceIndicies[workspaceIndex]];
  }
}