diff --git a/Device/Mask/DetectorMask.cpp b/Device/Mask/DetectorMask.cpp
index 1d5987915278af4362b3f8de76bc05c38928fdc1..df4c0ef6dff0f073652bc82b9b9e2008b974499f 100644
--- a/Device/Mask/DetectorMask.cpp
+++ b/Device/Mask/DetectorMask.cpp
@@ -102,6 +102,11 @@ const IShape2D* DetectorMask::getMaskShape(size_t mask_index, bool& mask_value)
     return m_stack[mask_index]->shape;
 }
 
+const MaskPattern* DetectorMask::patternAt(size_t iMask) const
+{
+    return m_stack.at(iMask);
+}
+
 void DetectorMask::process_masks()
 {
     m_masked->setAllTo(false);
diff --git a/Device/Mask/DetectorMask.h b/Device/Mask/DetectorMask.h
index a89921e059adbfcd801f825d41347edbd0cf35d7..b78363176de50cc0c7b7342901c5fe258d5055a9 100644
--- a/Device/Mask/DetectorMask.h
+++ b/Device/Mask/DetectorMask.h
@@ -71,6 +71,8 @@ public:
 
     const IShape2D* getMaskShape(size_t mask_index, bool& mask_value) const;
 
+    const MaskPattern* patternAt(size_t iMask) const;
+
 private:
     void process_masks();
 
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index e19a9ede129c1634cb063bf1b1026fdd57ec4ab1..36263075233ad0049149cc2b6e87a40b368758cd 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -456,6 +456,9 @@ Returns true if has masks.
 %feature("docstring")  DetectorMask::getMaskShape "const IShape2D * DetectorMask::getMaskShape(size_t mask_index, bool &mask_value) const
 ";
 
+%feature("docstring")  DetectorMask::patternAt "const MaskPattern * DetectorMask::patternAt(size_t iMask) const
+";
+
 
 // File: classEllipse.xml
 %feature("docstring") Ellipse "
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index f12cdb01cacfc689cb8bd16446f31a0e84f9c228..bd78d5d9f8b7d10f0e336648ed24677cd22729de 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -3707,6 +3707,14 @@ class DetectorMask(object):
         """
         return _libBornAgainDevice.DetectorMask_getMaskShape(self, mask_index, mask_value)
 
+    def patternAt(self, iMask):
+        r"""
+        patternAt(DetectorMask self, size_t iMask) -> MaskPattern
+        const MaskPattern * DetectorMask::patternAt(size_t iMask) const
+
+        """
+        return _libBornAgainDevice.DetectorMask_patternAt(self, iMask)
+
 # Register DetectorMask in _libBornAgainDevice:
 _libBornAgainDevice.DetectorMask_swigregister(DetectorMask)
 
diff --git a/auto/Wrap/libBornAgainDevice_wrap.cpp b/auto/Wrap/libBornAgainDevice_wrap.cpp
index 6a803b3f9d2600e76fe91f57840098ae8b7e69ff..fbeeca394c429525dfff697a784c6ffa9cd82ac0 100644
--- a/auto/Wrap/libBornAgainDevice_wrap.cpp
+++ b/auto/Wrap/libBornAgainDevice_wrap.cpp
@@ -33747,6 +33747,36 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_DetectorMask_patternAt(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  DetectorMask *arg1 = (DetectorMask *) 0 ;
+  size_t arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
+  PyObject *swig_obj[2] ;
+  MaskPattern *result = 0 ;
+  
+  if (!SWIG_Python_UnpackTuple(args, "DetectorMask_patternAt", 2, 2, swig_obj)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_DetectorMask, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DetectorMask_patternAt" "', argument " "1"" of type '" "DetectorMask const *""'"); 
+  }
+  arg1 = reinterpret_cast< DetectorMask * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(swig_obj[1], &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DetectorMask_patternAt" "', argument " "2"" of type '" "size_t""'");
+  } 
+  arg2 = static_cast< size_t >(val2);
+  result = (MaskPattern *)((DetectorMask const *)arg1)->patternAt(arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_MaskPattern, 0 |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *DetectorMask_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL;
@@ -43914,6 +43944,11 @@ static PyMethodDef SwigMethods[] = {
 		"const IShape2D * DetectorMask::getMaskShape(size_t mask_index, bool &mask_value) const\n"
 		"\n"
 		""},
+	 { "DetectorMask_patternAt", _wrap_DetectorMask_patternAt, METH_VARARGS, "\n"
+		"DetectorMask_patternAt(DetectorMask self, size_t iMask) -> MaskPattern\n"
+		"const MaskPattern * DetectorMask::patternAt(size_t iMask) const\n"
+		"\n"
+		""},
 	 { "DetectorMask_swigregister", DetectorMask_swigregister, METH_O, NULL},
 	 { "DetectorMask_swiginit", DetectorMask_swiginit, METH_VARARGS, NULL},
 	 { "IDetector_clone", _wrap_IDetector_clone, METH_O, "\n"