Let $X$ be a random variable with pdf (probability density function) $f$. Let $A\subset\mathbb{R}$. How to compute $E(X|X\in A)$? This is a condition expectation that conditions on an event instead of another random variable $Y$. I don't see such a topic covered in any book, because $X$ is always a discrete random variable when a book talks about conditioning on an event. And when $X$ is continuous, the conditional expectation is always about another random variable $Y$.
I have the following argument $$E(X|X\in A)=\int x f(x|A)\,dx,$$ where $f(x|A)$ is the conditional density function, which conditions on an event $A$. I don't find a definition of it in any probability book so here is my definition $$f(x|A)=\frac{f(x)1_A(x)}{P(A)}.$$ With this definition, we have $$ E(X|X\in A)=\int x f(x|A)\,dx=\int_{x\in A} \frac{xf(x)}{P(A)}\,dx=\frac{\int_{x\in A} xf(x)\,dx}{\int_{x\in A} f(x)\,dx}. $$
For example, $E(X|X\le 5)=\frac{\int_{-\infty}^5 xf(x)\,dx}{\int_{-\infty}^5 f(x)\,dx}$.
Does my argument above correct? Is there a way to fit the above theory into a general theory given in a standard probability book? For example, does it have something to do with $E(X|Y)$ where $Y$ is another random variable? Any book covering such a problem is also welcomed.