BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
RectangularDetector Class Reference

Description

A flat rectangular detector with axes and resolution function.

Definition at line 26 of file RectangularDetector.h.

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 () override
 
std::vector< size_t > active_indices () const
 Returns vector of unmasked detector indices. More...
 
void addDetAxis (const IAxis &axis)
 
void 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. More...
 
const PolFilteranalyzer () const
 Returns detection properties. More...
 
void applyDetectorResolution (Datafield *p_intensity_map) const
 Applies the detector resolution to the given intensity maps. More...
 
OwningVector< IAxisaxesClippedToRegionOfInterest () const
 Returns the axes clipped to the region of interest. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". More...
 
const IAxisaxis (size_t index) const
 One axis of the complete detector. Any region of interest is not taken into account. More...
 
size_t axisBinIndex (size_t index, size_t selected_axis) const
 Calculate axis index for given global index. More...
 
SimulationAreaIterator beginNonMaskedPoints () const
 Create begin-iterator to iterate over all points which are not masked and lay within the "Region of Interest". More...
 
SimulationAreaIterator beginRegionOfInterestPoints () const
 Create begin-iterator to iterate over all points which lay within the "Region of Interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". No matter whether masked or not. More...
 
void checkNodeArgs () const
 Raises exception if a parameter value is invalid. More...
 
std::string className () const final
 Returns the class name, to be hard-coded in each leaf class that inherits from INode. More...
 
RectangularDetectorclone () const override
 
std::unique_ptr< DetectorContextcreateContext () const
 
DatafieldcreateDetectorIntensity (const std::vector< std::unique_ptr< DiffuseElement >> &elements) const
 Returns new intensity map with resolution applied, and cropped to ROI if applicable. More...
 
std::unique_ptr< DatafieldcreateDetectorMap () const
 Returns empty detector map in given axes units. This map is a data array limited to the size of the "Region of interest". More...
 
Coords defaultCoords () const override
 Returns default axes units. More...
 
size_t detectorIndexToRegionOfInterestIndex (size_t detectorIndex) const
 
const DetectorMaskdetectorMask () const
 
const IDetectorResolutiondetectorResolution () const
 Returns a pointer to detector resolution object. More...
 
SimulationAreaIterator endNonMaskedPoints () const
 Create end-iterator to iterate over all points which are not masked and lay within the "Region of Interest". More...
 
SimulationAreaIterator endRegionOfInterestPoints () const
 Create end-iterator to iterate over all points which lay within the "Region of Interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". No matter whether masked or not. More...
 
EDetectorArrangement getDetectorArrangment () const
 
double getDirectBeamU0 () const
 
double getDirectBeamV0 () const
 
R3 getDirectionVector () const
 
double getDistance () const
 
R3 getNormalVector () const
 
double getU0 () const
 
double getV0 () const
 
bool hasExplicitRegionOfInterest () const
 True if a region of interest is explicitly set. More...
 
double height () const
 
void iterateOverNonMaskedPoints (std::function< void(const_iterator)> func) const
 Iterate over all non-masked points within "region of interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". More...
 
void iterateOverRegionOfInterest (std::function< void(const_iterator)> func) const
 Iterate over all points within "region of interest", no matter whether they are masked or not. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". More...
 
void maskAll ()
 Put the mask for all detector channels (i.e. exclude whole detector from the analysis) More...
 
std::vector< const INode * > nodeChildren () const override
 Returns all children. More...
 
std::vector< const INode * > nodeOffspring () const
 Returns all descendants. More...
 
size_t numberOfElements () const
 Returns number of simulation elements. More...
 
ICoordSystemoffspecCoords (IAxis *beamAxis, const Direction &beamDirection) const override
 
virtual std::vector< ParaMetaparDefs () const
 Returns the parameter definitions, to be hard-coded in each leaf class. More...
 
size_t rank () const
 Returns number of defined axes. More...
 
std::pair< double, double > regionOfInterestBounds (size_t iAxis) const
 The lower and upper bound of the region of interest. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". More...
 
size_t regionOfInterestIndexToDetectorIndex (size_t regionOfInterestIndex) const
 Convert an index of the region of interest to an index of the detector. If no region of interest is set, then the index stays unmodified (since ROI == detector area). More...
 
RectangularPixelregionOfInterestPixel () const
 
void resetRegionOfInterest ()
 Resets region of interest making whole detector plane available for the simulation. More...
 
CoordSystem2DscatteringCoords (const Beam &beam) const override
 
void setAnalyzer (R3 direction, double efficiency, double total_transmission)
 Sets the polarization analyzer characteristics of the detector. More...
 
void setDetectorNormal (const Direction &direction) override
 Inits detector with the beam settings. More...
 
void setDetectorParameters (size_t n_x, double x_min, double x_max, size_t n_y, double y_min, double y_max)
 Sets equidistant axes. More...
 
void setDetectorPosition (R3 normal_to_detector, double u0, double v0, R3 direction=R3(0.0, -1.0, 0.0))
 
void setDetectorResolution (const IDetectorResolution &p_detector_resolution)
 Sets the detector resolution. More...
 
void setDirectBeamPosition (double u0, double v0)
 
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 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)
 
size_t sizeOfRegionOfInterest () const
 The size of the "Region of Interest". Same as totalSize() if no region of interest has been explicitly set. More...
 
size_t totalSize () const
 Returns total number of pixels. Any region of interest is not taken into account. More...
 
virtual void transferToCPP ()
 Used for Python overriding of clone (see swig/tweaks.py) More...
 
double width () const
 
size_t xSize () const
 
size_t ySize () const
 

Protected Member Functions

virtual std::pair< double, double > boundsOfExplicitRegionOfInterest (size_t iAxis) const
 Lower and upper bound of one axis of an explicitly set ROI. Return 0/0 if no ROI has been explicitly set. More...
 
void clear ()
 
size_t getGlobalIndex (size_t x, size_t y) const
 Calculate global index from two axis indices. More...
 
virtual size_t sizeOfExplicitRegionOfInterest () const
 Return 0 if no ROI has been explicitly set. Size means number of data points. More...
 

Protected Attributes

std::vector< RoiOfAxism_explicitROI
 an explicitly defined region of interest. Empty if no ROI has been defined. Vector index corresponds to axis index in m_axes More...
 
std::vector< double > m_P
 

Private Member Functions

std::string axisName (size_t index) const override
 Returns the name for the axis with given index. More...
 
IPixelcreatePixel (size_t index) const override
 Creates an IPixel for the given Datafield object and index. More...
 
size_t indexOfSpecular (const Beam &beam) const override
 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. More...
 
void initNormalVector (R3 central_k)
 
void initUandV (double alpha_i)
 
void setDistanceAndOffset (double distance, double u0, double v0)
 
void swapContent (RectangularDetector &other)
 swap function More...
 

Private Attributes

OwningVector< IAxism_axes
 
double m_dbeam_u0
 
double m_dbeam_v0
 position of direct beam in detector coordinates More...
 
EDetectorArrangement m_detector_arrangement
 
std::shared_ptr< DetectorMaskm_detector_mask
 
std::unique_ptr< IDetectorResolutionm_detector_resolution
 
R3 m_direction
 direction vector of detector coordinate system More...
 
double m_distance
 distance from sample origin to the detector plane More...
 
R3 m_normal_to_detector
 
PolFilter m_polAnalyzer
 
double m_u0
 
R3 m_u_unit
 
double m_v0
 position of normal vector hitting point in detector coordinates More...
 
R3 m_v_unit
 

Member Typedef Documentation

◆ const_iterator

Definition at line 59 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 27 of file RectangularDetector.cpp.

28  : m_u0(0.0)
29  , m_v0(0.0)
30  , m_direction(R3(0.0, -1.0, 0.0))
31  , m_distance(0.0)
32  , m_dbeam_u0(0.0)
33  , m_dbeam_v0(0.0)
35 {
36  setDetectorParameters(nxbins, 0.0, width, nybins, 0.0, height);
37 }
void setDetectorParameters(size_t n_x, double x_min, double x_max, size_t n_y, double y_min, double y_max)
Sets equidistant axes.
Definition: IDetector.cpp:329
R3 m_direction
direction vector of detector coordinate system
double m_dbeam_v0
position of direct beam in detector coordinates
double m_v0
position of normal vector hitting point in detector coordinates
double m_distance
distance from sample origin to the detector plane
EDetectorArrangement m_detector_arrangement

References height(), IDetector::setDetectorParameters(), and width().

Referenced by clone().

Here is the call graph for this function:

◆ RectangularDetector() [2/2]

RectangularDetector::RectangularDetector ( const RectangularDetector other)
default

◆ ~RectangularDetector()

RectangularDetector::~RectangularDetector ( )
overridedefault

Member Function Documentation

◆ active_indices()

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

Returns vector of unmasked detector indices.

Definition at line 346 of file IDetector.cpp.

347 {
348  std::vector<size_t> result;
349 
350  iterateOverNonMaskedPoints([&](const_iterator it) { result.push_back(it.detectorIndex()); });
351 
352  return result;
353 }
const SimulationAreaIterator & const_iterator
Definition: IDetector.h:59
void iterateOverNonMaskedPoints(std::function< void(const_iterator)> func) const
Iterate over all non-masked points within "region of interest". If no region of interest is explicitl...
Definition: IDetector.cpp:252

References SimulationAreaIterator::detectorIndex(), and IDetector::iterateOverNonMaskedPoints().

Referenced by DetectorContext::setup_context().

Here is the call graph for this function:

◆ addDetAxis()

void IDetector::addDetAxis ( const IAxis axis)
inherited

Definition at line 57 of file IDetector.cpp.

58 {
60  if (rank() == 2)
61  m_detector_mask.reset(new DetectorMask(*m_axes[0], *m_axes[1]));
62 }
Collection of detector masks.
Definition: DetectorMask.h:42
virtual IAxis * clone() const =0
OwningVector< IAxis > m_axes
Definition: IDetector.h:248
const IAxis & axis(size_t index) const
One axis of the complete detector. Any region of interest is not taken into account.
Definition: IDetector.cpp:74
size_t rank() const
Returns number of defined axes.
Definition: IDetector.cpp:64
std::shared_ptr< DetectorMask > m_detector_mask
Definition: IDetector.h:251
void emplace_back(T *e)
Definition: OwningVector.h:62

References IDetector::axis(), IAxis::clone(), OwningVector< T >::emplace_back(), IDetector::m_axes, IDetector::m_detector_mask, and IDetector::rank().

Referenced by IDetector::setDetectorParameters().

Here is the call graph for this function:

◆ addMask()

void IDetector::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 360 of file IDetector.cpp.

361 {
362  m_detector_mask->addMask(shape, mask_value);
363 }

References IDetector::m_detector_mask.

Referenced by ISimulation2D::addMask(), and IDetector::maskAll().

◆ analyzer()

const PolFilter& IDetector::analyzer ( ) const
inlineinherited

Returns detection properties.

Definition at line 204 of file IDetector.h.

204 { return m_polAnalyzer; }
PolFilter m_polAnalyzer
Definition: IDetector.h:249

References IDetector::m_polAnalyzer.

Referenced by ISimulation2D::force_polarized(), ISimulation2D::generateElements(), and DetectorContext::setup_context().

◆ applyDetectorResolution()

void IDetector::applyDetectorResolution ( Datafield p_intensity_map) const
inherited

Applies the detector resolution to the given intensity maps.

Definition at line 169 of file IDetector.cpp.

170 {
171  ASSERT(p_intensity_map);
172 
173  if (m_detector_resolution) {
174  m_detector_resolution->applyDetectorResolution(p_intensity_map);
175  if (detectorMask() && detectorMask()->hasMasks()) {
176  // sets amplitude in masked areas to zero
177  std::unique_ptr<Datafield> buff(new Datafield(p_intensity_map->frame().cloned_axes()));
179  (*buff)[it.roiIndex()] = (*p_intensity_map)[it.roiIndex()];
180  });
181  p_intensity_map->setVector(buff->flatVector());
182  }
183  }
184 }
#define ASSERT(condition)
Definition: Assert.h:45
Stores radiation power per bin.
Definition: Datafield.h:30
void setVector(const std::vector< double > &data_vector)
Sets new values to raw data vector.
Definition: Datafield.cpp:69
const Frame & frame() const
Definition: Datafield.cpp:86
std::vector< IAxis * > cloned_axes() const
Returns cloned axes.
Definition: Frame.cpp:32
std::unique_ptr< IDetectorResolution > m_detector_resolution
Definition: IDetector.h:250
const DetectorMask * detectorMask() const
Definition: IDetector.cpp:372

References ASSERT, Frame::cloned_axes(), IDetector::detectorMask(), Datafield::frame(), IDetector::iterateOverNonMaskedPoints(), IDetector::m_detector_resolution, SimulationAreaIterator::roiIndex(), and Datafield::setVector().

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

Here is the call graph for this function:

◆ axesClippedToRegionOfInterest()

OwningVector< IAxis > IDetector::axesClippedToRegionOfInterest ( ) const
inherited

Returns the axes clipped to the region of interest. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest".

Definition at line 136 of file IDetector.cpp.

137 {
138  OwningVector<IAxis> result;
139  for (size_t iAxis = 0; iAxis < m_axes.size(); ++iAxis) {
140  auto* axis = m_axes[iAxis]->clone();
142  result.emplace_back(axis);
143  }
144  return result;
145 }
virtual void clip(double lower, double upper)
Clips this axis to the given values.
Definition: IAxis.cpp:35
std::pair< double, double > regionOfInterestBounds(size_t iAxis) const
The lower and upper bound of the region of interest. If no region of interest is explicitly defined,...
Definition: IDetector.cpp:227
size_t size() const
Definition: OwningVector.h:70

References IDetector::axis(), IAxis::clip(), OwningVector< T >::emplace_back(), IDetector::m_axes, IDetector::regionOfInterestBounds(), and OwningVector< T >::size().

Referenced by offspecCoords(), SphericalDetector::offspecCoords(), scatteringCoords(), and SphericalDetector::scatteringCoords().

Here is the call graph for this function:

◆ axis()

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

One axis of the complete detector. Any region of interest is not taken into account.

Definition at line 74 of file IDetector.cpp.

75 {
76  ASSERT(index < rank());
77  return *m_axes[index];
78 }

References ASSERT, IDetector::m_axes, and IDetector::rank().

Referenced by IDetector::RoiOfAxis::RoiOfAxis(), IDetector::addDetAxis(), IDetector::axesClippedToRegionOfInterest(), IDetector::createDetectorMap(), createPixel(), SphericalDetector::createPixel(), IDetector::getGlobalIndex(), height(), indexOfSpecular(), SphericalDetector::indexOfSpecular(), OffspecSimulation::intensityMapSize(), OffspecSimulation::pack_result(), IDetector::setRegionOfInterest(), OffspecSimulation::transferDetectorImage(), width(), xSize(), and ySize().

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

81 {
82  const size_t dim = rank();
83  size_t remainder(index);
84  size_t i_axis = dim;
85  for (size_t i = 0; i < dim; ++i) {
86  --i_axis;
87  if (selected_axis == i_axis)
88  return remainder % m_axes[i_axis]->size();
89  remainder /= m_axes[i_axis]->size();
90  }
91  ASSERT(0);
92 }

References ASSERT, IDetector::m_axes, IDetector::rank(), and OwningVector< T >::size().

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

Here is the call graph for this function:

◆ axisName()

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

Returns the name for the axis with given index.

Implements IDetector.

Definition at line 185 of file RectangularDetector.cpp.

186 {
187  switch (index) {
188  case 0:
189  return "u";
190  case 1:
191  return "v";
192  default:
193  throw std::runtime_error(
194  "RectangularDetector::getAxisName(size_t index) -> Error! index > 1");
195  }
196 }

◆ beginNonMaskedPoints()

SimulationAreaIterator IDetector::beginNonMaskedPoints ( ) const
inherited

Create begin-iterator to iterate over all points which are not masked and lay within the "Region of Interest".

Definition at line 261 of file IDetector.cpp.

262 {
264 }
@ notMasked
iterate over all points in "region of interest" and not masked
static SimulationAreaIterator createBegin(const IDetector *detector, Mode mode)
Create begin-iterator to iterate over all points according to the given mode.

References SimulationAreaIterator::createBegin(), and SimulationAreaIterator::notMasked.

Referenced by IDetector::createDetectorIntensity(), and IDetector::iterateOverNonMaskedPoints().

Here is the call graph for this function:

◆ beginRegionOfInterestPoints()

SimulationAreaIterator IDetector::beginRegionOfInterestPoints ( ) const
inherited

Create begin-iterator to iterate over all points which lay within the "Region of Interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". No matter whether masked or not.

Definition at line 271 of file IDetector.cpp.

272 {
274 }
@ regionOfInterest
iterate over all points in "region of interest", no matter whether masked

References SimulationAreaIterator::createBegin(), and SimulationAreaIterator::regionOfInterest.

Referenced by IDetector::iterateOverRegionOfInterest().

Here is the call graph for this function:

◆ boundsOfExplicitRegionOfInterest()

std::pair< double, double > IDetector::boundsOfExplicitRegionOfInterest ( size_t  iAxis) const
protectedvirtualinherited

Lower and upper bound of one axis of an explicitly set ROI. Return 0/0 if no ROI has been explicitly set.

Definition at line 106 of file IDetector.cpp.

107 {
108  ASSERT(iAxis < rank());
109  if (iAxis < m_explicitROI.size())
110  return {m_explicitROI[iAxis].lower, m_explicitROI[iAxis].upper};
111  return {0., 0.};
112 }
std::vector< RoiOfAxis > m_explicitROI
an explicitly defined region of interest. Empty if no ROI has been defined. Vector index corresponds ...
Definition: IDetector.h:242

References ASSERT, IDetector::m_explicitROI, and IDetector::rank().

Referenced by IDetector::regionOfInterestBounds().

Here is the call graph for this function:

◆ checkNodeArgs()

void INode::checkNodeArgs ( ) const
inherited

Raises exception if a parameter value is invalid.

Definition at line 27 of file INode.cpp.

28 {
29  size_t nP = m_P.size();
30  if (parDefs().size() != nP) {
31  std::cerr << "BUG in class " << className() << std::endl;
32  std::cerr << "#m_P = " << nP << std::endl;
33  std::cerr << "#PDf = " << parDefs().size() << std::endl;
34  for (const ParaMeta& pm : parDefs())
35  std::cerr << " PDf: " << pm.name << std::endl;
36  ASSERT(0);
37  }
38  ASSERT(parDefs().size() == nP);
39  for (size_t i = 0; i < nP; ++i) {
40  const ParaMeta pm = parDefs()[i];
41 
43  if (pm.vMin == -INF) {
44  ASSERT(pm.vMax == +INF);
45  // nothing to do
46  } else if (pm.vMax == +INF) {
47  ASSERT(pm.vMin == 0);
48  limits = RealLimits::nonnegative();
49  } else {
50  limits = RealLimits::limited(pm.vMin, pm.vMax);
51  }
52  limits.check(pm.name, m_P[i]);
53  }
54 }
const double INF
Definition: INode.h:26
virtual std::vector< ParaMeta > parDefs() const
Returns the parameter definitions, to be hard-coded in each leaf class.
Definition: INode.h:51
std::vector< double > m_P
Definition: INode.h:63
virtual std::string className() const =0
Returns the class name, to be hard-coded in each leaf class that inherits from INode.
Limits for a real fit parameter.
Definition: RealLimits.h:24
static RealLimits limitless()
Creates an object without bounds (default)
Definition: RealLimits.cpp:139
void check(const std::string &name, double value) const
Throws if value is outside limits. Parameter 'name' is for exception message.
Definition: RealLimits.cpp:170
static RealLimits nonnegative()
Creates an object which can have only positive values with 0. included.
Definition: RealLimits.cpp:124
static RealLimits limited(double left_bound_value, double right_bound_value)
Creates an object bounded from the left and right.
Definition: RealLimits.cpp:134
Metadata of one model parameter.
Definition: INode.h:29
double vMin
Definition: INode.h:33
double vMax
Definition: INode.h:34
std::string name
Definition: INode.h:30

References ASSERT, RealLimits::check(), INode::className(), INF, RealLimits::limited(), RealLimits::limitless(), INode::m_P, ParaMeta::name, RealLimits::nonnegative(), INode::parDefs(), ParaMeta::vMax, and ParaMeta::vMin.

Referenced by BarGauss::BarGauss(), BarLorentz::BarLorentz(), Bipyramid4::Bipyramid4(), Box::Box(), CantellatedCube::CantellatedCube(), Cone::Cone(), ConstantBackground::ConstantBackground(), CosineRippleBox::CosineRippleBox(), CosineRippleGauss::CosineRippleGauss(), CosineRippleLorentz::CosineRippleLorentz(), Cylinder::Cylinder(), DistributionCosine::DistributionCosine(), DistributionGate::DistributionGate(), DistributionGaussian::DistributionGaussian(), DistributionLogNormal::DistributionLogNormal(), DistributionLorentz::DistributionLorentz(), DistributionTrapezoid::DistributionTrapezoid(), Dodecahedron::Dodecahedron(), EllipsoidalCylinder::EllipsoidalCylinder(), FootprintGauss::FootprintGauss(), FootprintSquare::FootprintSquare(), FuzzySphere::FuzzySphere(), GaussSphere::GaussSphere(), HemiEllipsoid::HemiEllipsoid(), HollowSphere::HollowSphere(), HorizontalCylinder::HorizontalCylinder(), Icosahedron::Icosahedron(), LongBoxGauss::LongBoxGauss(), LongBoxLorentz::LongBoxLorentz(), PlatonicOctahedron::PlatonicOctahedron(), PlatonicTetrahedron::PlatonicTetrahedron(), Prism3::Prism3(), Prism6::Prism6(), Profile1DCauchy::Profile1DCauchy(), Profile1DCosine::Profile1DCosine(), Profile1DGate::Profile1DGate(), Profile1DGauss::Profile1DGauss(), Profile1DTriangle::Profile1DTriangle(), Profile1DVoigt::Profile1DVoigt(), Profile2DCauchy::Profile2DCauchy(), Profile2DCone::Profile2DCone(), Profile2DGate::Profile2DGate(), Profile2DGauss::Profile2DGauss(), Profile2DVoigt::Profile2DVoigt(), Pyramid2::Pyramid2(), Pyramid3::Pyramid3(), Pyramid4::Pyramid4(), Pyramid6::Pyramid6(), RotationEuler::RotationEuler(), RotationX::RotationX(), RotationY::RotationY(), RotationZ::RotationZ(), SawtoothRippleBox::SawtoothRippleBox(), SawtoothRippleGauss::SawtoothRippleGauss(), SawtoothRippleLorentz::SawtoothRippleLorentz(), Sphere::Sphere(), Spheroid::Spheroid(), TruncatedCube::TruncatedCube(), TruncatedSphere::TruncatedSphere(), and TruncatedSpheroid::TruncatedSpheroid().

Here is the call graph for this function:

◆ className()

std::string RectangularDetector::className ( ) const
inlinefinalvirtual

Returns the class name, to be hard-coded in each leaf class that inherits from INode.

Implements INode.

Definition at line 47 of file RectangularDetector.h.

47 { return "RectangularDetector"; }

◆ clear()

void IDetector::clear ( )
protectedinherited

Definition at line 69 of file IDetector.cpp.

70 {
71  m_axes.clear();
72 }
void clear()
Definition: OwningVector.h:63

References OwningVector< T >::clear(), and IDetector::m_axes.

Referenced by IDetector::setDetectorParameters().

Here is the call graph for this function:

◆ clone()

RectangularDetector * RectangularDetector::clone ( ) const
overridevirtual

Implements IDetector.

Definition at line 45 of file RectangularDetector.cpp.

46 {
47  return new RectangularDetector(*this);
48 }
RectangularDetector(size_t nxbins, double width, size_t nybins, double height)
Rectangular detector constructor.

References RectangularDetector().

Here is the call graph for this function:

◆ createContext()

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

Definition at line 355 of file IDetector.cpp.

356 {
357  return std::make_unique<DetectorContext>(this);
358 }

Referenced by ISimulation2D::prepareSimulation().

◆ createDetectorIntensity()

Datafield * IDetector::createDetectorIntensity ( const std::vector< std::unique_ptr< DiffuseElement >> &  elements) const
inherited

Returns new intensity map with resolution applied, and cropped to ROI if applicable.

Definition at line 191 of file IDetector.cpp.

193 {
194  std::unique_ptr<Datafield> detectorMap(createDetectorMap());
195  ASSERT(detectorMap);
196  size_t elementIndex = 0;
197  for (auto it = beginNonMaskedPoints(); it != endNonMaskedPoints(); ++it)
198  (*detectorMap)[it.roiIndex()] = elements[elementIndex++]->intensity();
200  applyDetectorResolution(detectorMap.get());
201 
202  return detectorMap.release();
203 }
SimulationAreaIterator beginNonMaskedPoints() const
Create begin-iterator to iterate over all points which are not masked and lay within the "Region of I...
Definition: IDetector.cpp:261
std::unique_ptr< Datafield > createDetectorMap() const
Returns empty detector map in given axes units. This map is a data array limited to the size of the "...
Definition: IDetector.cpp:205
SimulationAreaIterator endNonMaskedPoints() const
Create end-iterator to iterate over all points which are not masked and lay within the "Region of Int...
Definition: IDetector.cpp:266
void applyDetectorResolution(Datafield *p_intensity_map) const
Applies the detector resolution to the given intensity maps.
Definition: IDetector.cpp:169

References IDetector::applyDetectorResolution(), ASSERT, IDetector::beginNonMaskedPoints(), IDetector::createDetectorMap(), IDetector::endNonMaskedPoints(), and IDetector::m_detector_resolution.

Here is the call graph for this function:

◆ createDetectorMap()

std::unique_ptr< Datafield > IDetector::createDetectorMap ( ) const
inherited

Returns empty detector map in given axes units. This map is a data array limited to the size of the "Region of interest".

Definition at line 205 of file IDetector.cpp.

206 {
207  const size_t dim = rank();
208  ASSERT(dim != 0);
209 
210  std::vector<IAxis*> axes;
211  for (size_t iAxis = 0; iAxis < dim; ++iAxis) {
212  IAxis* tmp = axis(iAxis).clone();
213  tmp->clip(regionOfInterestBounds(iAxis));
214  axes.emplace_back(tmp);
215  }
216 
217  return std::make_unique<Datafield>(axes);
218 }
Abstract base class for one-dimensional axes.
Definition: IAxis.h:27

References ASSERT, IDetector::axis(), IAxis::clip(), IAxis::clone(), IDetector::rank(), and IDetector::regionOfInterestBounds().

Referenced by IDetector::createDetectorIntensity().

Here is the call graph for this function:

◆ createPixel()

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

Creates an IPixel for the given Datafield object and index.

Implements IDetector.

Definition at line 169 of file RectangularDetector.cpp.

170 {
171  const IAxis& u_axis = axis(0);
172  const IAxis& v_axis = axis(1);
173  const size_t u_index = axisBinIndex(index, 0);
174  const size_t v_index = axisBinIndex(index, 1);
175 
176  const Bin1D u_bin = u_axis.bin(u_index);
177  const Bin1D v_bin = v_axis.bin(v_index);
178  const R3 corner_position(m_normal_to_detector + (u_bin.m_lower - m_u0) * m_u_unit
179  + (v_bin.m_lower - m_v0) * m_v_unit);
180  const R3 width = u_bin.binSize() * m_u_unit;
181  const R3 height = v_bin.binSize() * m_v_unit;
182  return new RectangularPixel(corner_position, width, height);
183 }
Definition: Bin.h:20
double binSize() const
Definition: Bin.h:31
double m_lower
lower bound of the bin
Definition: Bin.h:28
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:80
A pixel in a RectangularDetector.

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

Here is the call graph for this function:

◆ defaultCoords()

Coords RectangularDetector::defaultCoords ( ) const
inlineoverridevirtual

Returns default axes units.

Implements IDetector.

Definition at line 74 of file RectangularDetector.h.

74 { return Coords::MM; }

References MM.

◆ detectorIndexToRegionOfInterestIndex()

size_t IDetector::detectorIndexToRegionOfInterestIndex ( size_t  detectorIndex) const
inherited

Definition at line 294 of file IDetector.cpp.

295 {
296  if (m_explicitROI.size() != 2)
297  return detectorIndex;
298 
299  const auto& x = m_explicitROI[0];
300  const auto& y = m_explicitROI[1];
301 
302  const size_t ny = ycoord(detectorIndex, y.detectorSize);
303  if (ny < y.lowerIndex || ny > y.upperIndex)
304  throw std::runtime_error("IDetector::detectorIndexToRegionOfInterestIndex() -> Error.");
305 
306  const size_t nx = xcoord(detectorIndex, x.detectorSize, y.detectorSize);
307  if (nx < x.lowerIndex || nx > x.upperIndex)
308  throw std::runtime_error("IDetector::detectorIndexToRegionOfInterestIndex() -> Error.");
309 
310  return ny - y.lowerIndex + (nx - x.lowerIndex) * y.roiSize;
311 }

References IDetector::m_explicitROI.

◆ detectorMask()

const DetectorMask * IDetector::detectorMask ( ) const
inherited

Definition at line 372 of file IDetector.cpp.

373 {
374  return m_detector_mask.get();
375 }

References IDetector::m_detector_mask.

Referenced by IDetector::applyDetectorResolution(), and SimulationAreaIterator::isMasked().

◆ detectorResolution()

const IDetectorResolution * IDetector::detectorResolution ( ) const
inherited

Returns a pointer to detector resolution object.

Definition at line 186 of file IDetector.cpp.

187 {
188  return m_detector_resolution.get();
189 }

References IDetector::m_detector_resolution.

◆ endNonMaskedPoints()

SimulationAreaIterator IDetector::endNonMaskedPoints ( ) const
inherited

Create end-iterator to iterate over all points which are not masked and lay within the "Region of Interest".

Definition at line 266 of file IDetector.cpp.

267 {
269 }
SimulationAreaIterator createEnd() const
Convenience function to create an end-iterator matching to this iterator.

References SimulationAreaIterator::createEnd(), and SimulationAreaIterator::notMasked.

Referenced by IDetector::createDetectorIntensity(), and IDetector::iterateOverNonMaskedPoints().

Here is the call graph for this function:

◆ endRegionOfInterestPoints()

SimulationAreaIterator IDetector::endRegionOfInterestPoints ( ) const
inherited

Create end-iterator to iterate over all points which lay within the "Region of Interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest". No matter whether masked or not.

Definition at line 276 of file IDetector.cpp.

References SimulationAreaIterator::createEnd(), and SimulationAreaIterator::regionOfInterest.

Referenced by IDetector::iterateOverRegionOfInterest().

Here is the call graph for this function:

◆ getDetectorArrangment()

RectangularDetector::EDetectorArrangement RectangularDetector::getDetectorArrangment ( ) const

Definition at line 147 of file RectangularDetector.cpp.

148 {
149  return m_detector_arrangement;
150 }

References m_detector_arrangement.

◆ getDirectBeamU0()

double RectangularDetector::getDirectBeamU0 ( ) const

Definition at line 137 of file RectangularDetector.cpp.

138 {
139  return m_dbeam_u0;
140 }

References m_dbeam_u0.

◆ getDirectBeamV0()

double RectangularDetector::getDirectBeamV0 ( ) const

Definition at line 142 of file RectangularDetector.cpp.

143 {
144  return m_dbeam_v0;
145 }

References m_dbeam_v0.

◆ getDirectionVector()

R3 RectangularDetector::getDirectionVector ( ) const

Definition at line 127 of file RectangularDetector.cpp.

128 {
129  return m_direction;
130 }

References m_direction.

◆ getDistance()

double RectangularDetector::getDistance ( ) const

Definition at line 132 of file RectangularDetector.cpp.

133 {
134  return m_distance;
135 }

References m_distance.

◆ getGlobalIndex()

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

Calculate global index from two axis indices.

Definition at line 377 of file IDetector.cpp.

378 {
379  if (rank() != 2)
380  return totalSize();
381  return x * axis(1).size() + y;
382 }
virtual size_t size() const =0
Returns the number of bins.
size_t totalSize() const
Returns total number of pixels. Any region of interest is not taken into account.
Definition: IDetector.cpp:114

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

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

Here is the call graph for this function:

◆ getNormalVector()

R3 RectangularDetector::getNormalVector ( ) const

Definition at line 112 of file RectangularDetector.cpp.

113 {
114  return m_normal_to_detector;
115 }

References m_normal_to_detector.

◆ getU0()

double RectangularDetector::getU0 ( ) const

Definition at line 117 of file RectangularDetector.cpp.

118 {
119  return m_u0;
120 }

References m_u0.

◆ getV0()

double RectangularDetector::getV0 ( ) const

Definition at line 122 of file RectangularDetector.cpp.

123 {
124  return m_v0;
125 }

References m_v0.

◆ hasExplicitRegionOfInterest()

bool IDetector::hasExplicitRegionOfInterest ( ) const
inherited

True if a region of interest is explicitly set.

Definition at line 131 of file IDetector.cpp.

132 {
133  return !m_axes.empty() && (m_explicitROI.size() == m_axes.size());
134 }
bool empty() const
Definition: OwningVector.h:71

References OwningVector< T >::empty(), IDetector::m_axes, IDetector::m_explicitROI, and OwningVector< T >::size().

Here is the call graph for this function:

◆ height()

double RectangularDetector::height ( ) const

Definition at line 97 of file RectangularDetector.cpp.

98 {
99  return axis(1).span();
100 }
double span() const
Returns distance from first to last point.
Definition: IAxis.cpp:55

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

Referenced by RectangularDetector(), createPixel(), and regionOfInterestPixel().

Here is the call graph for this function:

◆ indexOfSpecular()

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

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

Definition at line 198 of file RectangularDetector.cpp.

199 {
200  if (rank() != 2)
201  return totalSize();
202  const double alpha = beam.direction().alpha();
203  const double phi = beam.direction().phi();
204  const R3 k_spec = vecOfLambdaAlphaPhi(beam.wavelength(), alpha, phi);
205  const R3 normal_unit = m_normal_to_detector.unit();
206  const double kd = k_spec.dot(normal_unit);
207  if (kd <= 0.0)
208  return totalSize();
209  ASSERT(m_distance != 0);
210  const R3 rpix = k_spec * (m_distance / kd);
211  const double u = rpix.dot(m_u_unit) + m_u0;
212  const double v = rpix.dot(m_v_unit) + m_v0;
213  const IAxis& u_axis = axis(0); // the x axis, GISAS only
214  const IAxis& v_axis = axis(1); // the y axis, in reflectometer plane
215  if (!u_axis.contains(u) || !v_axis.contains(v))
216  return totalSize();
217  return getGlobalIndex(u_axis.findClosestIndex(u), v_axis.findClosestIndex(v));
218 }
R3 vecOfLambdaAlphaPhi(double _lambda, double _alpha, double _phi)
Definition: Direction.cpp:19
Direction direction() const
Definition: Beam.h:46
double wavelength() const
Definition: Beam.h:44
double phi() const
Definition: Direction.h:37
double alpha() const
Definition: Direction.h:36
virtual bool contains(double value) const
Returns true if axis contains given point.
Definition: IAxis.cpp:45
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: IDetector.cpp:377

References Direction::alpha(), ASSERT, IDetector::axis(), IAxis::contains(), Beam::direction(), IAxis::findClosestIndex(), IDetector::getGlobalIndex(), m_distance, m_normal_to_detector, m_u0, m_u_unit, m_v0, m_v_unit, Direction::phi(), IDetector::rank(), IDetector::totalSize(), vecOfLambdaAlphaPhi(), and Beam::wavelength().

Here is the call graph for this function:

◆ initNormalVector()

void RectangularDetector::initNormalVector ( R3  central_k)
private

Definition at line 233 of file RectangularDetector.cpp.

234 {
235  R3 central_k_unit = central_k.unit();
236 
238  // do nothing
239  }
240 
242  m_normal_to_detector = R3(m_distance, 0.0, 0.0);
243 
244 
246  m_normal_to_detector = m_distance * central_k_unit;
247 
248 
251  m_normal_to_detector = m_distance * central_k_unit;
253  }
254 
255  else
256  throw std::runtime_error("RectangularDetector::init() -> Unknown detector arrangement");
257 }

References GENERIC, m_detector_arrangement, m_distance, m_normal_to_detector, PERPENDICULAR_TO_DIRECT_BEAM, PERPENDICULAR_TO_REFLECTED_BEAM, PERPENDICULAR_TO_REFLECTED_BEAM_DPOS, and PERPENDICULAR_TO_SAMPLE.

Referenced by setDetectorNormal().

◆ initUandV()

void RectangularDetector::initUandV ( double  alpha_i)
private

Definition at line 259 of file RectangularDetector.cpp.

260 {
262  R3 u_direction =
264  m_u_unit = u_direction.unit();
265  m_v_unit = m_u_unit.cross(m_normal_to_detector).unit();
266 
268  R3 z(0.0, 0.0, 1.0);
269  R3 normal_unit = m_normal_to_detector.unit();
270  R3 zp = z - z.dot(normal_unit) * normal_unit;
271  double uz = zp.dot(m_u_unit) / zp.mag();
272  double vz = zp.dot(m_v_unit) / zp.mag();
273  m_u0 = m_dbeam_u0 + m_distance * std::tan(2 * alpha_i) * uz;
274  m_v0 = m_dbeam_v0 + m_distance * std::tan(2 * alpha_i) * vz;
275  }
276 }

References 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, and PERPENDICULAR_TO_REFLECTED_BEAM_DPOS.

Referenced by setDetectorNormal().

◆ iterateOverNonMaskedPoints()

void IDetector::iterateOverNonMaskedPoints ( std::function< void(const_iterator)>  func) const
inherited

Iterate over all non-masked points within "region of interest". If no region of interest is explicitly defined, then the whole detector is taken as "region of interest".

Definition at line 252 of file IDetector.cpp.

253 {
254  if (this->rank() == 0)
255  return;
256 
257  for (auto it = beginNonMaskedPoints(); it != endNonMaskedPoints(); ++it)
258  func(it);
259 }

References IDetector::beginNonMaskedPoints(), IDetector::endNonMaskedPoints(), and IDetector::rank().

Referenced by IDetector::active_indices(), IDetector::applyDetectorResolution(), and IDetector::numberOfElements().

Here is the call graph for this function:

◆ iterateOverRegionOfInterest()

void IDetector::iterateOverRegionOfInterest ( std::function< void(const_iterator)>  func) const
inherited

Iterate over all points within "region of interest", no matter whether they are masked or not. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest".

Definition at line 243 of file IDetector.cpp.

244 {
245  if (this->rank() == 0)
246  return;
247 
248  for (auto it = beginRegionOfInterestPoints(); it != endRegionOfInterestPoints(); ++it)
249  func(it);
250 }
SimulationAreaIterator beginRegionOfInterestPoints() const
Create begin-iterator to iterate over all points which lay within the "Region of Interest"....
Definition: IDetector.cpp:271
SimulationAreaIterator endRegionOfInterestPoints() const
Create end-iterator to iterate over all points which lay within the "Region of Interest"....
Definition: IDetector.cpp:276

References IDetector::beginRegionOfInterestPoints(), IDetector::endRegionOfInterestPoints(), and IDetector::rank().

Referenced by ScatteringSimulation::intensityMapSize().

Here is the call graph for this function:

◆ maskAll()

void IDetector::maskAll ( )
inherited

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

Definition at line 365 of file IDetector.cpp.

366 {
367  if (rank() != 2)
368  return;
369  addMask(InfinitePlane(), true);
370 }
void 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...
Definition: IDetector.cpp:360
The infinite plane is used for masking the entire detector.
Definition: InfinitePlane.h:28

References IDetector::addMask(), and IDetector::rank().

Referenced by ISimulation2D::maskAll().

Here is the call graph for this function:

◆ nodeChildren()

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

Returns all children.

Reimplemented from INode.

Definition at line 238 of file IDetector.cpp.

239 {
240  return std::vector<const INode*>() << &m_polAnalyzer << m_detector_resolution;
241 }

References IDetector::m_detector_resolution, and IDetector::m_polAnalyzer.

◆ nodeOffspring()

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

Returns all descendants.

Definition at line 61 of file INode.cpp.

62 {
63  std::vector<const INode*> result;
64  result.push_back(this);
65  for (const auto* child : nodeChildren()) {
66  for (const auto* p : child->nodeOffspring())
67  result.push_back(p);
68  }
69  return result;
70 }
virtual std::vector< const INode * > nodeChildren() const
Returns all children.
Definition: INode.cpp:56

References INode::nodeChildren().

Here is the call graph for this function:

◆ numberOfElements()

size_t IDetector::numberOfElements ( ) const
inherited

Returns number of simulation elements.

Definition at line 220 of file IDetector.cpp.

221 {
222  size_t result(0);
223  iterateOverNonMaskedPoints([&result](const_iterator) { ++result; });
224  return result;
225 }

References IDetector::iterateOverNonMaskedPoints().

Here is the call graph for this function:

◆ offspecCoords()

ICoordSystem * RectangularDetector::offspecCoords ( IAxis beamAxis,
const Direction beamDirection 
) const
overridevirtual

Implements IDetector.

Definition at line 278 of file RectangularDetector.cpp.

280 {
281  const auto axes = axesClippedToRegionOfInterest();
282  ASSERT(axes.size() == 2);
283  const IAxis& yAxis = *axes[1];
284 
285  std::unique_ptr<RectangularPixel> det_pixel(regionOfInterestPixel());
286  IAxis* alpha_f_axis = det_pixel->createAxis(yAxis.size());
287 
288  OwningVector<IAxis> axes2({beamAxis, alpha_f_axis});
289  return new OffspecCoordinates(axes2, beamDirection);
290 }
OwningVector< IAxis > axesClippedToRegionOfInterest() const
Returns the axes clipped to the region of interest. If no region of interest is explicitly defined,...
Definition: IDetector.cpp:136
ICoordSystem class that handles the unit translations for off-specular simulations with a spherical d...
RectangularPixel * regionOfInterestPixel() const

References ASSERT, IDetector::axesClippedToRegionOfInterest(), regionOfInterestPixel(), and IAxis::size().

Here is the call graph for this function:

◆ parDefs()

virtual std::vector<ParaMeta> INode::parDefs ( ) const
inlinevirtualinherited

Returns the parameter definitions, to be hard-coded in each leaf class.

Reimplemented in ConstantBackground, GaussSphere, FuzzySphere, RotationEuler, RotationZ, RotationY, RotationX, Crystal, Layer, HexagonalLattice2D, SquareLattice2D, BasicLattice2D, LayerRoughness, TruncatedSpheroid, TruncatedSphere, TruncatedCube, Spheroid, Sphere, SawtoothRippleLorentz, SawtoothRippleGauss, SawtoothRippleBox, Pyramid6, Pyramid4, Pyramid3, Pyramid2, Prism6, Prism3, PlatonicTetrahedron, PlatonicOctahedron, LongBoxLorentz, LongBoxGauss, Icosahedron, HorizontalCylinder, HollowSphere, HemiEllipsoid, EllipsoidalCylinder, Dodecahedron, Cylinder, CosineRippleLorentz, CosineRippleGauss, CosineRippleBox, Cone, CantellatedCube, Box, Bipyramid4, BarLorentz, BarGauss, Profile2DVoigt, Profile2DCone, Profile2DGate, Profile2DGauss, Profile2DCauchy, Profile1DVoigt, Profile1DCosine, Profile1DTriangle, Profile1DGate, Profile1DGauss, Profile1DCauchy, MisesGaussPeakShape, MisesFisherGaussPeakShape, LorentzFisherPeakShape, GaussFisherPeakShape, IsotropicLorentzPeakShape, IsotropicGaussPeakShape, ParticleLayout, InterferenceTwin, InterferenceRadialParaCrystal, InterferenceHardDisk, Interference2DSuperLattice, Interference2DParaCrystal, Interference1DLattice, DistributionTrapezoid, DistributionCosine, DistributionLogNormal, DistributionGaussian, DistributionLorentz, DistributionGate, ResolutionFunction2DGaussian, PolFilter, FootprintSquare, and FootprintGauss.

Definition at line 51 of file INode.h.

51 { return {}; }

Referenced by INode::checkNodeArgs(), and IFormFactor::pythonConstructor().

◆ rank()

size_t IDetector::rank ( ) const
inherited

◆ regionOfInterestBounds()

std::pair< double, double > IDetector::regionOfInterestBounds ( size_t  iAxis) const
inherited

The lower and upper bound of the region of interest. If no region of interest is explicitly defined, then the whole detector is taken as "region of interest".

Definition at line 227 of file IDetector.cpp.

228 {
229  ASSERT(iAxis < m_axes.size());
230 
231  const auto explicitBounds = boundsOfExplicitRegionOfInterest(iAxis);
232  if (explicitBounds.first != 0 || explicitBounds.second != 0)
233  return explicitBounds;
234 
235  return m_axes[iAxis]->bounds();
236 }
virtual std::pair< double, double > boundsOfExplicitRegionOfInterest(size_t iAxis) const
Lower and upper bound of one axis of an explicitly set ROI. Return 0/0 if no ROI has been explicitly ...
Definition: IDetector.cpp:106

References ASSERT, IDetector::boundsOfExplicitRegionOfInterest(), IDetector::m_axes, and OwningVector< T >::size().

Referenced by IDetector::axesClippedToRegionOfInterest(), IDetector::createDetectorMap(), and regionOfInterestPixel().

Here is the call graph for this function:

◆ regionOfInterestIndexToDetectorIndex()

size_t IDetector::regionOfInterestIndexToDetectorIndex ( size_t  regionOfInterestIndex) const
inherited

Convert an index of the region of interest to an index of the detector. If no region of interest is set, then the index stays unmodified (since ROI == detector area).

Definition at line 281 of file IDetector.cpp.

282 {
283  if (m_explicitROI.size() != 2)
284  return regionOfInterestIndex;
285 
286  const auto& x = m_explicitROI[0];
287  const auto& y = m_explicitROI[1];
288 
289  const size_t globalIndex0 = y.lowerIndex + x.lowerIndex * y.detectorSize;
290  return globalIndex0 + ycoord(regionOfInterestIndex, y.roiSize)
291  + xcoord(regionOfInterestIndex, x.roiSize, y.roiSize) * y.detectorSize;
292 }

References IDetector::m_explicitROI.

Referenced by SimulationAreaIterator::detectorIndex(), and SimulationAreaIterator::isMasked().

◆ regionOfInterestPixel()

RectangularPixel * RectangularDetector::regionOfInterestPixel ( ) const

Definition at line 152 of file RectangularDetector.cpp.

153 {
154  const auto uAxisBoundsROI = regionOfInterestBounds(0);
155  const auto vAxisBoundsROI = regionOfInterestBounds(1);
156 
157  const double u_min = uAxisBoundsROI.first;
158  const double v_min = vAxisBoundsROI.first;
159  const double width = uAxisBoundsROI.second - uAxisBoundsROI.first;
160  const double height = vAxisBoundsROI.second - vAxisBoundsROI.first;
161 
162  const R3 corner_position(m_normal_to_detector + (u_min - m_u0) * m_u_unit
163  + (v_min - m_v0) * m_v_unit);
164  const R3 uaxis_vector = width * m_u_unit;
165  const R3 vaxis_vector = height * m_v_unit;
166  return new RectangularPixel(corner_position, uaxis_vector, vaxis_vector);
167 }

References height(), m_normal_to_detector, m_u0, m_u_unit, m_v0, m_v_unit, IDetector::regionOfInterestBounds(), and width().

Referenced by offspecCoords(), and scatteringCoords().

Here is the call graph for this function:

◆ resetRegionOfInterest()

void IDetector::resetRegionOfInterest ( )
inherited

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

Definition at line 164 of file IDetector.cpp.

165 {
166  m_explicitROI.clear();
167 }

References IDetector::m_explicitROI.

◆ scatteringCoords()

CoordSystem2D * RectangularDetector::scatteringCoords ( const Beam beam) const
overridevirtual

Implements IDetector.

Definition at line 292 of file RectangularDetector.cpp.

293 {
295  beam.direction(), beam.wavelength());
296 }
ICoordSystem class that handles the unit translations for rectangular detectors Its default units are...
Definition: CoordSystem2D.h:90

References IDetector::axesClippedToRegionOfInterest(), Beam::direction(), regionOfInterestPixel(), and Beam::wavelength().

Here is the call graph for this function:

◆ setAnalyzer()

void IDetector::setAnalyzer ( R3  direction,
double  efficiency,
double  total_transmission 
)
inherited

Sets the polarization analyzer characteristics of the detector.

Definition at line 147 of file IDetector.cpp.

148 {
149  m_polAnalyzer = PolFilter(direction, efficiency, total_transmission);
150 }
Detector properties (efficiency, transmission).
Definition: PolFilter.h:27

References IDetector::m_polAnalyzer.

◆ setDetectorNormal()

void RectangularDetector::setDetectorNormal ( const Direction )
overridevirtual

Inits detector with the beam settings.

Reimplemented from IDetector.

Definition at line 50 of file RectangularDetector.cpp.

51 {
52  initNormalVector(direction.vector());
53  initUandV(-direction.alpha());
54 }
void initNormalVector(R3 central_k)
void initUandV(double alpha_i)

References Direction::alpha(), initNormalVector(), initUandV(), and Direction::vector().

Here is the call graph for this function:

◆ setDetectorParameters()

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

Sets equidistant axes.

Definition at line 329 of file IDetector.cpp.

331 {
332  clear();
333  addDetAxis(FixedBinAxis(axisName(0), n_x, x_min, x_max));
334  addDetAxis(FixedBinAxis(axisName(1), n_y, y_min, y_max));
335 }
Axis with fixed bin size.
Definition: FixedBinAxis.h:23
void addDetAxis(const IAxis &axis)
Definition: IDetector.cpp:57
virtual std::string axisName(size_t index) const =0
Returns the name for the axis with given index.
void clear()
Definition: IDetector.cpp:69

References IDetector::addDetAxis(), IDetector::axisName(), and IDetector::clear().

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

Here is the call graph for this function:

◆ setDetectorPosition()

void RectangularDetector::setDetectorPosition ( R3  normal_to_detector,
double  u0,
double  v0,
R3  direction = R3(0.0, -1.0, 0.0) 
)

Definition at line 56 of file RectangularDetector.cpp.

58 {
60  m_normal_to_detector = normal_to_detector;
62  m_u0 = u0;
63  m_v0 = v0;
64  m_direction = direction;
65 }

References GENERIC, m_detector_arrangement, m_direction, m_distance, m_normal_to_detector, m_u0, and m_v0.

◆ setDetectorResolution()

void IDetector::setDetectorResolution ( const IDetectorResolution p_detector_resolution)
inherited

Sets the detector resolution.

Definition at line 152 of file IDetector.cpp.

153 {
154  m_detector_resolution.reset(p_detector_resolution.clone());
155 }
IDetectorResolution * clone() const override=0

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

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 220 of file RectangularDetector.cpp.

221 {
222  if (distance <= 0.0) {
223  std::ostringstream message;
224  message << "RectangularDetector::setPerpendicularToSample() -> Error. "
225  << "Distance to sample can't be negative or zero";
226  throw std::runtime_error(message.str());
227  }
228  m_distance = distance;
229  m_u0 = u0;
230  m_v0 = v0;
231 }

References m_distance, m_u0, and m_v0.

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

◆ setPerpendicularToDirectBeam()

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

Definition at line 73 of file RectangularDetector.cpp.

74 {
76  setDistanceAndOffset(distance, u0, v0);
77 }
void setDistanceAndOffset(double distance, double u0, double v0)

References m_detector_arrangement, PERPENDICULAR_TO_DIRECT_BEAM, and setDistanceAndOffset().

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 79 of file RectangularDetector.cpp.

References m_detector_arrangement, PERPENDICULAR_TO_REFLECTED_BEAM, and setDistanceAndOffset().

Here is the call graph for this function:

◆ setPerpendicularToSampleX()

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

Definition at line 67 of file RectangularDetector.cpp.

68 {
70  setDistanceAndOffset(distance, u0, v0);
71 }

References m_detector_arrangement, PERPENDICULAR_TO_SAMPLE, and setDistanceAndOffset().

Here is the call graph for this function:

◆ setRegionOfInterest()

void IDetector::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 337 of file IDetector.cpp.

338 {
339  ASSERT(rank() == 2);
340 
341  m_explicitROI.clear();
342  m_explicitROI.emplace_back(axis(0), xlow, xup);
343  m_explicitROI.emplace_back(axis(1), ylow, yup);
344 }

References ASSERT, IDetector::axis(), IDetector::m_explicitROI, and IDetector::rank().

Referenced by ISimulation2D::setRegionOfInterest().

Here is the call graph for this function:

◆ setResolutionFunction()

void IDetector::setResolutionFunction ( const IResolutionFunction2D resFunc)
inherited

Definition at line 158 of file IDetector.cpp.

159 {
160  ConvolutionDetectorResolution convFunc(resFunc);
161  setDetectorResolution(convFunc);
162 }
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:152

References IDetector::setDetectorResolution().

Here is the call graph for this function:

◆ sizeOfExplicitRegionOfInterest()

size_t IDetector::sizeOfExplicitRegionOfInterest ( ) const
protectedvirtualinherited

Return 0 if no ROI has been explicitly set. Size means number of data points.

Definition at line 94 of file IDetector.cpp.

95 {
96  if (m_explicitROI.size() != m_axes.size())
97  return 0;
98 
99  size_t s = 1;
100  for (const auto& roiOfAxis : m_explicitROI)
101  s *= roiOfAxis.roiSize;
102 
103  return s;
104 }

References IDetector::m_axes, IDetector::m_explicitROI, and OwningVector< T >::size().

Referenced by IDetector::sizeOfRegionOfInterest().

Here is the call graph for this function:

◆ sizeOfRegionOfInterest()

size_t IDetector::sizeOfRegionOfInterest ( ) const
inherited

The size of the "Region of Interest". Same as totalSize() if no region of interest has been explicitly set.

Definition at line 125 of file IDetector.cpp.

126 {
127  const auto explicitSize = sizeOfExplicitRegionOfInterest();
128  return (explicitSize != 0) ? explicitSize : totalSize();
129 }
virtual size_t sizeOfExplicitRegionOfInterest() const
Return 0 if no ROI has been explicitly set. Size means number of data points.
Definition: IDetector.cpp:94

References IDetector::sizeOfExplicitRegionOfInterest(), and IDetector::totalSize().

Referenced by SimulationAreaIterator::createEnd().

Here is the call graph for this function:

◆ swapContent()

void RectangularDetector::swapContent ( RectangularDetector other)
private

swap function

◆ totalSize()

size_t IDetector::totalSize ( ) const
inherited

Returns total number of pixels. Any region of interest is not taken into account.

Definition at line 114 of file IDetector.cpp.

115 {
116  const size_t dim = rank();
117  if (dim == 0)
118  return 0;
119  size_t result = 1;
120  for (size_t i_axis = 0; i_axis < dim; ++i_axis)
121  result *= m_axes[i_axis]->size();
122  return result;
123 }

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

Referenced by IDetector::getGlobalIndex(), indexOfSpecular(), SphericalDetector::indexOfSpecular(), and IDetector::sizeOfRegionOfInterest().

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

◆ width()

double RectangularDetector::width ( ) const

Definition at line 92 of file RectangularDetector.cpp.

93 {
94  return axis(0).span();
95 }

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

Referenced by RectangularDetector(), createPixel(), and regionOfInterestPixel().

Here is the call graph for this function:

◆ xSize()

size_t RectangularDetector::xSize ( ) const

Definition at line 102 of file RectangularDetector.cpp.

103 {
104  return axis(0).size();
105 }

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

Here is the call graph for this function:

◆ ySize()

size_t RectangularDetector::ySize ( ) const

Definition at line 107 of file RectangularDetector.cpp.

108 {
109  return axis(1).size();
110 }

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

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 103 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 103 of file RectangularDetector.h.

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

◆ m_detector_arrangement

◆ m_detector_mask

std::shared_ptr<DetectorMask> IDetector::m_detector_mask
privateinherited

Definition at line 251 of file IDetector.h.

Referenced by IDetector::addDetAxis(), IDetector::addMask(), and IDetector::detectorMask().

◆ m_detector_resolution

◆ m_direction

R3 RectangularDetector::m_direction
private

direction vector of detector coordinate system

Definition at line 101 of file RectangularDetector.h.

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

◆ m_distance

double RectangularDetector::m_distance
private

distance from sample origin to the detector plane

Definition at line 102 of file RectangularDetector.h.

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

◆ m_explicitROI

std::vector<RoiOfAxis> IDetector::m_explicitROI
protectedinherited

◆ m_normal_to_detector

R3 RectangularDetector::m_normal_to_detector
private

◆ m_P

◆ m_polAnalyzer

PolFilter IDetector::m_polAnalyzer
privateinherited

◆ m_u0

double RectangularDetector::m_u0
private

◆ m_u_unit

R3 RectangularDetector::m_u_unit
private

◆ m_v0

double RectangularDetector::m_v0
private

position of normal vector hitting point in detector coordinates

Definition at line 100 of file RectangularDetector.h.

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

◆ m_v_unit

R3 RectangularDetector::m_v_unit
private

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