BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ConvolutionDetectorResolution Class Reference

Convolutes the intensity in 1 or 2 dimensions with a resolution function. More...

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

Public Types

typedef double(* cumulative_DF_1d) (double)
 

Public Member Functions

 ConvolutionDetectorResolution (const IResolutionFunction2D &p_res_function_2d)
 Constructor taking a 2 dimensional resolution function as argument. More...
 
 ConvolutionDetectorResolution (cumulative_DF_1d res_function_1d)
 Constructor taking a 1 dimensional resolution function as argument. More...
 
virtual ~ConvolutionDetectorResolution ()
 
void accept (INodeVisitor *visitor) const final
 Calls the INodeVisitor's visit method. More...
 
virtual void applyDetectorResolution (OutputData< double > *p_intensity_map) const
 Convolve given intensities with the encapsulated resolution. More...
 
void applyDetectorResolutionPol (OutputData< Eigen::Matrix2d > *p_matrix_intensity) const
 Applies the detector resolution to the matrix-valued intensity data. More...
 
virtual ConvolutionDetectorResolutionclone () const
 
int copyNumber (const INode *node) const
 Returns copyNumber of child, which takes into account existence of children with same name. More...
 
ParameterPoolcreateParameterTree () const
 Creates new parameter pool, with all local parameters and those of its children. More...
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number. More...
 
std::vector< const INode * > getChildren () const
 Returns a vector of children. More...
 
const std::string & getName () const
 
const IResolutionFunction2DgetResolutionFunction2D () const
 
virtual void onChange ()
 Action to be taken in inherited class when a parameter has changed. More...
 
RealParameterparameter (const std::string &name) const
 Returns parameter with given 'name'. More...
 
ParameterPoolparameterPool () const
 Returns pointer to the parameter pool. More...
 
std::string parametersToString () const
 Returns multiline string representing available parameters. More...
 
INodeparent ()
 
const INodeparent () const
 
std::vector< const INode * > progeny () const
 Returns a vector of all descendants. More...
 
void registerChild (INode *node)
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
void setParameterValue (const std::string &name, double value)
 
virtual void setParent (const INode *newParent)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
virtual std::string treeToString () const
 Returns multiline string representing tree structure below the node. More...
 

Static Public Member Functions

static std::string XComponentName (const std::string &base_name)
 
static std::string YComponentName (const std::string &base_name)
 
static std::string ZComponentName (const std::string &base_name)
 

Protected Member Functions

 ConvolutionDetectorResolution (const ConvolutionDetectorResolution &other)
 

Protected Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void apply1dConvolution (OutputData< double > *p_intensity_map) const
 
void apply2dConvolution (OutputData< double > *p_intensity_map) const
 
double getIntegratedPDF1d (double x, double step) const
 
double getIntegratedPDF2d (double x, double step_x, double y, double step_y) const
 
void setResolutionFunction (const IResolutionFunction2D &resFunc)
 

Private Attributes

size_t m_dimension
 
std::string m_name
 
const INodem_parent {nullptr}
 
std::unique_ptr< ParameterPoolm_pool
 parameter pool (kind of pointer-to-implementation) More...
 
cumulative_DF_1d m_res_function_1d
 
std::unique_ptr< IResolutionFunction2Dm_res_function_2d
 

Detailed Description

Convolutes the intensity in 1 or 2 dimensions with a resolution function.

Limitation: this class assumes that the data points are evenly distributed on each axis

Definition at line 31 of file ConvolutionDetectorResolution.h.

Member Typedef Documentation

◆ cumulative_DF_1d

typedef double(* ConvolutionDetectorResolution::cumulative_DF_1d) (double)

Definition at line 33 of file ConvolutionDetectorResolution.h.

Constructor & Destructor Documentation

◆ ConvolutionDetectorResolution() [1/3]

ConvolutionDetectorResolution::ConvolutionDetectorResolution ( cumulative_DF_1d  res_function_1d)

Constructor taking a 1 dimensional resolution function as argument.

Definition at line 18 of file ConvolutionDetectorResolution.cpp.

19  : m_dimension(1), m_res_function_1d(res_function_1d)
20 {
21  setName("ConvolutionDetectorResolution");
22 }
void setName(const std::string &name)

References IParametricComponent::setName().

Referenced by clone().

Here is the call graph for this function:

◆ ConvolutionDetectorResolution() [2/3]

ConvolutionDetectorResolution::ConvolutionDetectorResolution ( const IResolutionFunction2D p_res_function_2d)

Constructor taking a 2 dimensional resolution function as argument.

Definition at line 24 of file ConvolutionDetectorResolution.cpp.

27 {
28  setName("ConvolutionDetectorResolution");
29  setResolutionFunction(p_res_function_2d);
30 }
void setResolutionFunction(const IResolutionFunction2D &resFunc)

References IParametricComponent::setName(), and setResolutionFunction().

Here is the call graph for this function:

◆ ~ConvolutionDetectorResolution()

ConvolutionDetectorResolution::~ConvolutionDetectorResolution ( )
virtualdefault

◆ ConvolutionDetectorResolution() [3/3]

ConvolutionDetectorResolution::ConvolutionDetectorResolution ( const ConvolutionDetectorResolution other)
protected

Definition at line 34 of file ConvolutionDetectorResolution.cpp.

36 {
37  m_dimension = other.m_dimension;
39  if (other.m_res_function_2d)
41  setName(other.getName());
42 }
std::unique_ptr< IResolutionFunction2D > m_res_function_2d
const std::string & getName() const

References IParametricComponent::getName(), m_dimension, m_res_function_1d, m_res_function_2d, IParametricComponent::setName(), and setResolutionFunction().

Here is the call graph for this function:

Member Function Documentation

◆ accept()

void ConvolutionDetectorResolution::accept ( INodeVisitor visitor) const
inlinefinalvirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 48 of file ConvolutionDetectorResolution.h.

48 { visitor->visit(this); }
virtual void visit(const BasicLattice2D *)
Definition: INodeVisitor.h:151

◆ apply1dConvolution()

void ConvolutionDetectorResolution::apply1dConvolution ( OutputData< double > *  p_intensity_map) const
private

Definition at line 82 of file ConvolutionDetectorResolution.cpp.

83 {
84  if (m_res_function_1d == 0)
85  throw std::runtime_error("ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
86  "No 1d resolution function present for convolution of 1d data.");
87  if (p_intensity_map->rank() != 1)
88  throw std::runtime_error(
89  "ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
90  "Number of axes for intensity map does not correspond to the dimension of the map.");
91  const IAxis& axis = p_intensity_map->axis(0);
92  // Construct source vector from original intensity map
93  std::vector<double> source_vector = p_intensity_map->getRawDataVector();
94  size_t data_size = source_vector.size();
95  if (data_size < 2)
96  return; // No convolution for sets of zero or one element
97  // Construct kernel vector from resolution function
98  if (axis.size() != data_size)
99  throw std::runtime_error(
100  "ConvolutionDetectorResolution::apply1dConvolution() -> Error! "
101  "Size of axis for intensity map does not correspond to size of data in the map.");
102  double step_size = std::abs(axis[0] - axis[axis.size() - 1]) / (data_size - 1);
103  double mid_value = axis[axis.size() / 2]; // because Convolve expects zero at midpoint
104  std::vector<double> kernel;
105  for (size_t index = 0; index < data_size; ++index) {
106  kernel.push_back(getIntegratedPDF1d(axis[index] - mid_value, step_size));
107  }
108  // Calculate convolution
109  std::vector<double> result;
110  Convolve().fftconvolve(source_vector, kernel, result);
111  // Truncate negative values that can arise because of finite precision of Fourier Transform
112  std::for_each(result.begin(), result.end(), [](double& val) { val = std::max(0.0, val); });
113  // Populate intensity map with results
114  p_intensity_map->setRawDataVector(result);
115 }
double getIntegratedPDF1d(double x, double step) const
Convolution of two real vectors (in 1D or 2D) using Fast Fourier Transform.
Definition: Convolve.h:38
void fftconvolve(const double1d_t &source, const double1d_t &kernel, double1d_t &result)
convolution in 1D
Definition: Convolve.cpp:138
Interface for one-dimensional axes.
Definition: IAxis.h:25
virtual size_t size() const =0
retrieve the number of bins
size_t rank() const
Returns number of dimensions.
Definition: OutputData.h:56
std::vector< T > getRawDataVector() const
Returns copy of raw data vector.
Definition: OutputData.h:334
const IAxis & axis(size_t serial_number) const
returns axis with given serial number
Definition: OutputData.h:318
void setRawDataVector(const std::vector< T > &data_vector)
Sets new values to raw data vector.
Definition: OutputData.h:556

References OutputData< T >::axis(), Convolve::fftconvolve(), getIntegratedPDF1d(), OutputData< T >::getRawDataVector(), m_res_function_1d, OutputData< T >::rank(), OutputData< T >::setRawDataVector(), and IAxis::size().

Referenced by applyDetectorResolution().

Here is the call graph for this function:

◆ apply2dConvolution()

void ConvolutionDetectorResolution::apply2dConvolution ( OutputData< double > *  p_intensity_map) const
private

Definition at line 117 of file ConvolutionDetectorResolution.cpp.

118 {
119  if (m_res_function_2d == 0)
120  throw std::runtime_error("ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
121  "No 2d resolution function present for convolution of 2d data.");
122  if (p_intensity_map->rank() != 2)
123  throw std::runtime_error(
124  "ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
125  "Number of axes for intensity map does not correspond to the dimension of the map.");
126  const IAxis& axis_1 = p_intensity_map->axis(0);
127  const IAxis& axis_2 = p_intensity_map->axis(1);
128  size_t axis_size_1 = axis_1.size();
129  size_t axis_size_2 = axis_2.size();
130  if (axis_size_1 < 2 || axis_size_2 < 2)
131  return; // No 2d convolution for 1d data
132  // Construct source vector array from original intensity map
133  std::vector<double> raw_source_vector = p_intensity_map->getRawDataVector();
134  std::vector<std::vector<double>> source;
135  size_t raw_data_size = raw_source_vector.size();
136  if (raw_data_size != axis_size_1 * axis_size_2)
137  throw std::runtime_error(
138  "ConvolutionDetectorResolution::apply2dConvolution() -> Error! "
139  "Intensity map data size does not match the product of its axes' sizes");
140  for (auto it = raw_source_vector.begin(); it != raw_source_vector.end(); it += axis_size_2) {
141  std::vector<double> row_vector(it, it + axis_size_2);
142  source.push_back(row_vector);
143  }
144  // Construct kernel vector from resolution function
145  std::vector<std::vector<double>> kernel;
146  kernel.resize(axis_size_1);
147  double mid_value_1 = axis_1[axis_size_1 / 2]; // because Convolve expects zero at midpoint
148  double mid_value_2 = axis_2[axis_size_2 / 2]; // because Convolve expects zero at midpoint
149  double step_size_1 = std::abs(axis_1[0] - axis_1[axis_size_1 - 1]) / (axis_size_1 - 1);
150  double step_size_2 = std::abs(axis_2[0] - axis_2[axis_size_2 - 1]) / (axis_size_2 - 1);
151  for (size_t index_1 = 0; index_1 < axis_size_1; ++index_1) {
152  double value_1 = axis_1[index_1] - mid_value_1;
153  std::vector<double> row_vector;
154  row_vector.resize(axis_size_2, 0.0);
155  for (size_t index_2 = 0; index_2 < axis_size_2; ++index_2) {
156  double value_2 = axis_2[index_2] - mid_value_2;
157  double z_value = getIntegratedPDF2d(value_1, step_size_1, value_2, step_size_2);
158  row_vector[index_2] = z_value;
159  }
160  kernel[index_1] = row_vector;
161  }
162  // Calculate convolution
163  std::vector<std::vector<double>> result;
164  Convolve().fftconvolve(source, kernel, result);
165  // Populate intensity map with results
166  std::vector<double> result_vector;
167  for (size_t index_1 = 0; index_1 < axis_size_1; ++index_1) {
168  for (size_t index_2 = 0; index_2 < axis_size_2; ++index_2) {
169  double value = result[index_1][index_2];
170  result_vector.push_back(value);
171  }
172  }
173  // Truncate negative values that can arise because of finite precision of Fourier Transform
174  std::for_each(result_vector.begin(), result_vector.end(),
175  [](double& val) { val = std::max(0.0, val); });
176  for (auto it = p_intensity_map->begin(); it != p_intensity_map->end(); ++it)
177  (*it) = result_vector[it.getIndex()];
178 }
double getIntegratedPDF2d(double x, double step_x, double y, double step_y) const
iterator end()
Returns read/write iterator that points to the one past last element.
Definition: OutputData.h:93
iterator begin()
Returns read/write iterator that points to the first element.
Definition: OutputData.h:343

References OutputData< T >::axis(), OutputData< T >::begin(), OutputData< T >::end(), Convolve::fftconvolve(), getIntegratedPDF2d(), OutputData< T >::getRawDataVector(), m_res_function_2d, OutputData< T >::rank(), and IAxis::size().

Referenced by applyDetectorResolution().

Here is the call graph for this function:

◆ applyDetectorResolution()

void ConvolutionDetectorResolution::applyDetectorResolution ( OutputData< double > *  p_intensity_map) const
virtual

Convolve given intensities with the encapsulated resolution.

Implements IDetectorResolution.

Definition at line 54 of file ConvolutionDetectorResolution.cpp.

56 {
57  if (p_intensity_map->rank() != m_dimension) {
58  throw std::runtime_error(
59  "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! "
60  "Intensity map must have same dimension as detector resolution function.");
61  }
62  switch (m_dimension) {
63  case 1:
64  apply1dConvolution(p_intensity_map);
65  break;
66  case 2:
67  apply2dConvolution(p_intensity_map);
68  break;
69  default:
70  throw std::runtime_error(
71  "ConvolutionDetectorResolution::applyDetectorResolution() -> Error! "
72  "Class ConvolutionDetectorResolution must be initialized with dimension 1 or 2.");
73  }
74 }
void apply1dConvolution(OutputData< double > *p_intensity_map) const
void apply2dConvolution(OutputData< double > *p_intensity_map) const

References apply1dConvolution(), apply2dConvolution(), m_dimension, and OutputData< T >::rank().

Here is the call graph for this function:

◆ applyDetectorResolutionPol()

void IDetectorResolution::applyDetectorResolutionPol ( OutputData< Eigen::Matrix2d > *  p_matrix_intensity) const
inherited

Applies the detector resolution to the matrix-valued intensity data.

◆ clone()

ConvolutionDetectorResolution * ConvolutionDetectorResolution::clone ( ) const
virtual

Implements IDetectorResolution.

Definition at line 44 of file ConvolutionDetectorResolution.cpp.

45 {
46  return new ConvolutionDetectorResolution(*this);
47 }
ConvolutionDetectorResolution(cumulative_DF_1d res_function_1d)
Constructor taking a 1 dimensional resolution function as argument.

References ConvolutionDetectorResolution().

Here is the call graph for this function:

◆ copyNumber()

int INode::copyNumber ( const INode node) const
inherited

Returns copyNumber of child, which takes into account existence of children with same name.

Definition at line 94 of file INode.cpp.

95 {
96  if (node->parent() != this)
97  return -1;
98 
99  int result(-1), count(0);
100  for (auto child : getChildren()) {
101 
102  if (child == nullptr)
103  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
104 
105  if (child == node)
106  result = count;
107 
108  if (child->getName() == node->getName())
109  ++count;
110  }
111 
112  return count > 1 ? result : -1;
113 }
const INode * parent() const
Definition: INode.cpp:84
virtual std::vector< const INode * > getChildren() const
Returns a vector of children.
Definition: INode.cpp:63

References INode::getChildren(), IParametricComponent::getName(), and INode::parent().

Referenced by INode::displayName().

Here is the call graph for this function:

◆ createParameterTree()

ParameterPool * INode::createParameterTree ( ) const
virtualinherited

Creates new parameter pool, with all local parameters and those of its children.

Reimplemented from IParametricComponent.

Definition at line 126 of file INode.cpp.

127 {
128  std::unique_ptr<ParameterPool> result(new ParameterPool);
129 
130  for (const INode* child : progeny()) {
131  const std::string path = NodeUtils::nodePath(child, parent()) + "/";
132  child->parameterPool()->copyToExternalPool(path, result.get());
133  }
134 
135  return result.release();
136 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49
std::vector< const INode * > progeny() const
Returns a vector of all descendants.
Definition: INode.cpp:68
Container with parameters for IParametricComponent object.
Definition: ParameterPool.h:29
std::string nodePath(const INode *node, const INode *root=nullptr)
Returns path composed of node's displayName, with respect to root node.
Definition: NodeUtils.cpp:89

References NodeUtils::nodePath(), INode::parent(), and INode::progeny().

Referenced by ISimulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecularSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ displayName()

std::string INode::displayName ( ) const
inherited

Returns display name, composed from the name of node and it's copy number.

Definition at line 115 of file INode.cpp.

116 {
117  std::string result = getName();
118  if (m_parent) {
119  int index = m_parent->copyNumber(this);
120  if (index >= 0)
121  result = result + std::to_string(index);
122  }
123  return result;
124 }
const INode * m_parent
Definition: INode.h:83
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:94

References INode::copyNumber(), IParametricComponent::getName(), and INode::m_parent.

Referenced by NodeUtils::nodePath().

Here is the call graph for this function:

◆ getChildren()

std::vector< const INode * > ConvolutionDetectorResolution::getChildren ( ) const
virtual

Returns a vector of children.

Reimplemented from INode.

Definition at line 49 of file ConvolutionDetectorResolution.cpp.

50 {
51  return std::vector<const INode*>() << m_res_function_2d;
52 }

References m_res_function_2d.

◆ getIntegratedPDF1d()

double ConvolutionDetectorResolution::getIntegratedPDF1d ( double  x,
double  step 
) const
private

Definition at line 180 of file ConvolutionDetectorResolution.cpp.

181 {
182  double halfstep = step / 2.0;
183  double xmin = x - halfstep;
184  double xmax = x + halfstep;
185  ASSERT(m_res_function_1d != nullptr);
186  return m_res_function_1d(xmax) - m_res_function_1d(xmin);
187 }
#define ASSERT(condition)
Definition: Assert.h:31

References ASSERT, and m_res_function_1d.

Referenced by apply1dConvolution().

◆ getIntegratedPDF2d()

double ConvolutionDetectorResolution::getIntegratedPDF2d ( double  x,
double  step_x,
double  y,
double  step_y 
) const
private

Definition at line 189 of file ConvolutionDetectorResolution.cpp.

191 {
192  double halfstepx = step_x / 2.0;
193  double halfstepy = step_y / 2.0;
194  double xmin = x - halfstepx;
195  double xmax = x + halfstepx;
196  double ymin = y - halfstepy;
197  double ymax = y + halfstepy;
198  double result =
199  m_res_function_2d->evaluateCDF(xmax, ymax) - m_res_function_2d->evaluateCDF(xmax, ymin)
200  - m_res_function_2d->evaluateCDF(xmin, ymax) + m_res_function_2d->evaluateCDF(xmin, ymin);
201  return result;
202 }

References m_res_function_2d.

Referenced by apply2dConvolution().

◆ getName()

◆ getResolutionFunction2D()

const IResolutionFunction2D * ConvolutionDetectorResolution::getResolutionFunction2D ( ) const
inline

Definition at line 69 of file ConvolutionDetectorResolution.h.

70 {
71  return m_res_function_2d.get();
72 }

References m_res_function_2d.

◆ onChange()

◆ parameter()

RealParameter * IParametricComponent::parameter ( const std::string &  name) const
inherited

Returns parameter with given 'name'.

Definition at line 86 of file IParametricComponent.cpp.

87 {
88  return m_pool->parameter(name);
89 }
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)
QString const & name(EShape k)
Definition: particles.cpp:21

References IParametricComponent::m_pool, and RealSpace::Particles::name().

Referenced by DepthProbeSimulation::initialize(), SpecularSimulation::initialize(), Lattice3D::initialize(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), IParticle::registerPosition(), Layer::registerThickness(), Lattice2D::setRotationEnabled(), and DistributionLogNormal::setUnits().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParametricComponent::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 39 of file IParametricComponent.h.

39 { return m_pool.get(); } // has non-const usages!

References IParametricComponent::m_pool.

Referenced by INode::INode(), IParametricComponent::IParametricComponent(), pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

std::string IParametricComponent::parametersToString ( ) const
inherited

Returns multiline string representing available parameters.

Definition at line 43 of file IParametricComponent.cpp.

44 {
45  std::ostringstream result;
46  std::unique_ptr<ParameterPool> P_pool(createParameterTree());
47  result << *P_pool << "\n";
48  return result.str();
49 }
virtual ParameterPool * createParameterTree() const
Creates new parameter pool, with all local parameters and those of its children.

References IParametricComponent::createParameterTree().

Here is the call graph for this function:

◆ parent() [1/2]

INode * INode::parent ( )
inherited

Definition at line 89 of file INode.cpp.

90 {
91  return const_cast<INode*>(m_parent);
92 }

References INode::m_parent.

◆ parent() [2/2]

◆ progeny()

std::vector< const INode * > INode::progeny ( ) const
inherited

Returns a vector of all descendants.

Definition at line 68 of file INode.cpp.

69 {
70  std::vector<const INode*> result;
71  result.push_back(this);
72  for (const auto* child : getChildren()) {
73  for (const auto* p : child->progeny())
74  result.push_back(p);
75  }
76  return result;
77 }

References INode::getChildren().

Referenced by INode::createParameterTree(), and ParticleDistribution::generateParticles().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 57 of file INode.cpp.

58 {
59  ASSERT(node);
60  node->setParent(this);
61 }
virtual void setParent(const INode *newParent)
Definition: INode.cpp:79

References ASSERT, and INode::setParent().

Referenced by Beam::Beam(), Crystal::Crystal(), IDetector::IDetector(), Instrument::Instrument(), InterferenceFunction2DLattice::InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), Particle::Particle(), ParticleDistribution::ParticleDistribution(), ParticleLayout::addAndRegisterAbstractParticle(), ParticleCoreShell::addAndRegisterCore(), MultiLayer::addAndRegisterInterface(), MultiLayer::addAndRegisterLayer(), ParticleCoreShell::addAndRegisterShell(), Layer::addLayout(), ParticleComposition::addParticlePointer(), ISimulation::initialize(), MesoCrystal::initialize(), Beam::operator=(), Instrument::operator=(), IParticle::rotate(), ParticleLayout::setAndRegisterInterferenceFunction(), ISimulation::setBackground(), InterferenceFunction1DLattice::setDecayFunction(), InterferenceFunction2DLattice::setDecayFunction(), Instrument::setDetector(), IDetector::setDetectorResolution(), Beam::setFootprintFactor(), Particle::setFormFactor(), InterferenceFunctionFinite3DLattice::setLattice(), InterferenceFunctionRadialParaCrystal::setProbabilityDistribution(), InterferenceFunction2DParaCrystal::setProbabilityDistributions(), setResolutionFunction(), IParticle::setRotation(), LayerInterface::setRoughness(), and InterferenceFunction2DSuperLattice::setSubstructureIFF().

Here is the call graph for this function:

◆ registerParameter()

RealParameter & IParametricComponent::registerParameter ( const std::string &  name,
double *  parpointer 
)
inherited

Definition at line 51 of file IParametricComponent.cpp.

52 {
53  return m_pool->addParameter(
54  new RealParameter(name, data, getName(), [&]() -> void { onChange(); }));
55 }
virtual void onChange()
Action to be taken in inherited class when a parameter has changed.
Wraps a parameter of type double.
Definition: RealParameter.h:31

References IParametricComponent::getName(), IParametricComponent::m_pool, RealSpace::Particles::name(), and IParametricComponent::onChange().

Referenced by BasicLattice2D::BasicLattice2D(), Beam::Beam(), CylindersInBABuilder::CylindersInBABuilder(), DetectionProperties::DetectionProperties(), HexagonalLattice2D::HexagonalLattice2D(), IInterferenceFunction::IInterferenceFunction(), INode::INode(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), Lattice2D::Lattice2D(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleDistribution::ParticleDistribution(), PlainMultiLayerBySLDBuilder::PlainMultiLayerBySLDBuilder(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), ResonatorBuilder::ResonatorBuilder(), SquareLattice2D::SquareLattice2D(), TriangularRippleBuilder::TriangularRippleBuilder(), IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParametricComponent::registerVector(), ParticleLayout::registerWeight(), and Lattice2D::setRotationEnabled().

Here is the call graph for this function:

◆ registerVector()

void IParametricComponent::registerVector ( const std::string &  base_name,
kvector_t p_vec,
const std::string &  units = "nm" 
)
inherited

Definition at line 57 of file IParametricComponent.cpp.

59 {
60  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
61  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
62  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
63 }
static std::string XComponentName(const std::string &base_name)
static std::string ZComponentName(const std::string &base_name)
RealParameter & registerParameter(const std::string &name, double *parpointer)
static std::string YComponentName(const std::string &base_name)
RealParameter & setUnit(const std::string &name)
MVVM_MODEL_EXPORT std::string base_name(const std::string &path)
Provide the filename of a file path.
Definition: fileutils.cpp:78

References ModelView::Utils::base_name(), IParametricComponent::registerParameter(), RealParameter::setUnit(), IParametricComponent::XComponentName(), IParametricComponent::YComponentName(), and IParametricComponent::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer::MultiLayer(), Lattice3D::initialize(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ removeParameter()

void IParametricComponent::removeParameter ( const std::string &  name)
inherited

Definition at line 91 of file IParametricComponent.cpp.

92 {
93  m_pool->removeParameter(name);
94 }

References IParametricComponent::m_pool, and RealSpace::Particles::name().

Referenced by IParticle::registerAbundance(), ParticleLayout::registerParticleDensity(), Layer::registerThickness(), IParametricComponent::removeVector(), and Lattice2D::setRotationEnabled().

Here is the call graph for this function:

◆ removeVector()

void IParametricComponent::removeVector ( const std::string &  base_name)
inherited

Definition at line 96 of file IParametricComponent.cpp.

References ModelView::Utils::base_name(), IParametricComponent::removeParameter(), IParametricComponent::XComponentName(), IParametricComponent::YComponentName(), and IParametricComponent::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ setName()

void IParametricComponent::setName ( const std::string &  name)
inlineinherited

Definition at line 69 of file IParametricComponent.h.

69 { m_name = name; }

References IParametricComponent::m_name, and RealSpace::Particles::name().

Referenced by BasicLattice2D::BasicLattice2D(), Beam::Beam(), ConvolutionDetectorResolution(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice2D::HexagonalLattice2D(), IDetector::IDetector(), INode::INode(), Instrument::Instrument(), InterferenceFunction1DLattice::InterferenceFunction1DLattice(), InterferenceFunction2DLattice::InterferenceFunction2DLattice(), InterferenceFunction2DParaCrystal::InterferenceFunction2DParaCrystal(), InterferenceFunction2DSuperLattice::InterferenceFunction2DSuperLattice(), InterferenceFunction3DLattice::InterferenceFunction3DLattice(), InterferenceFunctionFinite2DLattice::InterferenceFunctionFinite2DLattice(), InterferenceFunctionFinite3DLattice::InterferenceFunctionFinite3DLattice(), InterferenceFunctionHardDisk::InterferenceFunctionHardDisk(), InterferenceFunctionNone::InterferenceFunctionNone(), InterferenceFunctionRadialParaCrystal::InterferenceFunctionRadialParaCrystal(), InterferenceFunctionTwin::InterferenceFunctionTwin(), ISampleBuilder::ISampleBuilder(), IsGISAXSDetector::IsGISAXSDetector(), Lattice3D::Lattice3D(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SphericalDetector::SphericalDetector(), SquareLattice2D::SquareLattice2D(), Layer::clone(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecularSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), Particle::initialize(), ParticleComposition::initialize(), Beam::operator=(), SampleBuilderNode::operator=(), SampleBuilderNode::reset(), and SampleBuilderNode::setSBN().

Here is the call graph for this function:

◆ setParameterValue()

void IParametricComponent::setParameterValue ( const std::string &  name,
double  value 
)
inherited

Definition at line 65 of file IParametricComponent.cpp.

66 {
67  if (name.find('*') == std::string::npos && name.find('/') == std::string::npos) {
68  m_pool->setParameterValue(name, value);
69  } else {
70  std::unique_ptr<ParameterPool> P_pool{createParameterTree()};
71  if (name.find('*') != std::string::npos)
72  P_pool->setMatchedParametersValue(name, value);
73  else
74  P_pool->setParameterValue(name, value);
75  }
76 }
int setMatchedParametersValue(const std::string &wildcards, double value)
Sets value of the nonzero parameters that match pattern ('*' allowed), or throws.

References IParametricComponent::createParameterTree(), IParametricComponent::m_pool, RealSpace::Particles::name(), and ParameterPool::setMatchedParametersValue().

Referenced by AsymRippleBuilder::buildSample(), and IParametricComponent::setVectorValue().

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 79 of file INode.cpp.

80 {
81  m_parent = newParent;
82 }

References INode::m_parent.

Referenced by INode::registerChild(), SampleProvider::setBuilder(), and SampleProvider::setParent().

◆ setResolutionFunction()

void ConvolutionDetectorResolution::setResolutionFunction ( const IResolutionFunction2D resFunc)
private

Definition at line 76 of file ConvolutionDetectorResolution.cpp.

77 {
78  m_res_function_2d.reset(resFunc.clone());
80 }
void registerChild(INode *node)
Definition: INode.cpp:57
virtual IResolutionFunction2D * clone() const =0

References IResolutionFunction2D::clone(), m_res_function_2d, and INode::registerChild().

Referenced by ConvolutionDetectorResolution().

Here is the call graph for this function:

◆ setVectorValue()

void IParametricComponent::setVectorValue ( const std::string &  base_name,
kvector_t  value 
)
inherited

Definition at line 78 of file IParametricComponent.cpp.

79 {
83 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:65
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:63
void setParameterValue(const std::string &name, double value)

References ModelView::Utils::base_name(), IParametricComponent::setParameterValue(), BasicVector3D< T >::x(), IParametricComponent::XComponentName(), BasicVector3D< T >::y(), IParametricComponent::YComponentName(), BasicVector3D< T >::z(), and IParametricComponent::ZComponentName().

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 34 of file ICloneable.h.

◆ treeToString()

std::string INode::treeToString ( ) const
virtualinherited

Returns multiline string representing tree structure below the node.

Definition at line 52 of file INode.cpp.

53 {
54  return NodeUtils::nodeToString(this);
55 }
std::string nodeToString(const INode *node)
Returns multiline string representing tree structure starting from given node.
Definition: NodeUtils.cpp:81

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ XComponentName()

std::string IParametricComponent::XComponentName ( const std::string &  base_name)
staticinherited

Definition at line 103 of file IParametricComponent.cpp.

104 {
105  return base_name + "X";
106 }

References ModelView::Utils::base_name().

Referenced by Lattice3D::initialize(), IParticle::registerPosition(), IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

◆ YComponentName()

std::string IParametricComponent::YComponentName ( const std::string &  base_name)
staticinherited

Definition at line 108 of file IParametricComponent.cpp.

109 {
110  return base_name + "Y";
111 }

References ModelView::Utils::base_name().

Referenced by IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

◆ ZComponentName()

std::string IParametricComponent::ZComponentName ( const std::string &  base_name)
staticinherited

Definition at line 113 of file IParametricComponent.cpp.

114 {
115  return base_name + "Z";
116 }

References ModelView::Utils::base_name().

Referenced by IParametricComponent::registerVector(), IParametricComponent::removeVector(), IParametricComponent::setVectorValue(), and VectorParameterTranslator::translate().

Here is the call graph for this function:

Member Data Documentation

◆ m_dimension

size_t ConvolutionDetectorResolution::m_dimension
private

◆ m_name

std::string IParametricComponent::m_name
privateinherited

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 88 of file INode.h.

Referenced by INode::INode().

◆ m_P

std::vector<double> INode::m_P
protectedinherited

Definition at line 89 of file INode.h.

Referenced by INode::INode(), and IFootprintFactor::setWidthRatio().

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 83 of file INode.h.

Referenced by INode::displayName(), INode::parent(), and INode::setParent().

◆ m_pool

◆ m_res_function_1d

cumulative_DF_1d ConvolutionDetectorResolution::m_res_function_1d
private

◆ m_res_function_2d

std::unique_ptr<IResolutionFunction2D> ConvolutionDetectorResolution::m_res_function_2d
private

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