From beba8ce87a70bedfd55fb0497ea321f439fe2fe4 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Fri, 31 Mar 2023 09:42:26 +0200
Subject: [PATCH] merge DpElement into simulation

---
 Resample/Element/DepthprobeElement.cpp  | 39 -------------
 Resample/Element/DepthprobeElement.h    | 66 ----------------------
 Sim/Simulation/DepthprobeSimulation.cpp | 73 ++++++++++++++++++++++++-
 3 files changed, 70 insertions(+), 108 deletions(-)
 delete mode 100644 Resample/Element/DepthprobeElement.cpp
 delete mode 100644 Resample/Element/DepthprobeElement.h

diff --git a/Resample/Element/DepthprobeElement.cpp b/Resample/Element/DepthprobeElement.cpp
deleted file mode 100644
index d24190adc91..00000000000
--- a/Resample/Element/DepthprobeElement.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//  ************************************************************************************************
-//
-//  BornAgain: simulate and fit reflection and scattering
-//
-//! @file      Resample/Element/DepthprobeElement.cpp
-//! @brief     Implements class DepthprobeElement.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2018
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-//  ************************************************************************************************
-
-#include "Resample/Element/DepthprobeElement.h"
-#include "Base/Axis/IAxis.h"
-#include "Base/Util/Assert.h"
-#include "Base/Vector/GisasDirection.h"
-
-DepthprobeElement::DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
-                                     bool calculation_flag)
-    : IElement()
-    , m_wavelength(wavelength)
-    , m_alpha_i(alpha_i)
-    , m_z_positions(z_positions)
-    , m_calculation_flag(calculation_flag)
-{
-    ASSERT(z_positions);
-    m_intensities.resize(z_positions->size(), 0.0);
-}
-
-DepthprobeElement::DepthprobeElement(DepthprobeElement&& other) noexcept = default;
-
-DepthprobeElement::~DepthprobeElement() = default;
-
-R3 DepthprobeElement::getKi() const
-{
-    return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i);
-}
diff --git a/Resample/Element/DepthprobeElement.h b/Resample/Element/DepthprobeElement.h
deleted file mode 100644
index 4c5dde5c404..00000000000
--- a/Resample/Element/DepthprobeElement.h
+++ /dev/null
@@ -1,66 +0,0 @@
-//  ************************************************************************************************
-//
-//  BornAgain: simulate and fit reflection and scattering
-//
-//! @file      Resample/Element/DepthprobeElement.h
-//! @brief     Defines class DepthprobeElement.
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2018
-//! @authors   Scientific Computing Group at MLZ (see CITATION, AUTHORS)
-//
-//  ************************************************************************************************
-
-#ifdef SWIG
-#error no need to expose this header to Swig
-#endif // SWIG
-#ifndef BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
-#define BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
-
-#include "Resample/Element/IElement.h"
-#include <valarray>
-
-class IAxis;
-
-class DepthprobeElement : public IElement {
-public:
-    DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
-                      bool calculation_flag);
-    DepthprobeElement(const DepthprobeElement& other) = delete;
-    DepthprobeElement(DepthprobeElement&& other) noexcept;
-
-    ~DepthprobeElement();
-
-    double wavelength() const { return m_wavelength; }
-    double alphaI() const { return m_alpha_i; }
-    R3 getKi() const;
-
-    template <typename T>
-    void setIntensities(T&& intensities)
-    {
-        static_assert(
-            std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
-            "Error in DepthprobeElement::setIntensities: wrong type of input data.");
-        m_intensities = std::forward<T>(intensities);
-    }
-
-    const std::valarray<double>& getIntensities() const { return m_intensities; }
-
-    void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
-    const IAxis* getZPositions() const { return m_z_positions; }
-
-    size_t size() const { return m_intensities.size(); }
-
-    //! if it's false, zero intensity is assigned to the element
-    bool isCalculated() const { return m_calculation_flag; }
-
-private:
-    const double m_wavelength;
-    const double m_alpha_i;              //!< incident angle of the beam
-    std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
-    const IAxis* m_z_positions;          //!< positions (lower z corresponds to a greater depth)
-    const bool m_calculation_flag;
-};
-
-#endif // BORNAGAIN_RESAMPLE_ELEMENT_DEPTHPROBEELEMENT_H
diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp
index de917b531cd..1fc7f1e0e1e 100644
--- a/Sim/Simulation/DepthprobeSimulation.cpp
+++ b/Sim/Simulation/DepthprobeSimulation.cpp
@@ -16,19 +16,21 @@
 #include "Base/Axis/Bin.h"
 #include "Base/Axis/FixedBinAxis.h"
 #include "Base/Math/Constants.h"
+#include "Base/Progress/ProgressHandler.h"
 #include "Base/Util/Assert.h"
+#include "Base/Vector/GisasDirection.h"
 #include "Device/Beam/IFootprintFactor.h"
 #include "Device/Coord/CoordSystem2D.h"
 #include "Device/Data/Datafield.h"
 #include "Device/Histo/SimulationResult.h"
 #include "Param/Distrib/DistributionHandler.h"
 #include "Param/Distrib/Distributions.h"
-#include "Resample/Element/DepthprobeElement.h"
-#include "Sim/Scan/AlphaScan.h"
+#include "Resample/Element/IElement.h"
 #include "Resample/Flux/ScalarFlux.h"
 #include "Resample/Processed/ReSample.h"
-#include "Base/Progress/ProgressHandler.h"
+#include "Sim/Scan/AlphaScan.h"
 #include <iostream>
+#include <valarray>
 
 DepthprobeSimulation::DepthprobeSimulation(const IBeamScan& scan, const MultiLayer& sample,
                                            const IAxis& zaxis)
@@ -78,6 +80,71 @@ void DepthprobeSimulation::initDistributionHandler()
     }
 }
 
+//>>>>>>>
+
+class DepthprobeElement : public IElement {
+public:
+    DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
+                      bool calculation_flag);
+    DepthprobeElement(const DepthprobeElement& other) = delete;
+    DepthprobeElement(DepthprobeElement&& other) noexcept;
+
+    ~DepthprobeElement();
+
+    double wavelength() const { return m_wavelength; }
+    double alphaI() const { return m_alpha_i; }
+    R3 getKi() const;
+
+    template <typename T>
+    void setIntensities(T&& intensities)
+    {
+        static_assert(
+            std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
+            "Error in DepthprobeElement::setIntensities: wrong type of input data.");
+        m_intensities = std::forward<T>(intensities);
+    }
+
+    const std::valarray<double>& getIntensities() const { return m_intensities; }
+
+    void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
+    const IAxis* getZPositions() const { return m_z_positions; }
+
+    size_t size() const { return m_intensities.size(); }
+
+    //! if it's false, zero intensity is assigned to the element
+    bool isCalculated() const { return m_calculation_flag; }
+
+private:
+    const double m_wavelength;
+    const double m_alpha_i;              //!< incident angle of the beam
+    std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
+    const IAxis* m_z_positions;          //!< positions (lower z corresponds to a greater depth)
+    const bool m_calculation_flag;
+};
+
+DepthprobeElement::DepthprobeElement(double wavelength, double alpha_i, const IAxis* z_positions,
+                                     bool calculation_flag)
+    : IElement()
+    , m_wavelength(wavelength)
+    , m_alpha_i(alpha_i)
+    , m_z_positions(z_positions)
+    , m_calculation_flag(calculation_flag)
+{
+    ASSERT(z_positions);
+    m_intensities.resize(z_positions->size(), 0.0);
+}
+
+DepthprobeElement::DepthprobeElement(DepthprobeElement&& other) noexcept = default;
+
+DepthprobeElement::~DepthprobeElement() = default;
+
+R3 DepthprobeElement::getKi() const
+{
+    return vecOfLambdaAlphaPhi(m_wavelength, m_alpha_i);
+}
+
+//<<<<<<<
+
 void DepthprobeSimulation::runComputation(const ReSample& re_sample, size_t i, double weight)
 {
     const double result_angle = m_scan->coordinateAxis()->bin(i).center() + m_scan->alphaOffset();
-- 
GitLab