add the thr_scan.c for fitting ERF and get the threshold during scan