本文整理汇总了C++中api::MatrixWorkspace_const_sptr::getNeighboursExact方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_const_sptr::getNeighboursExact方法的具体用法?C++ MatrixWorkspace_const_sptr::getNeighboursExact怎么用?C++ MatrixWorkspace_const_sptr::getNeighboursExact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api::MatrixWorkspace_const_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_const_sptr::getNeighboursExact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/**
* Function that retrieves the two-theta and azimuthal angles from a given
* detector. It then looks up the nearest neighbours. Using those detectors,
* it calculates the two-theta and azimuthal angle widths.
* @param workspace : the workspace containing the needed detector information
*/
void SofQW3::getValuesAndWidths(API::MatrixWorkspace_const_sptr workspace)
{
// Trigger a build of the nearst neighbors outside the OpenMP loop
const int numNeighbours = 4;
const size_t nHistos = workspace->getNumberHistograms();
g_log.debug() << "Number of Histograms: " << nHistos << std::endl;
this->m_theta = std::vector<double>(nHistos);
this->m_thetaWidths = std::vector<double>(nHistos);
this->m_phi = std::vector<double>(nHistos);
this->m_phiWidths = std::vector<double>(nHistos);
for (size_t i = 0; i < nHistos; ++i)
{
m_progress->report("Calculating detector angular widths");
DetConstPtr detector = workspace->getDetector(i);
g_log.debug() << "Current histogram: " << i << std::endl;
specid_t inSpec = workspace->getSpectrum(i)->getSpectrumNo();
SpectraDistanceMap neighbours = workspace->getNeighboursExact(inSpec,
numNeighbours,
true);
g_log.debug() << "Current ID: " << inSpec << std::endl;
// Convert from spectrum numbers to workspace indices
double thetaWidth = -DBL_MAX;
double phiWidth = -DBL_MAX;
// Find theta and phi widths
double theta = workspace->detectorTwoTheta(detector);
double phi = detector->getPhi();
specid_t deltaPlus1 = inSpec + 1;
specid_t deltaMinus1 = inSpec - 1;
specid_t deltaPlusT = inSpec + this->m_detNeighbourOffset;
specid_t deltaMinusT = inSpec - this->m_detNeighbourOffset;
for (SpectraDistanceMap::iterator it = neighbours.begin();
it != neighbours.end(); ++it)
{
specid_t spec = it->first;
g_log.debug() << "Neighbor ID: " << spec << std::endl;
if (spec == deltaPlus1 || spec == deltaMinus1 ||
spec == deltaPlusT || spec == deltaMinusT)
{
DetConstPtr detector_n = workspace->getDetector(spec - 1);
double theta_n = workspace->detectorTwoTheta(detector_n);
double phi_n = detector_n->getPhi();
double dTheta = std::fabs(theta - theta_n);
double dPhi = std::fabs(phi - phi_n);
if (dTheta > thetaWidth)
{
thetaWidth = dTheta;
//g_log.debug() << "Current ThetaWidth: " << thetaWidth << std::endl;
}
if (dPhi > phiWidth)
{
phiWidth = dPhi;
//g_log.debug() << "Current PhiWidth: " << phiWidth << std::endl;
}
}
}
this->m_theta[i] = theta;
this->m_phi[i] = phi;
this->m_thetaWidths[i] = thetaWidth;
this->m_phiWidths[i] = phiWidth;
}
}