Mordell-Weil lattices for higher genus fibration over a curve Cohomology of Drinfeld modular varieties. Part II: Automorphic forms, trace formulas and Langlands correspondence. With an appendix by Jean-Loup Waldspurger 