From 60b6b9219c74f553a0180679af65c1260e517861 Mon Sep 17 00:00:00 2001
From: Pete Peterson <petersonpf@ornl.gov>
Date: Thu, 12 Jul 2018 12:26:19 -0400
Subject: [PATCH] Fix bug in not specifying time-of-flight range

Allow everything to use the workspace ranges as everything else would
do
---
 .../src/AlignAndFocusPowder.cpp               | 33 +++++++++++++------
 docs/source/release/v3.13.0/diffraction.rst   |  1 +
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
index efa41473f50..457f9f169d6 100644
--- a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
+++ b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
@@ -256,26 +256,35 @@ void AlignAndFocusPowder::exec() {
       dspace = false;
   }
   if (dspace) {
-    if (m_params.size() == 1 && dmax > 0) {
-      double step = m_params[0];
-      m_params.clear();
-      if (step > 0 || dmin > 0) {
+    if (m_params.size() == 1 && (!isEmpty(dmin)) && (!isEmpty(dmax))) {
+      if (dmin > 0. && dmax > dmin) {
+        double step = m_params[0];
+        m_params.clear();
         m_params.push_back(dmin);
         m_params.push_back(step);
         m_params.push_back(dmax);
-        g_log.information() << "d-Spacing Binning: " << m_params[0] << "  "
-                            << m_params[1] << "  " << m_params[2] << "\n";
+        g_log.information() << "d-Spacing binning updated: " << m_params[0]
+                            << "  " << m_params[1] << "  " << m_params[2]
+                            << "\n";
+      } else {
+        g_log.warning() << "something is wrong with dmin (" << dmin
+                        << ") and dmax (" << dmax
+                        << "). They are being ignored.\n";
       }
     }
   } else {
-    if (m_params.size() == 1 && tmax > 0) {
-      double step = m_params[0];
-      if (step > 0 || tmin > 0) {
+    if (m_params.size() == 1 && (!isEmpty(tmin)) && (!isEmpty(tmax))) {
+      if (tmin > 0. && tmax > tmin) {
+        double step = m_params[0];
         m_params[0] = tmin;
         m_params.push_back(step);
         m_params.push_back(tmax);
-        g_log.information() << "TOF Binning: " << m_params[0] << "  "
+        g_log.information() << "TOF binning updated: " << m_params[0] << "  "
                             << m_params[1] << "  " << m_params[2] << "\n";
+      } else {
+        g_log.warning() << "something is wrong with tmin (" << tmin
+                        << ") and tmax (" << tmax
+                        << "). They are being ignored.\n";
       }
     }
   }
@@ -776,6 +785,10 @@ AlignAndFocusPowder::rebin(API::MatrixWorkspace_sptr matrixws) {
       g_log.information() << param << " ";
     g_log.information() << ") started at "
                         << Types::Core::DateAndTime::getCurrentTime() << "\n";
+    for (double param : m_params)
+      if (isEmpty(param))
+        g_log.warning("encountered empty binning parameter");
+
     API::IAlgorithm_sptr rebin3Alg = createChildAlgorithm("Rebin");
     rebin3Alg->setProperty("InputWorkspace", matrixws);
     rebin3Alg->setProperty("OutputWorkspace", matrixws);
diff --git a/docs/source/release/v3.13.0/diffraction.rst b/docs/source/release/v3.13.0/diffraction.rst
index 2aa2024a226..6000b59cc3a 100644
--- a/docs/source/release/v3.13.0/diffraction.rst
+++ b/docs/source/release/v3.13.0/diffraction.rst
@@ -40,6 +40,7 @@ Improvements
   - The ``.maud`` calibration file format, for conversion to d-spacing (uses a new algorithm
     :ref:`SaveGEMMAUDParamFile <algm-SaveGEMMAUDParamFile>`
 - :ref:`PDCalibration <algm-PDCalibration>` has major upgrades including making use of :ref:`FitPeaks <algm-FitPeaks>` for the individual peak fitting
+- :ref:`AlignAndFocusPowder <algm-AlignAndFocusPowder>` had a bug when binning in time-of-flight without using a property manager to specify the time-of-flight range. In other words: characterization files are no longer necessary.
 
 Engineering Diffraction
 -----------------------
-- 
GitLab