From 4769b32a10089a7b9eb160115331a80b86b9442f Mon Sep 17 00:00:00 2001
From: "McDonnell, Marshall T" <mcdonnellmt@ornl.gov>
Date: Tue, 8 May 2018 14:44:46 -0400
Subject: [PATCH] Response to reviewer comments

---
 .../CalculateCarpenterSampleCorrection.h      | 13 +++-----
 .../CarpenterSampleCorrection.h               | 12 +++----
 .../src/CarpenterSampleCorrection.cpp         | 32 +++++++------------
 .../CalculateCarpenterSampleCorrection-v1.rst |  4 +--
 .../CarpenterSampleCorrection-v1.rst          |  4 +--
 .../algorithms/MayersSampleCorrection-v1.rst  |  2 --
 6 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h
index cfffe09facf..b9d812c4465 100644
--- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h
+++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCarpenterSampleCorrection.h
@@ -3,7 +3,7 @@
 
 #include "MantidAPI/AlgorithmManager.h"
 #include "MantidAPI/AnalysisDataService.h"
-#include "MantidAPI/DistributedAlgorithm.h"
+#include "MantidAPI/DataProcessorAlgorithm.h"
 #include "MantidAPI/WorkspaceGroup.h"
 #include "MantidAPI/WorkspaceUnitValidator.h"
 #include "MantidHistogramData/Points.h"
@@ -20,12 +20,9 @@ namespace Algorithms {
     correct vanadium spectrum at IPNS.  Algorithm originally worked
     out by Jack Carpenter and Asfia Huq and implmented in Java by
     Alok Chatterjee.  Translated to C++ by Dennis Mikkelson.
-
-    @author Dennis Mikkelson
-    @date 17/08/2010
-
-    Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory &
-    NScD Oak Ridge National Laboratory
+    
+    Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
+    National Laboratory & European Spallation Source
 
     This file is part of Mantid.
 
@@ -47,7 +44,7 @@ namespace Algorithms {
     Code Documentation is available at: <http://doxygen.mantidproject.org>
  */
 class DLLExport CalculateCarpenterSampleCorrection
-    : public API::DistributedAlgorithm {
+    : public API::DistributedDataProcessorAlgorithm {
 public:
   /// Algorithm's name for identification overriding a virtual method
   const std::string name() const override;
diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h
index 64504e0fc1f..0969365dd33 100644
--- a/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h
+++ b/Framework/Algorithms/inc/MantidAlgorithms/CarpenterSampleCorrection.h
@@ -1,9 +1,8 @@
 #ifndef MANTID_ALGORITHM_MULTIPLE_SCATTERING_ABSORPTION_H_
 #define MANTID_ALGORITHM_MULTIPLE_SCATTERING_ABSORPTION_H_
-
 #include "MantidAPI/AlgorithmManager.h"
 #include "MantidAPI/AnalysisDataService.h"
-#include "MantidAPI/DistributedAlgorithm.h"
+#include "MantidAPI/DataProcessorAlgorithm.h"
 #include "MantidAPI/WorkspaceGroup.h"
 #include <vector>
 
@@ -21,11 +20,8 @@ namespace Algorithms {
     out by Jack Carpenter and Asfia Huq and implmented in Java by
     Alok Chatterjee.  Translated to C++ by Dennis Mikkelson.
 
-    @author Dennis Mikkelson
-    @date 17/08/2010
-
-    Copyright &copy; 2010 ISIS Rutherford Appleton Laboratory &
-    NScD Oak Ridge National Laboratory
+    Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
+    National Laboratory & European Spallation Source
 
     This file is part of Mantid.
 
@@ -46,7 +42,7 @@ namespace Algorithms {
                   <https://github.com/mantidproject/mantid>
     Code Documentation is available at: <http://doxygen.mantidproject.org>
  */
-class DLLExport CarpenterSampleCorrection : public API::DistributedAlgorithm {
+class DLLExport CarpenterSampleCorrection : public API::DistributedDataProcessorAlgorithm {
 public:
   /// Algorithm's name for identification overriding a virtual method
   const std::string name() const override;
diff --git a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp
index f77e431db7f..cc7c3297dff 100644
--- a/Framework/Algorithms/src/CarpenterSampleCorrection.cpp
+++ b/Framework/Algorithms/src/CarpenterSampleCorrection.cpp
@@ -33,9 +33,6 @@ using std::vector;
 using namespace Mantid::PhysicalConstants;
 using namespace Geometry;
 
-// Constants required internally only, so make them static. These are
-// Chebyshev expansion coefficients copied directly from Carpenter 1969 Table 1
-// clang-format off
 const std::string CarpenterSampleCorrection::name() const {
   return "CarpenterSampleCorrection";
 }
@@ -55,6 +52,9 @@ void CarpenterSampleCorrection::init() {
   wsValidator->add<WorkspaceUnitValidator>("Wavelength");
   wsValidator->add<InstrumentValidator>();
 
+  auto algCalcCarpenter = AlgorithmManager::Instance().createUnmanaged("CalculateCarpenterSampleCorrection");
+  algCalcCarpenter->initialize();
+
   declareProperty(make_unique<WorkspaceProperty<API::MatrixWorkspace> >(
                       "InputWorkspace", "", Direction::Input, wsValidator),
                   "The name of the input workspace.");
@@ -62,15 +62,10 @@ void CarpenterSampleCorrection::init() {
                       "OutputWorkspace", "", Direction::Output),
                   "The name of the output workspace.");
 
-  declareProperty("AttenuationXSection", 2.8, "Coefficient 1, absorption cross "
-                                              "section / 1.81 if not set with "
-                                              "SetSampleMaterial");
-  declareProperty("ScatteringXSection", 5.1, "Coefficient 3, total scattering "
-                                             "cross section if not set with "
-                                             "SetSampleMaterial");
-  declareProperty("SampleNumberDensity", 0.0721,
-                  "Coefficient 2, density if not set with SetSampleMaterial");
-  declareProperty("CylinderSampleRadius", 0.3175, "Sample radius, in cm");
+  copyProperty(algCalcCarpenter, "AttenuationXSection");
+  copyProperty(algCalcCarpenter, "ScatteringXSection");
+  copyProperty(algCalcCarpenter, "SampleNumberDensity");
+  copyProperty(algCalcCarpenter, "CylinderSampleRadius");
 }
 
 /**
@@ -120,8 +115,8 @@ WorkspaceGroup_sptr CarpenterSampleCorrection::calculateCorrection(
     MatrixWorkspace_sptr &inputWksp, double radius, double coeff1,
     double coeff2, double coeff3, bool doAbs, bool doMS) {
   auto calculate =
-      this->createChildAlgorithm("CalculateCarpenterSampleCorrection");
-  calculate->initialize();
+      this->createChildAlgorithm("CalculateCarpenterSampleCorrection",
+                                  0.0, 0.25);
   calculate->setProperty("InputWorkspace", inputWksp);
   calculate->setProperty("CylinderSampleRadius", radius);
   calculate->setProperty("AttenuationXSection", coeff1);
@@ -138,8 +133,7 @@ WorkspaceGroup_sptr CarpenterSampleCorrection::calculateCorrection(
 MatrixWorkspace_sptr
 CarpenterSampleCorrection::divide(const MatrixWorkspace_sptr lhsWS,
                                   const MatrixWorkspace_sptr rhsWS) {
-  IAlgorithm_sptr divide = this->createChildAlgorithm("Divide");
-  divide->initialize();
+  IAlgorithm_sptr divide = this->createChildAlgorithm("Divide", 0.25, 0.5);
   divide->setProperty("LHSWorkspace", lhsWS);
   divide->setProperty("RHSWorkspace", rhsWS);
   divide->execute();
@@ -150,8 +144,7 @@ CarpenterSampleCorrection::divide(const MatrixWorkspace_sptr lhsWS,
 MatrixWorkspace_sptr
 CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr lhsWS,
                                     const MatrixWorkspace_sptr rhsWS) {
-  auto multiply = this->createChildAlgorithm("Multiply");
-  multiply->initialize();
+  auto multiply = this->createChildAlgorithm("Multiply", 0.5, 0.75);
   multiply->setProperty("LHSWorkspace", lhsWS);
   multiply->setProperty("RHSWorkspace", rhsWS);
   multiply->execute();
@@ -162,8 +155,7 @@ CarpenterSampleCorrection::multiply(const MatrixWorkspace_sptr lhsWS,
 MatrixWorkspace_sptr
 CarpenterSampleCorrection::minus(const MatrixWorkspace_sptr lhsWS,
                                  const MatrixWorkspace_sptr rhsWS) {
-  auto minus = this->createChildAlgorithm("Minus");
-  minus->initialize();
+  auto minus = this->createChildAlgorithm("Minus", 0.75, 1.0);
   minus->setProperty("LHSWorkspace", lhsWS);
   minus->setProperty("RHSWorkspace", rhsWS);
   minus->execute();
diff --git a/docs/source/algorithms/CalculateCarpenterSampleCorrection-v1.rst b/docs/source/algorithms/CalculateCarpenterSampleCorrection-v1.rst
index 5a69ef609cb..61ad1d82c9b 100644
--- a/docs/source/algorithms/CalculateCarpenterSampleCorrection-v1.rst
+++ b/docs/source/algorithms/CalculateCarpenterSampleCorrection-v1.rst
@@ -36,6 +36,8 @@ expansion coefficients:
 where the Chebyshev coefficients :math:`c_{s}(m,n)` up to  m + n 
 :math:`\leqslant` 5 have been tabulated and are stored as an array by the algorithm.
 
+This version of the correction follows the implemenation in [1] in that it only calculates for the correction in-plane, unlike [2] that generalizes the correction to out-of-plane.
+
 This algorithm calculates and outputs the absorption and/or multiple scattering correction workspaces to be applied to the InputWorkspace. Thus, there are, at most, two workspaces in the OutputWorkspaceBaseName group workspace. This allows for flexibility of applying either correction to a workspace without having to apply both (as is the case with :ref:`algm-CarpenterSampleCorrection`). For the case where both corrections are calculated, the output will be the following:
 
 1. The absorption correction workspace will be OutputWorkspaceBaseName + `_abs` and will be in `.getItem(0)`.
@@ -167,8 +169,6 @@ References
 
 .. [3] D.F.R. Mildner and J.M.Carpenter *Improvements to the Chebyshev Expansion of Attenuation Correction Factors for Cylindrical Samples.* J Appl Crystallogr **23.5** (1990): 378–386 doi: `10.1107/S0021889890005258 <http://dx.doi.org/10.1107/S0021889890005258>`_
 
-.. seealso :: Algorithm :ref:`algm-MayersSampleCorrection`
-
 .. categories::
 
 .. sourcelink::
diff --git a/docs/source/algorithms/CarpenterSampleCorrection-v1.rst b/docs/source/algorithms/CarpenterSampleCorrection-v1.rst
index b3e88a225c5..6ad17d7d325 100644
--- a/docs/source/algorithms/CarpenterSampleCorrection-v1.rst
+++ b/docs/source/algorithms/CarpenterSampleCorrection-v1.rst
@@ -36,6 +36,8 @@ expansion coefficients:
 where the Chebyshev coefficients :math:`c_{s}(m,n)` up to  m + n 
 :math:`\leqslant` 5 have been tabulated and are stored as an array by the algorithm.
 
+This version of the correction follows the implemenation in [1] in that it only calculates for the correction in-plane, unlike [2] that generalizes the correction to out-of-plane.
+
 This algorithm calls :ref:`algm-CalculateCarpenterSampleCorrection` to calculate both absorption and multiple scattering corrections and then applies both to the sample workspace.
 
 Usage
@@ -72,8 +74,6 @@ References
 
 .. [3] D.F.R. Mildner and J.M.Carpenter *Improvements to the Chebyshev Expansion of Attenuation Correction Factors for Cylindrical Samples.* J Appl Crystallogr **23.5** (1990): 378–386 doi: `10.1107/S0021889890005258 <http://dx.doi.org/10.1107/S0021889890005258>`_
 
-.. seealso :: Algorithm :ref:`algm-MayersSampleCorrection`
-
 .. categories::
 
 .. sourcelink::
diff --git a/docs/source/algorithms/MayersSampleCorrection-v1.rst b/docs/source/algorithms/MayersSampleCorrection-v1.rst
index 8afc8aab57a..20266639829 100644
--- a/docs/source/algorithms/MayersSampleCorrection-v1.rst
+++ b/docs/source/algorithms/MayersSampleCorrection-v1.rst
@@ -97,8 +97,6 @@ References
 .. [1] Lindley, E.J., & Mayers, J. Cywinski, R. (Ed.). (1988). Experimental method and corrections to data. United Kingdom: Adam Hilger. - https://inis.iaea.org/search/search.aspx?orig_q=RN:20000574
 
 
-.. seealso :: Algorithm :ref:`algm-CarpenterSampleCorrection`
-
 .. categories::
 
 .. sourcelink::
-- 
GitLab