本文整理汇总了C++中mantid::geometry::IMDDimension_const_sptr::getMaximum方法的典型用法代码示例。如果您正苦于以下问题:C++ IMDDimension_const_sptr::getMaximum方法的具体用法?C++ IMDDimension_const_sptr::getMaximum怎么用?C++ IMDDimension_const_sptr::getMaximum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::geometry::IMDDimension_const_sptr
的用法示例。
在下文中一共展示了IMDDimension_const_sptr::getMaximum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getProperty
/**
* Make 1D MatrixWorkspace
*/
void ConvertMDHistoToMatrixWorkspace::make1DWorkspace() {
IMDHistoWorkspace_sptr inputWorkspace = getProperty("InputWorkspace");
// This code is copied from MantidQwtIMDWorkspaceData
Mantid::Geometry::VecIMDDimension_const_sptr nonIntegDims =
inputWorkspace->getNonIntegratedDimensions();
std::string alongDim = "";
if (!nonIntegDims.empty())
alongDim = nonIntegDims[0]->getDimensionId();
else
alongDim = inputWorkspace->getDimension(0)->getDimensionId();
size_t nd = inputWorkspace->getNumDims();
Mantid::Kernel::VMD start = VMD(nd);
Mantid::Kernel::VMD end = VMD(nd);
size_t id = 0;
for (size_t d = 0; d < nd; d++) {
Mantid::Geometry::IMDDimension_const_sptr dim =
inputWorkspace->getDimension(d);
if (dim->getDimensionId() == alongDim) {
// All the way through in the single dimension
start[d] = dim->getMinimum();
end[d] = dim->getMaximum();
id = d; // We take the first non integrated dimension to be the diemnsion
// of interest.
} else {
// Mid point along each dimension
start[d] = (dim->getMaximum() + dim->getMinimum()) / 2.0f;
end[d] = start[d];
}
}
// Unit direction of the line
Mantid::Kernel::VMD dir = end - start;
dir.normalize();
std::string normProp = getPropertyValue("Normalization");
Mantid::API::MDNormalization normalization;
if (normProp == "NoNormalization") {
normalization = NoNormalization;
} else if (normProp == "VolumeNormalization") {
normalization = VolumeNormalization;
} else if (normProp == "NumEventsNormalization") {
normalization = NumEventsNormalization;
} else {
normalization = NoNormalization;
}
auto line = inputWorkspace->getLineData(start, end, normalization);
MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(
"Workspace2D", 1, line.x.size(), line.y.size());
outputWorkspace->dataY(0).assign(line.y.begin(), line.y.end());
outputWorkspace->dataE(0).assign(line.e.begin(), line.e.end());
const size_t numberTransformsToOriginal =
inputWorkspace->getNumberTransformsToOriginal();
CoordTransform_const_sptr transform =
boost::make_shared<NullCoordTransform>(inputWorkspace->getNumDims());
if (numberTransformsToOriginal > 0) {
const size_t indexToLastTransform = numberTransformsToOriginal - 1;
transform = CoordTransform_const_sptr(
inputWorkspace->getTransformToOriginal(indexToLastTransform),
NullDeleter());
}
assert(line.x.size() == outputWorkspace->dataX(0).size());
std::string xAxisLabel = inputWorkspace->getDimension(id)->getName();
const bool autoFind = this->getProperty("FindXAxis");
if (autoFind) {
// We look to the original workspace if possbible to find the dimension of
// interest to plot against.
id = findXAxis(start, end, transform.get(), inputWorkspace.get(), g_log, id,
xAxisLabel);
}
for (size_t i = 0; i < line.x.size(); ++i) {
// Coordinates in the workspace being plotted
VMD wsCoord = start + dir * line.x[i];
VMD inTargetCoord = transform->applyVMD(wsCoord);
outputWorkspace->dataX(0)[i] = inTargetCoord[id];
}
boost::shared_ptr<Kernel::Units::Label> labelX =
boost::dynamic_pointer_cast<Kernel::Units::Label>(
Kernel::UnitFactory::Instance().create("Label"));
labelX->setLabel(xAxisLabel);
outputWorkspace->getAxis(0)->unit() = labelX;
outputWorkspace->setYUnitLabel("Signal");
//.........这里部分代码省略.........