  We propose a new conjectural way to calculate the local $L$-factor
$L=L_\chi(\pi,\rho,s)$ where $\pi$ is a representation of a $p$-adic group $G$,
$\rho$ is an algebraic representation of the dual group $G^{\vee}$ and $\chi$
is an algebraic character of $G$ satisfying a positivity condition.
  A method going back to Godement and Jacquet yields a description of $L$ using
as an input a certain space ${\mathcal S}_\rho$ of functions on $G$ depending
on $\rho$. A (partly conjectural) description of ${\mathcal S}_\rho$ involving
trace of Frobenius functions associated to perverse sheaves on the loop space
of a semigroup containing $G$ was developed %by Bouthier, Ngo and Sakellaridis,
partly based on an earlier work of Braverman and Kazhdan. Here we propose a
different, more general conjectural description of ${\mathcal S}_\rho$: it also
refers to trace of Frobenius functions but instead of the loop space of a
semi-group we work with the ramified global Grassmannian fibering over the
configuration space of points on a global curve defined by Beilinson-Drinfeld
and Gaitsgory (a relation between two approaches is discussed in the appendix).
  Our main result asserts validity of our conjectures where $\pi$ is generated
by an Iwahori fixed vector: we show that in this case it is compatible with the
standard formula for $L$ involving local Langlands correspondence which is
known for such representations $\pi$.
  The proof is based on properties of the coherent realization of the affine
Hecke category.
