Detection of internal electric fields in BaTiO3 thin films by optical second harmonic generation