Observer design for a class of nonlinear Hamiltonian systems based on energy function structure