#!/bin/bash
rm -f temp1
for x in `seq -23 23`
do
	for y in `seq -5 5`
	do
		sim=`grep "^$x.$y" $1`
		real=`grep "^$x.$y" $2`
		gain=`grep "^$x.$y" $3`
		if [ -n "$gain" ]
		then
			echo "$sim	$real	$gain" >> temp1
		fi
	done
done

echo "#x	y	gain"
cat temp1|awk '{ if ($3>10 && $8>10) print $1,$2,$4*$13/$9; else print $1,$2,$13 }'|tr ' ' '\t'
#grep -A 500 "^\-23" sim_ep > temp1
#grep -A 500 "^\-23" 1351_ep > temp2
#grep -A 500 "^\-23" /home/meeg/lcsim/hps-detectors/detectors/HPS-TestRun-v2/calibECal/default.gain > temp3

#paste temp1 temp2 temp3 > temp4
