From db75b7024a4b79a5264a1e4a4423a01aa23f5ef9 Mon Sep 17 00:00:00 2001
From: Russell Taylor <taylorrj@ornl.gov>
Date: Wed, 7 Sep 2011 13:42:34 +0000
Subject: [PATCH] Fix build. Method definition removed by mistake? Re #3451.

---
 Code/Mantid/Framework/Algorithms/src/Q1D2.cpp | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Code/Mantid/Framework/Algorithms/src/Q1D2.cpp b/Code/Mantid/Framework/Algorithms/src/Q1D2.cpp
index 32429208577..d09f028ea09 100644
--- a/Code/Mantid/Framework/Algorithms/src/Q1D2.cpp
+++ b/Code/Mantid/Framework/Algorithms/src/Q1D2.cpp
@@ -510,6 +510,28 @@ void Q1D2::getQBinPlus1(const MantidVec & OutQs, const double QToFind, MantidVec
   loc = std::lower_bound(OutQs.begin(), OutQs.end(), QToFind);
 }
 
+/** Divides the number of counts in each output Q bin by the wrighting ("number that would expected to arrive")
+*  The errors are propogated using the uncorrolated error estimate for multiplication/division
+*  @param[in] normSum the weighting for each bin
+*  @param[in] normError2 square of the error on the normalization
+*  @param[in, out] counts counts in each bin
+*  @param[in, out] errors input the _square_ of the error on each bin, output the total error (unsquared)
+*/
+void Q1D2::normalize(const MantidVec & normSum, const MantidVec & normError2, MantidVec & counts, MantidVec & errors) const
+{
+  for (size_t k = 0; k < counts.size(); ++k)
+  {
+    // the normalisation is a = b/c where b = counts c =normalistion term
+    const double c = normSum[k];
+    const double a = counts[k] /= c;
+    // when a = b/c, the formula for Da, the error on a, in terms of Db, etc. is (Da/a)^2 = (Db/b)^2 + (Dc/c)^2
+    //(Da)^2 = ((Db/b)^2 + (Dc/c)^2)*(b^2/c^2) = ((Db/c)^2 + (b*Dc/c^2)^2) = (Db^2 + (b*Dc/c)^2)/c^2 = (Db^2 + (Dc*a)^2)/c^2
+    //this will work as long as c>0, but then the above formula above can't deal with 0 either
+    const double aOverc = a/c;
+    errors[k] = std::sqrt(errors[k]/(c*c) + normError2[k]*aOverc*aOverc);
+  }
+}
+
 } // namespace Algorithms
 } // namespace Mantid
 
-- 
GitLab