We discuss how the integrators used for the Hybrid Monte Carlo (HMC) algorithm not only approximately conserve some Hamiltonian $H$ but exactly conserve a nearby shadow Hamiltonian (tilde H), and how the difference $Delta H equiv tilde H - H $ may be expressed as an expansion in Poisson brackets. By measuring average values of these Poisson brackets over the equilibrium distribution $propto e^{-H}$ generated by HMC we can find the optimal integrator parameters from a single simulation. We show that a good way of doing this in practice is to minimize the variance of $Delta H$ rather than its magnitude, as has been previously suggested. Some details of how to compute Poisson brackets for gauge and fermion fields, and for nested and force gradient integrators are also presented.