Example #1
0
/*
 * Add parameter logs and convert to MD for a single run
 *
 * @param input_workspace :: datasource workspace
 * @param emode :: analysis mode "Elastic", "Direct" or "Indirect"
 * @param efix :: datasource energy values in meV
 * @param psi :: goniometer rotation in degrees
 * @param gl :: goniometer rotation in degrees
 * @param gs :: goniometer rotation in degrees
 * @param in_place :: do merge step at the same time as converting to
 *MDWorkspace
 * @param alatt :: length of crystal lattice parameter in angstroms
 * @param angdeg :: lattice angle
 * @param u :: lattice vector parallel to incident neutron beam
 * @param v :: lattice vector perpendicular to u in the horizontal plane
 * @param out_mdws :output workspace to use if merge step is carried out
 */
Mantid::API::IMDEventWorkspace_sptr CreateMD::single_run(
    Mantid::API::MatrixWorkspace_sptr input_workspace, const std::string &emode,
    double efix, double psi, double gl, double gs, bool in_place,
    const std::vector<double> &alatt, const std::vector<double> &angdeg,
    const std::vector<double> &u, const std::vector<double> &v,
    const std::string &filebackend_filename, const bool filebackend,
    Mantid::API::IMDEventWorkspace_sptr out_mdws) {

  std::vector<std::vector<double>> ub_params{alatt, angdeg, u, v};

  if (any_given(ub_params) && !all_given(ub_params)) {
    throw std::invalid_argument(
        "Either specify all of alatt, angledeg, u, v or none of them");
  } else {
    if (input_workspace->sample().hasOrientedLattice()) {
      g_log.warning() << "Sample already has a UB. This will not be "
                         "overwritten. Use ClearUB and re-run.\n";
    } else {
      setUB(input_workspace, alatt[0], alatt[1], alatt[2], angdeg[0], angdeg[1],
            angdeg[2], u, v);
    }

    if (efix > 0.0) {
      addSampleLog(input_workspace, "Ei", efix);
    }

    addSampleLog(input_workspace, "gl", gl);
    addSampleLog(input_workspace, "gs", gs);
    addSampleLog(input_workspace, "psi", psi);
    setGoniometer(input_workspace);

    return convertToMD(input_workspace, emode, in_place, filebackend_filename,
                       filebackend, out_mdws);
  }
}