This example shows how to obtain a DetectorInfo object from a workspace object.
The return value is a ``DetectorInfo`` object.
.. testcode:: CreateDetectorInfoObject
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
print(type(info))
**Example 2 - Calling the setMasked method on the DetectorInfo Object:**
This example shows how to call the ``setMasked`` method.
The method takes in an integer ``index`` parameter which corresponds to a component and a boolean ``masked`` parameter which allows the user to set the masking to True or False.
.. testcode:: CallSetMaskedMethod
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
# Call setMasked
print(info.setMasked(0, True))
print(info.isMasked(0))
print(info.setMasked(0, False))
print(info.isMasked(0))
**Example 3 - Calling the twoTheta method on the DetectorInfo Object:**
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.
.. testcode:: CallTwoThetaMethod
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
# Call twoTheta
print(type(info.twoTheta(0)))
**Example 4 - Calling the position method on the DetectorInfo Object:**
The ``position()`` method takes an ``index`` parameter which represents a detector index and returns the absolute position of that detector. The returned object is of type V3D which is a essentially 3D vector.
.. testcode:: CallPositionMethod
# Create a workspace to use
ws = CreateSampleWorkspace()
# Get the DetectorInfo object
info = ws.detectorInfo()
# Call the position method
print(type(info.position(0)))
**Example 5 - Calling the size method on the DetectorInfo Object:**
The ``size()`` method does not take in any parameters and returns a number of detectors in the instrument. One can also use the built in ``__len__`` function to obtain the same result.