/**
 * @returns The bin bounadries for the new workspace
 */
BinEdges CreateSimulationWorkspace::createBinBoundaries() const {
  const std::vector<double> rbparams = getProperty("BinParams");
  MantidVec newBins;
  const int numBoundaries =
      Mantid::Kernel::VectorHelper::createAxisFromRebinParams(rbparams,
                                                              newBins);
  if (numBoundaries <= 2) {
    throw std::invalid_argument(
        "Error in BinParams - Gave invalid number of bin boundaries: " +
        std::to_string(numBoundaries));
  }
  return BinEdges(std::move(newBins));
}
Exemple #2
0
/// Return a Histogram based on previously set information. Throws if
/// information is incomplete are inconsisten.
Histogram HistogramBuilder::build() const {
  if (!m_x)
    throw std::runtime_error("HistogramBuilder: No X data has been set");
  if (!m_y)
    throw std::runtime_error("HistogramBuilder: No Y data has been set");

  std::unique_ptr<Histogram> histogram;
  if (getHistogramXMode(m_x->size(), m_y->size()) ==
      Histogram::XMode::BinEdges) {
    if (m_isDistribution)
      histogram =
          Kernel::make_unique<Histogram>(BinEdges(m_x), Frequencies(m_y));
    else
      histogram = Kernel::make_unique<Histogram>(BinEdges(m_x), Counts(m_y));
  } else {
    if (m_isDistribution)
      histogram = Kernel::make_unique<Histogram>(Points(m_x), Frequencies(m_y));
    else
      histogram = Kernel::make_unique<Histogram>(Points(m_x), Counts(m_y));
  }
  if (m_e)
    histogram->setSharedE(m_e);
  return *histogram;
}