Particle-hole excitations in 12C and 40Ca photoreactions