Geometry dependence of the proton affinities in the electronic ground, excited triplet and ionized doublet states of H2CO and H2COH+