Signal Estimation after detection Part 2
After signal detection, how to estimate the clean signal $s(t)$?

Matched filtering is used to detect the presence of a known signal in noise. There is no estimation part when you are talking about a matched filter. The estimate part comes after you have done the matched filter and need to estimate the symbols.
It looks like you are talking about a communication system context, but the matched filtering in those systems is not done by matched filtering the symbols as in your example code. For each symbol, the true symbol is unknown and the pulse shape is known, and that is why the matched filter uses the pulse shape to matched filter. Perhaps all that you want to know about matched filtering can be found here, https://dsp.stackexchange.com/a/9389/31316, and you should give it a read.
Edit
The OP questions about the zero threshold and whether there are other methods. That threshold is set through using the maximum likelihood solution, or minimum distance decoding. For the case of BPSK, you want to decide if $x$ contains $s_1=+1$ or $s_2=-1$, and the ML rule is to choose $\hat{s}=s_1$ if:
$$ |x-s_1|&lt;|x-s_2| $$
This can also be interpreted as partitioning the IQ diagram into different regions (Voronoi regions), a region for $s_1$ and a different region for $s_2$. These regions end up looking like this (note how for BPSK the threshold line is at zero):

For full derivation, see Tse's Wireless Comms book section A.2.1, https://web.stanford.edu/~dntse/Chapters_PDF/Fundamentals_Wireless_Communication_AppendixA.pdf.