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

A flat rectangular detector with axes and resolution function. More...

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

Public Types

using const_iterator = const SimulationAreaIterator &
 
enum  EDetectorArrangement {
  GENERIC , PERPENDICULAR_TO_SAMPLE , PERPENDICULAR_TO_DIRECT_BEAM , PERPENDICULAR_TO_REFLECTED_BEAM ,
  PERPENDICULAR_TO_REFLECTED_BEAM_DPOS
}
 

Public Member Functions

 RectangularDetector (const RectangularDetector &other)
 
 RectangularDetector (size_t nxbins, double width, size_t nybins, double height)
 Rectangular detector constructor. More...
 
 ~RectangularDetector ()
 
void accept (INodeVisitor *visitor) const final
 Calls the INodeVisitor's visit method. More...
 
std::vector< size_t > active_indices () const
 Returns vector of unmasked detector indices. More...
 
void addAxis (const IAxis &axis)
 
void addMask (const IShape2D &shape, bool mask_value=true)
 Adds mask of given shape to the stack of detector masks. More...
 
void applyDetectorResolution (OutputData< double > *p_intensity_map) const
 Applies the detector resolution to the given intensity maps. More...
 
const IAxisaxis (size_t index) const
 
size_t axisBinIndex (size_t index, size_t selected_axis) const
 Calculate axis index for given global index. More...
 
RectangularDetectorclone () const override
 
int copyNumber (const INode *node) const
 Returns copyNumber of child, which takes into account existence of children with same name. More...
 
std::unique_ptr< DetectorContextcreateContext () const
 
OutputData< double > * createDetectorIntensity (const std::vector< SimulationElement > &elements) const
 Returns new intensity map with detector resolution applied. More...
 
std::unique_ptr< OutputData< double > > createDetectorMap () const
 Returns empty detector map in given axes units. More...
 
ParameterPoolcreateParameterTree () const
 Creates new parameter pool, with all local parameters and those of its children. More...
 
Axes::Units defaultAxesUnits () const override
 return default axes units More...
 
const DetectionPropertiesdetectionProperties () const
 Returns detection properties. More...
 
const DetectorMaskdetectorMask () const override
 Returns detector masks container. More...
 
const IDetectorResolutiondetectorResolution () const
 Returns a pointer to detector resolution object. More...
 
size_t dimension () const
 Returns actual dimensionality of the detector (number of defined axes) More...
 
std::string displayName () const
 Returns display name, composed from the name of node and it's copy number. More...
 
std::vector< const INode * > getChildren () const override
 Returns a vector of children. More...
 
EDetectorArrangement getDetectorArrangment () const
 
double getDirectBeamU0 () const
 
double getDirectBeamV0 () const
 
kvector_t getDirectionVector () const
 
double getDistance () const
 
double getHeight () const
 
const std::string & getName () const
 
size_t getNbinsX () const
 
size_t getNbinsY () const
 
kvector_t getNormalVector () const
 
double getU0 () const
 
double getV0 () const
 
double getWidth () const
 
void init (const Beam &beam) override
 Inits detector with the beam settings. More...
 
void iterate (std::function< void(const_iterator)> func, bool visit_masks=false) const
 
void maskAll ()
 Put the mask for all detector channels (i.e. exclude whole detector from the analysis) More...
 
size_t numberOfSimulationElements () const
 Returns number of simulation elements. More...
 
virtual void onChange ()
 Action to be taken in inherited class when a parameter has changed. More...
 
RealParameterparameter (const std::string &name) const
 Returns parameter with given 'name'. More...
 
ParameterPoolparameterPool () const
 Returns pointer to the parameter pool. More...
 
std::string parametersToString () const
 Returns multiline string representing available parameters. More...
 
INodeparent ()
 
const INodeparent () const
 
std::vector< const INode * > progeny () const
 Returns a vector of all descendants. More...
 
const RegionOfInterestregionOfInterest () const override
 Returns region of interest if exists. More...
 
RectangularPixelregionOfInterestPixel () const
 
void registerChild (INode *node)
 
RealParameterregisterParameter (const std::string &name, double *parpointer)
 
void registerVector (const std::string &base_name, kvector_t *p_vec, const std::string &units="nm")
 
void removeParameter (const std::string &name)
 
void removeVector (const std::string &base_name)
 
void resetRegionOfInterest () override
 Resets region of interest making whole detector plane available for the simulation. More...
 
void setAnalyzerProperties (const kvector_t direction, double efficiency, double total_transmission)
 Sets the polarization analyzer characteristics of the detector. More...
 
void 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. More...
 
void setDetectorResolution (const IDetectorResolution &p_detector_resolution)
 Sets the detector resolution. More...
 
void setDirectBeamPosition (double u0, double v0)
 
void setName (const std::string &name)
 
void setParameterValue (const std::string &name, double value)
 
virtual void setParent (const INode *newParent)
 
void setPerpendicularToDirectBeam (double distance, double u0, double v0)
 
void setPerpendicularToReflectedBeam (double distance, double u0=0.0, double v0=0.0)
 
void setPerpendicularToSampleX (double distance, double u0, double v0)
 
void setPosition (const kvector_t normal_to_detector, double u0, double v0, const kvector_t direction=kvector_t(0.0, -1.0, 0.0))
 
void setRegionOfInterest (double xlow, double ylow, double xup, double yup)
 Sets rectangular region of interest with lower left and upper right corners defined. More...
 
void setResolutionFunction (const IResolutionFunction2D &resFunc)
 
void setVectorValue (const std::string &base_name, kvector_t value)
 
size_t totalSize () const
 Returns total number of pixels. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
virtual std::string treeToString () const
 Returns multiline string representing tree structure below the node. More...
 

Static Public Member Functions

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

Protected Member Functions

std::string axisName (size_t index) const override
 Returns the name for the axis with given index. More...
 
void clear ()
 
virtual std::unique_ptr< IAxiscreateAxis (size_t index, size_t n_bins, double min, double max) const
 Generates an axis with correct name and default binning for given index. More...
 
IPixelcreatePixel (size_t index) const override
 Creates an IPixel for the given OutputData object and index. More...
 
size_t getGlobalIndex (size_t x, size_t y) const
 Calculate global index from two axis indices. More...
 
size_t indexOfSpecular (const Beam &beam) const override
 Returns index of pixel that contains the specular wavevector. More...
 
void swapContent (RectangularDetector &other)
 swap function More...
 

Protected Attributes

const size_t m_NP
 
std::vector< double > m_P
 

Private Member Functions

void initNormalVector (const kvector_t central_k)
 
void initUandV (double alpha_i)
 
void setDataToDetectorMap (OutputData< double > &detectorMap, const std::vector< SimulationElement > &elements) const
 
void setDistanceAndOffset (double distance, double u0, double v0)
 

Private Attributes

CloneableVector< IAxism_axes
 
double m_dbeam_u0
 
double m_dbeam_v0
 position of direct beam in detector coordinates More...
 
DetectionProperties m_detection_properties
 
EDetectorArrangement m_detector_arrangement
 
DetectorMask m_detector_mask
 
std::unique_ptr< IDetectorResolutionm_detector_resolution
 
kvector_t m_direction
 direction vector of detector coordinate system More...
 
double m_distance
 distance from sample origin to the detector plane More...
 
std::string m_name
 
kvector_t m_normal_to_detector
 
const INodem_parent {nullptr}
 
std::unique_ptr< ParameterPoolm_pool
 parameter pool (kind of pointer-to-implementation) More...
 
std::unique_ptr< RegionOfInterestm_region_of_interest
 
double m_u0
 
kvector_t m_u_unit
 
double m_v0
 position of normal vector hitting point in detector coordinates More...
 
kvector_t m_v_unit
 

Detailed Description

A flat rectangular detector with axes and resolution function.

Definition at line 26 of file RectangularDetector.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 38 of file IDetector.h.

Member Enumeration Documentation

◆ EDetectorArrangement

Enumerator
GENERIC 
PERPENDICULAR_TO_SAMPLE 
PERPENDICULAR_TO_DIRECT_BEAM 
PERPENDICULAR_TO_REFLECTED_BEAM 
PERPENDICULAR_TO_REFLECTED_BEAM_DPOS 

Definition at line 28 of file RectangularDetector.h.

Constructor & Destructor Documentation

◆ RectangularDetector() [1/2]

RectangularDetector::RectangularDetector ( size_t  nxbins,
double  width,
size_t  nybins,
double  height 
)

Rectangular detector constructor.

Parameters
nxbinsNumber of bins (pixels) in x-direction
widthWidth of the detector in mm along x-direction
nybinsNumber of bins (pixels) in y-direction
heightHeight of the detector in mm along y-direction

Definition at line 24 of file RectangularDetector.cpp.

25  : m_u0(0.0)
26  , m_v0(0.0)
27  , m_direction(kvector_t(0.0, -1.0, 0.0))
28  , m_distance(0.0)
29  , m_dbeam_u0(0.0)
30  , m_dbeam_v0(0.0)
32 {
33  setDetectorParameters(nxbins, 0.0, width, nybins, 0.0, height);
34  setName("RectangularDetector");
35 }
BasicVector3D< double > kvector_t
Definition: Vectors3D.h:21
void 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: IDetector2D.cpp:35
void setName(const std::string &name)
double m_dbeam_v0
position of direct beam in detector coordinates
double m_v0
position of normal vector hitting point in detector coordinates
kvector_t m_direction
direction vector of detector coordinate system
double m_distance
distance from sample origin to the detector plane
EDetectorArrangement m_detector_arrangement

References IDetector2D::setDetectorParameters(), and IParametricComponent::setName().

Referenced by clone().

Here is the call graph for this function:

◆ RectangularDetector() [2/2]

RectangularDetector::RectangularDetector ( const RectangularDetector other)

Definition at line 37 of file RectangularDetector.cpp.

38  : IDetector2D(other)
40  , m_u0(other.m_u0)
41  , m_v0(other.m_v0)
42  , m_direction(other.m_direction)
43  , m_distance(other.m_distance)
44  , m_dbeam_u0(other.m_dbeam_u0)
45  , m_dbeam_v0(other.m_dbeam_v0)
47  , m_u_unit(other.m_u_unit)
48  , m_v_unit(other.m_v_unit)
49 {
50  setName("RectangularDetector");
51 }

References IParametricComponent::setName().

Here is the call graph for this function:

◆ ~RectangularDetector()

RectangularDetector::~RectangularDetector ( )
default

Member Function Documentation

◆ accept()

void RectangularDetector::accept ( INodeVisitor visitor) const
inlinefinalvirtual

Calls the INodeVisitor's visit method.

Implements INode.

Definition at line 47 of file RectangularDetector.h.

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

◆ active_indices()

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

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:

◆ addAxis()

void IDetector::addAxis ( const IAxis axis)
inherited

Definition at line 41 of file IDetector.cpp.

42 {
44 }
void push_back(T *t)
virtual IAxis * clone() const =0
clone function
const IAxis & axis(size_t index) const
Definition: IDetector.cpp:56
CloneableVector< IAxis > m_axes
Definition: IDetector.h:114

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

Referenced by SpecularDetector1D::SpecularDetector1D(), SpecularDetector1D::setAxis(), IDetector2D::setDetectorParameters(), and SpecularSimulation::setScan().

Here is the call graph for this function:

◆ addMask()

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

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 74 of file IDetector2D.cpp.

75 {
76  m_detector_mask.addMask(shape, mask_value);
78 }
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.
DetectorMask m_detector_mask
Definition: IDetector2D.h:86

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

Referenced by ISimulation2D::addMask(), DetectorItem::addMasksToDomain(), and IDetector2D::maskAll().

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 118 of file IDetector.cpp.

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

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

Referenced by IDetector::createDetectorIntensity(), and OffSpecularSimulation::transferDetectorImage().

Here is the call graph for this function:

◆ axis()

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

Definition at line 56 of file IDetector.cpp.

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

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

Referenced by RegionOfInterest::RegionOfInterest(), SpecularDetector1D::SpecularDetector1D(), IDetector::addAxis(), UnitConverterSimple::addDetectorAxis(), OffSpecularConverter::addDetectorYAxis(), IDetector::createDetectorMap(), createPixel(), SphericalDetector::createPixel(), IDetector2D::getGlobalIndex(), getHeight(), getNbinsX(), getNbinsY(), getWidth(), indexOfSpecular(), SphericalDetector::indexOfSpecular(), DetectorMask::initMaskData(), OffSpecularSimulation::intensityMapSize(), DetectorUtils::isQuadratic(), regionOfInterestPixel(), SpecularDetector1D::setAxis(), TransformFromDomain::setSphericalDetector(), OffSpecularSimulation::transferDetectorImage(), and OffSpecularSimulation::transferResultsToIntensityMap().

Here is the call graph for this function:

◆ axisBinIndex()

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

Calculate axis index for given global index.

Definition at line 63 of file IDetector.cpp.

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

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

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

Here is the call graph for this function:

◆ axisName()

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

Returns the name for the axis with given index.

Implements IDetector.

Definition at line 209 of file RectangularDetector.cpp.

210 {
211  switch (index) {
212  case 0:
213  return "u";
214  case 1:
215  return "v";
216  default:
217  throw std::runtime_error(
218  "RectangularDetector::getAxisName(size_t index) -> Error! index > 1");
219  }
220 }

◆ clear()

void IDetector::clear ( )
protectedinherited

Definition at line 51 of file IDetector.cpp.

52 {
53  m_axes.clear();
54 }

References IDetector::m_axes.

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

◆ clone()

RectangularDetector * RectangularDetector::clone ( ) const
overridevirtual

Implements IDetector2D.

Definition at line 55 of file RectangularDetector.cpp.

56 {
57  return new RectangularDetector(*this);
58 }
RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
Rectangular detector constructor.

References RectangularDetector().

Here is the call graph for this function:

◆ copyNumber()

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

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

Definition at line 94 of file INode.cpp.

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

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

Referenced by INode::displayName().

Here is the call graph for this function:

◆ 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 78 of file IDetector.cpp.

80 {
81  if (max <= min)
82  throw std::runtime_error("IDetector::createAxis() -> Error! max <= min");
83  if (n_bins == 0)
84  throw std::runtime_error("IDetector::createAxis() -> Error! Number n_bins can't be zero.");
85  return std::make_unique<FixedBinAxis>(axisName(index), n_bins, min, max);
86 }
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:

◆ createContext()

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

Definition at line 69 of file IDetector2D.cpp.

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

Referenced by ISimulation2D::prepareSimulation().

◆ 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 144 of file IDetector.cpp.

145 {
146  std::unique_ptr<OutputData<double>> detectorMap(createDetectorMap());
147  if (!detectorMap)
148  throw std::runtime_error("Instrument::createDetectorIntensity:"
149  "can't create detector map.");
150 
151  setDataToDetectorMap(*detectorMap, elements);
153  applyDetectorResolution(detectorMap.get());
154 
155  return detectorMap.release();
156 }
void setDataToDetectorMap(OutputData< double > &detectorMap, const std::vector< SimulationElement > &elements) const
Definition: IDetector.cpp:175
void applyDetectorResolution(OutputData< double > *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
Definition: IDetector.cpp:118
std::unique_ptr< OutputData< double > > createDetectorMap() const
Returns empty detector map in given axes units.
Definition: IDetector.cpp:158

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

Here is the call graph for this function:

◆ createDetectorMap()

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

Returns empty detector map in given axes units.

Definition at line 158 of file IDetector.cpp.

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

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

Referenced by IDetector::createDetectorIntensity().

Here is the call graph for this function:

◆ createParameterTree()

ParameterPool * INode::createParameterTree ( ) const
virtualinherited

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

Reimplemented from IParametricComponent.

Definition at line 126 of file INode.cpp.

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

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

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

Here is the call graph for this function:

◆ createPixel()

IPixel * RectangularDetector::createPixel ( size_t  index) const
overrideprotectedvirtual

Creates an IPixel for the given OutputData object and index.

Implements IDetector2D.

Definition at line 193 of file RectangularDetector.cpp.

194 {
195  const IAxis& u_axis = axis(0);
196  const IAxis& v_axis = axis(1);
197  const size_t u_index = axisBinIndex(index, 0);
198  const size_t v_index = axisBinIndex(index, 1);
199 
200  const Bin1D u_bin = u_axis.bin(u_index);
201  const Bin1D v_bin = v_axis.bin(v_index);
202  const kvector_t corner_position(m_normal_to_detector + (u_bin.m_lower - m_u0) * m_u_unit
203  + (v_bin.m_lower - m_v0) * m_v_unit);
204  const kvector_t width = u_bin.binSize() * m_u_unit;
205  const kvector_t height = v_bin.binSize() * m_v_unit;
206  return new RectangularPixel(corner_position, width, height);
207 }
Interface for one-dimensional axes.
Definition: IAxis.h:25
virtual Bin1D bin(size_t index) const =0
retrieve a 1d bin for the given index
size_t axisBinIndex(size_t index, size_t selected_axis) const
Calculate axis index for given global index.
Definition: IDetector.cpp:63
A pixel in a RectangularDetector.
Definition: Bin.h:20
double binSize() const
Definition: Bin.h:26
double m_lower
lower bound of the bin
Definition: Bin.h:23

References IDetector::axis(), IDetector::axisBinIndex(), IAxis::bin(), Bin1D::binSize(), Bin1D::m_lower, m_normal_to_detector, m_u0, m_u_unit, m_v0, and m_v_unit.

Here is the call graph for this function:

◆ defaultAxesUnits()

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

return default axes units

Reimplemented from IDetector.

Definition at line 164 of file RectangularDetector.cpp.

165 {
166  return Axes::Units::MM;
167 }

◆ detectionProperties()

const DetectionProperties& IDetector::detectionProperties ( ) const
inlineinherited

◆ detectorMask()

const DetectorMask * IDetector2D::detectorMask ( ) const
overridevirtualinherited

Returns detector masks container.

Implements IDetector.

Definition at line 87 of file IDetector2D.cpp.

88 {
89  return &m_detector_mask;
90 }

References IDetector2D::m_detector_mask.

◆ detectorResolution()

const IDetectorResolution * IDetector::detectorResolution ( ) const
inherited

Returns a pointer to detector resolution object.

Definition at line 138 of file IDetector.cpp.

139 {
140  return m_detector_resolution.get();
141 }

References IDetector::m_detector_resolution.

Referenced by TransformFromDomain::setDetectorResolution().

◆ dimension()

◆ displayName()

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

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

Definition at line 115 of file INode.cpp.

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

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

Referenced by NodeUtils::nodePath().

Here is the call graph for this function:

◆ getChildren()

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

Returns a vector of children.

Reimplemented from INode.

Definition at line 192 of file IDetector.cpp.

193 {
194  return std::vector<const INode*>() << &m_detection_properties << m_detector_resolution;
195 }

References IDetector::m_detection_properties, and IDetector::m_detector_resolution.

◆ getDetectorArrangment()

RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrangment ( ) const

Definition at line 159 of file RectangularDetector.cpp.

160 {
161  return m_detector_arrangement;
162 }

References m_detector_arrangement.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getDirectBeamU0()

double RectangularDetector::getDirectBeamU0 ( ) const

Definition at line 149 of file RectangularDetector.cpp.

150 {
151  return m_dbeam_u0;
152 }

References m_dbeam_u0.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getDirectBeamV0()

double RectangularDetector::getDirectBeamV0 ( ) const

Definition at line 154 of file RectangularDetector.cpp.

155 {
156  return m_dbeam_v0;
157 }

References m_dbeam_v0.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getDirectionVector()

kvector_t RectangularDetector::getDirectionVector ( ) const

Definition at line 139 of file RectangularDetector.cpp.

140 {
141  return m_direction;
142 }

References m_direction.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getDistance()

double RectangularDetector::getDistance ( ) const

Definition at line 144 of file RectangularDetector.cpp.

145 {
146  return m_distance;
147 }

References m_distance.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getGlobalIndex()

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

Calculate global index from two axis indices.

Definition at line 92 of file IDetector2D.cpp.

93 {
94  if (dimension() != 2)
95  return totalSize();
96  return x * axis(1).size() + y;
97 }
virtual size_t size() const =0
retrieve the number of bins
size_t totalSize() const
Returns total number of pixels.
Definition: IDetector.cpp:88

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

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

Here is the call graph for this function:

◆ getHeight()

double RectangularDetector::getHeight ( ) const

Definition at line 109 of file RectangularDetector.cpp.

110 {
111  return axis(1).span();
112 }
double span() const
Returns distance from first to last point.
Definition: IAxis.cpp:42

References IDetector::axis(), and IAxis::span().

Referenced by regionOfInterestPixel(), and TransformFromDomain::setRectangularDetector().

Here is the call graph for this function:

◆ getName()

◆ getNbinsX()

size_t RectangularDetector::getNbinsX ( ) const

Definition at line 114 of file RectangularDetector.cpp.

115 {
116  return axis(0).size();
117 }

References IDetector::axis(), and IAxis::size().

Referenced by TransformFromDomain::setRectangularDetector().

Here is the call graph for this function:

◆ getNbinsY()

size_t RectangularDetector::getNbinsY ( ) const

Definition at line 119 of file RectangularDetector.cpp.

120 {
121  return axis(1).size();
122 }

References IDetector::axis(), and IAxis::size().

Referenced by TransformFromDomain::setRectangularDetector().

Here is the call graph for this function:

◆ getNormalVector()

kvector_t RectangularDetector::getNormalVector ( ) const

Definition at line 124 of file RectangularDetector.cpp.

125 {
126  return m_normal_to_detector;
127 }

References m_normal_to_detector.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getU0()

double RectangularDetector::getU0 ( ) const

Definition at line 129 of file RectangularDetector.cpp.

130 {
131  return m_u0;
132 }

References m_u0.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getV0()

double RectangularDetector::getV0 ( ) const

Definition at line 134 of file RectangularDetector.cpp.

135 {
136  return m_v0;
137 }

References m_v0.

Referenced by TransformFromDomain::setRectangularDetector().

◆ getWidth()

double RectangularDetector::getWidth ( ) const

Definition at line 104 of file RectangularDetector.cpp.

105 {
106  return axis(0).span();
107 }

References IDetector::axis(), and IAxis::span().

Referenced by regionOfInterestPixel(), and TransformFromDomain::setRectangularDetector().

Here is the call graph for this function:

◆ indexOfSpecular()

size_t RectangularDetector::indexOfSpecular ( const Beam beam) const
overrideprotectedvirtual

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.

Implements IDetector2D.

Definition at line 222 of file RectangularDetector.cpp.

223 {
224  if (dimension() != 2)
225  return totalSize();
226  const double alpha = beam.direction().alpha();
227  const double phi = beam.direction().phi();
228  const kvector_t k_spec = vecOfLambdaAlphaPhi(beam.wavelength(), alpha, phi);
229  const kvector_t normal_unit = m_normal_to_detector.unit();
230  const double kd = k_spec.dot(normal_unit);
231  if (kd <= 0.0)
232  return totalSize();
233  ASSERT(m_distance != 0);
234  const kvector_t rpix = k_spec * (m_distance / kd);
235  const double u = rpix.dot(m_u_unit) + m_u0;
236  const double v = rpix.dot(m_v_unit) + m_v0;
237  const IAxis& u_axis = axis(0); // the x axis, GISAS only
238  const IAxis& v_axis = axis(1); // the y axis, in reflectometer plane
239  if (!u_axis.contains(u) || !v_axis.contains(v))
240  return totalSize();
241  return getGlobalIndex(u_axis.findClosestIndex(u), v_axis.findClosestIndex(v));
242 }
#define ASSERT(condition)
Definition: Assert.h:31
kvector_t vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Definition: Direction.cpp:19
auto dot(const BasicVector3D< U > &v) const
Returns dot product of vectors (antilinear in the first [=self] argument).
BasicVector3D< T > unit() const
Returns unit vector in direction of this. Throws for null vector.
Direction direction() const
Definition: Beam.h:45
double wavelength() const
Definition: Beam.h:43
double phi() const
Definition: Direction.h:30
double alpha() const
Definition: Direction.h:29
virtual bool contains(double value) const
Returns true if axis contains given point.
Definition: IAxis.cpp:37
virtual size_t findClosestIndex(double value) const =0
find bin index which is best match for given value
size_t getGlobalIndex(size_t x, size_t y) const
Calculate global index from two axis indices.
Definition: IDetector2D.cpp:92

References Direction::alpha(), ASSERT, IDetector::axis(), IAxis::contains(), IDetector::dimension(), Beam::direction(), BasicVector3D< T >::dot(), IAxis::findClosestIndex(), IDetector2D::getGlobalIndex(), m_distance, m_normal_to_detector, m_u0, m_u_unit, m_v0, m_v_unit, Direction::phi(), IDetector::totalSize(), BasicVector3D< T >::unit(), vecOfLambdaAlphaPhi(), and Beam::wavelength().

Here is the call graph for this function:

◆ init()

void RectangularDetector::init ( const Beam )
overridevirtual

Inits detector with the beam settings.

Reimplemented from IDetector.

Definition at line 60 of file RectangularDetector.cpp.

61 {
62  double alpha_i = beam.direction().alpha();
63  kvector_t central_k = beam.getCentralK();
64  initNormalVector(central_k);
65  initUandV(alpha_i);
66 }
void initUandV(double alpha_i)
void initNormalVector(const kvector_t central_k)

References Direction::alpha(), Beam::direction(), Beam::getCentralK(), initNormalVector(), and initUandV().

Here is the call graph for this function:

◆ initNormalVector()

void RectangularDetector::initNormalVector ( const kvector_t  central_k)
private

Definition at line 257 of file RectangularDetector.cpp.

258 {
259  kvector_t central_k_unit = central_k.unit();
260 
262  // do nothing
263  }
264 
267  }
268 
270  m_normal_to_detector = m_distance * central_k_unit;
271  }
272 
275  m_normal_to_detector = m_distance * central_k_unit;
277  }
278 
279  else {
280  throw std::runtime_error("RectangularDetector::init() -> Unknown detector arrangement");
281  }
282 }
T z() const
Returns z-component in cartesian coordinate system.
Definition: BasicVector3D.h:67
void setZ(const T &a)
Sets z-component in cartesian coordinate system.
Definition: BasicVector3D.h:74

References GENERIC, m_detector_arrangement, m_distance, m_normal_to_detector, PERPENDICULAR_TO_DIRECT_BEAM, PERPENDICULAR_TO_REFLECTED_BEAM, PERPENDICULAR_TO_REFLECTED_BEAM_DPOS, PERPENDICULAR_TO_SAMPLE, BasicVector3D< T >::setZ(), BasicVector3D< T >::unit(), and BasicVector3D< T >::z().

Referenced by init().

Here is the call graph for this function:

◆ initUandV()

void RectangularDetector::initUandV ( double  alpha_i)
private

Definition at line 284 of file RectangularDetector.cpp.

285 {
287  kvector_t u_direction =
289  m_u_unit = u_direction.unit();
291 
293  kvector_t z(0.0, 0.0, 1.0);
294  kvector_t normal_unit = m_normal_to_detector.unit();
295  kvector_t zp = z - z.dot(normal_unit) * normal_unit;
296  double uz = zp.dot(m_u_unit) / zp.mag();
297  double vz = zp.dot(m_v_unit) / zp.mag();
298  m_u0 = m_dbeam_u0 + m_distance * std::tan(2 * alpha_i) * uz;
299  m_v0 = m_dbeam_v0 + m_distance * std::tan(2 * alpha_i) * vz;
300  }
301 }
double mag() const
Returns magnitude of the vector.
auto cross(const BasicVector3D< U > &v) const
Returns cross product of vectors (linear in both arguments).

References BasicVector3D< T >::cross(), BasicVector3D< T >::dot(), m_dbeam_u0, m_dbeam_v0, m_detector_arrangement, m_direction, m_distance, m_normal_to_detector, m_u0, m_u_unit, m_v0, m_v_unit, BasicVector3D< T >::mag(), PERPENDICULAR_TO_REFLECTED_BEAM_DPOS, and BasicVector3D< T >::unit().

Referenced by init().

Here is the call graph for this function:

◆ iterate()

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

Definition at line 197 of file IDetector.cpp.

198 {
199  if (this->dimension() == 0)
200  return;
201 
202  if (visit_masks) {
203  SimulationRoiArea area(this);
204  for (SimulationRoiArea::iterator it = area.begin(); it != area.end(); ++it)
205  func(it);
206  } else {
207  SimulationArea area(this);
208  for (SimulationArea::iterator it = area.begin(); it != area.end(); ++it)
209  func(it);
210  }
211 }
Holds iteration logic over active detector channels in the presence of ROI.

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

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

Here is the call graph for this function:

◆ maskAll()

void IDetector2D::maskAll ( )
inherited

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

Definition at line 80 of file IDetector2D.cpp.

81 {
82  if (dimension() != 2)
83  return;
84  addMask(InfinitePlane(), true);
85 }
void addMask(const IShape2D &shape, bool mask_value=true)
Adds mask of given shape to the stack of detector masks.
Definition: IDetector2D.cpp:74
The infinite plane is used for masking the entire detector.
Definition: InfinitePlane.h:28

References IDetector2D::addMask(), and IDetector::dimension().

Referenced by ISimulation2D::maskAll().

Here is the call graph for this function:

◆ numberOfSimulationElements()

size_t IDetector::numberOfSimulationElements ( ) const
inherited

Returns number of simulation elements.

Definition at line 185 of file IDetector.cpp.

186 {
187  size_t result(0);
188  iterate([&result](const_iterator) { ++result; });
189  return result;
190 }

References IDetector::iterate().

Here is the call graph for this function:

◆ onChange()

◆ parameter()

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

Returns parameter with given 'name'.

Definition at line 86 of file IParametricComponent.cpp.

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

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

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

Here is the call graph for this function:

◆ parameterPool()

ParameterPool* IParametricComponent::parameterPool ( ) const
inlineinherited

Returns pointer to the parameter pool.

Definition at line 39 of file IParametricComponent.h.

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

References IParametricComponent::m_pool.

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

◆ parametersToString()

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

Returns multiline string representing available parameters.

Definition at line 43 of file IParametricComponent.cpp.

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

References IParametricComponent::createParameterTree().

Here is the call graph for this function:

◆ parent() [1/2]

INode * INode::parent ( )
inherited

Definition at line 89 of file INode.cpp.

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

References INode::m_parent.

◆ parent() [2/2]

◆ progeny()

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

Returns a vector of all descendants.

Definition at line 68 of file INode.cpp.

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

References INode::getChildren().

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

Here is the call graph for this function:

◆ regionOfInterest()

const RegionOfInterest * IDetector2D::regionOfInterest ( ) const
overridevirtualinherited

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 }
std::unique_ptr< RegionOfInterest > m_region_of_interest
Definition: IDetector2D.h:87

References IDetector2D::m_region_of_interest.

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

◆ regionOfInterestPixel()

RectangularPixel * RectangularDetector::regionOfInterestPixel ( ) const

Definition at line 169 of file RectangularDetector.cpp.

170 {
171  const IAxis& u_axis = axis(0);
172  const IAxis& v_axis = axis(1);
173  double u_min, v_min, width, height;
174  auto p_roi = regionOfInterest();
175  if (p_roi) {
176  u_min = p_roi->getXlow();
177  v_min = p_roi->getYlow();
178  width = p_roi->getXup() - p_roi->getXlow();
179  height = p_roi->getYup() - p_roi->getYlow();
180  } else {
181  u_min = u_axis.lowerBound();
182  v_min = v_axis.lowerBound();
183  width = getWidth();
184  height = getHeight();
185  }
186  const kvector_t corner_position(m_normal_to_detector + (u_min - m_u0) * m_u_unit
187  + (v_min - m_v0) * m_v_unit);
188  const kvector_t uaxis_vector = width * m_u_unit;
189  const kvector_t vaxis_vector = height * m_v_unit;
190  return new RectangularPixel(corner_position, uaxis_vector, vaxis_vector);
191 }
virtual double lowerBound() const =0
Returns value of first point of axis.
const RegionOfInterest * regionOfInterest() const override
Returns region of interest if exists.
Definition: IDetector2D.cpp:43

References IDetector::axis(), getHeight(), getWidth(), IAxis::lowerBound(), m_normal_to_detector, m_u0, m_u_unit, m_v0, m_v_unit, and IDetector2D::regionOfInterest().

Referenced by RectangularConverter::RectangularConverter().

Here is the call graph for this function:

◆ registerChild()

void INode::registerChild ( INode node)
inherited

Definition at line 57 of file INode.cpp.

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

References ASSERT, and INode::setParent().

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

Here is the call graph for this function:

◆ registerParameter()

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

Definition at line 51 of file IParametricComponent.cpp.

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

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

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

Here is the call graph for this function:

◆ registerVector()

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

Definition at line 57 of file IParametricComponent.cpp.

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

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

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

Here is the call graph for this function:

◆ removeParameter()

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

Definition at line 91 of file IParametricComponent.cpp.

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

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

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

Here is the call graph for this function:

◆ removeVector()

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

Definition at line 96 of file IParametricComponent.cpp.

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

Referenced by IParticle::registerPosition().

Here is the call graph for this function:

◆ resetRegionOfInterest()

void IDetector2D::resetRegionOfInterest ( )
overridevirtualinherited

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(), IDetector2D::m_detector_mask, and IDetector2D::m_region_of_interest.

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 99 of file IDetector.cpp.

101 {
102  m_detection_properties.setAnalyzerProperties(direction, efficiency, total_transmission);
103 }
void setAnalyzerProperties(const kvector_t direction, double efficiency, double total_transmission)
Sets the polarization analyzer characteristics of the detector.

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

Referenced by StandardSimulations::BasicGISAS00(), StandardSimulations::BasicPolarizedGISAS(), StandardSimulations::MaxiGISAS00(), StandardSimulations::MiniGISASPolarizationMM(), StandardSimulations::MiniGISASPolarizationMP(), StandardSimulations::MiniGISASPolarizationPM(), and StandardSimulations::MiniGISASPolarizationPP().

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 175 of file IDetector.cpp.

177 {
178  if (elements.empty())
179  return;
180  iterate([&](const_iterator it) {
181  detectorMap[it.roiIndex()] = elements[it.elementIndex()].intensity();
182  });
183 }

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

Referenced by IDetector::createDetectorIntensity().

Here is the call graph for this function:

◆ setDetectorParameters()

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

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:51
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:78
void addAxis(const IAxis &axis)
Definition: IDetector.cpp:41

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

Referenced by IsGISAXSDetector::IsGISAXSDetector(), RectangularDetector(), SphericalDetector::SphericalDetector(), and ISimulation2D::setDetectorParameters().

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

106 {
107  m_detector_resolution.reset(p_detector_resolution.clone());
109 }
virtual IDetectorResolution * clone() const =0
void registerChild(INode *node)
Definition: INode.cpp:57

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

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

Here is the call graph for this function:

◆ setDirectBeamPosition()

void RectangularDetector::setDirectBeamPosition ( double  u0,
double  v0 
)

◆ setDistanceAndOffset()

void RectangularDetector::setDistanceAndOffset ( double  distance,
double  u0,
double  v0 
)
private

Definition at line 244 of file RectangularDetector.cpp.

245 {
246  if (distance <= 0.0) {
247  std::ostringstream message;
248  message << "RectangularDetector::setPerpendicularToSample() -> Error. "
249  << "Distance to sample can't be negative or zero";
250  throw std::runtime_error(message.str());
251  }
252  m_distance = distance;
253  m_u0 = u0;
254  m_v0 = v0;
255 }

References m_distance, m_u0, and m_v0.

Referenced by setPerpendicularToDirectBeam(), setPerpendicularToReflectedBeam(), and setPerpendicularToSampleX().

◆ setName()

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

Definition at line 69 of file IParametricComponent.h.

69 { m_name = name; }

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

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

Here is the call graph for this function:

◆ setParameterValue()

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

Definition at line 65 of file IParametricComponent.cpp.

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

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

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

Here is the call graph for this function:

◆ setParent()

void INode::setParent ( const INode newParent)
virtualinherited

Reimplemented in SampleProvider.

Definition at line 79 of file INode.cpp.

80 {
81  m_parent = newParent;
82 }

References INode::m_parent.

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

◆ setPerpendicularToDirectBeam()

void RectangularDetector::setPerpendicularToDirectBeam ( double  distance,
double  u0,
double  v0 
)

Definition at line 85 of file RectangularDetector.cpp.

86 {
88  setDistanceAndOffset(distance, u0, v0);
89 }
void setDistanceAndOffset(double distance, double u0, double v0)

References m_detector_arrangement, PERPENDICULAR_TO_DIRECT_BEAM, and setDistanceAndOffset().

Referenced by StandardSimulations::RectDetectorPerpToDirectBeam().

Here is the call graph for this function:

◆ setPerpendicularToReflectedBeam()

void RectangularDetector::setPerpendicularToReflectedBeam ( double  distance,
double  u0 = 0.0,
double  v0 = 0.0 
)

Definition at line 91 of file RectangularDetector.cpp.

References m_detector_arrangement, PERPENDICULAR_TO_REFLECTED_BEAM, and setDistanceAndOffset().

Referenced by StandardSimulations::RectDetectorPerpToReflectedBeam(), and StandardSimulations::RectDetectorPerpToReflectedBeamDpos().

Here is the call graph for this function:

◆ setPerpendicularToSampleX()

void RectangularDetector::setPerpendicularToSampleX ( double  distance,
double  u0,
double  v0 
)

Definition at line 79 of file RectangularDetector.cpp.

80 {
82  setDistanceAndOffset(distance, u0, v0);
83 }

References m_detector_arrangement, PERPENDICULAR_TO_SAMPLE, and setDistanceAndOffset().

Referenced by StandardSimulations::RectDetectorPerpToSample().

Here is the call graph for this function:

◆ setPosition()

void RectangularDetector::setPosition ( const kvector_t  normal_to_detector,
double  u0,
double  v0,
const kvector_t  direction = kvector_t(0.0, -1.0, 0.0) 
)

Definition at line 68 of file RectangularDetector.cpp.

70 {
72  m_normal_to_detector = normal_to_detector;
74  m_u0 = u0;
75  m_v0 = v0;
76  m_direction = direction;
77 }

References GENERIC, m_detector_arrangement, m_direction, m_distance, m_normal_to_detector, m_u0, m_v0, and BasicVector3D< T >::mag().

Referenced by StandardSimulations::RectDetectorGeneric().

Here is the call graph for this function:

◆ setRegionOfInterest()

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

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(), IDetector2D::m_detector_mask, and IDetector2D::m_region_of_interest.

Referenced by DetectorItem::addMasksToDomain(), and ISimulation2D::setRegionOfInterest().

Here is the call graph for this function:

◆ setResolutionFunction()

void IDetector::setResolutionFunction ( const IResolutionFunction2D resFunc)
inherited

Definition at line 112 of file IDetector.cpp.

113 {
114  ConvolutionDetectorResolution convFunc(resFunc);
115  setDetectorResolution(convFunc);
116 }
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:105

References IDetector::setDetectorResolution().

Referenced by ISimulation::setDetectorResolutionFunction().

Here is the call graph for this function:

◆ setVectorValue()

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

Definition at line 78 of file IParametricComponent.cpp.

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

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

Here is the call graph for this function:

◆ swapContent()

void RectangularDetector::swapContent ( RectangularDetector other)
protected

swap function

◆ totalSize()

size_t IDetector::totalSize ( ) const
inherited

Returns total number of pixels.

Definition at line 88 of file IDetector.cpp.

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

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

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

Here is the call graph for this function:

◆ transferToCPP()

virtual void ICloneable::transferToCPP ( )
inlinevirtualinherited

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

Definition at line 34 of file ICloneable.h.

◆ treeToString()

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

Returns multiline string representing tree structure below the node.

Definition at line 52 of file INode.cpp.

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

References NodeUtils::nodeToString().

Here is the call graph for this function:

◆ XComponentName()

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

Definition at line 103 of file IParametricComponent.cpp.

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

References ModelView::Utils::base_name().

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

Here is the call graph for this function:

◆ YComponentName()

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

Definition at line 108 of file IParametricComponent.cpp.

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

References ModelView::Utils::base_name().

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

Here is the call graph for this function:

◆ ZComponentName()

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

Definition at line 113 of file IParametricComponent.cpp.

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

References ModelView::Utils::base_name().

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

Here is the call graph for this function:

Member Data Documentation

◆ m_axes

◆ m_dbeam_u0

double RectangularDetector::m_dbeam_u0
private

Definition at line 104 of file RectangularDetector.h.

Referenced by getDirectBeamU0(), initUandV(), and setDirectBeamPosition().

◆ m_dbeam_v0

double RectangularDetector::m_dbeam_v0
private

position of direct beam in detector coordinates

Definition at line 104 of file RectangularDetector.h.

Referenced by getDirectBeamV0(), initUandV(), and setDirectBeamPosition().

◆ m_detection_properties

DetectionProperties IDetector::m_detection_properties
privateinherited

◆ m_detector_arrangement

◆ m_detector_mask

DetectorMask IDetector2D::m_detector_mask
privateinherited

◆ m_detector_resolution

◆ m_direction

kvector_t RectangularDetector::m_direction
private

direction vector of detector coordinate system

Definition at line 102 of file RectangularDetector.h.

Referenced by getDirectionVector(), initUandV(), and setPosition().

◆ m_distance

double RectangularDetector::m_distance
private

distance from sample origin to the detector plane

Definition at line 103 of file RectangularDetector.h.

Referenced by getDistance(), indexOfSpecular(), initNormalVector(), initUandV(), setDistanceAndOffset(), and setPosition().

◆ m_name

std::string IParametricComponent::m_name
privateinherited

◆ m_normal_to_detector

kvector_t RectangularDetector::m_normal_to_detector
private

◆ m_NP

const size_t INode::m_NP
protectedinherited

Definition at line 88 of file INode.h.

Referenced by INode::INode().

◆ m_P

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

Definition at line 89 of file INode.h.

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

◆ m_parent

const INode* INode::m_parent {nullptr}
privateinherited

Definition at line 83 of file INode.h.

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

◆ m_pool

◆ m_region_of_interest

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

◆ m_u0

double RectangularDetector::m_u0
private

◆ m_u_unit

kvector_t RectangularDetector::m_u_unit
private

◆ m_v0

double RectangularDetector::m_v0
private

position of normal vector hitting point in detector coordinates

Definition at line 101 of file RectangularDetector.h.

Referenced by createPixel(), getV0(), indexOfSpecular(), initUandV(), regionOfInterestPixel(), setDistanceAndOffset(), and setPosition().

◆ m_v_unit

kvector_t RectangularDetector::m_v_unit
private

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