本文整理汇总了C++中api::MatrixWorkspace_sptr::spectrumInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_sptr::spectrumInfo方法的具体用法?C++ MatrixWorkspace_sptr::spectrumInfo怎么用?C++ MatrixWorkspace_sptr::spectrumInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::MatrixWorkspace_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_sptr::spectrumInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: populate_values_from_file
void FindDetectorsPar::populate_values_from_file(
const API::MatrixWorkspace_sptr &inputWS) {
size_t nHist = inputWS->getNumberHistograms();
if (this->current_ASCII_file.Type == PAR_type) {
// in this case data in azimuthal width and polar width are in fact real
// sizes in meters; have to transform it in into angular values
for (size_t i = 0; i < nHist; i++) {
azimuthalWidth[i] =
atan2(azimuthalWidth[i], secondaryFlightpath[i]) * rad2deg;
polarWidth[i] = atan2(polarWidth[i], secondaryFlightpath[i]) * rad2deg;
}
m_SizesAreLinear = false;
} else {
const auto &spectrumInfo = inputWS->spectrumInfo();
secondaryFlightpath.resize(nHist);
for (size_t i = 0; i < nHist; i++) {
if (!spectrumInfo.hasDetectors(i) || spectrumInfo.isMonitor(i))
continue;
/// this is the only value, which is not defined in phx file, so we
/// calculate it
secondaryFlightpath[i] = spectrumInfo.l2(i);
}
}
}
示例2: catch
/// Validate the some of the algorithm's input properties.
std::map<std::string, std::string> ReflectometrySumInQ::validateInputs() {
std::map<std::string, std::string> issues;
API::MatrixWorkspace_sptr inWS;
Indexing::SpectrumIndexSet indices;
// validateInputs is called on the individual workspaces when the algorithm
// is executed, it but may get called on a group from AlgorithmDialog. This
// isn't handled in getWorkspaceAndIndices. We should fix this properly but
// for now skip validation for groups to avoid an exception. See #22933
try {
std::tie(inWS, indices) =
getWorkspaceAndIndices<API::MatrixWorkspace>(Prop::INPUT_WS);
} catch (std::runtime_error &) {
return issues;
}
const auto &spectrumInfo = inWS->spectrumInfo();
const double beamCentre = getProperty(Prop::BEAM_CENTRE);
const size_t beamCentreIndex = static_cast<size_t>(beamCentre);
bool beamCentreFound{false};
for (const auto i : indices) {
if (spectrumInfo.isMonitor(i)) {
issues["InputWorkspaceIndexSet"] = "Index set cannot include monitors.";
break;
} else if ((i > 0 && spectrumInfo.isMonitor(i - 1)) ||
(i < spectrumInfo.size() - 1 && spectrumInfo.isMonitor(i + 1))) {
issues["InputWorkspaceIndexSet"] =
"A neighbour to any detector in the index set cannot be a monitor";
break;
}
if (i == beamCentreIndex) {
beamCentreFound = true;
break;
}
}
if (!beamCentreFound) {
issues[Prop::BEAM_CENTRE] =
"Beam centre is not included in InputWorkspaceIndexSet.";
}
return issues;
}
示例3: exec
/** Execute the algorithm.
*/
void CreateEPP::exec() {
API::MatrixWorkspace_sptr inputWS =
getProperty(PropertyNames::INPUT_WORKSPACE);
const auto &spectrumInfo = inputWS->spectrumInfo();
API::ITableWorkspace_sptr outputWS =
API::WorkspaceFactory::Instance().createTable("TableWorkspace");
addEPPColumns(outputWS);
const double sigma = getProperty(PropertyNames::SIGMA);
const size_t spectraCount = spectrumInfo.size();
outputWS->setRowCount(spectraCount);
const auto l1 = spectrumInfo.l1();
const double EFixed = inputWS->run().getPropertyAsSingleValue("Ei");
for (size_t i = 0; i < spectraCount; ++i) {
const auto l2 = spectrumInfo.l2(i);
const auto elasticTOF = Kernel::UnitConversion::run(
"Energy", "TOF", EFixed, l1, l2, 0, Kernel::DeltaEMode::Direct, EFixed);
outputWS->getRef<int>(ColumnNames::WS_INDEX, i) = static_cast<int>(i);
outputWS->getRef<double>(ColumnNames::PEAK_CENTRE, i) = elasticTOF;
outputWS->getRef<double>(ColumnNames::PEAK_CENTRE_ERR, i) = 0;
outputWS->getRef<double>(ColumnNames::SIGMA, i) = sigma;
outputWS->getRef<double>(ColumnNames::SIGMA_ERR, i) = 0;
double height = 0;
try {
const auto elasticIndex = inputWS->binIndexOf(elasticTOF, i);
height = inputWS->y(i)[elasticIndex];
} catch (std::out_of_range &) {
std::ostringstream sout;
sout << "EPP out of TOF range for workspace index " << i
<< ". Peak height set to zero.";
g_log.warning() << sout.str();
}
outputWS->getRef<double>(ColumnNames::HEIGHT, i) = height;
outputWS->getRef<double>(ColumnNames::CHI_SQUARED, i) = 1;
outputWS->getRef<std::string>(ColumnNames::STATUS, i) = "success";
}
setProperty(PropertyNames::OUTPUT_WORKSPACE, outputWS);
}