本文整理汇总了C++中Workspace2D_sptr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace2D_sptr::reset方法的具体用法?C++ Workspace2D_sptr::reset怎么用?C++ Workspace2D_sptr::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace2D_sptr
的用法示例。
在下文中一共展示了Workspace2D_sptr::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
/** Executes the algorithm
*
* @throw Exception::FileError If the grouping file cannot be opened or read successfully
* @throw runtime_error If unable to run one of the Child Algorithms successfully
*/
void ReadGroupsFromFile::exec()
{
MatrixWorkspace_const_sptr ws = getProperty("InstrumentWorkspace");
// Get the instrument.
Instrument_const_sptr inst = ws->getInstrument();
// Create a copy (without the data) of the workspace - it will contain the
Workspace2D_sptr localWorkspace =
boost::dynamic_pointer_cast<Workspace2D>(WorkspaceFactory::Instance().create(ws, ws->getNumberHistograms(), 2, 1));
if (!localWorkspace)
throw std::runtime_error("Failed when creating a Workspace2D from the input!");
const std::string groupfile=getProperty("GroupingFilename");
if ( ! groupfile.empty() )
{
std::string filename(groupfile);
std::transform(filename.begin(), filename.end(), filename.begin(), tolower);
if ( filename.find(".xml") != std::string::npos )
{
readXMLGroupingFile(groupfile);
}
else
{
readGroupingFile(groupfile);
}
}
// Get the instrument.
const int64_t nHist=localWorkspace->getNumberHistograms();
// Determine whether the user wants to see unselected detectors or not
const std::string su=getProperty("ShowUnselected");
bool showunselected=(!su.compare("True"));
bool success=false;
for (int64_t i=0;i<nHist;i++)
{
ISpectrum * spec = localWorkspace->getSpectrum(i);
const std::set<detid_t> & dets = spec->getDetectorIDs();
if (dets.empty()) // Nothing
{
spec->dataY()[0]=0.0;
continue;
}
// Find the first detector ID in the list
calmap::const_iterator it=calibration.find(*dets.begin());
if (it==calibration.end()) //Could not find the detector
{
spec->dataY()[0]=0.0;
continue;
}
if (showunselected)
{
if (((*it).second).second==0)
spec->dataY()[0]=0.0;
else
spec->dataY()[0]=static_cast<double>(((*it).second).first);
}
else
spec->dataY()[0]=static_cast<double>(((*it).second).first);
if (!success) success=true; //At least one detector is found in the cal file
}
progress(1);
calibration.clear();
if (!success) //Do some cleanup
{
localWorkspace.reset();
throw std::runtime_error("Fail to found a detector in "+groupfile+" existing in instrument "+inst->getName());
}
setProperty("OutputWorkspace",localWorkspace);
return;
}