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

Description

Abstract detector interface.

Handles also "region of interest" (ROI). In general, the ROI is the whole detector, and all methods related to ROI work on the whole detector. If a ROI different to the detector size is explicitly set, then ROI-related methods work on this reduced ROI. Therefore, when calling ROI related methods, the distinction between "explicit ROI exists: yes/no" does not have to be made by the caller, but it is handled in here. For access to the whole detector, even if a smaller ROI is explicitly defined, use the non-ROI-related methods like totalSize() or axes(). Any method which is not speaking of "explicit ROI" handles the "implicit ROI", i.e. uses an explicitly set ROI or the whole detector if no explicit ROI exists. To access the explicitly set ROI, use the methods which have the explicit in its name, like sizeOfExplicitRegionOfInterest().

Inheritance diagram for IDetector:

Public Types

using const_iterator = const SimulationAreaIterator &
 

Public Member Functions

 IDetector ()
 
 ~IDetector () 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...
 
IDetectorclone () const override=0
 
DatafieldcreateDetectorIntensity (const std::vector< std::unique_ptr< DiffuseElement >> &elements) const
 Returns new intensity map with resolution applied, and cropped to ROI if applicable. More...
 
virtual IPixel * createPixel (size_t index) const =0
 Creates an IPixel for the given Datafield object and index. More...
 
virtual Coords defaultCoords () const =0
 Return 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...
 
bool hasExplicitRegionOfInterest () const
 True if a region of interest is explicitly set. More...
 
virtual size_t indexOfSpecular (const Beam &beam) const =0
 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 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...
 
virtual ICoordSystem * offspecCoords (IAxis *beamAxis, const Direction &beamDirection) const =0
 
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...
 
void resetRegionOfInterest ()
 Resets region of interest making whole detector plane available for the simulation. More...
 
virtual CoordSystem2D * scatteringCoords (const Beam &beam) const =0
 
void setAnalyzer (R3 direction, double efficiency, double total_transmission)
 Sets the polarization analyzer characteristics of the detector. More...
 
virtual void setDetectorNormal (const Direction &)
 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 setDetectorResolution (const IDetectorResolution &p_detector_resolution)
 Sets the detector resolution. More...
 
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...
 

Protected Member Functions

 IDetector (const IDetector &other)
 
virtual std::string axisName (size_t index) const =0
 Returns the name for the axis with given index. More...
 
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&

Constructor & Destructor Documentation

◆ IDetector() [1/2]

IDetector::IDetector ( )

◆ ~IDetector()

IDetector::~IDetector ( )
override

◆ IDetector() [2/2]

IDetector::IDetector ( const IDetector other)
protected

Member Function Documentation

◆ active_indices()

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

Returns vector of unmasked detector indices.

◆ addDetAxis()

void IDetector::addDetAxis ( const IAxis &  axis)

◆ addMask()

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

Adds mask of given shape to the stack of detector masks. The mask value 'true' means that the channel will be excluded from the simulation. The mask which is added last has priority.

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

◆ applyDetectorResolution()

void IDetector::applyDetectorResolution ( Datafield p_intensity_map) const

Applies the detector resolution to the given intensity maps.

◆ axesClippedToRegionOfInterest()

OwningVector<IAxis> IDetector::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".

◆ axis()

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

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

Calculate axis index for given global index.

◆ axisName()

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

Returns the name for the axis with given index.

◆ boundsOfExplicitRegionOfInterest()

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

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

◆ clear()

void IDetector::clear ( )
protected

◆ clone()

IDetector* IDetector::clone ( ) const
overridepure virtual

Implemented in SphericalDetector, and RectangularDetector.

◆ createDetectorIntensity()

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

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

◆ createPixel()

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

Creates an IPixel for the given Datafield object and index.

◆ defaultCoords()

virtual Coords IDetector::defaultCoords ( ) const
pure virtual

Return default axes units.

Implemented in SphericalDetector, and RectangularDetector.

◆ detectorIndexToRegionOfInterestIndex()

size_t IDetector::detectorIndexToRegionOfInterestIndex ( size_t  detectorIndex) const

◆ detectorMask()

const DetectorMask* IDetector::detectorMask ( ) const

◆ detectorResolution()

const IDetectorResolution* IDetector::detectorResolution ( ) const

Returns a pointer to detector resolution object.

◆ getGlobalIndex()

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

Calculate global index from two axis indices.

◆ hasExplicitRegionOfInterest()

bool IDetector::hasExplicitRegionOfInterest ( ) const

True if a region of interest is explicitly set.

◆ indexOfSpecular()

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

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

◆ iterateOverNonMaskedPoints()

void IDetector::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".

◆ iterateOverRegionOfInterest()

void IDetector::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".

◆ maskAll()

void IDetector::maskAll ( )

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

◆ nodeChildren()

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

◆ numberOfElements()

size_t IDetector::numberOfElements ( ) const

Returns number of simulation elements.

◆ offspecCoords()

virtual ICoordSystem* IDetector::offspecCoords ( IAxis *  beamAxis,
const Direction beamDirection 
) const
pure virtual

Implemented in SphericalDetector, and RectangularDetector.

◆ rank()

size_t IDetector::rank ( ) const

Returns number of defined axes.

◆ regionOfInterestBounds()

std::pair<double, double> IDetector::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".

◆ regionOfInterestIndexToDetectorIndex()

size_t IDetector::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).

◆ resetRegionOfInterest()

void IDetector::resetRegionOfInterest ( )

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

◆ scatteringCoords()

virtual CoordSystem2D* IDetector::scatteringCoords ( const Beam beam) const
pure virtual

Implemented in SphericalDetector, and RectangularDetector.

◆ setAnalyzer()

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

Sets the polarization analyzer characteristics of the detector.

◆ setDetectorNormal()

virtual void IDetector::setDetectorNormal ( const Direction )
virtual

Inits detector with the beam settings.

Reimplemented in RectangularDetector.

◆ setDetectorParameters()

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

Sets equidistant axes.

◆ setDetectorResolution()

void IDetector::setDetectorResolution ( const IDetectorResolution p_detector_resolution)

Sets the detector resolution.

◆ setRegionOfInterest()

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

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

◆ setResolutionFunction()

void IDetector::setResolutionFunction ( const IResolutionFunction2D resFunc)

◆ sizeOfExplicitRegionOfInterest()

virtual size_t IDetector::sizeOfExplicitRegionOfInterest ( ) const
protectedvirtual

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

◆ sizeOfRegionOfInterest()

size_t IDetector::sizeOfRegionOfInterest ( ) const

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

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