当前位置: 首页>>代码示例>>C++>>正文


C++ EventWorkspace_const_sptr::spectrumInfo方法代码示例

本文整理汇总了C++中EventWorkspace_const_sptr::spectrumInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_const_sptr::spectrumInfo方法的具体用法?C++ EventWorkspace_const_sptr::spectrumInfo怎么用?C++ EventWorkspace_const_sptr::spectrumInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventWorkspace_const_sptr的用法示例。


在下文中一共展示了EventWorkspace_const_sptr::spectrumInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: execEvent

/** Executes the algorithm
 *@param localworkspace :: the input workspace
 *@param indices :: set of indices to sum up
 */
void SumSpectra::execEvent(EventWorkspace_const_sptr localworkspace,
                           std::set<int> &indices) {
  auto outputWorkspace = create<EventWorkspace>(*localworkspace, 1);

  Progress progress(this, 0, 1, indices.size());

  // Get the pointer to the output event list
  EventList &outEL = outputWorkspace->getSpectrum(0);
  outEL.setSpectrumNo(m_outSpecNum);
  outEL.clearDetectorIDs();

  const auto &spectrumInfo = localworkspace->spectrumInfo();
  // Loop over spectra
  size_t numSpectra(0);
  size_t numMasked(0);
  size_t numZeros(0);
  for (const auto i : indices) {
    // Don't go outside the range.
    if ((i >= m_numberOfSpectra) || (i < 0)) {
      g_log.error() << "Invalid index " << i
                    << " was specified. Sum was aborted.\n";
      break;
    }

    if (spectrumInfo.hasDetectors(i)) {
      // Skip monitors, if the property is set to do so
      if (!m_keepMonitors && spectrumInfo.isMonitor(i))
        continue;
      // Skip masked detectors
      if (spectrumInfo.isMasked(i)) {
        numMasked++;
        continue;
      }
    }
    numSpectra++;

    // Add the event lists with the operator
    const EventList &tOutEL = localworkspace->getSpectrum(i);
    if (tOutEL.empty()) {
      ++numZeros;
    }
    outEL += tOutEL;

    progress.report();
  }

  outputWorkspace->mutableRun().addProperty("NumAllSpectra", int(numSpectra),
                                            "", true);
  outputWorkspace->mutableRun().addProperty("NumMaskSpectra", int(numMasked),
                                            "", true);
  outputWorkspace->mutableRun().addProperty("NumZeroSpectra", int(numZeros), "",
                                            true);

  // Assign it to the output workspace property
  setProperty("OutputWorkspace", std::move(outputWorkspace));
}
开发者ID:,项目名称:,代码行数:60,代码来源:


注:本文中的EventWorkspace_const_sptr::spectrumInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。