From c22fc64dd94e83a4d65ad89aca436c82e1a52e2c Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (laptop)" <j.wuttke@fz-juelich.de>
Date: Sun, 31 Mar 2013 11:35:05 +0200
Subject: [PATCH] Layout; confused about Transform3D.h

---
 Core/Algorithms/inc/LayerDWBASimulation.h     |  34 +-
 Core/Algorithms/src/Detector.cpp              |   8 +-
 Core/FormFactors/src/FormFactorDWBAConstZ.cpp |  16 +-
 Core/Geometry/inc/Transform3D.h               | 310 ------------------
 Core/Samples/inc/IDispersalState.h            |   2 +-
 Core/Samples/inc/IInterferenceFunction.h      |   2 +-
 .../inc/InterferenceFunction1DParaCrystal.h   |  33 +-
 Core/Samples/inc/InterferenceFunctionNone.h   |   6 +-
 .../src/InterferenceFunction1DParaCrystal.cpp |  36 +-
 .../DoubleToComplexInterpolatingFunction.h    |  28 +-
 Core/Tools/inc/IDoubleToComplexFunction.h     |  30 +-
 Core/Tools/inc/MathFunctions.h                |  46 ++-
 Core/Tools/inc/OutputData.h                   | 162 +++++----
 13 files changed, 227 insertions(+), 486 deletions(-)
 delete mode 100644 Core/Geometry/inc/Transform3D.h

diff --git a/Core/Algorithms/inc/LayerDWBASimulation.h b/Core/Algorithms/inc/LayerDWBASimulation.h
index dffa2479db1..7f5f1b9a3d6 100644
--- a/Core/Algorithms/inc/LayerDWBASimulation.h
+++ b/Core/Algorithms/inc/LayerDWBASimulation.h
@@ -24,27 +24,27 @@
 class LayerDWBASimulation : public DWBASimulation
 {
  public:
-   LayerDWBASimulation();
-   virtual ~LayerDWBASimulation();
+    LayerDWBASimulation();
+    virtual ~LayerDWBASimulation();
 
-   LayerDWBASimulation *clone() const
-   {
-       throw NotImplementedException(
-           "ISimulation::clone() -> Error: not implemented exception.");
-   }
+    LayerDWBASimulation *clone() const
+    {
+        throw NotImplementedException(
+            "ISimulation::clone() -> Error: not implemented exception.");
+    }
 
-   void setKzFunction(const IDoubleToComplexMap& kz_function);
-   void setReflectionTransmissionFunction(
-       const IDoubleToPairOfComplexMap& rt_map);
-   void setKzAndRTFunctions(const IDoubleToComplexMap& kz_function,
-                            const IDoubleToPairOfComplexMap& rt_map);
+    void setKzFunction(const IDoubleToComplexMap& kz_function);
+    void setReflectionTransmissionFunction(
+        const IDoubleToPairOfComplexMap& rt_map);
+    void setKzAndRTFunctions(const IDoubleToComplexMap& kz_function,
+                             const IDoubleToPairOfComplexMap& rt_map);
 
  protected:
-   Bin1DCVector getKfBin(double wavelength,
-                         const Bin1D& alpha_bin,
-                         const Bin1D& phi_bin) const;
-   IDoubleToComplexMap *mp_kz_function;
-   IDoubleToPairOfComplexMap *mp_RT_function;
+    Bin1DCVector getKfBin(double wavelength,
+                          const Bin1D& alpha_bin,
+                          const Bin1D& phi_bin) const;
+    IDoubleToComplexMap *mp_kz_function;
+    IDoubleToPairOfComplexMap *mp_RT_function;
 };
 
 #endif /* LAYERDWBASIMULATION_H_ */
diff --git a/Core/Algorithms/src/Detector.cpp b/Core/Algorithms/src/Detector.cpp
index 62aa1a2e7bc..35638454d3e 100644
--- a/Core/Algorithms/src/Detector.cpp
+++ b/Core/Algorithms/src/Detector.cpp
@@ -80,10 +80,10 @@ void Detector::addAxis(const AxisParameters& axis_params)
 
 const IAxis& Detector::getAxis(size_t index) const
 {
-	if (isCorrectAxisIndex(index)) {
-		return *m_axes[index];
-	}
-	throw OutOfBoundsException("Not so many axes in this detector.");
+    if (isCorrectAxisIndex(index)) {
+        return *m_axes[index];
+    }
+    throw OutOfBoundsException("Not so many axes in this detector.");
 }
 
 void Detector::applyDetectorResolution(
diff --git a/Core/FormFactors/src/FormFactorDWBAConstZ.cpp b/Core/FormFactors/src/FormFactorDWBAConstZ.cpp
index cb9ca0d2be5..96d4d76e58c 100644
--- a/Core/FormFactors/src/FormFactorDWBAConstZ.cpp
+++ b/Core/FormFactors/src/FormFactorDWBAConstZ.cpp
@@ -27,15 +27,15 @@ complex_t FormFactorDWBAConstZ::evaluate(
     const cvector_t& k_i, const Bin1DCVector& k_f_bin,
     double alpha_i, double alpha_f) const
 {
-	calculateTerms(k_i, k_f_bin, alpha_i, alpha_f);
-	complex_t k_iz = k_i.z();
-	complex_t k_fz = k_f_bin.getMidPoint().z();
-	m_term_S *= getDepthPhase(k_iz-k_fz);
-	m_term_RS *= getDepthPhase(-k_iz-k_fz);
-	m_term_SR *= getDepthPhase(k_iz+k_fz);
-	m_term_RSR *= getDepthPhase(-k_iz+k_fz);
+    calculateTerms(k_i, k_f_bin, alpha_i, alpha_f);
+    complex_t k_iz = k_i.z();
+    complex_t k_fz = k_f_bin.getMidPoint().z();
+    m_term_S *= getDepthPhase(k_iz-k_fz);
+    m_term_RS *= getDepthPhase(-k_iz-k_fz);
+    m_term_SR *= getDepthPhase(k_iz+k_fz);
+    m_term_RSR *= getDepthPhase(-k_iz+k_fz);
 
-	return m_term_S + m_term_RS + m_term_SR + m_term_RSR;
+    return m_term_S + m_term_RS + m_term_SR + m_term_RSR;
 }
 
 FormFactorDWBAConstZ* FormFactorDWBAConstZ::clone() const
diff --git a/Core/Geometry/inc/Transform3D.h b/Core/Geometry/inc/Transform3D.h
deleted file mode 100644
index 94ea7b96e0a..00000000000
--- a/Core/Geometry/inc/Transform3D.h
+++ /dev/null
@@ -1,310 +0,0 @@
-// ************************************************************************** //
-//
-//  heinzlibs:  Library collection of the Scientific Computing Group at
-//              Heinz Maier-Leibnitz Zentrum (MLZ) Garching
-//
-//  libgeo3d:   Library for three-dimensional Euclidian geometry,
-//              based on CLHEP/Geometry 1.9 of 1.4.2003,
-//              forked after v 1.5 2010/06/16 16:21:27,
-//
-//! @file       Geometry/inc/Transform3D.h
-//! @brief      Defines class Transform3D.
-//!
-//! @homepage   http://apps.jcns.fz-juelich.de/BornAgain
-//! @license    GNU General Public License v3 or higher (see COPYING)
-//! @copyright  Forschungszentrum Jülich GmbH 2013
-//! @authors    E. Chernyaev <Evgueni.Tcherniaev@cern.ch> 1996-2003
-//! @authors    C. Durniak, G. Pospelov, W. Van Herck, J. Wuttke
-//!
-//! Changes w.r.t. CLHEP:
-//! - eliminated distinction vector/normal/point
-//! - eliminated unused transforms
-//! - reworked doxygen comments
-//
-// ************************************************************************** //
-
-#ifndef GEOMETRY_TRANSFROM3D_H
-#define GEOMETRY_TRANSFROM3D_H
-
-#include <cmath>
-#include "BasicVector3D.h"
-
-// remnants of CLHEP:
-#define Point3D  BasicVector3D
-
-namespace Geometry {
-
-// ************************************************************************** //
-//  Main class Transform3D
-// ************************************************************************** //
-
-//! Rotate vectors in three dimensions.
-
-//! Uses a 3x3 double-precision transform matrix to store rotations
-//! (and potentially rescalings and inversions).
-//!
-//! Identity transformation:
-//!   Transform3D::Identity   - global identity transformation;
-//!   any constructor without parameters, e.g. Transform3D();
-//!   m.setIdentity()            - set "m" to identity;
-//!
-//! General transformations:
-//!   Transform3D(m,v)         - transformation given by Rotation "m"
-//!                              and CLHEP::Hep3Vector "v";
-//!   Transform3D(a0,a1,a2, b0,b1,b2) - transformation given by initial
-//!                               and transformed positions of three points;
-//! Rotations:
-//!   Rotate3D(m)              - rotation given by CLHEP::HepRotation "m";
-//!   Rotate3D(ang,v)          - rotation through the angle "ang" around
-//!                              vector "v";
-//!   Rotate3D(ang,p1,p2)      - rotation through the angle "ang"
-//!                              counterclockwise around the axis given by
-//!                              two points p1->p2;
-//!   RotateX3D(ang)           - rotation around X-axis;
-//!   RotateY3D(ang)           - rotation around Y-axis;
-//!   RotateZ3D(ang)           - rotation around Z-axis;
-//!
-//! Inverse transformation:
-//!   m.inverse() or           - returns inverse transformation;
-//!
-//! Compound transformation:
-//!   m3 = m2 * m1             - it is relatively slow in comparison with
-//!                              transformation of a vector. Use parenthesis
-//!                              to avoid this operation (see example below);
-//!
-//! Several specialized classes are derived from it:
-//!
-//! RotateX3D,    RotateY3D,    RotateZ3D,    Rotate3D.
-//!
-//! The idea behind these classes is to provide some additional constructors
-//! for Transform3D, they normally should not be used as separate classes.
-//!
-//! Example:
-//! @code
-//!   Transform3D m;
-//!   m = TranslateX3D(10.*cm);
-//! @endcode
-//!
-//! @author <Evgueni.Tcherniaev@cern.ch> 1996-2003
-//!
-class Transform3D {
- protected:
-    // 3x3  Transformation Matrix
-    double xx_, xy_, xz_,     
-           yx_, yy_, yz_,
-           zx_, zy_, zz_;
-
-    //! Protected constructor.
-    Transform3D(double XX, double XY, double XZ,
-                double YX, double YY, double YZ,
-                double ZX, double ZY, double ZZ)
-        : xx_(XX), xy_(XY), xz_(XZ),
-          yx_(YX), yy_(YY), yz_(YZ),
-          zx_(ZX), zy_(ZY), zz_(ZZ) {}
-
-    //! Sets transformation matrix.
-    void setTransform(double XX, double XY, double XZ,
-                      double YX, double YY, double YZ,
-                      double ZX, double ZY, double ZZ) {
-        xx_ = XX; xy_ = XY; xz_ = XZ;
-        yx_ = YX; yy_ = YY; yz_ = YZ;
-        zx_ = ZX; zy_ = ZY; zz_ = ZZ;
-    }
-
- public:
-    //! Global identity transformation. */
-    static const Transform3D Identity;
-
-    //! Helper class for implemention of C-style subscripting r[i][j] 
-    class Transform3D_row {
-      public:
-        inline Transform3D_row(const Transform3D&, int);
-        inline double operator [] (int) const;
-      private:
-        const Transform3D& rr;
-        int ii;
-    };
-
-    //! Default constructor - sets the Identity transformation.
-    Transform3D()
-        : xx_(1), xy_(0), xz_(0),
-          yx_(0), yy_(1), yz_(0),
-          zx_(0), zy_(0), zz_(1) {}
-  
-    //! Copy constructor.
-    Transform3D(const Transform3D& m)
-        : xx_(m.xx_), xy_(m.xy_), xz_(m.xz_),
-          yx_(m.yx_), yy_(m.yy_), yz_(m.yz_),
-          zx_(m.zx_), zy_(m.zy_), zz_(m.zz_) {}
-
-    //! Destructor.
-    //! Virtual for now as some persistency mechanism needs that,
-    //! in future releases this might go away again.
-    virtual ~Transform3D() {}
-
-    //! Returns object of the helper class for C-style subscripting r[i][j]
-    inline const Transform3D_row operator [] (int) const; 
-
-    //! Fortran-style subscripting: returns (i,j) element of the matrix.
-    double operator () (int, int) const;
-
-    //! Returns xx-element of the transformation matrix.
-    double xx() const { return xx_; }
-    //! Returns xy-element of the transformation matrix.
-    double xy() const { return xy_; }
-    //! Returns xz-element of the transformation matrix.
-    double xz() const { return xz_; }
-    //! Returns yx-element of the transformation matrix.
-    double yx() const { return yx_; }
-    //! Returns yy-element of the transformation matrix.
-    double yy() const { return yy_; }
-    //! Returns yz-element of the transformation matrix.
-    double yz() const { return yz_; }
-    //! Returns zx-element of the transformation matrix.
-    double zx() const { return zx_; }
-    //! Returns zy-element of the transformation matrix.
-    double zy() const { return zy_; }
-    //! Returns zz-element of the transformation matrix.
-    double zz() const { return zz_; }
-    
-    //! Assignment.
-    Transform3D& operator=(const Transform3D&m) {
-        xx_= m.xx_; xy_= m.xy_; xz_= m.xz_;
-        yx_= m.yx_; yy_= m.yy_; yz_= m.yz_;
-        zx_= m.zx_; zy_= m.zy_; zz_= m.zz_;
-        return *this;
-    }
-
-    //! Sets the Identity transformation.
-    void setIdentity() { 
-        xy_= xz_= yx_= yz_= zx_= zy_= 0; xx_= yy_= zz_= 1;
-    }
-    
-    //! Returns the inverse transformation.
-    Transform3D inverse() const;
-    
-    //! Concatenation of transforms. Read efficiency warning!
-    //!
-    //! Warning:
-    //! Do not use this function for one-time computations:
-    //! Transform3D*Transform3D is roughly 3 times slower than
-    //! Transform3D*Vector3D. Therefore prefer v2 = m3*(m2*(m1*v1))
-    //! over v2 = m3*m2*m1*v1. (The latter expression is written
-    //! without parentheses because operator* is left associative).
-    //!
-    //! Use of Transform3D*Transform3D is reasonable when the
-    //! resulting transformation will be used several times.
-    //!
-    Transform3D operator*(const Transform3D& b) const;
-    };
-
-// ************************************************************************** //
-//   Rotations
-// ************************************************************************** //
-
-//! A rotation of 3D geometrical objects (points, vectors, normals).
-
-//! This class provides additional constructors for Transform3D
-//! and should not be used as a separate class.
-//! 
-//! Example of use:
-//! @code
-//!   Transform3D m;
-//!   m = Rotate3D(30.*deg, HepVector3D(1.,1.,1.));
-//! @endcode
-//!
-//! @author <Evgueni.Tcherniaev@cern.ch> 1996-2003
-//!
-class Rotate3D : public Transform3D {
- public:
-    //! Default constructor: sets the Identity transformation.
-    Rotate3D() : Transform3D() {}
-    
-    //! Construct rotation by angle a around axis p1->p2.
-    Rotate3D(double a,
-	     const Point3D<double>& p1,
-	     const Point3D<double>& p2);
-    
-    //! Constructor from angle and axis.
-
-    //! @param a angle of rotation
-    //! @param v axis of rotation
-    inline Rotate3D(double a, const BasicVector3D<double>& v)
-    //  TODO(C++11): simplify using delegating constructor
-    { *this = Rotate3D(a, Point3D<double>(0., 0., 0.),
-                       Point3D<double>(v.x(),v.y(),v.z()) ); }
-};
-
-//! A rotation of 3D geometrical objects around the x-axis.
-
-//! Should not be instantiated: see Rotate3D for example of use.
-//!
-//! @author <Evgueni.Tcherniaev@cern.ch>
-//!
-class RotateX3D : public Rotate3D {
- public:
-    //! Default constructor: sets the Identity transformation.
-    RotateX3D() : Rotate3D() {}
-    
-    //! Constructs a rotation around x-axis by angle a.
-    RotateX3D(double a) {
-        double cosa = std::cos(a), sina = std::sin(a); 
-        setTransform(1.,0.,0., 0.,cosa,-sina, 0.,sina,cosa);
-    }
-};
-
-//! A rotation of 3D geometrical objects around the y-axis.
-
-//! Should not be instantiated: see Rotate3D for example of use.
-//!
-//! @author <Evgueni.Tcherniaev@cern.ch>
-//!
-class RotateY3D : public Rotate3D {
- public:
-    //! Default constructor: sets the Identity transformation.
-    RotateY3D() : Rotate3D() {}
-    
-    //! Constructs a rotation around y-axis by angle a.
-    RotateY3D(double a) {
-        double cosa = std::cos(a), sina = std::sin(a); 
-        setTransform(cosa,0.,sina, 0.,1.,0., -sina,0.,cosa);
-    }
-};
-
-//! A rotation of 3D geometrical objects around the z-axis.
-
-//! Should not be instantiated: see Rotate3D for example of use.
-//!
-//! @author <Evgueni.Tcherniaev@cern.ch>
-//!
-class RotateZ3D : public Rotate3D {
- public:
-    //! Default constructor: sets the Identity transformation.
-    RotateZ3D() : Rotate3D() {}
-    
-    //! Constructs a rotation around z-axis by angle a.
-    RotateZ3D(double a) {
-        double cosa = std::cos(a), sina = std::sin(a); 
-        setTransform(cosa,-sina,0., sina,cosa,0., 0.,0.,1.);
-    }
-};
-
-// ************************************************************************** //
-//  Inlines that involve both Transform3D and Transform3D_row
-// ************************************************************************** //
-
-inline
-Transform3D::Transform3D_row::Transform3D_row(const Transform3D&  r, int i)
-    : rr(r), ii(i) {}
-
-inline
-double Transform3D::Transform3D_row::operator[](int jj) const
-    { return rr(ii,jj); }
-
-inline
-const Transform3D::Transform3D_row Transform3D::operator[](int i) const
-    { return Transform3D_row(*this, i); }
-
-}  // namespace Geometry
-
-#endif /* GEOMETRY_TRANSFROM3D_H */
diff --git a/Core/Samples/inc/IDispersalState.h b/Core/Samples/inc/IDispersalState.h
index abdaf8d3964..6eb3ce0e381 100644
--- a/Core/Samples/inc/IDispersalState.h
+++ b/Core/Samples/inc/IDispersalState.h
@@ -21,7 +21,7 @@
 class IDispersalState
 {
  public:
-	virtual ~IDispersalState() {}
+    virtual ~IDispersalState() {}
 };
 
 #endif /* IDISPERSALSTATE_H_ */
diff --git a/Core/Samples/inc/IInterferenceFunction.h b/Core/Samples/inc/IInterferenceFunction.h
index 2d175985601..598213d063f 100644
--- a/Core/Samples/inc/IInterferenceFunction.h
+++ b/Core/Samples/inc/IInterferenceFunction.h
@@ -27,7 +27,7 @@ class IInterferenceFunction : public ISample
     virtual ~IInterferenceFunction() {}
 
     virtual double evaluate(const cvector_t& q) const=0;
-	virtual IInterferenceFunction *clone() const=0;
+    virtual IInterferenceFunction *clone() const=0;
     virtual double getKappa() const { return 0.0; }
 };
 
diff --git a/Core/Samples/inc/InterferenceFunction1DParaCrystal.h b/Core/Samples/inc/InterferenceFunction1DParaCrystal.h
index ed49cd6deed..00ab68ddba0 100644
--- a/Core/Samples/inc/InterferenceFunction1DParaCrystal.h
+++ b/Core/Samples/inc/InterferenceFunction1DParaCrystal.h
@@ -21,25 +21,30 @@
 class InterferenceFunction1DParaCrystal : public IInterferenceFunction
 {
  public:
-	InterferenceFunction1DParaCrystal(double peak_distance, double width, double corr_length=0.0);
-	virtual ~InterferenceFunction1DParaCrystal() {}
-	virtual InterferenceFunction1DParaCrystal *clone() const {
-	    InterferenceFunction1DParaCrystal *p_clone = new InterferenceFunction1DParaCrystal(m_peak_distance, m_width, m_corr_length);
-	    p_clone->setKappa(m_kappa);
-	    return p_clone;
-	}
+    InterferenceFunction1DParaCrystal(
+        double peak_distance, double width, double corr_length=0.0);
+    virtual ~InterferenceFunction1DParaCrystal() {}
+    virtual InterferenceFunction1DParaCrystal *clone() const {
+        InterferenceFunction1DParaCrystal *p_clone =
+            new InterferenceFunction1DParaCrystal(
+                m_peak_distance, m_width, m_corr_length);
+        p_clone->setKappa(m_kappa);
+        return p_clone;
+    }
 
-	void setKappa(double kappa) { m_kappa = kappa; }
-	virtual double getKappa() const { return m_kappa; }
+    void setKappa(double kappa) { m_kappa = kappa; }
+    virtual double getKappa() const { return m_kappa; }
     virtual double evaluate(const cvector_t& q) const;
     //TODO: replace these with strategy pattern for different algorithms
     complex_t FTGaussianCorrLength(double qpar) const;
+
  protected:
-	double m_peak_distance;
-	double m_width;
-	double m_corr_length;
-	bool m_use_corr_length;
-	double m_kappa;
+    double m_peak_distance;
+    double m_width;
+    double m_corr_length;
+    bool m_use_corr_length;
+    double m_kappa;
+
  private:
     //! Registers some class members for later access via parameter pool
     virtual void init_parameters();
diff --git a/Core/Samples/inc/InterferenceFunctionNone.h b/Core/Samples/inc/InterferenceFunctionNone.h
index 91f095b2783..948eca07a59 100644
--- a/Core/Samples/inc/InterferenceFunctionNone.h
+++ b/Core/Samples/inc/InterferenceFunctionNone.h
@@ -24,11 +24,11 @@ class InterferenceFunctionNone : public IInterferenceFunction
 {
  public:
     InterferenceFunctionNone() { setName("InterferenceFunctionNone"); }
-	virtual ~InterferenceFunctionNone() {}
-	virtual InterferenceFunctionNone *clone() const { return new InterferenceFunctionNone(); }
+    virtual ~InterferenceFunctionNone() {}
+    virtual InterferenceFunctionNone *clone() const
+    { return new InterferenceFunctionNone(); }
 
     virtual double evaluate(const cvector_t& q) const { (void)q; return 1.0; }
-
 };
 
 #endif /* INTERFERENCEFUNCTIONNONE_H_ */
diff --git a/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp b/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp
index 5cb4495b426..398f4013e56 100644
--- a/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp
+++ b/Core/Samples/src/InterferenceFunction1DParaCrystal.cpp
@@ -17,14 +17,14 @@
 
 InterferenceFunction1DParaCrystal::InterferenceFunction1DParaCrystal(double peak_distance, double width, double corr_length)
 : m_peak_distance(peak_distance)
-, m_width(width)
-, m_corr_length(corr_length)
-, m_use_corr_length(true)
+    , m_width(width)
+    , m_corr_length(corr_length)
+    , m_use_corr_length(true)
 {
     setName("InterferenceFunction1DParaCrystal");
-	if (m_corr_length==0.0) {
-		m_use_corr_length = false;
-	}
+    if (m_corr_length==0.0) {
+        m_use_corr_length = false;
+    }
     init_parameters();
 }
 
@@ -41,18 +41,20 @@ double InterferenceFunction1DParaCrystal::evaluate(const cvector_t& q) const
     double qxr = q.x().real();
     double qyr = q.y().real();
     double qpar = std::sqrt(qxr*qxr + qyr*qyr);
-	complex_t p_transformed = FTGaussianCorrLength(qpar);
-	double interference_function = 1.0 + 2*(p_transformed/(complex_t(1.0, 0.0)-p_transformed)).real();
-	return interference_function;
+    complex_t p_transformed = FTGaussianCorrLength(qpar);
+    double interference_function = 1.0 +
+        2*(p_transformed/(complex_t(1.0, 0.0)-p_transformed)).real();
+    return interference_function;
 }
 
-complex_t InterferenceFunction1DParaCrystal::FTGaussianCorrLength(double qpar) const
+complex_t InterferenceFunction1DParaCrystal::FTGaussianCorrLength(
+    double qpar) const
 {
-	double exponent1 = -(m_width*m_width*qpar*qpar)/2.0;
-	complex_t exponent2 = complex_t(0.0, 1.0)*qpar*m_peak_distance;
-	complex_t result = std::exp(exponent2)*std::exp(exponent1);
-	if (m_use_corr_length) {
-		result *= std::exp(-m_peak_distance/m_corr_length);
-	}
-	return result;
+    double exponent1 = -(m_width*m_width*qpar*qpar)/2.0;
+    complex_t exponent2 = complex_t(0.0, 1.0)*qpar*m_peak_distance;
+    complex_t result = std::exp(exponent2)*std::exp(exponent1);
+    if (m_use_corr_length) {
+        result *= std::exp(-m_peak_distance/m_corr_length);
+    }
+    return result;
 }
diff --git a/Core/Tools/inc/DoubleToComplexInterpolatingFunction.h b/Core/Tools/inc/DoubleToComplexInterpolatingFunction.h
index 0783da1fab5..5c7b63383fd 100644
--- a/Core/Tools/inc/DoubleToComplexInterpolatingFunction.h
+++ b/Core/Tools/inc/DoubleToComplexInterpolatingFunction.h
@@ -22,29 +22,33 @@
 
 class DoubleToComplexInterpolatingFunction : public IDoubleToComplexFunction
 {
- public:
+public:
     typedef std::map<double, complex_t> container_t;
     enum InterpolatingMode { Nearest, Linear, Polar };
 
-	virtual ~DoubleToComplexInterpolatingFunction();
-    DoubleToComplexInterpolatingFunction(const std::map<double, complex_t>& value_map, InterpolatingMode imode=Nearest);
-	virtual DoubleToComplexInterpolatingFunction *clone() const;
+    virtual ~DoubleToComplexInterpolatingFunction();
+    DoubleToComplexInterpolatingFunction(
+        const std::map<double, complex_t>& value_map,
+        InterpolatingMode imode=Nearest);
+    virtual DoubleToComplexInterpolatingFunction *clone() const;
 
     virtual complex_t evaluate(double value);
 
- protected:
+protected:
     container_t m_value_map;
-	double m_lower_limit;
-	double m_upper_limit;
-	double m_low_step;
-	double m_high_step;
+    double m_lower_limit;
+    double m_upper_limit;
+    double m_low_step;
+    double m_high_step;
 
     InterpolatingMode m_interpolating_mode;
 
- private:
+private:
     //! copy constructor and assignment operator are hidden since there is a clone method
-    DoubleToComplexInterpolatingFunction(const DoubleToComplexInterpolatingFunction& );
-    DoubleToComplexInterpolatingFunction& operator=(const DoubleToComplexInterpolatingFunction& );
+    DoubleToComplexInterpolatingFunction(
+        const DoubleToComplexInterpolatingFunction& );
+    DoubleToComplexInterpolatingFunction& operator=(
+        const DoubleToComplexInterpolatingFunction& );
 };
 
 #endif /* DOUBLETOCOMPLEXINTERPOLATINGFUNCTION_H_ */
diff --git a/Core/Tools/inc/IDoubleToComplexFunction.h b/Core/Tools/inc/IDoubleToComplexFunction.h
index 19dec81e15f..98c8c658cb8 100644
--- a/Core/Tools/inc/IDoubleToComplexFunction.h
+++ b/Core/Tools/inc/IDoubleToComplexFunction.h
@@ -23,18 +23,18 @@
 
 class IDoubleToComplexFunction : public ICloneable
 {
- public:
-	virtual ~IDoubleToComplexFunction() {}
-	virtual IDoubleToComplexFunction *clone() const=0;
+public:
+    virtual ~IDoubleToComplexFunction() {}
+    virtual IDoubleToComplexFunction *clone() const=0;
 
-	virtual complex_t evaluate(double value)=0;
+    virtual complex_t evaluate(double value)=0;
 };
 
 //! Virtual base class for double to complex map.
 
 class IDoubleToComplexMap : public ICloneable
 {
- public:
+public:
     virtual ~IDoubleToComplexMap() {}
     virtual IDoubleToComplexMap *clone() const = 0;
 
@@ -45,7 +45,7 @@ class IDoubleToComplexMap : public ICloneable
 
 class IDoubleToPairOfComplexMap : public ICloneable
 {
- public:
+public:
     virtual ~IDoubleToPairOfComplexMap() {}
     virtual IDoubleToPairOfComplexMap *clone() const = 0;
 
@@ -56,17 +56,17 @@ class IDoubleToPairOfComplexMap : public ICloneable
 
 class DoubleToComplexFunctionWrapper : public IDoubleToComplexFunction
 {
- public:
-	typedef complex_t (*double_to_complex_t)(double);
-	DoubleToComplexFunctionWrapper(double_to_complex_t function) : m_function(function) {}
-	virtual DoubleToComplexFunctionWrapper *clone() const {
-	    return new DoubleToComplexFunctionWrapper(m_function);
-	}
+public:
+    typedef complex_t (*double_to_complex_t)(double);
+    DoubleToComplexFunctionWrapper(double_to_complex_t function)
+        : m_function(function) {}
+    virtual DoubleToComplexFunctionWrapper *clone() const
+    { return new DoubleToComplexFunctionWrapper(m_function); }
 
-	virtual complex_t evaluate(double value) { return m_function(value); }
+    virtual complex_t evaluate(double value) { return m_function(value); }
 
- private:
-	double_to_complex_t m_function;
+private:
+    double_to_complex_t m_function;
 };
 
 #endif /* IDOUBLETOCOMPLEXFUNCTION_H_ */
diff --git a/Core/Tools/inc/MathFunctions.h b/Core/Tools/inc/MathFunctions.h
index 06b24a3ef2a..ad619ffe968 100644
--- a/Core/Tools/inc/MathFunctions.h
+++ b/Core/Tools/inc/MathFunctions.h
@@ -64,11 +64,14 @@ complex_t Sinc(const complex_t& value);
 complex_t Laue(const complex_t& value, size_t N);
 
 enum TransformCase { ForwardFFT, BackwardFFT };
-std::vector<complex_t > FastFourierTransform(const std::vector<complex_t >& data, TransformCase tcase);
+std::vector<complex_t> FastFourierTransform(
+    const std::vector<complex_t >& data, TransformCase tcase);
 
-std::vector<complex_t > FastFourierTransform(const std::vector<double >& data, TransformCase tcase);
+std::vector<complex_t> FastFourierTransform(
+    const std::vector<double >& data, TransformCase tcase);
 
-std::vector<complex_t> ConvolveFFT(const std::vector<double>& signal, const std::vector<double>& resfunc);
+std::vector<complex_t> ConvolveFFT(
+    const std::vector<double>& signal, const std::vector<double>& resfunc);
 
 //! fast sine calculations (not actually fast)
 double FastSin(const double& x);
@@ -87,7 +90,12 @@ void FastSinCos(const complex_t& x, complex_t& xsin, complex_t& xcos);
 
 } // Namespace MathFunctions
 
-inline double MathFunctions::GenerateNormalRandom(double average, double std_dev)
+// ************************************************************************** //
+// Some inline implementations
+// ************************************************************************** //
+
+inline double MathFunctions::GenerateNormalRandom(
+    double average, double std_dev)
 {
     return GenerateStandardNormalRandom()*std_dev + average;
 }
@@ -105,33 +113,40 @@ inline double MathFunctions::Bessel_J1(double value)
 
 inline double MathFunctions::Bessel_C1(double value)
 {
-    return ( value > Numeric::double_epsilon ? gsl_sf_bessel_J1(value)/value : 0.5);
+    return value > Numeric::double_epsilon ?
+        gsl_sf_bessel_J1(value)/value : 0.5;
 }
 
-inline double MathFunctions::Si(double value)  // int_0^x du Sin(u)/u
+//! int_0^x du Sin(u)/u
+inline double MathFunctions::Si(double value)
 {
     return gsl_sf_Si(value);
 }
 
-inline double MathFunctions::Sinc(double value)  // Sin(x)/x
+//! Sin(x)/x
+inline double MathFunctions::Sinc(double value)
 {
     return gsl_sf_sinc(value/M_PI);
 }
 
-inline complex_t MathFunctions::Sinc(const complex_t& value)  // Sin(x)/x
+//! Sin(x)/x
+inline complex_t MathFunctions::Sinc(const complex_t& value)  
 {
     if(std::abs(value)<Numeric::double_epsilon)
-        return complex_t(1.0, 0.0);
+        return complex_t(1., 0.);
     return std::sin(value)/value;
 }
 
-inline complex_t MathFunctions::Laue(const complex_t& value, size_t N) // Exp(iNx/2)*Sin((N+1)x)/Sin(x)
+//! Exp(iNx/2)*Sin((N+1)x)/Sin(x)
+inline complex_t MathFunctions::Laue(
+const complex_t& value, size_t N) 
 {
     if (N==0)
-        return complex_t(1.0, 0.0);
+        return complex_t(1., 0.);
     if(std::abs(value)<Numeric::double_epsilon)
-        return complex_t(N+1.0, 0.0);
-    return std::exp(complex_t(0.0, 1.0)*value*(double)N/2.0)*std::sin(value*(N+1.0)/2.0)/std::sin(value/2.0);
+        return complex_t(N+1., 0.);
+    return std::exp(complex_t(0., 1.)*value*N/2)*
+        std::sin(value*(N+1)/2)/std::sin(value/2);
 }
 
 //! fast sine calculations (not actually fast)
@@ -164,10 +179,11 @@ inline complex_t MathFunctions::FastSin(const complex_t& x) {
 }
 
 //! fast complex cosine calculation
+//  cos(a+bi) = cos(a)cosh(b) - i*sin(a)*sinh(b);
 inline complex_t MathFunctions::FastCos(const complex_t& x) {
-    // cos(a+bi) = cos(a)cosh(b) - i*sin(a)*sinh(b);
     //return complex_t( FastCos(x.real())*std::cosh(x.imag()), -1*FastSin(x.real())*std::sinh(x.imag()));
-    return complex_t( std::cos(x.real())*std::cosh(x.imag()), -1*std::sin(x.real())*std::sinh(x.imag()));
+    return complex_t( std::cos(x.real())*std::cosh(x.imag()),
+                      -std::sin(x.real())*std::sinh(x.imag()));
 }
 
 //! simultaneous complex sine and cosine calculations
diff --git a/Core/Tools/inc/OutputData.h b/Core/Tools/inc/OutputData.h
index e3e20ec7739..74c4e078ef2 100644
--- a/Core/Tools/inc/OutputData.h
+++ b/Core/Tools/inc/OutputData.h
@@ -26,17 +26,19 @@
 
 //! Store data of any type in multi-dimensional space.
 
-template <class T> class OutputData
+template <class T>
+class OutputData
 {
  public:
     OutputData();
-    ~OutputData();
+    ~OutputData() { clear(); }
     OutputData* clone() const;
 
     void copyFrom(const OutputData<T>& x);
 
     void addAxis(const IAxis& new_axis);
-    void addAxis(const std::string& name, size_t size, double start, double end);
+    void addAxis(const std::string& name, size_t size,
+                 double start, double end);
 
     const IAxis *getAxis(size_t index) const;
     const IAxis *getAxis(const std::string& label) const;
@@ -195,10 +197,11 @@ template <class T> class OutputData
 };
 
 /* ***************************************************************************/
-// definitions
+// Implementation
 /* ***************************************************************************/
 
-template <class T> OutputData<T>::OutputData()
+template <class T>
+OutputData<T>::OutputData()
 : m_value_axes()
 , mp_ll_data(0)
 , mp_mask(0)
@@ -206,41 +209,32 @@ template <class T> OutputData<T>::OutputData()
     allocate();
 }
 
-template <class T> OutputData<T>::~OutputData()
-{
-    clear();
-}
-
-template <class T> OutputData<T>* OutputData<T>::clone() const
+template <class T>
+OutputData<T>* OutputData<T>::clone() const
 {
-	OutputData<T>* p_result = new OutputData<T>();
-	p_result->m_value_axes = m_value_axes;
+    OutputData<T>* p_result = new OutputData<T>();
+    p_result->m_value_axes = m_value_axes;
     (*p_result->mp_ll_data) = *mp_ll_data;
-
-    if (mp_mask) {
+    if (mp_mask)
         p_result->mp_mask = mp_mask->clone();
-    }
-
     return p_result;
 }
 
-template <class T> void OutputData<T>::copyFrom(const OutputData<T>& other)
+template <class T>
+void OutputData<T>::copyFrom(const OutputData<T>& other)
 {
     clear();
     m_value_axes = other.m_value_axes;
     delete mp_ll_data;
     mp_ll_data = 0;
-    if(other.mp_ll_data) {
+    if(other.mp_ll_data)
         mp_ll_data = new LLData<T>(*other.mp_ll_data);
-    }
-    if (other.getMask()) {
+    if (other.getMask())
         mp_mask = other.getMask()->clone();
-    }
 }
 
-
-
-template <class T> void OutputData<T>::addAxis(const IAxis& new_axis)
+template <class T>
+void OutputData<T>::addAxis(const IAxis& new_axis)
 {
     if( getAxis(new_axis.getName()) )
         throw LogicErrorException(
@@ -254,19 +248,26 @@ template <class T> void OutputData<T>::addAxis(const IAxis& new_axis)
 }
 
 template <class T>
-void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end)
+void OutputData<T>::addAxis(const std::string& name, size_t size,
+                            double start, double end)
 {
-    if( getAxis(name) ) throw LogicErrorException("OutputData<T>::addAxis(std::string name) -> Error! Attempt to add axis with already existing name '"+name+std::string("'"));
+    if( getAxis(name) )
+        throw LogicErrorException(
+            "OutputData<T>::addAxis(std::string name) -> "
+            "Error! Attempt to add axis with already existing name '" +
+            name+"'");
     AxisDouble new_axis(name, size, start, end);
     addAxis(new_axis);
 }
 
-template <class T> const IAxis *OutputData<T>::getAxis(size_t index) const
+template <class T>
+const IAxis *OutputData<T>::getAxis(size_t index) const
 {
     return m_value_axes[index];
 }
 
-template <class T> const IAxis *OutputData<T>::getAxis(const std::string& label) const
+template <class T>
+const IAxis *OutputData<T>::getAxis(const std::string& label) const
 {
     for (size_t i = 0; i < m_value_axes.size(); ++i) {
         if (m_value_axes[i]->getName() == label) {
@@ -277,13 +278,15 @@ template <class T> const IAxis *OutputData<T>::getAxis(const std::string& label)
 }
 
 // return index of axis
-template <class T> size_t OutputData<T>::getAxisIndex(const std::string& label) const
+template <class T>
+size_t OutputData<T>::getAxisIndex(const std::string& label) const
 {
-    for (size_t i = 0; i < m_value_axes.size(); ++i)
-    {
+    for (size_t i = 0; i < m_value_axes.size(); ++i) {
         if (m_value_axes[i]->getName() == label) return i;
     }
-    throw LogicErrorException("OutputData<T>::getAxisIndex() -> Error! Axis with given name not found '"+label+std::string("'"));
+    throw LogicErrorException(
+        "OutputData<T>::getAxisIndex() -> "
+        "Error! Axis with given name not found '"+label+std::string("'"));
 }
 
 
@@ -302,39 +305,39 @@ template <class T>
 inline std::vector<T> OutputData<T>::getRawDataVector() const
 {
     std::vector<T> result;
-    for (size_t i=0; i<getAllocatedSize(); ++i) {
+    for (size_t i=0; i<getAllocatedSize(); ++i)
         result.push_back((*mp_ll_data)[i]);
-    }
     return result;
 }
 
-template <class T> void OutputData<T>::fillRawDataArray(T *destination) const
+template <class T>
+void OutputData<T>::fillRawDataArray(T *destination) const
 {
-    for (size_t i=0; i<getAllocatedSize(); ++i) {
+    for (size_t i=0; i<getAllocatedSize(); ++i)
         destination[i] = (*mp_ll_data)[i];
-    }
     return;
 }
 
-template <class T> typename OutputData<T>::iterator OutputData<T>::begin()
+template <class T>
+typename OutputData<T>::iterator OutputData<T>::begin()
 {
     typename OutputData<T>::iterator result(this);
-    if (mp_mask) {
+    if (mp_mask)
         result.setMask(*mp_mask);
-    }
     return result;
 }
 
-template <class T> typename OutputData<T>::const_iterator OutputData<T>::begin() const
+template <class T>
+typename OutputData<T>::const_iterator OutputData<T>::begin() const
 {
     typename OutputData<T>::const_iterator result(this);
-    if (mp_mask) {
+    if (mp_mask)
         result.setMask(*mp_mask);
-    }
     return result;
 }
 
-template <class T> void OutputData<T>::setMask(const Mask& mask)
+template <class T>
+void OutputData<T>::setMask(const Mask& mask)
 {
     if (mp_mask !=& mask) {
         delete mp_mask;
@@ -343,12 +346,14 @@ template <class T> void OutputData<T>::setMask(const Mask& mask)
     }
 }
 
-template <class T> void OutputData<T>::addMask(const Mask& mask)
+template <class T>
+void OutputData<T>::addMask(const Mask& mask)
 {
     if (mask.mp_submask) {
         throw RuntimeErrorException(
-                    "OutputData<T>::addMask() -> "
-                    "Error! One can only add single masks to OutputDataIterator at a time");
+            "OutputData<T>::addMask() -> "
+            "Error! One can only add single masks to OutputDataIterator "
+            "at a time");
     }
     Mask *p_old_mask = getMask();
     mp_mask = mask.clone();
@@ -356,13 +361,15 @@ template <class T> void OutputData<T>::addMask(const Mask& mask)
     mp_mask->setMaxIndex(getAllocatedSize());
 }
 
-template<class T> void OutputData<T>::removeAllMasks()
+template<class T>
+void OutputData<T>::removeAllMasks()
 {
     delete mp_mask;
     mp_mask = 0;
 }
 
-template<class T> std::vector<int> OutputData<T>::toCoordinates(size_t index) const
+template<class T>
+std::vector<int> OutputData<T>::toCoordinates(size_t index) const
 {
     size_t remainder = index;
     std::vector<int> result;
@@ -370,14 +377,15 @@ template<class T> std::vector<int> OutputData<T>::toCoordinates(size_t index) co
     for (size_t i=0; i<mp_ll_data->getRank(); ++i)
     {
         result[mp_ll_data->getRank()-1-i] =
-                (int)(remainder % m_value_axes[mp_ll_data->getRank()-1-i]->getSize());
+            (int)(remainder %
+                  m_value_axes[mp_ll_data->getRank()-1-i]->getSize());
         remainder /= m_value_axes[mp_ll_data->getRank()-1-i]->getSize();
     }
     return result;
 }
 
-template<class T> int OutputData<T>::toCoordinate(
-        size_t index, size_t i_selected_axis) const
+template<class T>
+int OutputData<T>::toCoordinate(size_t index, size_t i_selected_axis) const
 {
     size_t remainder(index);
     for (size_t i=0; i<mp_ll_data->getRank(); ++i)
@@ -391,12 +399,14 @@ template<class T> int OutputData<T>::toCoordinate(
                               "Error! No axis with given number");
 }
 
-template <class T> size_t OutputData<T>::toIndex(std::vector<int> coordinates) const
+template <class T>
+size_t OutputData<T>::toIndex(std::vector<int> coordinates) const
 {
     if (coordinates.size() != mp_ll_data->getRank())
         throw LogicErrorException(
                     "size_t OutputData<T>::toIndex() -> "
-                    "Error! Number of coordinates must match rank of data structure");
+                    "Error! Number of coordinates must match "
+                    "rank of data structure");
     size_t result = 0;
     int step_size = 1;
     for (size_t i=mp_ll_data->getRank(); i>0; --i)
@@ -407,7 +417,8 @@ template <class T> size_t OutputData<T>::toIndex(std::vector<int> coordinates) c
     return result;
 }
 
-template <class T> size_t OutputData<T>::getIndexOfAxis(
+template <class T>
+size_t OutputData<T>::getIndexOfAxis(
         const std::string& axis_name, size_t total_index) const
 {
     std::vector<int> coordinates = toCoordinates(total_index);
@@ -422,7 +433,8 @@ template <class T> size_t OutputData<T>::getIndexOfAxis(
 }
 
 template <class T>
-double OutputData<T>::getValueOfAxis(const std::string& axis_name, size_t index) const
+double OutputData<T>::getValueOfAxis(
+    const std::string& axis_name, size_t index) const
 {
     for (size_t i=0; i<m_value_axes.size(); ++i) {
         if (m_value_axes[i]->getName() == axis_name) {
@@ -455,7 +467,8 @@ inline T OutputData<T>::totalSum() const
     return mp_ll_data->getTotalSum();
 }
 
-template <class T> void OutputData<T>::clear()
+template <class T>
+void OutputData<T>::clear()
 {
     m_value_axes.clear();
     delete mp_ll_data;
@@ -464,17 +477,20 @@ template <class T> void OutputData<T>::clear()
     mp_mask = 0;
 }
 
-template <class T> void OutputData<T>::setAllTo(const T& value)
+template <class T>
+void OutputData<T>::setAllTo(const T& value)
 {
     mp_ll_data->setAll(value);
 }
 
-template <class T> void OutputData<T>::scaleAll(const T& factor)
+template <class T>
+void OutputData<T>::scaleAll(const T& factor)
 {
     mp_ll_data->scaleAll(factor);
 }
 
-template <class T> void OutputData<T>::setAxisSizes(size_t rank, int *n_dims)
+template <class T>
+void OutputData<T>::setAxisSizes(size_t rank, int *n_dims)
 {
     clear();
     std::string basename("axis");
@@ -485,31 +501,36 @@ template <class T> void OutputData<T>::setAxisSizes(size_t rank, int *n_dims)
     }
 }
 
-template<class T> const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right)
+template<class T>
+const OutputData<T>& OutputData<T>::operator+=(const OutputData<T>& right)
 {
     *this->mp_ll_data += *right.mp_ll_data;
     return *this;
 }
 
-template<class T> const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right)
+template<class T>
+const OutputData<T>& OutputData<T>::operator-=(const OutputData<T>& right)
 {
     *this->mp_ll_data -= *right.mp_ll_data;
     return *this;
 }
 
-template<class T> const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right)
+template<class T>
+const OutputData<T>& OutputData<T>::operator*=(const OutputData<T>& right)
 {
     *this->mp_ll_data *= *right.mp_ll_data;
     return *this;
 }
 
-template<class T> const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right)
+template<class T>
+const OutputData<T>& OutputData<T>::operator/=(const OutputData<T>& right)
 {
     *this->mp_ll_data /= *right.mp_ll_data;
     return *this;
 }
 
-template <class T> void OutputData<T>::allocate()
+template <class T>
+void OutputData<T>::allocate()
 {
     delete mp_ll_data;
     size_t rank = m_value_axes.size();
@@ -523,7 +544,8 @@ template <class T> void OutputData<T>::allocate()
     delete[] dims;
 }
 
-template<class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector)
+template<class T>
+inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector)
 {
     if (data_vector.size() != getAllocatedSize()) {
         throw RuntimeErrorException("OutputData<T>::setRawDataVector() -> Error! setRawDataVector can only be called with a data vector of the correct size.");
@@ -533,7 +555,8 @@ template<class T> inline void OutputData<T>::setRawDataVector(const std::vector<
     }
 }
 
-template<class T> inline void OutputData<T>::setRawDataArray(const T *source)
+template<class T>
+inline void OutputData<T>::setRawDataArray(const T *source)
 {
     for (size_t i=0; i<getAllocatedSize(); ++i) {
         (*mp_ll_data)[i] = source[i];
@@ -541,7 +564,8 @@ template<class T> inline void OutputData<T>::setRawDataArray(const T *source)
 }
 
 //! Returns true if object have same dimensions
-template<class T> inline bool OutputData<T>::hasSameDimensions(
+template<class T>
+inline bool OutputData<T>::hasSameDimensions(
     const OutputData<T>& right) const
 {
     if(!mp_ll_data || !right.mp_ll_data ) return false;
-- 
GitLab