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

Public Types

using const_iterator = const SimulationAreaIterator &
 

Public Member Functions

 SpecularDetector1D (const IAxis &axis)
 
virtual ~SpecularDetector1D ()
 
SpecularDetector1Dclone () const override
 
void accept (INodeVisitor *visitor) const override
 
const DetectorMaskdetectorMask () const override
 
const RegionOfInterestregionOfInterest () const override
 
void resetRegionOfInterest () override
 
Axes::Units defaultAxesUnits () const override
 
virtual void init (const Beam &)
 
void addAxis (const IAxis &axis)
 
const IAxisgetAxis (size_t index) const
 
size_t dimension () const
 
size_t axisBinIndex (size_t index, size_t selected_axis) const
 
size_t totalSize () const
 
void setAnalyzerProperties (const kvector_t direction, double efficiency, double total_transmission)
 
void setDetectorResolution (const IDetectorResolution &p_detector_resolution)
 
void setResolutionFunction (const IResolutionFunction2D &resFunc)
 
void applyDetectorResolution (OutputData< double > *p_intensity_map) const
 
void removeDetectorResolution ()
 
const IDetectorResolutiondetectorResolution () const
 
std::unique_ptr< OutputData< double > > createDetectorMap () const
 
const DetectionPropertiesdetectionProperties () const
 
OutputData< double > * createDetectorIntensity (const std::vector< SimulationElement > &elements) const
 
size_t numberOfSimulationElements () const
 
std::vector< const INode * > getChildren () const override
 
void iterate (std::function< void(const_iterator)> func, bool visit_masks=false) 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

 SpecularDetector1D (const SpecularDetector1D &other)
 
std::string axisName (size_t index) const override
 
void initialize ()
 
void clear ()
 
virtual std::unique_ptr< IAxiscreateAxis (size_t index, size_t n_bins, double min, double max) const
 

Protected Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void setDataToDetectorMap (OutputData< double > &detectorMap, const std::vector< SimulationElement > &elements) const
 

Private Attributes

CloneableVector< IAxism_axes
 
DetectionProperties m_detection_properties
 
std::unique_ptr< IDetectorResolutionmP_detector_resolution
 
const INodem_parent {nullptr}
 
std::string m_name
 
std::unique_ptr< ParameterPoolm_pool
 

Detailed Description

1D detector for specular simulations.

Use of this detector is deprecated.

Definition at line 25 of file SpecularDetector1D.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 38 of file IDetector.h.

Constructor & Destructor Documentation

◆ SpecularDetector1D() [1/2]

SpecularDetector1D::SpecularDetector1D ( const IAxis axis)

Definition at line 17 of file SpecularDetector1D.cpp.

18 {
19  initialize();
20  addAxis(axis);
21 }
void addAxis(const IAxis &axis)
Definition: IDetector.cpp:39

References IDetector::addAxis(), and initialize().

Referenced by clone().

Here is the call graph for this function:

◆ ~SpecularDetector1D()

SpecularDetector1D::~SpecularDetector1D ( )
virtualdefault

◆ SpecularDetector1D() [2/2]

SpecularDetector1D::SpecularDetector1D ( const SpecularDetector1D other)
protected

Definition at line 23 of file SpecularDetector1D.cpp.

23  : IDetector(detector)
24 {
25  initialize();
26 }

References initialize().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

SpecularDetector1D * SpecularDetector1D::clone ( ) const
overridevirtual

Implements IDetector.

Definition at line 30 of file SpecularDetector1D.cpp.

31 {
32  return new SpecularDetector1D(*this);
33 }
SpecularDetector1D(const IAxis &axis)

References SpecularDetector1D().

Here is the call graph for this function:

◆ accept()

void SpecularDetector1D::accept ( INodeVisitor visitor) const
inlineoverridevirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 33 of file SpecularDetector1D.h.

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

References INodeVisitor::visit().

Here is the call graph for this function:

◆ detectorMask()

const DetectorMask* SpecularDetector1D::detectorMask ( ) const
inlineoverridevirtual

Returns detector masks container.

Implements IDetector.

Definition at line 36 of file SpecularDetector1D.h.

36 { return nullptr; }

◆ regionOfInterest()

const RegionOfInterest* SpecularDetector1D::regionOfInterest ( ) const
inlineoverridevirtual

Returns region of interest if exists.

Implements IDetector.

Definition at line 39 of file SpecularDetector1D.h.

39 { return nullptr; }

◆ resetRegionOfInterest()

void SpecularDetector1D::resetRegionOfInterest ( )
inlineoverridevirtual

Resets region of interest making whole detector plane available for the simulation.

Implements IDetector.

Definition at line 41 of file SpecularDetector1D.h.

41 {}

◆ defaultAxesUnits()

Axes::Units SpecularDetector1D::defaultAxesUnits ( ) const
overridevirtual

Return default axes units.

Reimplemented from IDetector.

Definition at line 35 of file SpecularDetector1D.cpp.

36 {
37  return Axes::Units::RADIANS;
38 }

◆ axisName()

std::string SpecularDetector1D::axisName ( size_t  index) const
overrideprotectedvirtual

Returns the name for the axis with given index.

Implements IDetector.

Definition at line 40 of file SpecularDetector1D.cpp.

41 {
42  if (index == 0) {
43  return "u";
44  } else
45  throw std::runtime_error(
46  "SpecularDetector1D::getAxisName(size_t index) -> Error! index > 0");
47 }

◆ initialize()

void SpecularDetector1D::initialize ( )
protected

Definition at line 49 of file SpecularDetector1D.cpp.

50 {
51  setName("SpecularDetector1D");
52 }
void setName(const std::string &name)

References IParameterized::setName().

Referenced by SpecularDetector1D().

Here is the call graph for this function:

◆ init()

virtual void IDetector::init ( const Beam )
inlinevirtualinherited

Inits detector with the beam settings.

Reimplemented in RectangularDetector.

Definition at line 46 of file IDetector.h.

46 {}

◆ addAxis()

void IDetector::addAxis ( const IAxis axis)
inherited

Definition at line 39 of file IDetector.cpp.

40 {
41  m_axes.push_back(axis.clone());
42 }
void push_back(T *t)
virtual IAxis * clone() const =0
clone function
CloneableVector< IAxis > m_axes
Definition: IDetector.h:126

References IAxis::clone(), IDetector::m_axes, and CloneableVector< T >::push_back().

Referenced by IDetector2D::setDetectorParameters(), and SpecularDetector1D().

Here is the call graph for this function:

◆ getAxis()

const IAxis & IDetector::getAxis ( size_t  index) const
inherited

Definition at line 54 of file IDetector.cpp.

55 {
56  if (index < dimension())
57  return *m_axes[index];
58  throw std::runtime_error("Error in IDetector::getAxis: not so many axes in this detector.");
59 }
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
Definition: IDetector.cpp:44

References IDetector::dimension(), and IDetector::m_axes.

Referenced by UnitConverterSimple::addDetectorAxis(), OffSpecularConverter::addDetectorYAxis(), IDetector::createDetectorMap(), RectangularDetector::createPixel(), SphericalDetector::createPixel(), anonymous_namespace{Simulation.cpp}::detHasSameDimensions(), IDetector2D::getGlobalIndex(), RectangularDetector::getHeight(), RectangularDetector::getNbinsX(), RectangularDetector::getNbinsY(), RectangularDetector::getWidth(), RectangularDetector::indexOfSpecular(), SphericalDetector::indexOfSpecular(), DetectorMask::initMaskData(), RegionOfInterest::RegionOfInterest(), and RectangularDetector::regionOfInterestPixel().

Here is the call graph for this function:

◆ dimension()

◆ axisBinIndex()

size_t IDetector::axisBinIndex ( size_t  index,
size_t  selected_axis 
) const
inherited

Calculate axis index for given global index.

Definition at line 61 of file IDetector.cpp.

62 {
63  const size_t dim = dimension();
64  size_t remainder(index);
65  size_t i_axis = dim;
66  for (size_t i = 0; i < dim; ++i) {
67  --i_axis;
68  if (selected_axis == i_axis)
69  return remainder % m_axes[i_axis]->size();
70  remainder /= m_axes[i_axis]->size();
71  }
72  throw std::runtime_error("IDetector::getAxisBinIndex() -> "
73  "Error! No axis with given number");
74 }

References IDetector::dimension(), and IDetector::m_axes.

Referenced by RectangularDetector::createPixel(), and SphericalDetector::createPixel().

Here is the call graph for this function:

◆ totalSize()

size_t IDetector::totalSize ( ) const
inherited

Returns total number of pixels.

Definition at line 87 of file IDetector.cpp.

88 {
89  const size_t dim = dimension();
90  if (dim == 0)
91  return 0;
92  size_t result = 1;
93  for (size_t i_axis = 0; i_axis < dim; ++i_axis)
94  result *= m_axes[i_axis]->size();
95  return result;
96 }

References IDetector::dimension(), and IDetector::m_axes.

Referenced by IDetector2D::getGlobalIndex(), IsGISAXSDetector::indexOfSpecular(), RectangularDetector::indexOfSpecular(), SphericalDetector::indexOfSpecular(), and SimulationArea::SimulationArea().

Here is the call graph for this function:

◆ setAnalyzerProperties()

void IDetector::setAnalyzerProperties ( const kvector_t  direction,
double  efficiency,
double  total_transmission 
)
inherited

Sets the polarization analyzer characteristics of the detector.

Definition at line 98 of file IDetector.cpp.

100 {
101  m_detection_properties.setAnalyzerProperties(direction, efficiency, total_transmission);
102 }
void setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission)
Sets the polarization analyzer characteristics of the detector.
DetectionProperties m_detection_properties
Definition: IDetector.h:127

References IDetector::m_detection_properties, and DetectionProperties::setAnalyzerProperties().

Here is the call graph for this function:

◆ setDetectorResolution()

void IDetector::setDetectorResolution ( const IDetectorResolution p_detector_resolution)
inherited

Sets the detector resolution.

Definition at line 104 of file IDetector.cpp.

105 {
106  mP_detector_resolution.reset(p_detector_resolution.clone());
108 }
virtual IDetectorResolution * clone() const =0
std::unique_ptr< IDetectorResolution > mP_detector_resolution
Definition: IDetector.h:128
void registerChild(INode *node)
Definition: INode.cpp:58

References IDetectorResolution::clone(), IDetector::mP_detector_resolution, and INode::registerChild().

Referenced by IDetector::IDetector(), and IDetector::setResolutionFunction().

Here is the call graph for this function:

◆ setResolutionFunction()

void IDetector::setResolutionFunction ( const IResolutionFunction2D resFunc)
inherited

Definition at line 111 of file IDetector.cpp.

112 {
113  ConvolutionDetectorResolution convFunc(resFunc);
114  setDetectorResolution(convFunc);
115 }
Convolutes the intensity in 1 or 2 dimensions with a resolution function.
void setDetectorResolution(const IDetectorResolution &p_detector_resolution)
Sets the detector resolution.
Definition: IDetector.cpp:104

References IDetector::setDetectorResolution().

Here is the call graph for this function:

◆ applyDetectorResolution()

void IDetector::applyDetectorResolution ( OutputData< double > *  p_intensity_map) const
inherited

Applies the detector resolution to the given intensity maps.

Definition at line 117 of file IDetector.cpp.

118 {
119  if (!p_intensity_map)
120  throw std::runtime_error("IDetector::applyDetectorResolution() -> "
121  "Error! Null pointer to intensity map");
123  mP_detector_resolution->applyDetectorResolution(p_intensity_map);
124  if (detectorMask() && detectorMask()->hasMasks()) {
125  // sets amplitude in masked areas to zero
126  std::unique_ptr<OutputData<double>> buff(new OutputData<double>());
127  buff->copyShapeFrom(*p_intensity_map);
128 
129  iterate([&](const_iterator it) {
130  (*buff)[it.roiIndex()] = (*p_intensity_map)[it.roiIndex()];
131  });
132  p_intensity_map->setRawDataVector(buff->getRawDataVector());
133  }
134  }
135 }
virtual const DetectorMask * detectorMask() const =0
Returns detector masks container.
const SimulationAreaIterator & const_iterator
Definition: IDetector.h:38
void iterate(std::function< void(const_iterator)> func, bool visit_masks=false) const
Definition: IDetector.cpp:201
void setRawDataVector(const std::vector< T > &data_vector)
Sets new values to raw data vector.
Definition: OutputData.h:559

References IDetector::detectorMask(), IDetector::iterate(), IDetector::mP_detector_resolution, SimulationAreaIterator::roiIndex(), and OutputData< T >::setRawDataVector().

Referenced by IDetector::createDetectorIntensity().

Here is the call graph for this function:

◆ removeDetectorResolution()

void IDetector::removeDetectorResolution ( )
inherited

Removes detector resolution function.

Definition at line 137 of file IDetector.cpp.

138 {
139  mP_detector_resolution.reset();
140 }

References IDetector::mP_detector_resolution.

◆ detectorResolution()

const IDetectorResolution * IDetector::detectorResolution ( ) const
inherited

Returns a pointer to detector resolution object.

Definition at line 142 of file IDetector.cpp.

143 {
144  return mP_detector_resolution.get();
145 }

References IDetector::mP_detector_resolution.

Referenced by SimulationToPython::defineDetectorResolutionFunction().

◆ createDetectorMap()

std::unique_ptr< OutputData< double > > IDetector::createDetectorMap ( ) const
inherited

Returns empty detector map in given axes units.

Definition at line 162 of file IDetector.cpp.

163 {
164  const size_t dim = dimension();
165  if (dim == 0)
166  throw std::runtime_error(
167  "Error in IDetector::createDetectorMap: dimensions of the detector are undefined");
168 
169  std::unique_ptr<OutputData<double>> result(new OutputData<double>);
170  for (size_t i = 0; i < dim; ++i)
171  if (auto roi = regionOfInterest())
172  result->addAxis(*roi->clipAxisToRoi(i, getAxis(i)));
173  else
174  result->addAxis(getAxis(i));
175 
176  return result;
177 }
const IAxis & getAxis(size_t index) const
Definition: IDetector.cpp:54
virtual const RegionOfInterest * regionOfInterest() const =0
Returns region of interest if exists.

References IDetector::dimension(), IDetector::getAxis(), and IDetector::regionOfInterest().

Referenced by IDetector::createDetectorIntensity().

Here is the call graph for this function:

◆ detectionProperties()

◆ createDetectorIntensity()

OutputData< double > * IDetector::createDetectorIntensity ( const std::vector< SimulationElement > &  elements) const
inherited

Returns new intensity map with detector resolution applied.

Map will be cropped to ROI if ROI is present.

Definition at line 148 of file IDetector.cpp.

149 {
150  std::unique_ptr<OutputData<double>> detectorMap(createDetectorMap());
151  if (!detectorMap)
152  throw Exceptions::RuntimeErrorException("Instrument::createDetectorIntensity:"
153  "can't create detector map.");
154 
155  setDataToDetectorMap(*detectorMap, elements);
157  applyDetectorResolution(detectorMap.get());
158 
159  return detectorMap.release();
160 }
void setDataToDetectorMap(OutputData< double > &detectorMap, const std::vector< SimulationElement > &elements) const
Definition: IDetector.cpp:179
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
Definition: IDetector.cpp:117
std::unique_ptr< OutputData< double > > createDetectorMap() const
Returns empty detector map in given axes units.
Definition: IDetector.cpp:162

References IDetector::applyDetectorResolution(), IDetector::createDetectorMap(), IDetector::mP_detector_resolution, and IDetector::setDataToDetectorMap().

Here is the call graph for this function:

◆ numberOfSimulationElements()

size_t IDetector::numberOfSimulationElements ( ) const
inherited

Returns number of simulation elements.

Definition at line 189 of file IDetector.cpp.

190 {
191  size_t result(0);
192  iterate([&result](const_iterator) { ++result; });
193  return result;
194 }

References IDetector::iterate().

Here is the call graph for this function:

◆ getChildren()

std::vector< const INode * > IDetector::getChildren ( ) const
overridevirtualinherited

Returns a vector of children (const).

Reimplemented from INode.

Definition at line 196 of file IDetector.cpp.

197 {
198  return std::vector<const INode*>() << &m_detection_properties << mP_detector_resolution;
199 }

References IDetector::m_detection_properties, and IDetector::mP_detector_resolution.

◆ iterate()

void IDetector::iterate ( std::function< void(const_iterator)>  func,
bool  visit_masks = false 
) const
inherited

Definition at line 201 of file IDetector.cpp.

202 {
203  if (this->dimension() == 0)
204  return;
205 
206  if (visit_masks) {
207  SimulationRoiArea area(this);
208  for (SimulationRoiArea::iterator it = area.begin(); it != area.end(); ++it)
209  func(it);
210  } else {
211  SimulationArea area(this);
212  for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it)
213  func(it);
214  }
215 }
An iterator for SimulationArea.
Holds iteration logic over active detector channels in the presence of masked areas and RegionOfInter...
Holds iteration logic over active detector channels in the presence of ROI.

References SimulationArea::begin(), IDetector::dimension(), and SimulationArea::end().

Referenced by IDetector::applyDetectorResolution(), Simulation::convertData(), GISASSimulation::intensityMapSize(), IDetector::numberOfSimulationElements(), and IDetector::setDataToDetectorMap().

Here is the call graph for this function:

◆ clear()

void IDetector::clear ( )
protectedinherited

Definition at line 49 of file IDetector.cpp.

50 {
51  m_axes.clear();
52 }

References IDetector::m_axes.

Referenced by IDetector2D::setDetectorParameters().

◆ createAxis()

std::unique_ptr< IAxis > IDetector::createAxis ( size_t  index,
size_t  n_bins,
double  min,
double  max 
) const
protectedvirtualinherited

Generates an axis with correct name and default binning for given index.

Reimplemented in IsGISAXSDetector.

Definition at line 76 of file IDetector.cpp.

78 {
79  if (max <= min)
80  throw Exceptions::LogicErrorException("IDetector::createAxis() -> Error! max <= min");
81  if (n_bins == 0)
83  "IDetector::createAxis() -> Error! Number n_bins can't be zero.");
84  return std::make_unique<FixedBinAxis>(axisName(index), n_bins, min, max);
85 }
virtual std::string axisName(size_t index) const =0
Returns the name for the axis with given index.

References IDetector::axisName().

Referenced by IDetector2D::setDetectorParameters().

Here is the call graph for this function:

◆ setDataToDetectorMap()

void IDetector::setDataToDetectorMap ( OutputData< double > &  detectorMap,
const std::vector< SimulationElement > &  elements 
) const
privateinherited

Definition at line 179 of file IDetector.cpp.

181 {
182  if (elements.empty())
183  return;
184  iterate([&](const_iterator it) {
185  detectorMap[it.roiIndex()] = elements[it.elementIndex()].getIntensity();
186  });
187 }

References SimulationAreaIterator::elementIndex(), IDetector::iterate(), and SimulationAreaIterator::roiIndex().

Referenced by IDetector::createDetectorIntensity().

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 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 }
#define ASSERT(condition)
Definition: Assert.h:26
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(), ConvolutionDetectorResolution::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
const std::string & getName() const

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::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(), 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_axes

◆ m_detection_properties

DetectionProperties IDetector::m_detection_properties
privateinherited

◆ mP_detector_resolution

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