BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DepthProbeElement.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Core/Element/DepthProbeElement.h
6 //! @brief Defines class DepthProbeElement.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_CORE_ELEMENT_DEPTHPROBEELEMENT_H
21 #define BORNAGAIN_CORE_ELEMENT_DEPTHPROBEELEMENT_H
22 
23 #include <valarray>
24 
25 #include "Base/Vector/Vectors3D.h"
26 
27 class IAxis;
28 
30 public:
31  DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions);
33  DepthProbeElement(DepthProbeElement&& other) noexcept;
34 
36 
38 
39  double wavelength() const { return m_wavelength; }
40  double getAlphaI() const { return m_alpha_i; }
41  kvector_t getKi() const;
42 
43  template <typename T> void setIntensities(T&& intensities)
44  {
45  static_assert(
46  std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
47  "Error in DepthProbeElement::setIntensities: wrong type of input data.");
48  m_intensities = std::forward<T>(intensities);
49  }
50 
51  const std::valarray<double>& getIntensities() const { return m_intensities; }
52 
53  void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
54  const IAxis* getZPositions() const { return m_z_positions; }
55 
56  size_t size() const { return m_intensities.size(); }
57 
58  //! Set calculation flag (if it's false, zero intensity is assigned to the element)
59  void setCalculationFlag(bool calculation_flag) { m_calculation_flag = calculation_flag; }
60  bool isCalculated() const { return m_calculation_flag; }
61 
62 private:
63  void swapContent(DepthProbeElement& other);
64 
65  double m_wavelength, m_alpha_i; //!< the wavelength and the incident angle of the beam
66  std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
67  const IAxis* m_z_positions; //!< positions (lower z corresponds to a greater depth)
69 };
70 
71 #endif // BORNAGAIN_CORE_ELEMENT_DEPTHPROBEELEMENT_H
72 #endif // USER_API
Defines basic vectors in Z^3, R^3, C^3.
double getAlphaI() const
const IAxis * m_z_positions
positions (lower z corresponds to a greater depth)
void swapContent(DepthProbeElement &other)
double m_alpha_i
the wavelength and the incident angle of the beam
void setIntensities(T &&intensities)
void setCalculationFlag(bool calculation_flag)
Set calculation flag (if it's false, zero intensity is assigned to the element)
const IAxis * getZPositions() const
double wavelength() const
bool isCalculated() const
DepthProbeElement(double wavelength, double alpha_i, const IAxis *z_positions)
std::valarray< double > m_intensities
simulated intensity for the set of z positions
DepthProbeElement & operator=(const DepthProbeElement &other)
kvector_t getKi() const
void setZPositions(const IAxis *z_positions)
size_t size() const
const std::valarray< double > & getIntensities() const
Interface for one-dimensional axes.
Definition: IAxis.h:25