Expectation of a minimum

Why is this: $E(\tau \wedge T) = \int_0^Ttf_\tau(t)dt+T(1-P(\tau\leq T))$, where $f_\tau(t)$ is the pdf of $\tau$. I am thinking its because $E(\tau \wedge T) = \tau P(\tau\leq T)+T(1-P(\tau\leq T))$ since $\tau \wedge T =\min(\tau,T) = \tau$ if $\tau\leq T)$ and T if $\tau> T)$. But the first part is I cannot figure out.

-

We have as you wrote $\tau \wedge T = \chi_{\{\tau \le T\}} \cdot \tau + T \cdot \chi_{\{\tau > T\}}$ where $\chi_A$ denotes the indicator function of $A$. We have $\chi_{\\{\tau \le T\\}} = \chi_{[0,T]} \circ \tau$, therefore \begin{align*} E(\tau \wedge T) &= E\bigl((\chi_{[0,T]}\cdot \mathrm{id}_{[0,\infty)}) \circ \tau\bigr) + T \cdot E(\chi_{\\{\tau > T\\}})\\ &= \int_0^\infty \chi_{[0,T]}(t) \cdot t \cdot f_\tau(t) \, dt + T \cdot P(\tau > T)\\ &= \int_0^T t f_\tau(t)\, dt + T \bigl(1 - P(\tau \le T)\bigr) \end{align*}