  We present a general framework to study the distribution of the flux through
the origin up to time $t$, in a non-interacting one-dimensional system of
particles with a step initial condition with a fixed density $\rho$ of
particles to the left of the origin. We focus principally on two cases: (i)
when the particles undergo diffusive dynamics (passive case) and (ii)
run-and-tumble dynamics for each particle (active case). In analogy with
disordered systems, we consider the flux distribution both for the annealed and
the quenched initial conditions, for the passive and active particles. In the
annealed case, we show that, for arbitrary particle dynamics, the flux
distribution is a Poissonian with a mean $\mu(t)$ that we compute exactly in
terms of the Green's function of the single particle dynamics. For the quenched
case, we show that, for the run-and-tumble dynamics, the quenched flux
distribution takes an anomalous large deviation form at large times $P_{\rm
qu}(Q,t) \sim \exp\left[-\rho\, v_0\, \gamma \, t^2 \psi_{\rm
RTP}\left(\frac{Q}{\rho v_0\,t} \right) \right]$, where $\gamma$ is the rate of
tumbling and $v_0$ is the ballistic speed between two successive tumblings. In
this paper, we compute the rate function $\psi_{\rm RTP}(q)$ and show that it
is nontrivial. Our method also gives access to the probability of the rare
event that, at time $t$, there is no particle to the right of the origin. For
diffusive and run-and-tumble dynamics, we find that this probability decays
with time as a stretched exponential, $\sim \exp(-c\, \sqrt{t})$ where the
constant $c$ can be computed exactly. We verify our results for these large
deviations by using an importance sampling Monte-Carlo method.
