Response of BaF2 detectors to photons of 3–50 MeV energy