本文整理汇总了C++中dataobjects::Workspace2D_sptr::replaceSpectraMap方法的典型用法代码示例。如果您正苦于以下问题:C++ Workspace2D_sptr::replaceSpectraMap方法的具体用法?C++ Workspace2D_sptr::replaceSpectraMap怎么用?C++ Workspace2D_sptr::replaceSpectraMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataobjects::Workspace2D_sptr
的用法示例。
在下文中一共展示了Workspace2D_sptr::replaceSpectraMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
/**
* Populate spectra mapping to detector IDs
*
* TODO: Get the detector size information from the workspace directly
*
* @param localWorkspace: Workspace2D object
* @param nxbins: number of bins in X
* @param nybins: number of bins in Y
*/
void LoadSpice2D::runLoadMappingTable(DataObjects::Workspace2D_sptr localWorkspace, int nxbins, int nybins)
{
// Get the number of monitor channels
boost::shared_ptr<const Geometry::Instrument> instrument = localWorkspace->getInstrument();
std::vector<detid_t> monitors = instrument->getMonitors();
const int nMonitors = static_cast<int>(monitors.size());
// Number of monitors should be consistent with data file format
if( nMonitors != LoadSpice2D::nMonitors ) {
std::stringstream error;
error << "Geometry error for " << instrument->getName() <<
": Spice data format defines " << LoadSpice2D::nMonitors << " monitors, " << nMonitors << " were/was found";
throw std::runtime_error(error.str());
}
const size_t ndet = nxbins*nybins + nMonitors;
boost::shared_array<detid_t> udet(new detid_t[ndet]);
boost::shared_array<specid_t> spec(new specid_t[ndet]);
// Generate mapping of detector/channel IDs to spectrum ID
// Detector/channel counter
int icount = 0;
// Monitor: IDs start at 1 and increment by 1
for(int i=0; i<nMonitors; i++)
{
spec[icount] = icount;
udet[icount] = icount+1;
icount++;
}
// Detector pixels
for(int ix=0; ix<nxbins; ix++)
{
for(int iy=0; iy<nybins; iy++)
{
spec[icount] = icount;
udet[icount] = 1000000 + iy*1000 + ix;
icount++;
}
}
// Populate the Spectra Map with parameters
localWorkspace->replaceSpectraMap(new API::SpectraDetectorMap(spec.get(), udet.get(), ndet));
}