Thermodynamical equilibrium and spacetime geometry