nmax=4000
fsim=0.95

fname='lossdata.txt'
gname='summary.txt'

array zvals[17];
zvals[1]=0.
zvals[2]=2.0582968
zvals[3]=2.902871
zvals[4]=3.682871
zvals[5]=4.302871
zvals[6]=4.847871
zvals[7]=5.952871
zvals[8]=6.907871
zvals[9]=7.862871
zvals[10]=8.817871
zvals[11]=9.772871
zvals[12]=10.727871
zvals[13]=11.642871
zvals[14]=12.262871
zvals[15]=13.032871
zvals[16]=13.652871
zvals[17]=16.375742

ff(x)=zvals[x+1]

set terminal postscript eps enhanced color lw 2 "Helvetica" 20
set border lw 0.75
set style line 1 lw 2 lt 1 lc rgb '#ee0000'
set style line 2 lw 2 lt 1 lc rgb 'dark-green'
set style line 3 lw 2 lt 1 lc rgb 'medium-blue'
set style line 4 lw 2 lt 1 lc rgb 'brown4'
set style line 5 lw 2 lt 1 lc rgb 'plum'
set style line 6 lw 2 lt 1 lc rgb 'light-green'
set style line 7 lw 2 lt 1 lc rgb 'skyblue'
set style line 8 lw 2 dt 1 lc rgb 'orange'
set style line 9 lw 2 dt 1 lc rgb 'gold'
set style line 10 lw 2 dt 1 lc rgb 'grey80'
set style line 11 lw 2 dt 2 lc rgb '#ee0000'
set style line 12 lw 2 dt 2 lc rgb 'dark-green'
set style line 13 lw 2 dt 2 lc rgb 'medium-blue'
set style line 14 lw 2 dt 2 lc rgb 'brown4'
set style line 15 lw 2 dt 2 lc rgb 'plum'
set style line 16 lw 2 dt 2 lc rgb 'light-green'
set style line 17 lw 2 dt 2 lc rgb 'skyblue'
set style line 18 lw 2 dt 2 lc rgb 'orange'
set style line 19 lw 2 dt 2 lc rgb 'gold'
set style line 20 lw 2 dt 2 lc rgb 'grey80'

set style increment user

unset title
set key top right font ",14"
set size 1,1
set title font ",28"

set output 'scatter_rate_bump.eps'
set xrange [0:*]
set key top right
set xlabel 'Z (m)'
set ylabel 'rate (1e6/s)'
set xtics auto
set ytics auto
plot [*:*] [*:*] \
  gname u (($0)):($1*1e-6*fsim) w lp ls 1 pt 1 t 'simulated scatter rate', \
  gname u (($0)):($2*1e-6) w lp ls 2 pt 2 t 'loss rate', \

set output 'scatter_bump.eps'
unset title
set key bottom
set xlabel '# turns'
set ylabel '# particles'
set xtics auto
set ytics auto
plot [*:1000] [0:*] \
     fname u (stringcolumn(1) eq '1' ? $2 : 'NaN'):($3) w lp t 'center straight', \
     fname u (stringcolumn(1) eq '2' ? $2 : 'NaN'):($3) w lp t 'end straight', \
     fname u (stringcolumn(1) eq '3' ? $2 : 'NaN'):($3) w lp t 'after QF1', \
     fname u (stringcolumn(1) eq '4' ? $2 : 'NaN'):($3) w lp t 'afterBend1', \
     fname u (stringcolumn(1) eq '5' ? $2 : 'NaN'):($3) w lp t 'after QF2', \
     fname u (stringcolumn(1) eq '6' ? $2 : 'NaN'):($3) w lp t 'after QF3', \
     fname u (stringcolumn(1) eq '7' ? $2 : 'NaN'):($3) w lp t 'after QF4', \
     fname u (stringcolumn(1) eq '8' ? $2 : 'NaN'):($3) w lp t 'after QF5', \
     fname u (stringcolumn(1) eq '9' ? $2 : 'NaN'):($3) w lp t 'after QF6', \
     fname u (stringcolumn(1) eq '10' ? $2 : 'NaN'):($3) w lp t 'after 2nd QF6', \
     fname u (stringcolumn(1) eq '11' ? $2 : 'NaN'):($3) w lp t 'after 2nd QF5', \

