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

Public Types

using const_iterator = const SimulationAreaIterator &
 

Public Member Functions

 IDetector2D ()
 
IDetector2Dclone () const override=0
 
virtual ~IDetector2D ()
 
void setDetectorParameters (size_t n_x, double x_min, double x_max, size_t n_y, double y_min, double y_max)
 
void removeMasks ()
 
const DetectorMaskdetectorMask () const override
 
void addMask (const IShape2D &shape, bool mask_value=true)
 
void maskAll ()
 
const RegionOfInterestregionOfInterest () const override
 
void setRegionOfInterest (double xlow, double ylow, double xup, double yup)
 
void resetRegionOfInterest () override
 
std::vector< size_t > active_indices () const
 
virtual IPixelcreatePixel (size_t index) const =0
 
virtual size_t indexOfSpecular (const Beam &beam) const =0
 
std::unique_ptr< DetectorContextcreateContext () const
 
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
 
virtual Axes::Units defaultAxesUnits () 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 void accept (INodeVisitor *visitor) const =0
 
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

 IDetector2D (const IDetector2D &other)
 
size_t getGlobalIndex (size_t x, size_t y) const
 
void clear ()
 
virtual std::string axisName (size_t index) const =0
 
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

DetectorMask m_detector_mask
 
std::unique_ptr< RegionOfInterestm_region_of_interest
 
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

Abstract 2D detector interface.

Definition at line 30 of file IDetector2D.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 38 of file IDetector.h.

Constructor & Destructor Documentation

◆ IDetector2D() [1/2]

IDetector2D::IDetector2D ( )
default

◆ ~IDetector2D()

IDetector2D::~IDetector2D ( )
virtualdefault

◆ IDetector2D() [2/2]

IDetector2D::IDetector2D ( const IDetector2D other)
protected

Definition at line 26 of file IDetector2D.cpp.

28 {
29  if (other.regionOfInterest())
31 }
DetectorMask m_detector_mask
Definition: IDetector2D.h:89
std::unique_ptr< RegionOfInterest > m_region_of_interest
Definition: IDetector2D.h:90
const RegionOfInterest * regionOfInterest() const override
Returns region of interest if exists.
Definition: IDetector2D.cpp:43
RegionOfInterest * clone() const

References RegionOfInterest::clone(), m_region_of_interest, and regionOfInterest().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

IDetector2D* IDetector2D::clone ( ) const
overridepure virtual

◆ setDetectorParameters()

void IDetector2D::setDetectorParameters ( size_t  n_x,
double  x_min,
double  x_max,
size_t  n_y,
double  y_min,
double  y_max 
)

Sets detector parameters using angle ranges.

Definition at line 35 of file IDetector2D.cpp.

37 {
38  clear();
39  addAxis(*createAxis(0, n_x, x_min, x_max));
40  addAxis(*createAxis(1, n_y, y_min, y_max));
41 }
void clear()
Definition: IDetector.cpp:49
virtual std::unique_ptr< IAxis > createAxis(size_t index, size_t n_bins, double min, double max) const
Generates an axis with correct name and default binning for given index.
Definition: IDetector.cpp:76
void addAxis(const IAxis &axis)
Definition: IDetector.cpp:39

References IDetector::addAxis(), IDetector::clear(), and IDetector::createAxis().

Referenced by IsGISAXSDetector::IsGISAXSDetector(), StandardSimulations::IsGISAXSSimulation1(), StandardSimulations::IsGISAXSSimulation2(), RectangularDetector::RectangularDetector(), Simulation2D::setDetectorParameters(), and SphericalDetector::SphericalDetector().

Here is the call graph for this function:

◆ removeMasks()

void IDetector2D::removeMasks ( )

Removes all masks from the detector.

Definition at line 74 of file IDetector2D.cpp.

75 {
77 }
void removeMasks()
remove all masks and return object to initial state

References m_detector_mask, and DetectorMask::removeMasks().

Referenced by Simulation2D::removeMasks().

Here is the call graph for this function:

◆ detectorMask()

const DetectorMask * IDetector2D::detectorMask ( ) const
overridevirtual

Returns detector masks container.

Implements IDetector.

Definition at line 93 of file IDetector2D.cpp.

94 {
95  return &m_detector_mask;
96 }

References m_detector_mask.

◆ addMask()

void IDetector2D::addMask ( const IShape2D shape,
bool  mask_value = true 
)

Adds mask of given shape to the stack of detector masks.

The mask value 'true' means that the channel will be excluded from the simulation. The mask which is added last has priority.

Parameters
shapeThe shape of mask (Rectangle, Polygon, Line, Ellipse)
mask_valueThe value of mask

Definition at line 79 of file IDetector2D.cpp.

80 {
81  m_detector_mask.addMask(shape, mask_value);
83 }
void addMask(const IShape2D &shape, bool mask_value)
Add mask to the stack of detector masks.
void initMaskData(const IDetector2D &detector)
Init the map of masks for the given detector plane.

References DetectorMask::addMask(), DetectorMask::initMaskData(), and m_detector_mask.

Referenced by Simulation2D::addMask(), and maskAll().

Here is the call graph for this function:

◆ maskAll()

void IDetector2D::maskAll ( )

Put the mask for all detector channels (i.e. exclude whole detector from the analysis)

Definition at line 85 of file IDetector2D.cpp.

86 {
87  if (dimension() != 2)
88  return;
90  addMask(InfinitePlane(), true);
91 }
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
Definition: IDetector2D.cpp:79
size_t dimension() const
Returns actual dimensionality of the detector (number of defined axes)
Definition: IDetector.cpp:44
The infinite plane is used for masking everything once and forever.
Definition: InfinitePlane.h:24

References addMask(), IDetector::dimension(), m_detector_mask, and DetectorMask::removeMasks().

Referenced by Simulation2D::maskAll().

Here is the call graph for this function:

◆ regionOfInterest()

const RegionOfInterest * IDetector2D::regionOfInterest ( ) const
overridevirtual

Returns region of interest if exists.

Implements IDetector.

Definition at line 43 of file IDetector2D.cpp.

44 {
45  return m_region_of_interest.get();
46 }

References m_region_of_interest.

Referenced by OffSpecularConverter::addDetectorYAxis(), IDetector2D(), and RectangularDetector::regionOfInterestPixel().

◆ setRegionOfInterest()

void IDetector2D::setRegionOfInterest ( double  xlow,
double  ylow,
double  xup,
double  yup 
)

Sets rectangular region of interest with lower left and upper right corners defined.

Definition at line 48 of file IDetector2D.cpp.

49 {
50  m_region_of_interest = std::make_unique<RegionOfInterest>(*this, xlow, ylow, xup, yup);
52 }

References DetectorMask::initMaskData(), m_detector_mask, and m_region_of_interest.

Referenced by Simulation2D::setRegionOfInterest().

Here is the call graph for this function:

◆ resetRegionOfInterest()

void IDetector2D::resetRegionOfInterest ( )
overridevirtual

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

Implements IDetector.

Definition at line 54 of file IDetector2D.cpp.

55 {
56  m_region_of_interest.reset();
58 }

References DetectorMask::initMaskData(), m_detector_mask, and m_region_of_interest.

Here is the call graph for this function:

◆ active_indices()

std::vector< size_t > IDetector2D::active_indices ( ) const

Returns vector of unmasked detector indices.

Definition at line 60 of file IDetector2D.cpp.

61 {
62  std::vector<size_t> result;
63  SimulationArea area(this);
64  for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it)
65  result.push_back(it.detectorIndex());
66  return result;
67 }
An iterator for SimulationArea.
Holds iteration logic over active detector channels in the presence of masked areas and RegionOfInter...

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

Referenced by DetectorContext::setup_context().

Here is the call graph for this function:

◆ createPixel()

virtual IPixel* IDetector2D::createPixel ( size_t  index) const
pure virtual

Creates an IPixel for the given OutputData object and index.

Implemented in SphericalDetector, and RectangularDetector.

Referenced by DetectorContext::setup_context().

◆ indexOfSpecular()

virtual size_t IDetector2D::indexOfSpecular ( const Beam beam) const
pure virtual

Returns index of pixel that contains the specular wavevector.

If no pixel contains this specular wavevector, the number of pixels is returned. This corresponds to an overflow index.

Implemented in SphericalDetector, RectangularDetector, and IsGISAXSDetector.

Referenced by Simulation2D::generateSimulationElements().

◆ createContext()

std::unique_ptr< DetectorContext > IDetector2D::createContext ( ) const

Definition at line 69 of file IDetector2D.cpp.

70 {
71  return std::make_unique<DetectorContext>(this);
72 }

Referenced by Simulation2D::prepareSimulation().

◆ getGlobalIndex()

size_t IDetector2D::getGlobalIndex ( size_t  x,
size_t  y 
) const
protected

Calculate global index from two axis indices.

Definition at line 98 of file IDetector2D.cpp.

99 {
100  if (dimension() != 2)
101  return totalSize();
102  return x * getAxis(1).size() + y;
103 }
virtual size_t size() const =0
retrieve the number of bins
size_t totalSize() const
Returns total number of pixels.
Definition: IDetector.cpp:87
const IAxis & getAxis(size_t index) const
Definition: IDetector.cpp:54

References IDetector::dimension(), IDetector::getAxis(), IAxis::size(), and IDetector::totalSize().

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

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 setDetectorParameters(), and SpecularDetector1D::SpecularDetector1D().

Here is the call graph for this function:

◆ getAxis()

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

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

◆ defaultAxesUnits()

virtual Axes::Units IDetector::defaultAxesUnits ( ) const
inlinevirtualinherited

Return default axes units.

Reimplemented in SphericalDetector, SpecularDetector1D, and RectangularDetector.

Definition at line 101 of file IDetector.h.

101 { return Axes::Units::DEFAULT; }

Referenced by anonymous_namespace{SimulationToPython.cpp}::printFunc().

◆ 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 }
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 setDetectorParameters().

◆ axisName()

virtual std::string IDetector::axisName ( size_t  index) const
protectedpure virtualinherited

Returns the name for the axis with given index.

Implemented in SphericalDetector, SpecularDetector1D, and RectangularDetector.

Referenced by IDetector::createAxis().

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

◆ accept()

virtual void INode::accept ( INodeVisitor visitor) const
pure virtualinherited

Calls the INodeVisitor's visit method.

Implemented in FormFactorSphereLogNormalRadius, FormFactorSphereGaussianRadius, FormFactorGaussSphere, FormFactorDecoratorRotation, FormFactorDecoratorPositionFactor, FormFactorDecoratorMaterial, ParticleDistribution, ParticleCoreShell, ParticleComposition, Particle, MesoCrystal, FormFactorWeighted, FormFactorCrystal, FormFactorCoreShell, Crystal, Layer, FormFactorTruncatedSpheroid, FormFactorTruncatedSphere, FormFactorTruncatedCube, FormFactorTetrahedron, FormFactorSawtoothRippleLorentz, FormFactorSawtoothRippleGauss, FormFactorSawtoothRippleBox, FormFactorPyramid, FormFactorPrism6, FormFactorPrism3, FormFactorLongBoxLorentz, FormFactorLongBoxGauss, FormFactorIcosahedron, FormFactorHollowSphere, FormFactorHemiEllipsoid, FormFactorFullSpheroid, FormFactorFullSphere, FormFactorEllipsoidalCylinder, FormFactorDot, FormFactorDodecahedron, FormFactorCylinder, FormFactorCuboctahedron, FormFactorCosineRippleLorentz, FormFactorCosineRippleGauss, FormFactorCosineRippleBox, FormFactorCone6, FormFactorCone, FormFactorCantellatedCube, FormFactorBox, FormFactorAnisoPyramid, FTDistribution1DVoigt, FTDistribution1DCosine, FTDistribution1DTriangle, FTDistribution1DGate, FTDistribution1DGauss, FTDistribution1DCauchy, InterferenceFunctionTwin, InterferenceFunctionRadialParaCrystal, InterferenceFunctionNone, InterferenceFunctionHardDisk, InterferenceFunctionFinite3DLattice, InterferenceFunctionFinite2DLattice, InterferenceFunction3DLattice, InterferenceFunction2DSuperLattice, InterferenceFunction2DParaCrystal, InterferenceFunction2DLattice, InterferenceFunction1DLattice, SpecularSimulation, DepthProbeSimulation, FormFactorDWBAPol, FormFactorDWBA, FormFactorBAPol, Lattice, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, SphericalDetector, SpecularDetector1D, FootprintSquare, FootprintGauss, Beam, GISASSimulation, PoissonNoiseBackground, ConstantBackground, MultiLayer, ParticleLayout, SampleProvider, SampleBuilderNode, HexagonalLattice, SquareLattice, BasicLattice, FormFactorBarLorentz, FormFactorBarGauss, FTDistribution2DVoigt, FTDistribution2DCone, FTDistribution2DGate, FTDistribution2DGauss, FTDistribution2DCauchy, FTDecayFunction2DVoigt, FTDecayFunction2DGauss, FTDecayFunction2DCauchy, FTDecayFunction1DVoigt, FTDecayFunction1DTriangle, FTDecayFunction1DGauss, FTDecayFunction1DCauchy, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, ConvolutionDetectorResolution, Instrument, RectangularDetector, IsGISAXSDetector, DetectionProperties, OffSpecSimulation, ILayout, LayerRoughness, LayerInterface, RotationEuler, RotationZ, RotationY, RotationX, IdentityRotation, and IAbstractParticle.

Referenced by VisitNodesPostorder(), and VisitNodesPreorder().

◆ 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(), 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_detector_mask

DetectorMask IDetector2D::m_detector_mask
private

◆ m_region_of_interest

std::unique_ptr<RegionOfInterest> IDetector2D::m_region_of_interest
private

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