BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
QzScan Class Reference

Description

Scan type with z-components of scattering vector as coordinate values. Wavelength and incident angles are not accessible separately.

Definition at line 28 of file QzScan.h.

Inheritance diagram for QzScan:
[legend]
Collaboration diagram for QzScan:
[legend]

Public Member Functions

 QzScan (const IAxis &qs_nm)
 
 QzScan (int nbins, double qz_min, double qz_max)
 Sets q-defined specular scan. Accepts either numpy array of q-values sorted in ascending order or an IAxis object with q-values. Alternatively an axis can be defined in-place, then the first passed parameter is the number of bins, second - minimum on-axis q-value, third - maximum on-axis q_value. More...
 
 QzScan (std::vector< double > qs_nm)
 Accepts qz-value vector (in inverse nm) More...
 
 ~QzScan () override
 
const PolFilteranalyzer () const
 
QzScanclone () const override
 
const IAxiscoordinateAxis () const override
 Returns coordinate axis assigned to the data holder. More...
 
CoordSystem1DcreateCoordSystem () const override
 
std::vector< double > createIntensities (const std::vector< SpecularElement > &eles) const override
 Returns intensity vector corresponding to convolution of given simulation elements. More...
 
std::vector< double > footprint (size_t i, size_t n_elements) const override
 Returns footprint correction factor for a range of simulation elements of size n_elements and starting from element with index i. More...
 
const IFootprintFactorfootprintFactor () const override
 Returns IFootprintFactor object pointer. More...
 
std::vector< SpecularElementgenerateElements () const override
 Generates simulation elements for specular simulations. More...
 
size_t numberOfElements () const override
 Returns the number of simulation elements. More...
 
double offset () const
 
bool polarized () const
 
PolMatrices polMatrices () const
 
const ScanResolutionresolution () const
 
void setAbsoluteQResolution (const IRangedDistribution &distr, const std::vector< double > &std_dev)
 Sets qz resolution values via IRangedDistribution and values of standard deviations. std_dev can be either single-valued or a numpy array. In the latter case the length of the array should coinside with the length of the qz-axis. More...
 
void setAbsoluteQResolution (const IRangedDistribution &distr, double std_dev)
 
void setAnalyzer (R3 direction, double efficiency, double total_transmission)
 Sets the polarization analyzer characteristics of the detector. More...
 
void setOffset (double offset)
 
void setPolarization (R3 bloch_vector)
 Sets the polarization density matrix according to the given Bloch vector. More...
 
void setQResolution (const ScanResolution &resolution)
 Sets q resolution values via ScanResolution object. More...
 
void setRelativeQResolution (const IRangedDistribution &distr, const std::vector< double > &rel_dev)
 Sets qz resolution values via IRangedDistribution and values of relative deviations (that is, rel_dev equals standard deviation divided by the mean value). rel_dev can be either single-valued or a numpy array. In the latter case the length of the array should coinside with the length of the qz-axis. More...
 
void setRelativeQResolution (const IRangedDistribution &distr, double rel_dev)
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
double wavelength () const override
 

Protected Attributes

std::unique_ptr< R3 > m_beamPolarization
 Bloch vector encoding the beam's polarization. More...
 
std::unique_ptr< PolFilterm_polAnalyzer
 

Private Member Functions

 QzScan (IAxis *qs_nm)
 
std::vector< std::vector< ParameterSample > > applyQResolution () const
 
std::vector< double > generateQzVector () const
 

Private Attributes

double m_offset = 0.
 
const std::unique_ptr< IAxism_qs
 
std::unique_ptr< ScanResolutionm_resolution
 

Constructor & Destructor Documentation

◆ QzScan() [1/4]

QzScan::QzScan ( std::vector< double >  qs_nm)

Accepts qz-value vector (in inverse nm)

Definition at line 39 of file QzScan.cpp.

40  : QzScan(new PointwiseAxis("qs", std::move(qs_nm)))
41 {
42 }
Axis containing arbitrary (non-equidistant) coordinate values. Lower boundary of the first bin and up...
Definition: PointwiseAxis.h:33
QzScan(std::vector< double > qs_nm)
Accepts qz-value vector (in inverse nm)
Definition: QzScan.cpp:39

Referenced by clone().

◆ QzScan() [2/4]

QzScan::QzScan ( const IAxis qs_nm)

Definition at line 44 of file QzScan.cpp.

45  : QzScan(qs_nm.clone())
46 {
47 }
virtual IAxis * clone() const =0

◆ QzScan() [3/4]

QzScan::QzScan ( int  nbins,
double  qz_min,
double  qz_max 
)

Sets q-defined specular scan. Accepts either numpy array of q-values sorted in ascending order or an IAxis object with q-values. Alternatively an axis can be defined in-place, then the first passed parameter is the number of bins, second - minimum on-axis q-value, third - maximum on-axis q_value.

Definition at line 49 of file QzScan.cpp.

50  : QzScan(new FixedBinAxis("qs", nbins, qz_min, qz_max))
51 {
52 }
Axis with fixed bin size.
Definition: FixedBinAxis.h:23

◆ ~QzScan()

QzScan::~QzScan ( )
overridedefault

◆ QzScan() [4/4]

QzScan::QzScan ( IAxis qs_nm)
private

Definition at line 25 of file QzScan.cpp.

26  : m_qs(std::move(qs_nm))
28 {
29  std::vector<double> axis_values = m_qs->binCenters();
30  if (!std::is_sorted(axis_values.begin(), axis_values.end()))
31  throw std::runtime_error("Error in QzScan::checkInitialization: q-vector values shall "
32  "be sorted in ascending order.");
33 
34  if (axis_values.front() < 0)
35  throw std::runtime_error("Error in QzScan::checkInitialization: q-vector values are out "
36  "of acceptable range.");
37 }
const std::unique_ptr< IAxis > m_qs
Definition: QzScan.h:97
std::unique_ptr< ScanResolution > m_resolution
Definition: QzScan.h:98
static ScanResolution * scanEmptyResolution()

References m_qs.

Member Function Documentation

◆ analyzer()

const PolFilter* ISpecularScan::analyzer ( ) const
inlineinherited

Definition at line 45 of file ISpecularScan.h.

45 { return m_polAnalyzer.get(); }
std::unique_ptr< PolFilter > m_polAnalyzer
Definition: ISpecularScan.h:78

References ISpecularScan::m_polAnalyzer.

◆ applyQResolution()

std::vector< std::vector< ParameterSample > > QzScan::applyQResolution ( ) const
private

Definition at line 167 of file QzScan.cpp.

168 {
169  return m_resolution->generateSamples(m_qs->binCenters());
170 }

References m_qs, and m_resolution.

Referenced by createIntensities(), and generateQzVector().

◆ clone()

QzScan * QzScan::clone ( ) const
overridevirtual

Implements ISpecularScan.

Definition at line 56 of file QzScan.cpp.

57 {
58  auto* result = new QzScan(*m_qs);
59  result->setQResolution(*m_resolution);
60  result->setOffset(m_offset);
61  // TODO merge with same code in AlphaScan
63  result->m_beamPolarization.reset(new R3(*m_beamPolarization));
64  if (m_polAnalyzer)
65  result->m_polAnalyzer.reset(new PolFilter(*m_polAnalyzer));
66  return result;
67 }
std::unique_ptr< R3 > m_beamPolarization
Bloch vector encoding the beam's polarization.
Definition: ISpecularScan.h:77
Detector properties (efficiency, transmission).
Definition: PolFilter.h:27
double m_offset
Definition: QzScan.h:100

References QzScan(), ISpecularScan::m_beamPolarization, m_offset, ISpecularScan::m_polAnalyzer, m_qs, and m_resolution.

Referenced by createCoordSystem().

Here is the call graph for this function:

◆ coordinateAxis()

const IAxis* QzScan::coordinateAxis ( ) const
inlineoverridevirtual

Returns coordinate axis assigned to the data holder.

Implements ISpecularScan.

Definition at line 51 of file QzScan.h.

51 { return m_qs.get(); }

References m_qs.

Referenced by createCoordSystem().

◆ createCoordSystem()

CoordSystem1D * QzScan::createCoordSystem ( ) const
overridevirtual

Implements ISpecularScan.

Definition at line 97 of file QzScan.cpp.

98 {
100 }
const IAxis * coordinateAxis() const override
Returns coordinate axis assigned to the data holder.
Definition: QzScan.h:51
QzScan * clone() const override
Definition: QzScan.cpp:56
Conversion of axis units for the case of q-defined reflectometry.
Definition: CoordSystem1D.h:99

References clone(), and coordinateAxis().

Here is the call graph for this function:

◆ createIntensities()

std::vector< double > QzScan::createIntensities ( const std::vector< SpecularElement > &  eles) const
overridevirtual

Returns intensity vector corresponding to convolution of given simulation elements.

Implements ISpecularScan.

Definition at line 102 of file QzScan.cpp.

103 {
104  const size_t axis_size = m_qs->size();
105  std::vector<double> result(axis_size, 0.0);
106 
107  const auto samples = applyQResolution();
108 
109  size_t elem_pos = 0;
110  for (size_t i = 0; i < axis_size; ++i) {
111  double& current = result[i];
112  for (size_t j = 0, size = samples[i].size(); j < size; ++j) {
113  current += eles[elem_pos].intensity() * samples[i][j].weight;
114  ++elem_pos;
115  }
116  }
117  return result;
118 }
std::vector< std::vector< ParameterSample > > applyQResolution() const
Definition: QzScan.cpp:167

References applyQResolution(), and m_qs.

Here is the call graph for this function:

◆ footprint()

std::vector< double > QzScan::footprint ( size_t  i,
size_t  n_elements 
) const
overridevirtual

Returns footprint correction factor for a range of simulation elements of size n_elements and starting from element with index i.

Implements ISpecularScan.

Definition at line 83 of file QzScan.cpp.

84 {
85  if (i + n_elements > numberOfElements())
86  throw std::runtime_error("Error in QzScan::footprint: given index exceeds the "
87  "number of simulation elements");
88  return std::vector<double>(n_elements, 1.0);
89 }
size_t numberOfElements() const override
Returns the number of simulation elements.
Definition: QzScan.cpp:92

References numberOfElements().

Here is the call graph for this function:

◆ footprintFactor()

const IFootprintFactor* QzScan::footprintFactor ( ) const
inlineoverridevirtual

Returns IFootprintFactor object pointer.

Implements ISpecularScan.

Definition at line 54 of file QzScan.h.

54 { return nullptr; }

◆ generateElements()

std::vector< SpecularElement > QzScan::generateElements ( ) const
overridevirtual

Generates simulation elements for specular simulations.

Implements ISpecularScan.

Definition at line 70 of file QzScan.cpp.

71 {
72  const std::vector<double> qz = generateQzVector();
73 
74  std::vector<SpecularElement> result;
75  result.reserve(qz.size());
76  for (size_t i = 0, size = qz.size(); i < size; ++i)
77  result.emplace_back(
78  SpecularElement::FromQzScan(-(qz[i] + m_offset) / 2.0, polMatrices(), qz[i] >= 0));
79 
80  return result;
81 }
PolMatrices polMatrices() const
std::vector< double > generateQzVector() const
Definition: QzScan.cpp:155
static SpecularElement FromQzScan(double kz, const PolMatrices &polMatrices, bool computable)

References SpecularElement::FromQzScan(), generateQzVector(), m_offset, and ISpecularScan::polMatrices().

Here is the call graph for this function:

◆ generateQzVector()

std::vector< double > QzScan::generateQzVector ( ) const
private

Definition at line 155 of file QzScan.cpp.

156 {
157  const auto samples = applyQResolution();
158 
159  std::vector<double> result;
160  result.reserve(numberOfElements());
161  for (size_t i = 0, size_out = samples.size(); i < size_out; ++i)
162  for (size_t j = 0, size_in = samples[i].size(); j < size_in; ++j)
163  result.push_back(samples[i][j].value);
164  return result;
165 }

References applyQResolution(), and numberOfElements().

Referenced by generateElements().

Here is the call graph for this function:

◆ numberOfElements()

size_t QzScan::numberOfElements ( ) const
overridevirtual

Returns the number of simulation elements.

Implements ISpecularScan.

Definition at line 92 of file QzScan.cpp.

93 {
94  return m_qs->size() * m_resolution->nSamples();
95 }

References m_qs, and m_resolution.

Referenced by footprint(), and generateQzVector().

◆ offset()

double QzScan::offset ( ) const
inline

Definition at line 89 of file QzScan.h.

89 { return m_offset; }

References m_offset.

Referenced by setOffset().

◆ polarized()

bool ISpecularScan::polarized ( ) const
inherited

Definition at line 31 of file ISpecularScan.cpp.

32 {
34 }

References ISpecularScan::m_beamPolarization, and ISpecularScan::m_polAnalyzer.

◆ polMatrices()

PolMatrices ISpecularScan::polMatrices ( ) const
inherited

Definition at line 36 of file ISpecularScan.cpp.

37 {
38  PolMatrices result;
41  if (m_polAnalyzer)
42  result.setAnalyzerMatrix(m_polAnalyzer->matrix());
43  return result;
44 }
Convenience class for handling polarization density matrix and polarization analyzer operator.
Definition: PolMatrices.h:29
void setAnalyzerMatrix(const SpinMatrix &analyzer)
Sets the polarization analyzer operator (in spin basis along z-axis)
Definition: PolMatrices.h:41
void setPolarizerMatrix(const SpinMatrix &polarization)
Sets the polarization density matrix (in spin basis along z-axis)
Definition: PolMatrices.h:35
static SpinMatrix FromBlochVector(const R3 &v)
Constructs matrix (I+v*s)/2, where s is the Pauli vector.
Definition: SpinMatrix.cpp:41

References SpinMatrix::FromBlochVector(), ISpecularScan::m_beamPolarization, ISpecularScan::m_polAnalyzer, PolMatrices::setAnalyzerMatrix(), and PolMatrices::setPolarizerMatrix().

Referenced by AlphaScan::generateElements(), and generateElements().

Here is the call graph for this function:

◆ resolution()

const ScanResolution* QzScan::resolution ( ) const
inline

Definition at line 42 of file QzScan.h.

42 { return m_resolution.get(); }

References m_resolution.

Referenced by setAbsoluteQResolution(), setQResolution(), and setRelativeQResolution().

◆ setAbsoluteQResolution() [1/2]

void QzScan::setAbsoluteQResolution ( const IRangedDistribution distr,
const std::vector< double > &  std_dev 
)

Sets qz resolution values via IRangedDistribution and values of standard deviations. std_dev can be either single-valued or a numpy array. In the latter case the length of the array should coinside with the length of the qz-axis.

Definition at line 147 of file QzScan.cpp.

149 {
150  std::unique_ptr<ScanResolution> resolution(
153 }
void setQResolution(const ScanResolution &resolution)
Sets q resolution values via ScanResolution object.
Definition: QzScan.cpp:120
const ScanResolution * resolution() const
Definition: QzScan.h:42
static ScanResolution * scanAbsoluteResolution(const IRangedDistribution &distr, double stddev)

References resolution(), ScanResolution::scanAbsoluteResolution(), and setQResolution().

Here is the call graph for this function:

◆ setAbsoluteQResolution() [2/2]

void QzScan::setAbsoluteQResolution ( const IRangedDistribution distr,
double  std_dev 
)

Definition at line 140 of file QzScan.cpp.

141 {
142  std::unique_ptr<ScanResolution> resolution(
145 }

References resolution(), ScanResolution::scanAbsoluteResolution(), and setQResolution().

Here is the call graph for this function:

◆ setAnalyzer()

void ISpecularScan::setAnalyzer ( R3  direction,
double  efficiency,
double  total_transmission 
)
inherited

Sets the polarization analyzer characteristics of the detector.

Definition at line 26 of file ISpecularScan.cpp.

27 {
28  m_polAnalyzer.reset(new PolFilter(direction, efficiency, total_transmission));
29 }

References ISpecularScan::m_polAnalyzer.

◆ setOffset()

void QzScan::setOffset ( double  offset)
inline

Definition at line 88 of file QzScan.h.

88 { m_offset = offset; }
double offset() const
Definition: QzScan.h:89

References m_offset, and offset().

Here is the call graph for this function:

◆ setPolarization()

void ISpecularScan::setPolarization ( R3  bloch_vector)
inherited

Sets the polarization density matrix according to the given Bloch vector.

Definition at line 21 of file ISpecularScan.cpp.

22 {
23  m_beamPolarization.reset(new R3(bloch_vector));
24 }

References ISpecularScan::m_beamPolarization.

◆ setQResolution()

void QzScan::setQResolution ( const ScanResolution resolution)

Sets q resolution values via ScanResolution object.

Definition at line 120 of file QzScan.cpp.

121 {
122  m_resolution.reset(resolution.clone());
123 }
ScanResolution * clone() const override=0

References ScanResolution::clone(), m_resolution, and resolution().

Referenced by setAbsoluteQResolution(), and setRelativeQResolution().

Here is the call graph for this function:

◆ setRelativeQResolution() [1/2]

void QzScan::setRelativeQResolution ( const IRangedDistribution distr,
const std::vector< double > &  rel_dev 
)

Sets qz resolution values via IRangedDistribution and values of relative deviations (that is, rel_dev equals standard deviation divided by the mean value). rel_dev can be either single-valued or a numpy array. In the latter case the length of the array should coinside with the length of the qz-axis.

Definition at line 132 of file QzScan.cpp.

134 {
135  std::unique_ptr<ScanResolution> resolution(
138 }
static ScanResolution * scanRelativeResolution(const IRangedDistribution &distr, double stddev)

References resolution(), ScanResolution::scanRelativeResolution(), and setQResolution().

Here is the call graph for this function:

◆ setRelativeQResolution() [2/2]

void QzScan::setRelativeQResolution ( const IRangedDistribution distr,
double  rel_dev 
)

Definition at line 125 of file QzScan.cpp.

126 {
127  std::unique_ptr<ScanResolution> resolution(
130 }

References resolution(), ScanResolution::scanRelativeResolution(), and setQResolution().

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

Used for Python overriding of clone (see swig/tweaks.py)

Definition at line 32 of file ICloneable.h.

◆ wavelength()

double QzScan::wavelength ( ) const
inlineoverridevirtual

Implements ISpecularScan.

Definition at line 44 of file QzScan.h.

44 { return 1.0; } // TODO (ISSUE #303)

Member Data Documentation

◆ m_beamPolarization

std::unique_ptr<R3> ISpecularScan::m_beamPolarization
protectedinherited

Bloch vector encoding the beam's polarization.

Definition at line 77 of file ISpecularScan.h.

Referenced by AlphaScan::clone(), clone(), ISpecularScan::polarized(), ISpecularScan::polMatrices(), and ISpecularScan::setPolarization().

◆ m_offset

double QzScan::m_offset = 0.
private

Definition at line 100 of file QzScan.h.

Referenced by clone(), generateElements(), offset(), and setOffset().

◆ m_polAnalyzer

std::unique_ptr<PolFilter> ISpecularScan::m_polAnalyzer
protectedinherited

◆ m_qs

const std::unique_ptr<IAxis> QzScan::m_qs
private

◆ m_resolution

std::unique_ptr<ScanResolution> QzScan::m_resolution
private

Definition at line 98 of file QzScan.h.

Referenced by applyQResolution(), clone(), numberOfElements(), resolution(), and setQResolution().


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