BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ProfileHelper Class Reference
Collaboration diagram for ProfileHelper:

Public Member Functions

 ProfileHelper (const ProcessedSample &sample)
 
 ~ProfileHelper ()
 
std::vector< complex_tcalculateProfile (const std::vector< double > &z_values) const
 
std::pair< double, double > defaultLimits () const
 

Private Attributes

std::vector< complex_tm_materialdata
 
std::vector< double > m_zlimits
 
std::vector< double > m_sigmas
 

Detailed Description

Object that can generate the material profile of a sample as a function of depth.

The generated profile contains the complex SLD for SLD materials and the parameters delta and beta for refractive index materials

Definition at line 31 of file ProfileHelper.h.

Constructor & Destructor Documentation

◆ ProfileHelper()

ProfileHelper::ProfileHelper ( const ProcessedSample sample)

Definition at line 26 of file ProfileHelper.cpp.

27 {
28  auto N = sample.numberOfSlices();
29  m_materialdata.reserve(N);
30  if (N > 1) {
31  m_zlimits.reserve(N - 1);
32  m_sigmas.reserve(N - 1);
33  }
34  auto& slices = sample.averageSlices();
35  for (size_t i = 0; i < N; ++i) {
36  m_materialdata.push_back(slices[i].material().materialData());
37  if (i + 1 < N) {
38  m_zlimits.push_back(sample.sliceBottomZ(i));
39  if (auto p_roughness = sample.bottomRoughness(i)) {
40  m_sigmas.push_back(p_roughness->getSigma());
41  } else {
42  m_sigmas.push_back(0.0);
43  }
44  }
45  }
46 }
double sliceBottomZ(size_t i) const
size_t numberOfSlices() const
const std::vector< Slice > & averageSlices() const
const LayerRoughness * bottomRoughness(size_t i) const
std::vector< complex_t > m_materialdata
Definition: ProfileHelper.h:41
std::vector< double > m_sigmas
Definition: ProfileHelper.h:43
std::vector< double > m_zlimits
Definition: ProfileHelper.h:42

References ProcessedSample::averageSlices(), ProcessedSample::bottomRoughness(), m_materialdata, m_sigmas, m_zlimits, ProcessedSample::numberOfSlices(), and ProcessedSample::sliceBottomZ().

Here is the call graph for this function:

◆ ~ProfileHelper()

ProfileHelper::~ProfileHelper ( )
default

Member Function Documentation

◆ calculateProfile()

std::vector< complex_t > ProfileHelper::calculateProfile ( const std::vector< double > &  z_values) const

Definition at line 51 of file ProfileHelper.cpp.

52 {
53  complex_t top_value = m_materialdata.size() ? m_materialdata[0] : 0.0;
54  std::vector<complex_t> result(z_values.size(), top_value);
55  for (size_t i = 0; i < m_zlimits.size(); ++i) {
56  auto sld_diff = m_materialdata[i + 1] - m_materialdata[i];
57  for (size_t j = 0; j < z_values.size(); ++j) {
58  auto arg = (z_values[j] - m_zlimits[i]);
59  auto t = Transition(arg, m_sigmas[i]);
60  result[j] += sld_diff * t;
61  }
62  }
63  return result;
64 }
std::complex< double > complex_t
Definition: Complex.h:20
double Transition(double x, double sigma)

References m_materialdata, m_sigmas, m_zlimits, and anonymous_namespace{ProfileHelper.cpp}::Transition().

Referenced by MaterialProfile().

Here is the call graph for this function:

◆ defaultLimits()

std::pair< double, double > ProfileHelper::defaultLimits ( ) const

Definition at line 66 of file ProfileHelper.cpp.

67 {
68  if (m_zlimits.size() < 1)
69  return {0.0, 0.0};
70  double interface_span = m_zlimits.front() - m_zlimits.back();
71  double default_margin = interface_span > 0.0 ? interface_span / 20.0 : 10.0;
72  double top_margin = m_sigmas.front() > 0.0 ? 5.0 * m_sigmas.front() : default_margin;
73  double bottom_margin = m_sigmas.back() > 0.0 ? 5.0 * m_sigmas.back() : default_margin;
74  double z_min = m_zlimits.back() - bottom_margin;
75  double z_max = m_zlimits.front() + top_margin;
76  return {z_min, z_max};
77 }

References m_sigmas, and m_zlimits.

Referenced by DefaultMaterialProfileLimits().

Member Data Documentation

◆ m_materialdata

std::vector<complex_t> ProfileHelper::m_materialdata
private

Definition at line 41 of file ProfileHelper.h.

Referenced by calculateProfile(), and ProfileHelper().

◆ m_zlimits

std::vector<double> ProfileHelper::m_zlimits
private

Definition at line 42 of file ProfileHelper.h.

Referenced by calculateProfile(), defaultLimits(), and ProfileHelper().

◆ m_sigmas

std::vector<double> ProfileHelper::m_sigmas
private

Definition at line 43 of file ProfileHelper.h.

Referenced by calculateProfile(), defaultLimits(), and ProfileHelper().


The documentation for this class was generated from the following files: