def mask_eiger(data, mask):
    """
    Mask data measured with an Eiger2M detector

    :param data: the 2D data to mask
    :param mask: the 2D mask to be updated
    :return: the masked data and the updated mask
    """
    if data.ndim != 2 or mask.ndim != 2:
        raise ValueError('Data and mask should be 2D arrays')
    if data.shape != mask.shape:
        raise ValueError('Data and mask must have the same shape\n data is ',
            data.shape, ' while mask is ', mask.shape)
    data[:, 255:259] = 0
    data[:, 513:517] = 0
    data[:, 771:775] = 0
    data[0:257, 72:80] = 0
    data[255:259, :] = 0
    data[511:552, :0] = 0
    data[804:809, :] = 0
    data[1061:1102, :] = 0
    data[1355:1359, :] = 0
    data[1611:1652, :] = 0
    data[1905:1909, :] = 0
    data[1248:1290, (478)] = 0
    data[1214:1298, (481)] = 0
    data[1649:1910, 620:628] = 0
    mask[:, 255:259] = 1
    mask[:, 513:517] = 1
    mask[:, 771:775] = 1
    mask[0:257, 72:80] = 1
    mask[255:259, :] = 1
    mask[511:552, :] = 1
    mask[804:809, :] = 1
    mask[1061:1102, :] = 1
    mask[1355:1359, :] = 1
    mask[1611:1652, :] = 1
    mask[1905:1909, :] = 1
    mask[1248:1290, (478)] = 1
    mask[1214:1298, (481)] = 1
    mask[1649:1910, 620:628] = 1
    return data, mask
