# Script to submit all fits to evaluate CCEscans

echo "========================================"
echo "Submit for:"
echo "       Detector $1"
echo "       Layer    $2"
echo "       Sector   $3"
echo "       Fill     $4"
echo "       Radius   $5"
FILENAME=tmp_scripts/run$1_$2_$3_$4_r$5.sh
VAL=3
#echo "source $HOME/.zshrc" > $FILENAME
echo "source $HOME/.bashrc" > $FILENAME
echo "export LHCBSTYLE=1" >> $FILENAME

echo "export DISK=/disk/data1/hep/elena" >> $FILENAME
echo "restart_root" >> $FILENAME

if [ "$1" = "IT" ]
then
VAL=7
fi

#landauFit
for i in {0..65}
do
  echo "$HOME/cmtuser/STMonitoring/STAging/macros/CCEScan/landauFit -b -d $1 -l $2 -s $3 -f $4 -c $i -v $VAL -ss -r $5" >> $FILENAME
done

#pulseFit
for i in {0..10}
do
echo "$HOME/cmtuser/STMonitoring/STAging/macros/CCEScan/pulseFit -b -d $1 -l $2 -s $3 -f $4 -c $i -v $VAL -ss -r $5" >> $FILENAME
done

#voltageFit
echo "$HOME/cmtuser/STMonitoring/STAging/macros/CCEScan/voltageFit -b -d $1 -l $2 -s $3 -f $4 -v $VAL -ss -r $5" >> $FILENAME

qsub -l cput=24000 $FILENAME
sleep 2
rm $FILENAME
echo "========================================"
echo ""
