#!//bin/tcsh

# $1 0=all rocs otherwise is the rocid you want to run
# $2 VERSION NUMBER
# $3 threshold
# $4 number of triggers

if ($#argv < 4) then
    echo "CDC start readout"
    echo "Insufficent parameters:"
    echo " ./startalladcs.csh ROC VERSION THRESHOLD TRIGGERS"
    echo "                    ROC = 0 start all ROCS"
    exit
endif

if ($1 == 0) then
    echo "Start up all CDC ROCS with version "$2" threshold "$3" and triggers: "$4
    echo 'ROC1'
    ssh hdcdcops@roccdc1 /home/hdcdcops/scripts/startupadcsCDC.csh 1 $2 13 $3 $4 \&
    echo 'ROC2'
    ssh hdcdcops@roccdc2 /home/hdcdcops/scripts/startupadcsCDC.csh 2 $2 12 $3 $4 \&
    echo 'ROC3'
    ssh hdcdcops@roccdc3 /home/hdcdcops/scripts/startupadcsCDC.csh 3 $2 12 $3 $4 \&
    echo 'ROC4'
    ssh hdcdcops@roccdc4 /home/hdcdcops/scripts/startupadcsCDC.csh 4 $2 13 $3 $4 \&

else
    echo "Start up all CDC ROC "$1" with version "$2" threshold "$3" and triggers: "$4
    if ($1 == 1 || $1 == 4) then	
    	ssh hdcdcops@roccdc$1 /home/hdcdcops/scripts/startupadcsCDC.csh $1 $2 13 $3 $4 \&
    else
        ssh hdcdcops@roccdc$1 /home/hdcdcops/scripts/startupadcsCDC.csh $1 $2 12 $3 $4 \&
    endif
endif
wait
gotodatadir
./CheckAllPedestals.sh $1 $2
cd ~/scripts
