本文整理汇总了C++中mantid::api::MatrixWorkspace_sptr::getDetector方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixWorkspace_sptr::getDetector方法的具体用法?C++ MatrixWorkspace_sptr::getDetector怎么用?C++ MatrixWorkspace_sptr::getDetector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid::api::MatrixWorkspace_sptr
的用法示例。
在下文中一共展示了MatrixWorkspace_sptr::getDetector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InstrumentDefinitionError
/// calculate distance from source to sample or detector
double ModeratorTzero::CalculateL1(Mantid::API::MatrixWorkspace_sptr inputWS, size_t i){
double L1(0);
// Get detector position
IDetector_const_sptr det;
try
{
det = inputWS->getDetector(i);
}
catch (Exception::NotFoundError&)
{
return 0;
}
if( det->isMonitor() )
{
L1=m_instrument->getSource()->getDistance(*det);
}
else
{
IComponent_const_sptr sample = m_instrument->getSample();
try
{
L1 = m_instrument->getSource()->getDistance(*sample);
}
catch (Exception::NotFoundError &)
{
g_log.error("Unable to calculate source-sample distance");
throw Exception::InstrumentDefinitionError("Unable to calculate source-sample distance", inputWS->getTitle());
}
}
return L1;
}
示例2: exec
/** Executes the algorithm
*
*/
void SumNeighbours::exec()
{
// Try and retrieve the optional properties
SumX = getProperty("SumX");
SumY = getProperty("SumY");
// Get the input workspace
Mantid::API::MatrixWorkspace_sptr inWS = getProperty("InputWorkspace");
Mantid::Geometry::IDetector_const_sptr det = inWS->getDetector(0);
// Check if grandparent is rectangular detector
boost::shared_ptr<const Geometry::IComponent> parent = det->getParent()->getParent();
boost::shared_ptr<const RectangularDetector> rect = boost::dynamic_pointer_cast<const RectangularDetector>(parent);
Mantid::API::MatrixWorkspace_sptr outWS;
IAlgorithm_sptr smooth = createChildAlgorithm("SmoothNeighbours");
smooth->setProperty("InputWorkspace", inWS);
if (rect)
{
smooth->setProperty("SumPixelsX",SumX);
smooth->setProperty("SumPixelsY",SumY);
}
else
{
smooth->setProperty<std::string>("RadiusUnits","NumberOfPixels");
smooth->setProperty("Radius",static_cast<double>(SumX*SumY*SumX*SumY));
smooth->setProperty("NumberOfNeighbours",SumX*SumY*SumX*SumY*4);
smooth->setProperty("SumNumberOfNeighbours",SumX*SumY);
}
smooth->executeAsChildAlg();
// Get back the result
outWS = smooth->getProperty("OutputWorkspace");
//Cast to the matrixOutputWS and save it
this->setProperty("OutputWorkspace", outWS);
}