BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
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().
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... | |
IDetector * | clone () const override=0 |
Datafield * | createDetectorIntensity (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 DetectorMask * | detectorMask () const |
const IDetectorResolution * | detectorResolution () 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... | |
using IDetector::const_iterator = const SimulationAreaIterator& |
IDetector::IDetector | ( | ) |
|
override |
|
protected |
std::vector<size_t> IDetector::active_indices | ( | ) | const |
Returns vector of unmasked detector indices.
void IDetector::addDetAxis | ( | const IAxis & | axis | ) |
void IDetector::addMask | ( | const IShape2D & | shape, |
bool | mask_value = true |
||
) |
void IDetector::applyDetectorResolution | ( | Datafield * | p_intensity_map | ) | const |
Applies the detector resolution to the given intensity maps.
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".
const IAxis& IDetector::axis | ( | size_t | index | ) | const |
One axis of the complete detector. Any region of interest is not taken into account.
size_t IDetector::axisBinIndex | ( | size_t | index, |
size_t | selected_axis | ||
) | const |
Calculate axis index for given global index.
|
protectedpure virtual |
Returns the name for the axis with given index.
|
protectedvirtual |
Lower and upper bound of one axis of an explicitly set ROI. Return 0/0 if no ROI has been explicitly set.
|
protected |
|
overridepure virtual |
Implemented in SphericalDetector, and RectangularDetector.
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.
|
pure virtual |
Creates an IPixel for the given Datafield object and index.
|
pure virtual |
Return default axes units.
Implemented in SphericalDetector, and RectangularDetector.
size_t IDetector::detectorIndexToRegionOfInterestIndex | ( | size_t | detectorIndex | ) | const |
const DetectorMask* IDetector::detectorMask | ( | ) | const |
const IDetectorResolution* IDetector::detectorResolution | ( | ) | const |
Returns a pointer to detector resolution object.
|
protected |
Calculate global index from two axis indices.
bool IDetector::hasExplicitRegionOfInterest | ( | ) | const |
True if a region of interest is explicitly set.
|
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.
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".
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".
void IDetector::maskAll | ( | ) |
Put the mask for all detector channels (i.e. exclude whole detector from the analysis)
|
override |
size_t IDetector::numberOfElements | ( | ) | const |
Returns number of simulation elements.
|
pure virtual |
Implemented in SphericalDetector, and RectangularDetector.
size_t IDetector::rank | ( | ) | const |
Returns number of defined axes.
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".
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).
void IDetector::resetRegionOfInterest | ( | ) |
Resets region of interest making whole detector plane available for the simulation.
|
pure virtual |
Implemented in SphericalDetector, and RectangularDetector.
void IDetector::setAnalyzer | ( | R3 | direction, |
double | efficiency, | ||
double | total_transmission | ||
) |
Sets the polarization analyzer characteristics of the detector.
|
virtual |
Inits detector with the beam settings.
Reimplemented in RectangularDetector.
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.
void IDetector::setDetectorResolution | ( | const IDetectorResolution & | p_detector_resolution | ) |
Sets the detector resolution.
void IDetector::setRegionOfInterest | ( | double | xlow, |
double | ylow, | ||
double | xup, | ||
double | yup | ||
) |
Sets rectangular region of interest with lower left and upper right corners defined.
void IDetector::setResolutionFunction | ( | const IResolutionFunction2D & | resFunc | ) |
|
protectedvirtual |
Return 0 if no ROI has been explicitly set. Size means number of data points.
size_t IDetector::sizeOfRegionOfInterest | ( | ) | const |
The size of the "Region of Interest". Same as totalSize() if no region of interest has been explicitly set.
size_t IDetector::totalSize | ( | ) | const |
Returns total number of pixels. Any region of interest is not taken into account.