def mask_eiger4m(data, mask):
    """
    Mask data measured with an Eiger4M 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[:, 1030:1040] = 1
    data[514:551, :] = 1
    data[1065:1102, :] = 1
    data[1616:1653, :] = 1
    mask[:, 1030:1040] = 1
    mask[514:551, :] = 1
    mask[1065:1102, :] = 1
    mask[1616:1653, :] = 1
    return data, mask
