Example #1
0
/// 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;
}