The trace formula of Selberg gives an equality between trace of Hecke operators (a spectral sum) on spaces of Maass forms and sums over closed geodesics mostly. The Eichler-Selberg trace formula, however, gives an identity between trace of Hecke operators on spaces of modular forms and sums over class numbers (or Kloosterman sums).

Are they both related or, rather, both complementary and we need both to have a full spectral picture (of what? a whole trace of Hecke operators?)

More specifically, how can both be made close/comparable? Can we for instance have a version of Selberg's trace formula where the geometric/arithmetic side is written as sum of some class numbers, or other arithmetic invariants?