The gain is derived from a set of paired flat fields with identical exposure time, using the Photon Transfer Curve method. For more information see the tutorial page.