def get_ccd_geometry(header):
    """Get basic geometry of CCD.

    Args:
        header (:class:`astropy.io.fits.header`): FITS header.

    Returns:
        tuple: A tuple of **(x1, x2, xbin, ybin)**, where
        **(0, x1)** is the columns of the prescan region,
        **(x1, x2)** is the columns of the science region,
        **(x2, )** is the columns of the overscan region,
        and **(xbin, ybin)** are the CCD binning along X and Y axes.
    """
    cdelt1 = int(round(header['CDELT1']))
    cdelt2 = int(round(header['CDELT2']))

    # check nx
    if header['ESO DET CHIP1 NX'] == header['ESO DET OUT1 NX']:
        nx = header['ESO DET OUT1 NX']
    else:
        raise ValueError

    # check ny
    if header['ESO DET CHIP1 NY'] == header['ESO DET OUT1 NY']:
        ny = header['ESO DET OUT1 NY']
    else:
        raise ValueError

    prex = header['HIERARCH ESO DET OUT1 PRSCX']
    prey = header['HIERARCH ESO DET OUT1 PRSCY']
    ovrx = header['HIERARCH ESO DET OUT1 OVSCX']
    ovry = header['HIERARCH ESO DET OUT1 OVSCY']

    if prey != 0 or ovry != 0:
        raise ValueError

    if prex + nx + ovrx != header['NAXIS1']:
        raise ValueError

    if prey + ny + ovry != header['NAXIS2']:
        raise ValueError

    if cdelt1*nx != 2048:
        raise ValueError
    if cdelt2*ny != 4096:
        raise ValueError

    x1 = prex
    x2 = prex + nx
    binx = cdelt1
    biny = cdelt2

    return x1, x2, binx, biny