#  This extract one specified event from sepics output
#  and makes output for "z fiber-pos particle_number"  table.
#
#  usage:  awk -f getdata nth=25 file1 file2
#   nth is to specify the event number
#   file1 is the scifi layer number to z value table
#   file2 is the sepics output.
#   
#   layer number to z value table can be obtained by
#   "layer2z < FirstInput"; layer2z can be created by 
#   make -f layer2z.mk
#
NF == 3 && $3!=0 {scifiz[$1]=$2; next}
NF == 3 && $3==0 {scinti[$1]=$2; next}
NF > 4 {++nc}
nc > nth  {exit}
# nc == nth && NF >4  {print scinti[1], $1, 0, 0;  
# print scinti[2],$2, 0, 0; print scinti[3], $3, 0, 0; next}
#nc == nth && NF== 4 && $1 > 0 {print $2, scifiz[$1], $3, $4}
nc == nth  {print}

