BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
DepthProbeElement.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Base/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_BASE_ELEMENT_DEPTHPROBEELEMENT_H
21 #define BORNAGAIN_BASE_ELEMENT_DEPTHPROBEELEMENT_H
22 
23 #include "Base/Element/IElement.h"
24 #include <heinz/Vectors3D.h>
25 #include <valarray>
26 
27 class IAxis;
28 
29 class DepthProbeElement : public IElement {
30 public:
31  DepthProbeElement(double wavelength, double alpha_i, const IAxis* z_positions);
32  DepthProbeElement(const DepthProbeElement& other) = delete;
34 
36 
37  double wavelength() const { return m_wavelength; }
38  double alphaI() const { return m_alpha_i; }
39  R3 getKi() const;
40 
41  template <typename T>
42  void setIntensities(T&& intensities)
43  {
44  static_assert(
45  std::is_assignable<std::valarray<double>, typename std::decay<T>::type>::value,
46  "Error in DepthProbeElement::setIntensities: wrong type of input data.");
47  m_intensities = std::forward<T>(intensities);
48  }
49 
50  const std::valarray<double>& getIntensities() const { return m_intensities; }
51 
52  void setZPositions(const IAxis* z_positions) { m_z_positions = z_positions; }
53  const IAxis* getZPositions() const { return m_z_positions; }
54 
55  size_t size() const { return m_intensities.size(); }
56 
57  //! Set calculation flag (if it's false, zero intensity is assigned to the element)
58  void setCalculationFlag(bool calculation_flag) { m_calculation_flag = calculation_flag; }
59  bool isCalculated() const { return m_calculation_flag; }
60 
61 private:
62  double m_wavelength, m_alpha_i; //!< the wavelength and the incident angle of the beam
63  std::valarray<double> m_intensities; //!< simulated intensity for the set of z positions
64  const IAxis* m_z_positions; //!< positions (lower z corresponds to a greater depth)
66 };
67 
68 #endif // BORNAGAIN_BASE_ELEMENT_DEPTHPROBEELEMENT_H
69 #endif // USER_API
Defines class DiffuseElement.
DepthProbeElement(const DepthProbeElement &other)=delete
const IAxis * m_z_positions
positions (lower z corresponds to a greater depth)
double m_alpha_i
the wavelength and the incident angle of the beam
double alphaI() const
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
void setZPositions(const IAxis *z_positions)
size_t size() const
const std::valarray< double > & getIntensities() const
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27