pro plot_do1pos, code, wave, avg, titout, m1=m1, m2=m2, qstop=qstop, unc_ok=unc_ok, dev_ok=dev_ok
;
;
;
;Ver 1.3  3-Feb-94 (MDM)
;Ver 1.4  4-Feb-94 (MDM) - modified to it could read the new DO1POS_SUMMARY file
;			   which had an extra two columns
;Ver 1.5  7-Feb-94 (MDM) - Added CODE = 3 (Series 592-612)
;			 - Corrected an error in the laser normalization and
;			   laser uncertainy flagging (the arrays were mis-aligned)
;			 - Modified to get laser information directly from
;			   "laser_info.txt"
;			 - Modified selection based on deviation to be relative
;			   deviation, not a fixed STDDEV value
;Ver 1.6 7-Feb-94 (MDM)  - Plot ABS(laser deviation)
;			 - Added CODE = 4 (Series 575-586)
;Ver 1.7 8-Feb-94 (MDM)  - Modified to use get_scan_ser
;			 - Modified to overplot a gaussian fit
;Ver 1.8 9-Feb-94 (MDM)  - Removed /YNOZERO from summary plot with gaussian
;V1.81	10-Feb-94 (MDM)  - Overplot all datapoints as diamonds
;			 - Added printing FWHM value
;
progver = 'PLOT_DO1POS  Ver 1.81'
f = 0.75
;
ytit = 'TRANS Average' 
if (keyword_set(m1)) then ytit = 'M1 Average'
if (keyword_set(m2)) then ytit = 'M2 Average'
;
ser0 = get_scan_ser(code, m1=m1, m2=m2, ver=tit1, tit=tit, dev_ok=dev_ok, unc_ok=unc_ok)
tit2 = 'DEV < ' + strtrim(dev_ok,2) + '!c' + 'UNC < ' + strtrim(unc_ok,2)
;
if (ser0(0) le 0) then begin
    print, 'No points found for ' + tit
    return
end
;
titout = tit + '  ' + ytit
;
avg0 = get_scan_ser(code, m1=m1, m2=m2, /avg, dev_ok=dev_ok, unc_ok=unc_ok)
laser_info, ser0, wave0
ss0 = sort(wave0)
;
ser = ser0(ss0)
wave = wave0(ss0)
avg = avg0(ss0)
laser_info, ser, wave, lpow, ldev
navg = avg/lpow
ldev = abs(ldev*100)
;
ser2 = get_scan_ser(code, m1=m1, m2=m2, dev_ok=999, unc_ok=999)
avg2 = get_scan_ser(code, m1=m1, m2=m2, /avg, dev_ok=999, unc_ok=999)
laser_info, ser2, wave2, lpow2
navg2 = avg2/lpow2
qok = bytarr(n_elements(ser2))+1
qok(where_arr(ser2, ser)) = 0	;exclude the points included in primary plot
ss2 = where(qok)
;
!p.multi = [0,1,2]
plot, wave, avg, /ynozer, ytit=ytit, tit=tit, psym=-1
if (ss2(0) ne -1) then oplot, wave2(ss2), avg2(ss2), psym=4
plot, wave, lpow, /ynozer, ytit='Laser Power', tit=tit, psym=-1
plottime, 0.8, .98, tit2, 0.5*f
plottime, 0, .98, tit1, 0.5*f & plottime & plottime, 0, 0, progver,f & pause
;
if (not keyword_set(m1) and not keyword_set(m2)) then begin	;transmission plots
    plot, wave, ldev, /ynozer, ytit='Laser change (%)', tit=tit, psym=-1
    plot, wave, navg, /ynozero, ytit='Normalized ' +ytit, tit=tit, psym=-1
    if (ss2(0) ne -1) then oplot, wave2(ss2), navg2(ss2), psym=4
    plottime, 0.8, .98, tit2, 0.5*f
    plottime, 0, .98, tit1, 0.5*f & plottime & plottime, 0, 0, progver, f & pause
    ;
    !p.multi = 0
    plot, wave, navg, ytit='Normalized ' +ytit, tit=tit, psym=-1, xrange=[6767,6768.6], thick=3
    if (ss2(0) ne -1) then oplot, wave2(ss2), navg2(ss2), psym=4
    errplot, wave, navg-navg*ldev/100., navg+navg*ldev/100.
    yfit=gaussfit3(wave,navg,coeff)
    xx2 = findgen(500)/499*(6768.6-6767)+6767
    gauss_funct3, xx2, coeff, yy2
    oplot, xx2, yy2
    outstr = 'coeff(' + strtrim(indgen(4),2) + ') = ' + string(coeff)
    for i=0,2 do plottime, .7, .8-i*.04, outstr(i), f
    plottime, .7, .8-3*.04, 'FWHM = ' + string(coeff(2)*2.355*1000) + ' mA', f

    plottime, 0.8, .98, tit2, 0.5*f
    plottime, 0, .98, tit1, 0.5*f & plottime & plottime, 0, 0, progver, f & pause
end
;
!p.multi = 0
if (keyword_set(qstop)) then stop
end
