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

Public Member Functions

 SimulationElement (double wavelength, double alpha_i, double phi_i, std::unique_ptr< IPixel > pixel)
 
 SimulationElement (const SimulationElement &other)
 
SimulationElementoperator= (const SimulationElement &other)
 
 SimulationElement (const SimulationElement &other, double x, double y)
 
 SimulationElement (SimulationElement &&other) noexcept
 
 ~SimulationElement ()
 
void setPolarization (const Eigen::Matrix2cd &polarization)
 
void setAnalyzerOperator (const Eigen::Matrix2cd &polarization_operator)
 
const PolarizationHandlerpolarizationHandler () const
 
double getWavelength () const
 
double getAlphaI () const
 
double getPhiI () const
 
double getAlphaMean () const
 
double getPhiMean () const
 
void setIntensity (double intensity)
 
void addIntensity (double intensity)
 
double getIntensity () const
 
kvector_t getKi () const
 
kvector_t getMeanKf () const
 
kvector_t getMeanQ () const
 
kvector_t getQ (double x, double y) const
 
double getIntegrationFactor (double x, double y) const
 
double getSolidAngle () const
 
double getAlpha (double x, double y) const
 
double getPhi (double x, double y) const
 
void setSpecular (bool is_specular)
 
bool isSpecular () const
 

Private Member Functions

void swapContent (SimulationElement &other)
 
kvector_t getKf (double x, double y) const
 

Private Attributes

PolarizationHandler m_polarization
 
double m_wavelength
 
double m_alpha_i
 
double m_phi_i
 
kvector_t m_k_i
 
kvector_t m_mean_kf
 
double m_intensity
 
std::unique_ptr< IPixelmP_pixel
 
bool m_is_specular
 

Detailed Description

Data stucture containing both input and output of a single detector cell.

Definition at line 28 of file SimulationElement.h.

Constructor & Destructor Documentation

◆ SimulationElement() [1/4]

SimulationElement::SimulationElement ( double  wavelength,
double  alpha_i,
double  phi_i,
std::unique_ptr< IPixel pixel 
)

Definition at line 17 of file SimulationElement.cpp.

19  : m_wavelength(wavelength), m_alpha_i(alpha_i), m_phi_i(phi_i),
21  m_mean_kf(pixel->getK(0.5, 0.5, m_wavelength)), m_intensity(0.0), mP_pixel(std::move(pixel)),
22  m_is_specular(false)
23 {
24 }
BasicVector3D< double > vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Creates a vector<double> as a wavevector with given wavelength and angles.
std::unique_ptr< IPixel > mP_pixel
double m_phi_i
wavelength and angles of beam
double m_intensity
simulated intensity for detector cell
kvector_t m_mean_kf
cached value of mean_kf
kvector_t m_k_i
cached value of k_i

◆ SimulationElement() [2/4]

SimulationElement::SimulationElement ( const SimulationElement other)

Definition at line 26 of file SimulationElement.cpp.

28  m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(other.m_k_i),
30 {
31  mP_pixel.reset(other.mP_pixel->clone());
32 }
PolarizationHandler m_polarization
bool isSpecular() const
Tells if simulation element corresponds to a specular peak.

References mP_pixel.

◆ SimulationElement() [3/4]

SimulationElement::SimulationElement ( const SimulationElement other,
double  x,
double  y 
)

Construct SimulationElement from other element and restrict k_f to specific value in the original detector pixel.

Definition at line 34 of file SimulationElement.cpp.

36  m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(other.m_k_i),
38 {
39  mP_pixel.reset(other.mP_pixel->createZeroSizePixel(x, y));
40  m_mean_kf = mP_pixel->getK(0.5, 0.5, m_wavelength);
41 }

References m_mean_kf, m_wavelength, and mP_pixel.

◆ SimulationElement() [4/4]

SimulationElement::SimulationElement ( SimulationElement &&  other)
noexcept

Definition at line 43 of file SimulationElement.cpp.

44  : m_polarization(std::move(other.m_polarization)), m_wavelength(other.m_wavelength),
45  m_alpha_i(other.m_alpha_i), m_phi_i(other.m_phi_i), m_k_i(std::move(other.m_k_i)),
47  mP_pixel(std::move(other.mP_pixel)), m_is_specular(other.isSpecular())
48 {
49 }

◆ ~SimulationElement()

SimulationElement::~SimulationElement ( )
default

Member Function Documentation

◆ operator=()

SimulationElement & SimulationElement::operator= ( const SimulationElement other)

Definition at line 53 of file SimulationElement.cpp.

54 {
55  if (this != &other) {
56  SimulationElement tmp(other);
57  tmp.swapContent(*this);
58  }
59  return *this;
60 }
Data stucture containing both input and output of a single detector cell.

References swapContent().

Here is the call graph for this function:

◆ setPolarization()

void SimulationElement::setPolarization ( const Eigen::Matrix2cd &  polarization)
inline

Sets the polarization density matrix (in spin basis along z-axis)

Definition at line 45 of file SimulationElement.h.

46  {
47  m_polarization.setPolarization(polarization);
48  }
void setPolarization(const Eigen::Matrix2cd &polarization)
Sets the polarization density matrix (in spin basis along z-axis)

References m_polarization, and PolarizationHandler::setPolarization().

Referenced by Simulation2D::generateSimulationElements().

Here is the call graph for this function:

◆ setAnalyzerOperator()

void SimulationElement::setAnalyzerOperator ( const Eigen::Matrix2cd &  polarization_operator)
inline

Sets the polarization analyzer operator (in spin basis along z-axis)

Definition at line 51 of file SimulationElement.h.

52  {
53  m_polarization.setAnalyzerOperator(polarization_operator);
54  }
void setAnalyzerOperator(const Eigen::Matrix2cd &analyzer)
Sets the polarization analyzer operator (in spin basis along z-axis)

References m_polarization, and PolarizationHandler::setAnalyzerOperator().

Referenced by Simulation2D::generateSimulationElements().

Here is the call graph for this function:

◆ polarizationHandler()

const PolarizationHandler& SimulationElement::polarizationHandler ( ) const
inline

◆ getWavelength()

double SimulationElement::getWavelength ( ) const
inline

◆ getAlphaI()

double SimulationElement::getAlphaI ( ) const
inline

Definition at line 60 of file SimulationElement.h.

60 { return m_alpha_i; }

References m_alpha_i.

Referenced by GISASSpecularComputation::compute(), and Simulation2D::normalize().

◆ getPhiI()

double SimulationElement::getPhiI ( ) const
inline

Definition at line 61 of file SimulationElement.h.

61 { return m_phi_i; }

References m_phi_i.

◆ getAlphaMean()

double SimulationElement::getAlphaMean ( ) const
inline

Definition at line 62 of file SimulationElement.h.

62 { return getAlpha(0.5, 0.5); }
double getAlpha(double x, double y) const

References getAlpha().

Referenced by ParticleLayoutComputation::compute(), and RoughMultiLayerComputation::compute().

Here is the call graph for this function:

◆ getPhiMean()

double SimulationElement::getPhiMean ( ) const
inline

Definition at line 63 of file SimulationElement.h.

63 { return getPhi(0.5, 0.5); }
double getPhi(double x, double y) const

References getPhi().

Here is the call graph for this function:

◆ setIntensity()

void SimulationElement::setIntensity ( double  intensity)
inline

◆ addIntensity()

void SimulationElement::addIntensity ( double  intensity)
inline

Definition at line 65 of file SimulationElement.h.

65 { m_intensity += intensity; }

References m_intensity.

Referenced by ParticleLayoutComputation::compute(), and RoughMultiLayerComputation::compute().

◆ getIntensity()

double SimulationElement::getIntensity ( ) const
inline

Definition at line 66 of file SimulationElement.h.

66 { return m_intensity; }

References m_intensity.

Referenced by Simulation2D::addBackgroundIntensity(), and Simulation2D::normalize().

◆ getKi()

kvector_t SimulationElement::getKi ( ) const

Definition at line 62 of file SimulationElement.cpp.

63 {
64  return m_k_i;
65 }

References m_k_i.

Referenced by FormFactorCoherentPart::evaluate(), FormFactorCoherentPart::evaluatePol(), getMeanQ(), and getQ().

◆ getMeanKf()

kvector_t SimulationElement::getMeanKf ( ) const

◆ getMeanQ()

kvector_t SimulationElement::getMeanQ ( ) const

Definition at line 79 of file SimulationElement.cpp.

80 {
81  return getKi() - getMeanKf();
82 }
kvector_t getMeanKf() const
kvector_t getKi() const

References getKi(), and getMeanKf().

Referenced by RoughMultiLayerComputation::compute(), DecouplingApproximationStrategy::polarizedCalculation(), SSCApproximationStrategy::polarizedCalculation(), DecouplingApproximationStrategy::scalarCalculation(), and SSCApproximationStrategy::scalarCalculation().

Here is the call graph for this function:

◆ getQ()

kvector_t SimulationElement::getQ ( double  x,
double  y 
) const

Returns scattering vector Q, with Kf determined from in-pixel coordinates x,y.

In-pixel coordinates take values from 0 to 1.

Definition at line 86 of file SimulationElement.cpp.

87 {
88  return getKi() - mP_pixel->getK(x, y, m_wavelength);
89 }

References getKi(), m_wavelength, and mP_pixel.

Here is the call graph for this function:

◆ getIntegrationFactor()

double SimulationElement::getIntegrationFactor ( double  x,
double  y 
) const

Definition at line 114 of file SimulationElement.cpp.

115 {
116  return mP_pixel->getIntegrationFactor(x, y);
117 }

References mP_pixel.

Referenced by IInterferenceFunctionStrategy::evaluate_for_fixed_angles().

◆ getSolidAngle()

double SimulationElement::getSolidAngle ( ) const

Definition at line 119 of file SimulationElement.cpp.

120 {
121  return mP_pixel->getSolidAngle();
122 }

References mP_pixel.

Referenced by GISASSpecularComputation::compute(), IInterferenceFunctionStrategy::evaluate(), and Simulation2D::normalize().

◆ getAlpha()

double SimulationElement::getAlpha ( double  x,
double  y 
) const

Definition at line 104 of file SimulationElement.cpp.

105 {
106  return M_PI_2 - getKf(x, y).theta();
107 }
#define M_PI_2
Definition: MathConstants.h:40
double theta() const
Returns polar angle.
kvector_t getKf(double x, double y) const
Returns outgoing wavevector Kf for in-pixel coordinates x,y.

References getKf(), M_PI_2, and BasicVector3D< T >::theta().

Referenced by getAlphaMean().

Here is the call graph for this function:

◆ getPhi()

double SimulationElement::getPhi ( double  x,
double  y 
) const

Definition at line 109 of file SimulationElement.cpp.

110 {
111  return getKf(x, y).phi();
112 }
double phi() const
Returns azimuth angle.

References getKf(), and BasicVector3D< T >::phi().

Referenced by getPhiMean().

Here is the call graph for this function:

◆ setSpecular()

void SimulationElement::setSpecular ( bool  is_specular)
inline

Set specularity indication on/off.

Definition at line 80 of file SimulationElement.h.

80 { m_is_specular = is_specular; }

References m_is_specular.

Referenced by Simulation2D::generateSimulationElements().

◆ isSpecular()

bool SimulationElement::isSpecular ( ) const
inline

Tells if simulation element corresponds to a specular peak.

Definition at line 83 of file SimulationElement.h.

83 { return m_is_specular; }

References m_is_specular.

Referenced by GISASSpecularComputation::compute().

◆ swapContent()

void SimulationElement::swapContent ( SimulationElement other)
private

Definition at line 91 of file SimulationElement.cpp.

92 {
96  std::swap(m_phi_i, other.m_phi_i);
97  std::swap(m_k_i, other.m_k_i);
100  std::swap(mP_pixel, other.mP_pixel);
102 }
void swap(OutputDataIterator< TValue, TContainer > &left, OutputDataIterator< TValue, TContainer > &right)
make Swappable
void swapContent(PolarizationHandler &other)

References m_alpha_i, m_intensity, m_is_specular, m_k_i, m_mean_kf, m_phi_i, m_polarization, m_wavelength, mP_pixel, swap(), and PolarizationHandler::swapContent().

Referenced by operator=().

Here is the call graph for this function:

◆ getKf()

kvector_t SimulationElement::getKf ( double  x,
double  y 
) const
private

Returns outgoing wavevector Kf for in-pixel coordinates x,y.

In-pixel coordinates take values from 0 to 1.

Definition at line 74 of file SimulationElement.cpp.

75 {
76  return mP_pixel->getK(x, y, m_wavelength);
77 }

References m_wavelength, and mP_pixel.

Referenced by getAlpha(), and getPhi().

Member Data Documentation

◆ m_polarization

PolarizationHandler SimulationElement::m_polarization
private

◆ m_wavelength

double SimulationElement::m_wavelength
private

Definition at line 91 of file SimulationElement.h.

Referenced by getKf(), getQ(), getWavelength(), SimulationElement(), and swapContent().

◆ m_alpha_i

double SimulationElement::m_alpha_i
private

Definition at line 91 of file SimulationElement.h.

Referenced by getAlphaI(), and swapContent().

◆ m_phi_i

double SimulationElement::m_phi_i
private

wavelength and angles of beam

Definition at line 91 of file SimulationElement.h.

Referenced by getPhiI(), and swapContent().

◆ m_k_i

kvector_t SimulationElement::m_k_i
private

cached value of k_i

Definition at line 92 of file SimulationElement.h.

Referenced by getKi(), and swapContent().

◆ m_mean_kf

kvector_t SimulationElement::m_mean_kf
private

cached value of mean_kf

Definition at line 93 of file SimulationElement.h.

Referenced by getMeanKf(), SimulationElement(), and swapContent().

◆ m_intensity

double SimulationElement::m_intensity
private

simulated intensity for detector cell

Definition at line 94 of file SimulationElement.h.

Referenced by addIntensity(), getIntensity(), setIntensity(), and swapContent().

◆ mP_pixel

std::unique_ptr<IPixel> SimulationElement::mP_pixel
private

◆ m_is_specular

bool SimulationElement::m_is_specular
private

Definition at line 96 of file SimulationElement.h.

Referenced by isSpecular(), setSpecular(), and swapContent().


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