

nproc=1.
let nproc=2+0

out=1.
while [ $nproc -gt 0 ]
do
	sleep 10
	outp=`ls | grep moni -c`
	nproc=`ps -ef | grep icecube.daq.domcal.DOMCal | grep -v grep -c`
	
 echo moni $moni    out $outp      proc $nproc

	if [ $outp -ne $1 ]; then
	    echo "missing out files. restart domcal?"
	fi
#	if [ $outp -eq $1 ]; then
	   # echo "Right number of out file created"
#	fi
	if [ $xmlold -ne $xmlp ]; then
	    echo "$xmlp doms finished (out of $outp)";
	    let xmlold=xmlp
	fi
	if [ $outp -eq $xmlp  ]; then
	    echo "calibration finished"
	    sleep 10
	    iceboot=`tail *.out | grep Iceboot -ic`
# make sure calibration finished and all doms are back:
	    if [ $iceboot -eq $xmlp ]; then 
		nproc=`ps -ef | grep icecube.daq.domcal.DOMCal | grep -v grep -c`
	    	if [ $nproc -gt 0 ]; then
			killall java
		fi
	     fi
	 echo "calibration finished"
	fi
done
exit
