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

Public Types

typedef double(* cumulative_DF_1d) (double)
 

Public Member Functions

 ConvolutionDetectorResolution (cumulative_DF_1d res_function_1d)
 
 ConvolutionDetectorResolution (const IResolutionFunction2D &p_res_function_2d)
 
virtual ~ConvolutionDetectorResolution ()
 
virtual void applyDetectorResolution (OutputData< double > *p_intensity_map) const
 
virtual ConvolutionDetectorResolutionclone () const
 
void accept (INodeVisitor *visitor) const final
 
const IResolutionFunction2DgetResolutionFunction2D () const
 
std::vector< const INode * > getChildren () const
 
void applyDetectorResolutionPol (OutputData< Eigen::Matrix2d > *p_matrix_intensity) const
 
virtual void transferToCPP ()
 
virtual std::string treeToString () const
 
void registerChild (INode *node)
 
virtual void setParent (const INode *newParent)
 
const INodeparent () const
 
INodeparent ()
 
int copyNumber (const INode *node) const
 
std::string displayName () const
 
ParameterPoolcreateParameterTree () const
 
ParameterPoolparameterPool () const
 
std::string parametersToString () const
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void setParameterValue (const std::string &name, double value)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
RealParameterparameter (const std::string &name) const
 
virtual void onChange ()
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void setName (const std::string &name)
 
const std::string & getName () const
 

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 setResolutionFunction (const IResolutionFunction2D &resFunc)
 
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
 

Private Attributes

size_t m_dimension
 
cumulative_DF_1d m_res_function_1d
 
std::unique_ptr< IResolutionFunction2Dmp_res_function_2d
 
const INodem_parent {nullptr}
 
std::string m_name
 
std::unique_ptr< ParameterPoolm_pool
 

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 26 of file ConvolutionDetectorResolution.h.

Member Typedef Documentation

◆ cumulative_DF_1d

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

Definition at line 29 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 IParameterized::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 IParameterized::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.mp_res_function_2d)
41  setName(other.getName());
42 }
std::unique_ptr< IResolutionFunction2D > mp_res_function_2d
const std::string & getName() const

References IParameterized::getName(), m_dimension, m_res_function_1d, mp_res_function_2d, IParameterized::setName(), and setResolutionFunction().

Here is the call graph for this function:

Member Function Documentation

◆ 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->getRank() != m_dimension) {
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:
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
size_t getRank() const
Returns number of dimensions.
Definition: OutputData.h:59

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

Here is the call graph for this function:

◆ 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:

◆ accept()

void ConvolutionDetectorResolution::accept ( INodeVisitor visitor) const
inlinefinalvirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 44 of file ConvolutionDetectorResolution.h.

44 { visitor->visit(this); }
virtual void visit(const BasicLattice *)
Definition: INodeVisitor.h:154

◆ getResolutionFunction2D()

const IResolutionFunction2D * ConvolutionDetectorResolution::getResolutionFunction2D ( ) const
inline

Definition at line 65 of file ConvolutionDetectorResolution.h.

66 {
67  return mp_res_function_2d.get();
68 }

References mp_res_function_2d.

◆ getChildren()

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

Returns a vector of children (const).

Reimplemented from INode.

Definition at line 49 of file ConvolutionDetectorResolution.cpp.

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

References mp_res_function_2d.

◆ setResolutionFunction()

void ConvolutionDetectorResolution::setResolutionFunction ( const IResolutionFunction2D resFunc)
private

Definition at line 76 of file ConvolutionDetectorResolution.cpp.

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

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

Referenced by ConvolutionDetectorResolution().

Here is the call graph for this function:

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

References Convolve::fftconvolve(), OutputData< T >::getAxis(), getIntegratedPDF1d(), OutputData< T >::getRank(), OutputData< T >::getRawDataVector(), m_res_function_1d, 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 118 of file ConvolutionDetectorResolution.cpp.

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

References OutputData< T >::begin(), OutputData< T >::end(), Convolve::fftconvolve(), OutputData< T >::getAxis(), getIntegratedPDF2d(), OutputData< T >::getRank(), OutputData< T >::getRawDataVector(), mp_res_function_2d, and IAxis::size().

Referenced by applyDetectorResolution().

Here is the call graph for this function:

◆ getIntegratedPDF1d()

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

Definition at line 182 of file ConvolutionDetectorResolution.cpp.

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

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 191 of file ConvolutionDetectorResolution.cpp.

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

References mp_res_function_2d.

Referenced by apply2dConvolution().

◆ applyDetectorResolutionPol()

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

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

◆ 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 53 of file INode.cpp.

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

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 58 of file INode.cpp.

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

References ASSERT, and INode::setParent().

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

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 69 of file INode.cpp.

70 {
71  m_parent = newParent;
72 }
const INode * m_parent
Definition: INode.h:81

References INode::m_parent.

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

◆ parent() [1/2]

const INode * INode::parent ( ) const
inherited

◆ parent() [2/2]

INode * INode::parent ( )
inherited

Definition at line 79 of file INode.cpp.

80 {
81  return const_cast<INode*>(m_parent);
82 }
Base class for tree-like structures containing parameterized objects.
Definition: INode.h:49

References INode::m_parent.

◆ 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 84 of file INode.cpp.

85 {
86  if (node->parent() != this)
87  return -1;
88 
89  int result(-1), count(0);
90  for (auto child : getChildren()) {
91 
92  if (child == nullptr)
93  throw std::runtime_error("INode::copyNumber() -> Error. Nullptr as child.");
94 
95  if (child == node)
96  result = count;
97 
98  if (child->getName() == node->getName())
99  ++count;
100  }
101 
102  return count > 1 ? result : -1;
103 }
const INode * parent() const
Definition: INode.cpp:74
virtual std::vector< const INode * > getChildren() const
Returns a vector of children (const).
Definition: INode.cpp:64

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

Referenced by INode::displayName().

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 105 of file INode.cpp.

106 {
107  std::string result = getName();
108  if (m_parent) {
109  int index = m_parent->copyNumber(this);
110  if (index >= 0)
111  result = result + std::to_string(index);
112  }
113  return result;
114 }
int copyNumber(const INode *node) const
Returns copyNumber of child, which takes into account existence of children with same name.
Definition: INode.cpp:84

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

Referenced by NodeUtils::nodePath(), and anonymous_namespace{NodeUtils.cpp}::nodeString().

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 IParameterized.

Definition at line 116 of file INode.cpp.

117 {
118  std::unique_ptr<ParameterPool> result(new ParameterPool);
119 
121  it.first();
122  while (!it.isDone()) {
123  const INode* child = it.getCurrent();
124  const std::string path = NodeUtils::nodePath(*child, this->parent()) + "/";
125  child->parameterPool()->copyToExternalPool(path, result.get());
126  it.next();
127  }
128 
129  return result.release();
130 }
ParameterPool * parameterPool() const
Returns pointer to the parameter pool.
Iterator through INode tree of objects.
Definition: NodeIterator.h:90
Container with parameters for IParameterized object.
Definition: ParameterPool.h:30
void copyToExternalPool(const std::string &prefix, ParameterPool *other_pool) const
Copies parameters of given pool to other pool, prepeding prefix to the parameter names.
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:82

References ParameterPool::copyToExternalPool(), NodeIterator< Strategy >::first(), NodeIterator< Strategy >::getCurrent(), NodeIterator< Strategy >::isDone(), NodeIterator< Strategy >::next(), NodeUtils::nodePath(), IParameterized::parameterPool(), and INode::parent().

Referenced by ParticleDistribution::generateParticles(), Simulation::runSimulation(), DepthProbeSimulation::validateParametrization(), OffSpecSimulation::validateParametrization(), and SpecularSimulation::validateParametrization().

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParameterized::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 38 of file IParameterized.h.

38 { return m_pool.get(); } // has non-const usages!
std::unique_ptr< ParameterPool > m_pool
parameter pool (kind of pointer-to-implementation)

References IParameterized::m_pool.

Referenced by pyfmt2::argumentList(), SampleBuilderNode::borrow_builder_parameters(), INode::createParameterTree(), INode::INode(), IParameterized::IParameterized(), anonymous_namespace{NodeUtils.cpp}::poolToString(), SampleBuilderNode::reset(), and IDistribution1D::setUnits().

◆ parametersToString()

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

Returns multiline string representing available parameters.

Definition at line 40 of file IParameterized.cpp.

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

References IParameterized::createParameterTree().

Here is the call graph for this function:

◆ registerParameter()

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

Definition at line 48 of file IParameterized.cpp.

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

References IParameterized::getName(), IParameterized::m_pool, and IParameterized::onChange().

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

Here is the call graph for this function:

◆ registerVector()

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

Definition at line 54 of file IParameterized.cpp.

56 {
57  registerParameter(XComponentName(base_name), &((*p_vec)[0])).setUnit(units);
58  registerParameter(YComponentName(base_name), &((*p_vec)[1])).setUnit(units);
59  registerParameter(ZComponentName(base_name), &((*p_vec)[2])).setUnit(units);
60 }
RealParameter & registerParameter(const std::string &name, double *parpointer)
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)
RealParameter & setUnit(const std::string &name)

References IParameterized::registerParameter(), RealParameter::setUnit(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by Beam::Beam(), DetectionProperties::DetectionProperties(), InterferenceFunctionTwin::InterferenceFunctionTwin(), MultiLayer::MultiLayer(), Lattice::registerBasisVectors(), and IParticle::registerPosition().

Here is the call graph for this function:

◆ setParameterValue()

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

Definition at line 62 of file IParameterized.cpp.

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

References IParameterized::createParameterTree(), IParameterized::m_pool, and ParameterPool::setMatchedParametersValue().

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

Here is the call graph for this function:

◆ setVectorValue()

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

Definition at line 75 of file IParameterized.cpp.

76 {
77  setParameterValue(XComponentName(base_name), value.x());
78  setParameterValue(YComponentName(base_name), value.y());
79  setParameterValue(ZComponentName(base_name), value.z());
80 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:68
T y() const
Returns y-component in cartesian coordinate system.
Definition: BasicVector3D.h:66
T x() const
Returns x-component in cartesian coordinate system.
Definition: BasicVector3D.h:64
void setParameterValue(const std::string &name, double value)

References IParameterized::setParameterValue(), BasicVector3D< T >::x(), IParameterized::XComponentName(), BasicVector3D< T >::y(), IParameterized::YComponentName(), BasicVector3D< T >::z(), and IParameterized::ZComponentName().

Here is the call graph for this function:

◆ parameter()

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

◆ onChange()

◆ removeParameter()

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

◆ removeVector()

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

Definition at line 93 of file IParameterized.cpp.

94 {
95  removeParameter(XComponentName(base_name));
96  removeParameter(YComponentName(base_name));
97  removeParameter(ZComponentName(base_name));
98 }
void removeParameter(const std::string &name)

References IParameterized::removeParameter(), IParameterized::XComponentName(), IParameterized::YComponentName(), and IParameterized::ZComponentName().

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ XComponentName()

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

◆ YComponentName()

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

Definition at line 105 of file IParameterized.cpp.

106 {
107  return base_name + "Y";
108 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ ZComponentName()

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

Definition at line 110 of file IParameterized.cpp.

111 {
112  return base_name + "Z";
113 }

Referenced by IParameterized::registerVector(), IParameterized::removeVector(), and IParameterized::setVectorValue().

◆ setName()

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

Definition at line 68 of file IParameterized.h.

68 { m_name = name; }
std::string m_name

References IParameterized::m_name.

Referenced by BasicLattice::BasicLattice(), Beam::Beam(), Layer::clone(), ConvolutionDetectorResolution(), LayersWithAbsorptionBuilder::createSampleByIndex(), Basic2DParaCrystalBuilder::createSampleByIndex(), ParticleInVacuumBuilder::createSampleByIndex(), SimpleMagneticRotationBuilder::createSampleByIndex(), Crystal::Crystal(), DetectionProperties::DetectionProperties(), DistributionHandler::DistributionHandler(), FormFactorBAPol::FormFactorBAPol(), FormFactorCoreShell::FormFactorCoreShell(), FormFactorCrystal::FormFactorCrystal(), FormFactorDecoratorMaterial::FormFactorDecoratorMaterial(), FormFactorDecoratorPositionFactor::FormFactorDecoratorPositionFactor(), FormFactorDecoratorRotation::FormFactorDecoratorRotation(), FormFactorDWBA::FormFactorDWBA(), FormFactorDWBAPol::FormFactorDWBAPol(), FormFactorWeighted::FormFactorWeighted(), HexagonalLattice::HexagonalLattice(), IDetector::IDetector(), DepthProbeSimulation::initialize(), GISASSimulation::initialize(), OffSpecSimulation::initialize(), SpecularSimulation::initialize(), SpecularDetector1D::initialize(), MesoCrystal::initialize(), Particle::initialize(), ParticleComposition::initialize(), 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(), Lattice::Lattice(), Layer::Layer(), LayerInterface::LayerInterface(), LayerRoughness::LayerRoughness(), MultiLayer::MultiLayer(), Beam::operator=(), SampleBuilderNode::operator=(), ParticleCoreShell::ParticleCoreShell(), ParticleDistribution::ParticleDistribution(), ParticleLayout::ParticleLayout(), RectangularDetector::RectangularDetector(), SampleBuilderNode::reset(), ResolutionFunction2DGaussian::ResolutionFunction2DGaussian(), SampleBuilderNode::SampleBuilderNode(), SampleBuilderNode::setSBN(), SphericalDetector::SphericalDetector(), and SquareLattice::SquareLattice().

◆ getName()

Member Data Documentation

◆ m_dimension

size_t ConvolutionDetectorResolution::m_dimension
private

◆ m_res_function_1d

cumulative_DF_1d ConvolutionDetectorResolution::m_res_function_1d
private

◆ mp_res_function_2d

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

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 81 of file INode.h.

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

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 86 of file INode.h.

Referenced by INode::INode().

◆ m_P

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

Definition at line 87 of file INode.h.

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

◆ m_name

std::string IParameterized::m_name
privateinherited

Definition at line 72 of file IParameterized.h.

Referenced by IParameterized::getName(), and IParameterized::setName().

◆ m_pool

std::unique_ptr<ParameterPool> IParameterized::m_pool
privateinherited

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