| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 |
|
|---|
| 4 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 5 | printprocesslog "INFO starting $0"
|
|---|
| 6 | program=RunCallisto
|
|---|
| 7 | step=Callisto
|
|---|
| 8 |
|
|---|
| 9 | set -C
|
|---|
| 10 |
|
|---|
| 11 | # get night and seqid
|
|---|
| 12 | if [ "$night" = "" ] && [ "$seqid" = "" ]
|
|---|
| 13 | then
|
|---|
| 14 | # if no number are provided by JobManager
|
|---|
| 15 | for (( i=0; i<100; i++ ))
|
|---|
| 16 | do
|
|---|
| 17 | # avoid too many simultaneous queries
|
|---|
| 18 | sleep $(( ( RANDOM % 10 ) + 1 ))
|
|---|
| 19 | # get todo list
|
|---|
| 20 | gettodo "1"
|
|---|
| 21 | echo ${primaries[@]}
|
|---|
| 22 |
|
|---|
| 23 | # get all needed variables
|
|---|
| 24 | night=${primaries[0]}
|
|---|
| 25 | seqid=${primaries[1]}
|
|---|
| 26 | nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
|
|---|
| 27 | seqnum=$night"_"`printf %03d $seqid`
|
|---|
| 28 |
|
|---|
| 29 | # check if script is already running
|
|---|
| 30 | lockfile=$lockpath"/lock-"$program"-"$seqnum".txt"
|
|---|
| 31 | checklock continue
|
|---|
| 32 | printprocesslog "INFO got todo with try #"$i
|
|---|
| 33 | break
|
|---|
| 34 | done
|
|---|
| 35 | else
|
|---|
| 36 | nightpath=`echo $night | cut -c 1-4`"/"`echo $night | cut -c 5-6`"/"`echo $night | cut -c 7-8`
|
|---|
| 37 | seqnum=$night"_"`printf %03d $seqid`
|
|---|
| 38 | # check if script is already running
|
|---|
| 39 | lockfile=$lockpath"/lock-"$program"-"$seqnum".txt"
|
|---|
| 40 | checklock
|
|---|
| 41 | s=0
|
|---|
| 42 | primaries=( $night $seqid )
|
|---|
| 43 | fi
|
|---|
| 44 |
|
|---|
| 45 | # get all needed paths and files
|
|---|
| 46 | delays="resources/delays-20150217.txt"
|
|---|
| 47 | drstimefiles=`ls $drstimepath | sort`
|
|---|
| 48 | for drstimefile in $drstimefiles
|
|---|
| 49 | do
|
|---|
| 50 | num=`echo $drstimefile | cut -c 1-8`
|
|---|
| 51 | if [ $num -gt $night ]
|
|---|
| 52 | then
|
|---|
| 53 | break
|
|---|
| 54 | fi
|
|---|
| 55 | drstime=$drstimepath/$drstimefile
|
|---|
| 56 | done
|
|---|
| 57 |
|
|---|
| 58 | seqfile=$seqpath"/"$nightpath"/"$seqnum".seq"
|
|---|
| 59 | outpath=$datapath"/callisto/"$nightpath
|
|---|
| 60 | makedir $outpath
|
|---|
| 61 | logfile=$outpath"/"$seqnum"-calibration.log"
|
|---|
| 62 |
|
|---|
| 63 | cd $mars
|
|---|
| 64 |
|
|---|
| 65 | # set status in DB
|
|---|
| 66 | # maybe already done in JobManager
|
|---|
| 67 | # but do it again to have real runtime
|
|---|
| 68 | setstatus "start"
|
|---|
| 69 |
|
|---|
| 70 | # run callisto
|
|---|
| 71 | printprocesslog "INFO starting callisto.C for sequence "$seqnum
|
|---|
| 72 |
|
|---|
| 73 | printprocesslog "DEBUG root -q -b fact/analysis/callisto.C\("\"$seqfile\""\,"\"$outpath\""\,\""$drstime"\"\,\""$delays"\"\) | tee $logfile "
|
|---|
| 74 | check1=`root -q -b fact/analysis/callisto.C\("\"$seqfile\""\,"\"$outpath\""\,\""$drstime"\"\,\""$delays"\"\) | tee $logfile | intgrep`
|
|---|
| 75 |
|
|---|
| 76 | case $check1 in
|
|---|
| 77 | 0) printprocesslog "INFO callisto was successful for sequence "$seqnum" (check1=$check1)"
|
|---|
| 78 | ;;
|
|---|
| 79 | *) printprocesslog "ERROR callisto.C failed for sequence "$seqnum" (check1=$check1)"
|
|---|
| 80 | check=$check1
|
|---|
| 81 | ;;
|
|---|
| 82 | esac
|
|---|
| 83 |
|
|---|
| 84 | setstatus "stop"
|
|---|
| 85 |
|
|---|
| 86 | finish
|
|---|
| 87 |
|
|---|