| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 4 | printprocesslog "INFO starting $0"
|
|---|
| 5 |
|
|---|
| 6 | # get dates
|
|---|
| 7 | if [ "$certaindate" != "" ]
|
|---|
| 8 | then
|
|---|
| 9 | checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'`
|
|---|
| 10 | if [ "$checkstring" = "" ]
|
|---|
| 11 | then
|
|---|
| 12 | echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)"
|
|---|
| 13 | finish
|
|---|
| 14 | fi
|
|---|
| 15 | getdates $certaindate
|
|---|
| 16 | else
|
|---|
| 17 | if [ "$1" = "" ]
|
|---|
| 18 | then
|
|---|
| 19 | # get all night
|
|---|
| 20 | #getdates "all"
|
|---|
| 21 | # get last 6 nights if hour between 7 and 19h, else only current night
|
|---|
| 22 | getdates 6 7 19
|
|---|
| 23 | else
|
|---|
| 24 | getdates $1
|
|---|
| 25 | fi
|
|---|
| 26 | fi
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | for date in ${dates[@]}
|
|---|
| 31 | do
|
|---|
| 32 | printprocesslog "INFO processing "$date
|
|---|
| 33 | #echo "INFO processing "$date
|
|---|
| 34 | night=`echo $date | sed -e 's/\///g'`
|
|---|
| 35 |
|
|---|
| 36 | numganymeds=0
|
|---|
| 37 | # getting all image files for this night
|
|---|
| 38 | printprocesslog "INFO get file list for night "$date
|
|---|
| 39 | files=( `find $anapath/star/$date -type f -name '*_I.root' 2>/dev/null | sort` )
|
|---|
| 40 | if [ ${#files[@]} -eq 0 ]
|
|---|
| 41 | then
|
|---|
| 42 | printprocesslog "INFO no image files available for night "$date
|
|---|
| 43 | continue
|
|---|
| 44 | fi
|
|---|
| 45 |
|
|---|
| 46 | for file in ${files[@]}
|
|---|
| 47 | do
|
|---|
| 48 | night=`basename $file | cut -d_ -f1`
|
|---|
| 49 | run=`basename $file | cut -d_ -f2`
|
|---|
| 50 | printprocesslog "INFO processing run "$run
|
|---|
| 51 | # process only if merpp-log is available to make sure that star-file is complete
|
|---|
| 52 | # at ISDC seq# != run# -> get seq#
|
|---|
| 53 | if echo $resulttable1 | grep ISDC >/dev/null 2>&1
|
|---|
| 54 | then
|
|---|
| 55 | query="SELECT LPAD(fSequenceID, 3, 0) FROM RunInfo WHERE fNight="$night" AND fRunID="$run
|
|---|
| 56 | seq=`sendquery`
|
|---|
| 57 | merpplog=`dirname $file`"/"$night"_"$seq"-merpp.log"
|
|---|
| 58 | else
|
|---|
| 59 | merpplog=`echo $file | sed -e 's/_I.root/-merpp.log/'`
|
|---|
| 60 | fi
|
|---|
| 61 | # check if merpp is finished
|
|---|
| 62 | stillrunning=`find $merpplog -mmin -1 2>/dev/null`
|
|---|
| 63 | if ! [ -e $merpplog ] || [ "$stillrunning" != "" ]
|
|---|
| 64 | then
|
|---|
| 65 | printprocesslog "INFO merpp still running - wait with file "$file
|
|---|
| 66 | continue
|
|---|
| 67 | fi
|
|---|
| 68 | # process only if ganymedlogfiles is not yet there
|
|---|
| 69 | logfile=`echo $file | sed -e 's/star/ganymed_run/' -e 's/_I[.]root/-ganymed[.]log/'`
|
|---|
| 70 | if ! ls $logfile >/dev/null 2>&1
|
|---|
| 71 | then
|
|---|
| 72 | printprocesslog "DEBUG `dirname $0`/RunGanymed.sh "$file
|
|---|
| 73 | if [ "$qlasge" = "yes" ]
|
|---|
| 74 | then
|
|---|
| 75 | printprocesslog "$sgepath/qsub -b y -q fact_short -v AUTOMATIONSETUP=$AUTOMATIONSETUP -v starfile=$file -e bla.txt -o bla.txt `dirname $0`/RunGanymed.sh"
|
|---|
| 76 | $sgepath/qsub -b y -q fact_short -v AUTOMATIONSETUP=$AUTOMATIONSETUP -v star=$file -e bla.txt -o bla.txt `dirname $0`/RunGanymed.sh
|
|---|
| 77 | else
|
|---|
| 78 | printprocesslog " INFO `dirname $0`/RunGanymed.sh $file"
|
|---|
| 79 | `dirname $0`/RunGanymed.sh $file
|
|---|
| 80 | echo "ganymed for "$file
|
|---|
| 81 | fi
|
|---|
| 82 | numganymeds=`echo " $numganymeds + 1 " | bc -l`
|
|---|
| 83 | fi
|
|---|
| 84 | done
|
|---|
| 85 | printprocesslog "INFO found "$numganymeds" ganymeds."
|
|---|
| 86 | done
|
|---|
| 87 |
|
|---|
| 88 | finish
|
|---|
| 89 |
|
|---|