コード例 #1
0
ファイル: NormaliseToMonitor.cpp プロジェクト: mganeva/mantid
/** Calculates the overall normalization factor.
 *  This multiplies result by (bin width * sum of monitor counts) / total
 * frame
 * width.
 *  @param X The BinEdges of the workspace
 *  @param Y The Counts of the workspace
 *  @param E The CountStandardDeviations of the workspace
 */
void NormaliseToMonitor::normalisationFactor(const BinEdges &X, Counts &Y,
                                             CountStandardDeviations &E) {
  const double monitorSum = std::accumulate(Y.begin(), Y.end(), 0.0);
  const double range = X.back() - X.front();
  auto specLength = Y.size();

  auto &yNew = Y.mutableRawData();
  auto &eNew = E.mutableRawData();

  for (size_t j = 0; j < specLength; ++j) {
    const double factor = range / ((X[j + 1] - X[j]) * monitorSum);
    yNew[j] *= factor;
    eNew[j] *= factor;
  }
}