In classical mechanics, the Hamiltonian is well defined by the Lagrangian. Whereas, energy is a very ambiguous term. We just say $E=T+U$, and usually it equals to Hamiltonian. Does there exist a way that, by just looking at the Lagrangian mathematically, we immediately know the relationship between the Hamiltonian and the energy of the system?
And if we have a system, the Hamiltonian of which does not equal to energy, what is the physical meaning of that difference?