\(\renewcommand\AA{\unicode{x212B}}\)
DetectorInfo¶
This is a python binding to the C++ class Mantid::Geometry::DetectorInfo.
Most of the information concerning DetectorInfo
can be found in the Instrument Access Layers document.
Purpose¶
The purpose of the DetectorInfo
object is to allow the user to access information about the detector(s) being used in an experiment. The DetectorInfo
object can be used to access geometric information such as the number of detectors in the beamline, the absolute position of a detector as well as the absolute rotation of a detector.
Many users may need this extra information so that they can have a better understanding of the beamline they are using. This information is easy and fast to access. Some information like mask flags can be modified directly.
The DetectorInfo
object is one of three objects that the user can gain access to from a workspace.
The other two are:
Indexing¶
The DetectorInfo
object is accessed by an index going from 0 to N-1, where N is the number of detectors.
It is important to note that the detector index is NOT the detector ID. A detector index is a way of addressing and enumerating detectors in the beamline.
A detector index can be found from a detector ID using indexOf
.
Usage¶
Example 1 - Creating a DetectorInfo Object:
This example shows how to obtain a DetectorInfo
object from a workspace object.
The return value is a DetectorInfo
object.
from mantid.geometry import DetectorInfo
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
print("The type is DetectorInfo: {}".format(isinstance(info, DetectorInfo)))
Output:
The type is DetectorInfo: True
Example 2 - Calling Some Methods on the DetectorInfo Object: This example shows how to call a few different methods on the DetectorInfo object.
The setMasked
method takes in an integer index
parameter which corresponds to a detector as well as a boolean masked
parameter.
The user then has the option to set the masking of the detector identified by index
to True
or False
.
The twoTheta()
method takes in an integer index
parameter which represents a detector index.
The return value is a float which represents the scattering angle with respect to the beam direction.
The position()
method takes an index
parameter which represents a detector index.
The method returns the absolute position of that detector.
The returned object is of type V3D
which is a point in 3D space.
The size()
method does not take in any parameters and returns the number of detectors in the instrument.
One can also use the built in __len__
function to obtain the same result.
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
# Call setMasked
info.setMasked(0, True)
print(info.isMasked(0))
info.setMasked(0, False)
print(info.isMasked(0))
# Call twoTheta
print(info.twoTheta(0))
# Call the position method
print(info.position(0))
# Call size and __len__
print(info.size())
print(len(info))
Output:
True
False
0.0
[0,0,5]
200
200
bases: mantid.geometry.DetectorInfo
- class mantid.geometry.DetectorInfo¶
- azimuthal((DetectorInfo)self, (int)index) float : ¶
Returns the out-of-plane angle in radians angle w.r.t. to vecPointingHorizontal
- clearMaskFlags((DetectorInfo)self) None : ¶
Sets all mask flags to false (unmasked).
- detectorIDs((DetectorInfo)arg1) numpy.ndarray : ¶
Returns all detector ids sorted by detector index
- hasMaskedDetectors((DetectorInfo)self) bool : ¶
Returns if there are masked detectors
- indexOf((DetectorInfo)self, (int)detId) int : ¶
Returns the index of the detector with the given id.
- isEquivalent((DetectorInfo)self, (DetectorInfo)other) bool : ¶
Returns True if the content of this detector is equivalent to the content of the other detector.
- isMasked((DetectorInfo)self, (int)index) bool : ¶
Returns True if the detector is masked.
- isMonitor((DetectorInfo)self, (int)index) bool : ¶
Returns True if the detector is a monitor.
- l1((DetectorInfo)self) float : ¶
Returns the l1 scattering distance
- l2((DetectorInfo)self, (int)index) float : ¶
Returns the l2 scattering distance
- position((DetectorInfo)self, (int)index) V3D : ¶
Returns the absolute position of the detector where the detector is identified by ‘index’.
- rotation((DetectorInfo)self, (int)index) Quat : ¶
Returns the absolute rotation of the detector where the detector is identified by ‘index’.
- setMasked((DetectorInfo)self, (int)index, (bool)masked) None : ¶
Set the mask flag of the detector where the detector is identified by ‘index’.
- size((DetectorInfo)self) int : ¶
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
- twoTheta((DetectorInfo)self, (int)index) float : ¶
Returns 2 theta (scattering angle w.r.t beam direction).