Thermodynamic ensembles and gravitation