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.

Inheritance diagram for RectangularDetector:

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...
 
void applyDetectorResolution (Datafield *p_intensity_map) const
 Applies the detector resolution to the given intensity maps. More...
 
OwningVector< IAxis > axesClippedToRegionOfInterest () 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 IAxis & axis (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...
 
std::string className () const final
 
RectangularDetectorclone () const override
 
DatafieldcreateDetectorIntensity (const std::vector< std::unique_ptr< DiffuseElement >> &elements) const
 Returns new intensity map with resolution applied, and cropped to ROI if applicable. 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...
 
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
 
size_t numberOfElements () const
 Returns number of simulation elements. More...
 
ICoordSystem * offspecCoords (IAxis *beamAxis, const Direction &beamDirection) const override
 
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...
 
RectangularPixel * regionOfInterestPixel () const
 
void resetRegionOfInterest ()
 Resets region of interest making whole detector plane available for the simulation. More...
 
CoordSystem2D * scatteringCoords (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...
 
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...
 

Member Typedef Documentation

◆ const_iterator

using IDetector::const_iterator = const SimulationAreaIterator&
inherited

Member Enumeration Documentation

◆ EDetectorArrangement

Enumerator
GENERIC 
PERPENDICULAR_TO_SAMPLE 
PERPENDICULAR_TO_DIRECT_BEAM 
PERPENDICULAR_TO_REFLECTED_BEAM 
PERPENDICULAR_TO_REFLECTED_BEAM_DPOS 

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

◆ RectangularDetector() [2/2]

RectangularDetector::RectangularDetector ( const RectangularDetector other)

◆ ~RectangularDetector()

RectangularDetector::~RectangularDetector ( )
override

Member Function Documentation

◆ active_indices()

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

Returns vector of unmasked detector indices.

◆ addDetAxis()

void IDetector::addDetAxis ( const IAxis &  axis)
inherited

◆ 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

◆ applyDetectorResolution()

void IDetector::applyDetectorResolution ( Datafield p_intensity_map) const
inherited

Applies the detector resolution to the given intensity maps.

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

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

◆ axisBinIndex()

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

Calculate axis index for given global index.

◆ boundsOfExplicitRegionOfInterest()

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

◆ className()

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

◆ clear()

void IDetector::clear ( )
protectedinherited

◆ clone()

RectangularDetector* RectangularDetector::clone ( ) const
overridevirtual

Implements IDetector.

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

◆ defaultCoords()

Coords RectangularDetector::defaultCoords ( ) const
overridevirtual

Returns default axes units.

Implements IDetector.

◆ detectorIndexToRegionOfInterestIndex()

size_t IDetector::detectorIndexToRegionOfInterestIndex ( size_t  detectorIndex) const
inherited

◆ detectorMask()

const DetectorMask* IDetector::detectorMask ( ) const
inherited

◆ detectorResolution()

const IDetectorResolution* IDetector::detectorResolution ( ) const
inherited

Returns a pointer to detector resolution object.

◆ getDetectorArrangment()

EDetectorArrangement RectangularDetector::getDetectorArrangment ( ) const

◆ getDirectBeamU0()

double RectangularDetector::getDirectBeamU0 ( ) const

◆ getDirectBeamV0()

double RectangularDetector::getDirectBeamV0 ( ) const

◆ getDirectionVector()

R3 RectangularDetector::getDirectionVector ( ) const

◆ getDistance()

double RectangularDetector::getDistance ( ) const

◆ getGlobalIndex()

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

Calculate global index from two axis indices.

◆ getNormalVector()

R3 RectangularDetector::getNormalVector ( ) const

◆ getU0()

double RectangularDetector::getU0 ( ) const

◆ getV0()

double RectangularDetector::getV0 ( ) const

◆ hasExplicitRegionOfInterest()

bool IDetector::hasExplicitRegionOfInterest ( ) const
inherited

True if a region of interest is explicitly set.

◆ height()

double RectangularDetector::height ( ) const

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

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

◆ maskAll()

void IDetector::maskAll ( )
inherited

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

◆ nodeChildren()

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

◆ numberOfElements()

size_t IDetector::numberOfElements ( ) const
inherited

Returns number of simulation elements.

◆ offspecCoords()

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

Implements IDetector.

◆ rank()

size_t IDetector::rank ( ) const
inherited

Returns number of defined axes.

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

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

◆ regionOfInterestPixel()

RectangularPixel* RectangularDetector::regionOfInterestPixel ( ) const

◆ resetRegionOfInterest()

void IDetector::resetRegionOfInterest ( )
inherited

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

◆ scatteringCoords()

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

Implements IDetector.

◆ setAnalyzer()

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

Sets the polarization analyzer characteristics of the detector.

◆ setDetectorNormal()

void RectangularDetector::setDetectorNormal ( const Direction )
overridevirtual

Inits detector with the beam settings.

Reimplemented from IDetector.

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

◆ setDetectorPosition()

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

◆ setDetectorResolution()

void IDetector::setDetectorResolution ( const IDetectorResolution p_detector_resolution)
inherited

Sets the detector resolution.

◆ setDirectBeamPosition()

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

◆ setPerpendicularToDirectBeam()

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

◆ setPerpendicularToReflectedBeam()

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

◆ setPerpendicularToSampleX()

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

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

◆ setResolutionFunction()

void IDetector::setResolutionFunction ( const IResolutionFunction2D resFunc)
inherited

◆ sizeOfExplicitRegionOfInterest()

virtual size_t IDetector::sizeOfExplicitRegionOfInterest ( ) const
protectedvirtualinherited

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

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

◆ totalSize()

size_t IDetector::totalSize ( ) const
inherited

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

◆ width()

double RectangularDetector::width ( ) const

◆ xSize()

size_t RectangularDetector::xSize ( ) const

◆ ySize()

size_t RectangularDetector::ySize ( ) const