本文整理汇总了C++中EventWorkspace_sptr::blocksize方法的典型用法代码示例。如果您正苦于以下问题:C++ EventWorkspace_sptr::blocksize方法的具体用法?C++ EventWorkspace_sptr::blocksize怎么用?C++ EventWorkspace_sptr::blocksize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventWorkspace_sptr
的用法示例。
在下文中一共展示了EventWorkspace_sptr::blocksize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: invalid_argument
/** Converts an EventWorkspace to an equivalent Workspace2D
* @param inputMatrixW :: input event workspace
* @return a MatrixWorkspace_sptr
*/
MatrixWorkspace_sptr
EventWorkspaceHelpers::convertEventTo2D(MatrixWorkspace_sptr inputMatrixW) {
EventWorkspace_sptr inputW =
boost::dynamic_pointer_cast<EventWorkspace>(inputMatrixW);
if (!inputW)
throw std::invalid_argument("EventWorkspaceHelpers::convertEventTo2D(): "
"Input workspace is not an EventWorkspace.");
size_t numBins = inputW->blocksize();
// Make a workspace 2D version of it
MatrixWorkspace_sptr outputW;
outputW = WorkspaceFactory::Instance().create(
"Workspace2D", inputW->getNumberHistograms(), numBins + 1, numBins);
WorkspaceFactory::Instance().initializeFromParent(inputW, outputW, false);
// Now let's set all the X bins and values
for (size_t i = 0; i < inputW->getNumberHistograms(); i++) {
outputW->getSpectrum(i).copyInfoFrom(inputW->getSpectrum(i));
outputW->setX(i, inputW->refX(i));
MantidVec &Yout = outputW->dataY(i);
const MantidVec &Yin = inputW->readY(i);
for (size_t j = 0; j < numBins; j++)
Yout[j] = Yin[j];
MantidVec &Eout = outputW->dataE(i);
const MantidVec &Ein = inputW->readE(i);
for (size_t j = 0; j < numBins; j++)
Eout[j] = Ein[j];
}
return outputW;
}