  We study a general class of models whose classical Hamiltonians are given by
H = U(x) p + V(x)/p, where x and p are the position and momentum of a particle
moving in one dimension, and U and V are positive functions. This class
includes the Hamiltonians H_I =x (p+1/p) and H_II=(x+ 1/x)(p+ 1/p), which have
been recently discussed in connection with the non trivial zeros of the Riemann
zeta function. We show that all these models are covariant under general
coordinate transformations. This remarkable property becomes explicit in the
Lagrangian formulation which describes a relativistic particle moving in a 1+1
dimensional spacetime whose metric is constructed from the functions U and V.
General covariance is maintained by quantization and we find that the spectra
are closely related to the geometry of the associated spacetimes. In
particular, the Hamiltonian H_I corresponds to a flat spacetime, whereas its
spectrum approaches the Riemann zeros in average. The latter property also
holds for the model H_II, whose underlying spacetime is asymptotically flat.
These results suggest the existence of a Hamiltonian whose underlying spacetime
encodes the prime numbers, and whose spectrum provides the Riemann zeros.
