From 0d75600ad394845ce01a5a45a2927c72e44616bc Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Mon, 18 May 2015 17:33:00 +0200
Subject: [PATCH] Removed normalization of unused polarized intensity

---
 Core/Algorithms/inc/Detector.h          |  5 +----
 Core/Algorithms/inc/Instrument.h        |  3 +--
 Core/Algorithms/src/Detector.cpp        | 11 +----------
 Core/Algorithms/src/GISASSimulation.cpp |  7 ++++++-
 Core/Algorithms/src/Instrument.cpp      |  9 ++-------
 5 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/Core/Algorithms/inc/Detector.h b/Core/Algorithms/inc/Detector.h
index d4f6932cbd3..3251c5dd1fb 100644
--- a/Core/Algorithms/inc/Detector.h
+++ b/Core/Algorithms/inc/Detector.h
@@ -90,11 +90,8 @@ public:
     virtual std::string addParametersToExternalPool(std::string path, ParameterPool *external_pool,
                                                     int copy_number = -1) const;
 
-#ifndef GCCXML_SKIP_THIS
     //! Normalize intensity data with detector cell sizes.
-    void normalize(OutputData<double> *p_data, OutputData<Eigen::Matrix2d> *p_polarized_data,
-                   double sin_alpha_i) const;
-#endif
+    void normalize(OutputData<double> *p_data, double sin_alpha_i) const;
 
 protected:
     virtual void print(std::ostream &ostr) const;
diff --git a/Core/Algorithms/inc/Instrument.h b/Core/Algorithms/inc/Instrument.h
index 6f1bcd3c05a..830c91d93d6 100644
--- a/Core/Algorithms/inc/Instrument.h
+++ b/Core/Algorithms/inc/Instrument.h
@@ -107,8 +107,7 @@ public:
 
 #ifndef GCCXML_SKIP_THIS
     //! normalize a detector image
-    void normalize(OutputData<double> *p_intensity,
-                   OutputData<Eigen::Matrix2d> *p_polarized_intensity = 0) const;
+    void normalize(OutputData<double> *p_intensity) const;
 #endif
 
 protected:
diff --git a/Core/Algorithms/src/Detector.cpp b/Core/Algorithms/src/Detector.cpp
index b072b0a1f3e..08606d7212b 100644
--- a/Core/Algorithms/src/Detector.cpp
+++ b/Core/Algorithms/src/Detector.cpp
@@ -147,8 +147,7 @@ std::string Detector::addParametersToExternalPool(std::string path, ParameterPoo
     return new_path;
 }
 
-void Detector::normalize(OutputData<double> *p_data, OutputData<Eigen::Matrix2d> *p_polarized_data,
-                         double sin_alpha_i) const
+void Detector::normalize(OutputData<double> *p_data, double sin_alpha_i) const
 {
     // if shapes do not match, do nothing
     if (!dataShapeMatches(p_data))
@@ -168,17 +167,9 @@ void Detector::normalize(OutputData<double> *p_data, OutputData<Eigen::Matrix2d>
     // This normalization assumes that the intensity map contains
     // total differential scattering cross sections
     // (as opposed to the usual cross section per scattering particle)
-    OutputData<Eigen::Matrix2d>::iterator it_pol;
-    if (p_polarized_data) {
-        it_pol = p_polarized_data->begin();
-    }
     for (OutputData<double>::iterator it = p_data->begin(); it != p_data->end(); ++it) {
         double factor = getSolidAngle(p_data, it.getIndex()) / sin_alpha_i;
         (*it) *= factor;
-        if (p_polarized_data) {
-            (*it_pol) *= factor;
-            ++it_pol;
-        }
     }
 }
 
diff --git a/Core/Algorithms/src/GISASSimulation.cpp b/Core/Algorithms/src/GISASSimulation.cpp
index 64046cfcd90..4dfd32be74d 100644
--- a/Core/Algorithms/src/GISASSimulation.cpp
+++ b/Core/Algorithms/src/GISASSimulation.cpp
@@ -91,9 +91,14 @@ GISASSimulation *GISASSimulation::clone() const
 void GISASSimulation::prepareSimulation()
 {
     if(!m_instrument.getDetectorDimension()) {
-        throw LogicErrorException("Simulation::prepareSimulation() "
+        throw LogicErrorException("GISASSimulation::prepareSimulation() "
                 "-> Error. The detector was not configured.");
     }
+    if (getWavelength() <= 0.0) {
+        throw ClassInitializationException(
+                "GISASSimulation::prepareSimulation() "
+                "-> Error. Incoming wavelength <= 0.");
+    }
     Simulation::prepareSimulation();
 }
 
diff --git a/Core/Algorithms/src/Instrument.cpp b/Core/Algorithms/src/Instrument.cpp
index 87a66206184..1fc53fb3b02 100644
--- a/Core/Algorithms/src/Instrument.cpp
+++ b/Core/Algorithms/src/Instrument.cpp
@@ -114,16 +114,11 @@ std::string Instrument::addParametersToExternalPool(
     return new_path;
 }
 
-void Instrument::normalize(OutputData<double> *p_intensity,
-        OutputData<Eigen::Matrix2d> *p_polarized_intensity) const
+void Instrument::normalize(OutputData<double> *p_intensity) const
 {
     // normalize by intensity, if strictly positive
     if (getIntensity()>0.0) {
         p_intensity->scaleAll(getIntensity());
-        if (p_polarized_intensity) {
-            p_polarized_intensity->scaleAll(
-                    Eigen::Matrix2d::Identity() * getIntensity());
-        }
     }
     kvector_t realpart(getBeam().getCentralK().x().real(),
                    getBeam().getCentralK().y().real(),
@@ -131,7 +126,7 @@ void Instrument::normalize(OutputData<double> *p_intensity,
 
     // normalize by detector cell sizes
     double sin_alpha_i = std::abs(realpart.cosTheta());
-    m_detector.normalize(p_intensity, p_polarized_intensity, sin_alpha_i);
+    m_detector.normalize(p_intensity, sin_alpha_i);
 }
 
 void Instrument::setDetectorResolutionFunction(
-- 
GitLab