#!/bin/csh -f
#
# lbeplot - plot LBE distribution for several logs
#
# usage: lbeplot [-t title] <log.elog>...
#
# Where log is a NORMAL style elog, not a LOG2 type.

if ($1 == -t) then
    if ($#argv >= 2) then
        set title="$2"
        shift; shift
    else
        shift
    endif    
endif

if ($#argv == 0) then
    echo 'usage: lbeplot [-t title] log.elog...'
    exit 1
endif

if (! $?title) then
    # if no title specified use file name
    set title="$1"
endif

set P=`procdir`

set TMP=/tmp/lbe$$
onintr cleanup
rm -rf $TMP
mkdir $TMP

echo set title \""$title"\" > $TMP/plot
echo set data style linespoints >> $TMP/plot
echo -n "plot [0:1] [0:1] " >> $TMP/plot

set file=0
foreach logfile ($*)
    lbe $logfile | cdf > $TMP/$file
    echo -n \"$file\", >> $TMP/plot
    @ file=$file + 1
end
echo 0 >> $TMP/plot

cd $TMP
lasergnu -l -f plot

cleanup:
rm -rf $TMP
