void PoldiSpectrumDomainFunction::poldiFunction1D(
    const std::vector<int> &indices, const FunctionDomain1D &domain,
    FunctionValues &values) const {

  FunctionValues localValues(domain);

  m_profileFunction->functionLocal(localValues.getPointerToCalculated(0),
                                   domain.getPointerAt(0), domain.size());

  double chopperSlitCount = static_cast<double>(m_chopperSlitOffsets.size());

  for (auto index : indices) {
    std::vector<double> factors(domain.size());

    for (size_t i = 0; i < factors.size(); ++i) {
      values.addToCalculated(i, chopperSlitCount * localValues[i] *
                                    m_timeTransformer->detectorElementIntensity(
                                        domain[i], static_cast<size_t>(index)));
    }
  }
}
void PoldiSpectrumLinearBackground::poldiFunction1D(
    const std::vector<int> &indices, const FunctionDomain1D &domain,
    FunctionValues &values) const {
  double backgroundDetector = getParameter(0);
  double wireCount = static_cast<double>(indices.size());
  double distributionFactor = wireCount * wireCount *
                              static_cast<double>(m_timeBinCount) /
                              (2.0 * static_cast<double>(domain.size()));
  double backgroundD = backgroundDetector * distributionFactor;

  for (size_t i = 0; i < values.size(); ++i) {
    values.addToCalculated(i, backgroundD);
  }
}
Example #3
0
/// Takes a d-based domain and creates a Q-based MatrixWorkspace.
MatrixWorkspace_sptr
PoldiFitPeaks2D::getQSpectrum(const FunctionDomain1D &domain,
                              const FunctionValues &values) const {
  // Put result into workspace, based on Q
  MatrixWorkspace_sptr ws1D = WorkspaceFactory::Instance().create(
      "Workspace2D", 1, domain.size(), values.size());

  auto &xData = ws1D->mutableX(0);
  auto &yData = ws1D->mutableY(0);
  size_t offset = values.size() - 1;
  for (size_t i = 0; i < values.size(); ++i) {
    xData[offset - i] = Conversions::dToQ(domain[i]);
    yData[offset - i] = values[i];
  }

  ws1D->getAxis(0)->setUnit("MomentumTransfer");
  return ws1D;
}