Beispiel #1
0
/**
 * Checks if the spectra at the given index of either input workspace is masked.
 * If so then the output spectra has zeroed data
 * and is also masked.
 * @param lhsSpectrumInfo :: The LHS spectrum info object
 * @param rhsSpectrumInfo :: The RHS spectrum info object
 * @param index :: The workspace index to check
 * @param out :: A pointer to the output workspace
 * @param outSpectrumInfo :: The spectrum info object of `out`
 * @returns True if further processing is not required on the spectra, false if
 * the binary operation should be performed.
 */
bool BinaryOperation::propagateSpectraMask(const SpectrumInfo &lhsSpectrumInfo,
                                           const SpectrumInfo &rhsSpectrumInfo,
                                           const int64_t index,
                                           MatrixWorkspace &out,
                                           SpectrumInfo &outSpectrumInfo) {
  bool continueOp(true);

  if ((lhsSpectrumInfo.hasDetectors(index) &&
       lhsSpectrumInfo.isMasked(index)) ||
      (rhsSpectrumInfo.hasDetectors(index) &&
       rhsSpectrumInfo.isMasked(index))) {
    continueOp = false;
    out.getSpectrum(index).clearData();
    PARALLEL_CRITICAL(setMasked) { outSpectrumInfo.setMasked(index, true); }
  }
// calculate time from sample to detector
void ModeratorTzeroLinear::calculateTfLi(const SpectrumInfo &spectrumInfo,
                                         size_t i, double &t_f, double &L_i) {
  static const double convFact = 1.0e-6 * sqrt(2 * PhysicalConstants::meV /
                                               PhysicalConstants::NeutronMass);
  static const double TfError = -1.0; // signal error when calculating final
                                      // time

  if (!spectrumInfo.hasDetectors(i)) {
    t_f = TfError;
    return;
  }

  if (spectrumInfo.isMonitor(i)) {
    L_i = spectrumInfo.sourcePosition().distance(spectrumInfo.position(i));
    t_f = 0.0; // t_f=0.0 since there is no sample to detector path
  } else {
    L_i = spectrumInfo.l1();
    // Get final energy E_f, final velocity v_f
    auto wsProp = spectrumInfo.detector(i).getNumberParameter("Efixed");
    if (!wsProp.empty()) {
      double E_f = wsProp.at(0);         //[E_f]=meV
      double v_f = convFact * sqrt(E_f); //[v_f]=meter/microsec
      t_f = spectrumInfo.l2(i) / v_f;
    } else {
      g_log.debug() << "Efixed not found for detector " << i << '\n';
      t_f = TfError;
    }
  }
}