ROC curves are formed by plotting Pd against Pfa and first you should decide whether you will use the CFAR approach or the CDR approach. For plotting Pd Vs SNR you should set a target Pfa and then calculate your Pd for each SNR value.
I think there might be problem with your threshold. It is constant and not changing as per your Pf. The MX is always greater than test(m). Therefore you are getting Pd as always 1.
in your program pd vs pfa is plotted, but pfa u consider is 0.1 that is equal to 0.45. Pfa is varing in your progrom. The value 0.45 is calculated for tracy-widom distribution for pfa=0.1. if pfa=0.2 then the value changes to other value.