$$\renewcommand\AA{\unicode{x212B}}$$

## Summary¶

Masks detectors whose centres fall within the given 3D shape.

## Properties¶

Name

Direction

Type

Default

Description

Workspace

InOut

MatrixWorkspace

Mandatory

The input workspace

ShapeXML

Input

string

Mandatory

The XML definition of the user defined shape.

IncludeMonitors

Input

boolean

False

Whether to include monitors if they are contained in the shape (default false)

## Description¶

Masks detectors that are contained within a user defined 3 dimensional shape within the instrument.

The algorithm places the user defined geometric shape within the virtual instrument and masks any detector detectors that in contained within it. A detector is considered to be contained it its central location point is contained within the shape.

### ChildAlgorithms used¶

MaskDetectorsInShape runs the following algorithms as child algorithms:

## Usage¶

# Create a workspace
ws = CreateSampleWorkspace()

# Define an infinite cylinder with its axis parallel to the Z-axis
# and the radius of 0.04
shapeXML = \
"""
<infinite-cylinder id="A" >
<centre x="0" y="0" z="0" />
<axis x="0" y="0" z="1" />
</infinite-cylinder>
"""
# Mask all detectors inside this cylinder

#Check the result
inside_dets = []
# Collect separately all masked detector IDs and IDs of detectors
# that are inside the cylinder defined by shapeXML
R2 = 0.04**2 # cylinder radius sqared
for i in range(ws.getNumberHistograms()):
det = ws.getDetector(i)
r = det.getPos()
if r.X()**2 + r.Y()**2 <= R2:
inside_dets.append( det.getID() )

# Print out the IDs
print(inside_dets)

# Check that the two arrays are equal

### Output¶

[100, 101, 102, 103, 104, 105, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134, 140, 141, 142, 143, 150, 200, 201, 202, 203, 204, 205, 210, 211, 212, 213, 214, 220, 221, 222, 223, 224, 230, 231, 232, 233, 234, 240, 241, 242, 243, 250]
[100, 101, 102, 103, 104, 105, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134, 140, 141, 142, 143, 150, 200, 201, 202, 203, 204, 205, 210, 211, 212, 213, 214, 220, 221, 222, 223, 224, 230, 231, 232, 233, 234, 240, 241, 242, 243, 250]
True