From 098c601c558bfaf30eb0f268cf58fd1236ab86a1 Mon Sep 17 00:00:00 2001
From: Peter Peterson <petersonpf@ornl.gov>
Date: Thu, 3 Oct 2013 11:53:18 -0400
Subject: [PATCH] Re #8074. Making CalFile optional.

Checks for whether it is empty and not grabbing workspaces. Filled in
the check for grouping workspace before diffraction focussing. Also
did a bit better checking on CropWorkspaces.
---
 .../src/AlignAndFocusPowder.cpp               | 26 +++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
index b264cb5e2d2..5219c0f2938 100644
--- a/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
+++ b/Code/Mantid/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp
@@ -328,13 +328,19 @@ namespace WorkflowAlgorithms
       }
 
       if (doCorrection) {
+        double tempmin;
+        double tempmax;
+        m_outputW->getXMinMax(tempmin, tempmax);
+
         g_log.information() << "running CropWorkspace(Xmin=" << xmin
                             << ", Xmax=" << xmax << ")\n" ;
         API::IAlgorithm_sptr cropAlg = createChildAlgorithm("CropWorkspace");
         cropAlg->setProperty("InputWorkspace", m_outputW);
         cropAlg->setProperty("OutputWorkspace", m_outputW);
-        if (xmin > 0.)cropAlg->setProperty("Xmin", xmin);
-        if (xmax > 0.)cropAlg->setProperty("Xmax", xmax);
+        if ((xmin > 0.) && (xmin > tempmin))
+          cropAlg->setProperty("Xmin", xmin);
+        if ((xmax > 0.) && (xmax < tempmax))
+          cropAlg->setProperty("Xmax", xmax);
         cropAlg->executeAsChildAlg();
         m_outputW = cropAlg->getProperty("OutputWorkspace");
       }
@@ -620,6 +626,12 @@ namespace WorkflowAlgorithms
     */
   API::MatrixWorkspace_sptr AlignAndFocusPowder::diffractionFocus(API::MatrixWorkspace_sptr ws)
   {
+    if (!m_groupWS)
+    {
+      g_log.information() << "not focussing data\n";
+      return ws;
+    }
+
     g_log.information() << "running DiffractionFocussing. \n";
 
     API::IAlgorithm_sptr focusAlg = createChildAlgorithm("DiffractionFocussing");
@@ -773,7 +785,7 @@ namespace WorkflowAlgorithms
   {
 
     // check if the workspaces exist with their canonical names so they are not reloaded for chunks
-    if (!m_groupWS)
+    if ((!m_groupWS) && (!calFileName.empty()))
     {
       try
       {
@@ -783,7 +795,7 @@ namespace WorkflowAlgorithms
         ; // not noteworthy
       }
     }
-    if (!m_offsetsWS)
+    if ((!m_offsetsWS) && (!calFileName.empty()))
     {
       try
       {
@@ -794,7 +806,7 @@ namespace WorkflowAlgorithms
         ; // not noteworthy
       }
     }
-    if (!m_maskWS)
+    if ((!m_maskWS) && (!calFileName.empty()))
     {
       try
       {
@@ -810,6 +822,10 @@ namespace WorkflowAlgorithms
     if (m_groupWS && m_offsetsWS && m_maskWS)
       return;
 
+    // see if the calfile is specified
+    if (calFileName.empty())
+      return;
+
     g_log.information() << "Loading Calibration file \"" << calFileName << "\"\n";
 
     // bunch of booleans to keep track of things
-- 
GitLab