本文整理汇总了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));
}