How to calculate the SNR from the data collected by ADC?

I want to design a filter to deal with periodic signals according to the actual collected data. In practice, I would like to use the SNR as the criterion to judge the performance of the filter. However, I meet a probelm about how to calculate the SNR according to a data set containing noise collected by the ADC. For example, here is a MATLAB demo to simulate the square signal with nosie collected using a 12-bit ADC:

t = 1:10000;    % length of collected data
fre = 50;       % signal frequency
fs = 20000;     % Sampling frequency
square_signal = square(2*pi*fre*t/fs);
figure(1)
plot(square_signal)
noise = randn(length(square_signal),1);    % noise
figure(2)


In practice, I only could get ad_data using the ADC, while the noise and square_signal are unknown. Besides, the ad_da are in the range of [0,4095] instead of [-1,1]. The data I actually collected using ADC is within the range of [400,1700], which is the same as as_data.

Now, what I want to do is to design the filter based on this collected data (ad_data), mainly the filter order. I use SNR to judge the filter's performance. I know how to use the noise and square_signal to calculate the SNR. However, this is not possible in what I am about to do since there is no way to get pure noise and square_signal.

So, my problem is how to calculate the SNR using the ad_data? Fox example, I'm designing a FIR filter using fir1(order,0.06). How to calculate the SNR of FIR output signal with different filter order? Besides, I also wonder whether the raw data ad_data needs to be normalized to [-1,1]? I find that the SNR calculated with the original data ad_data is much smaller from the SNR calculated with the data normalized to the range [-1, 1]. Which one is right?

You could directly use the above MATLAB demo signal as the original data to answer my questions. Thanks!

Not a direct answer to how to compute the SNR for a sine wave (which I could instead show) as I want to first point out some significant limitations with that approach and then have the OP consider if an SNR for a sine wave test tone still makes sense for the given application.

The typical SNR metric is for SNR in band, and for that the filter would pass both the signal and the noise, ideally with no modification to either (or scaling both by the same amount such as to not effect the SNR). For this, it is quite valuable to confirm that the SNR in band has not been degraded, as with poor filter design there are many opportunities to do so. However measuring the total power or the amount of power removed from the out-of-band spectrum, would not serve this purpose.

The signals of interest for the filter typical occupy a spectral occupancy, in which case other filter characteristics can significantly effect the SNR, notably passband ripple and group delay distortion (if the filter is not known to be linear phase).

To make an accurate SNR measurement that would account for all these effects (passband ripple, group delay distortion, quantization noise growth), I recommend using a correlation method with a reference signal that optimally occupies the spectral bandwidth. For this it is important that the reference signal not have energy out of band, as the rejection of that filter will decrease the correlation leading to a decrease in SNR. In contrast, if the signal does not occupy the same bandwidth as any intended signal in the application, then there can be distortions at certain frequencies imposed by the filter that would not be captured in the SNR assessment.

For more details on using correlation to assess SNR, please see this post and this post.