Unified approach to Thermodynamic Bethe Ansatz and finite size corrections for lattice models and field theories