The 4d Photoabsorption Spectra of La, LaF3, Ba and BaF2: Dependence on the Chemical and Structural Environment