| 1 | #!/bin/bash
|
|---|
| 2 | #
|
|---|
| 3 | source `dirname $0`/../Sourcefile.sh
|
|---|
| 4 | printprocesslog "INFO starting $0"
|
|---|
| 5 |
|
|---|
| 6 | #root=/opt/root_svn/bin/thisroot.sh
|
|---|
| 7 | #source $root
|
|---|
| 8 | #factpath=/home/fact/FACT++.in-run-fad-loss
|
|---|
| 9 |
|
|---|
| 10 | #anapath=/loc_data/analysis
|
|---|
| 11 |
|
|---|
| 12 | if [ "$1" = "" ]
|
|---|
| 13 | then
|
|---|
| 14 | # get date (before 18h there is no new data to be processed)
|
|---|
| 15 | datepath=`date --date="-18HOUR" +%Y/%m/%d`
|
|---|
| 16 | else
|
|---|
| 17 | datepath=$1
|
|---|
| 18 | fi
|
|---|
| 19 | printprocesslog "INFO processing "$datepath
|
|---|
| 20 | #echo "INFO processing "$datepath
|
|---|
| 21 | night=`echo $datepath | sed -e 's/\///g'`
|
|---|
| 22 |
|
|---|
| 23 | sources=( 1 2 5 7 )
|
|---|
| 24 | numganymeds=0
|
|---|
| 25 |
|
|---|
| 26 | for source in ${sources[@]}
|
|---|
| 27 | do
|
|---|
| 28 | # doing first 5min datasets, i.e. one image file per dataset
|
|---|
| 29 | min=5
|
|---|
| 30 | # getting all image files for this source and night
|
|---|
| 31 | printprocesslog "INFO get file list for source "$source
|
|---|
| 32 | files=( `find /loc_data/analysis/$source/star/$datepath -type f -name '*_I.root' 2>/dev/null | sort` )
|
|---|
| 33 | if [ ${#files[@]} -eq 0 ]
|
|---|
| 34 | then
|
|---|
| 35 | printprocesslog "INFO no image files available for source "$source" on "$datepath
|
|---|
| 36 | continue
|
|---|
| 37 | fi
|
|---|
| 38 | # write data set file
|
|---|
| 39 | dspath=$anapath/$source/datasets`printf %03d $min`min/$datepath
|
|---|
| 40 | makedir $dspath
|
|---|
| 41 | for (( i=1 ; i<=${#files[@]} ; i++ ))
|
|---|
| 42 | do
|
|---|
| 43 | dsfile=$dspath/dataset$i.txt
|
|---|
| 44 | printprocesslog "INFO writing dataset file "$dsfile
|
|---|
| 45 | # write dataset only if merpp-log is available to make sure that star-file is complete
|
|---|
| 46 | merpplog=`echo ${files[$i-1]} | sed -e 's/_I.root/-merpp.log/'`
|
|---|
| 47 | stillrunning=`find $merpplog -mmin -1 2>/dev/null`
|
|---|
| 48 | if [ -e $merpplog ] && [ "$stillrunning" == "" ]
|
|---|
| 49 | then
|
|---|
| 50 | echo `dirname ${files[$i-1]}`" "`basename ${files[$i-1]}` > $dsfile
|
|---|
| 51 | else
|
|---|
| 52 | echo "merpp still running - wait with file "${files[$i-1]}
|
|---|
| 53 | continue
|
|---|
| 54 | fi
|
|---|
| 55 | # process only if ganymedlogfiles is not yet there
|
|---|
| 56 | logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
|
|---|
| 57 | if ! ls $logfile >/dev/null 2>&1
|
|---|
| 58 | then
|
|---|
| 59 | echo $logfile" "${files[$i-1]}
|
|---|
| 60 | `dirname $0`/RunGanymed.sh $source $dsfile
|
|---|
| 61 | numganymeds=`echo " $numganymeds + 1 " | bc -l`
|
|---|
| 62 | fi
|
|---|
| 63 | done
|
|---|
| 64 |
|
|---|
| 65 | # get list of 5min-dataset-files as starting point
|
|---|
| 66 | printprocesslog "INFO get list of dataset files for "$min"min"
|
|---|
| 67 | files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
|
|---|
| 68 | minold=5
|
|---|
| 69 | # loop over data set files
|
|---|
| 70 | # copy always 2 in one new file for double observation time
|
|---|
| 71 | while [ ${#files[@]} -gt 1 ]
|
|---|
| 72 | do
|
|---|
| 73 | # get double observation time and path for datasets
|
|---|
| 74 | min=`echo " $minold + $minold " | bc -l `
|
|---|
| 75 | dspathold=$dspath
|
|---|
| 76 | dspath=$anapath"/"$source"/datasets"`printf %03d $min`"min/"$datepath
|
|---|
| 77 | makedir $dspath
|
|---|
| 78 | # loop over already existing data set files
|
|---|
| 79 | for (( i=0 ; i<=${#files[@]} ; i++ ))
|
|---|
| 80 | do
|
|---|
| 81 | # number of 1st and 2nd old dataset file
|
|---|
| 82 | num1=`echo " $i + $i + 1" | bc -l `
|
|---|
| 83 | num2=`echo " $i + $i + 2 " | bc -l `
|
|---|
| 84 | # number of new dataset file
|
|---|
| 85 | dsnum=`echo " $i + 1 " | bc -l `
|
|---|
| 86 | # continue only if 2 dataset files are left
|
|---|
| 87 | if ! [ ${files[$num1]} ]
|
|---|
| 88 | then
|
|---|
| 89 | break
|
|---|
| 90 | fi
|
|---|
| 91 | ds1=$dspathold"/dataset"$num1".txt"
|
|---|
| 92 | ds2=$dspathold"/dataset"$num2".txt"
|
|---|
| 93 | dsfile=$dspath"/dataset"$dsnum".txt"
|
|---|
| 94 | if ! [ -e $ds1 ] || ! [ -e $ds2 ]
|
|---|
| 95 | then
|
|---|
| 96 | echo $ds1" or "$ds2" is still missing -> continue."
|
|---|
| 97 | continue
|
|---|
| 98 | fi
|
|---|
| 99 | # copy two old into one new dataset file
|
|---|
| 100 | printprocesslog "INFO writing dataset "$dsfile
|
|---|
| 101 | cat $ds1 > $dsfile
|
|---|
| 102 | cat $ds2 >> $dsfile
|
|---|
| 103 | # process only if ganymedlogfiles is not yet there
|
|---|
| 104 | logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
|
|---|
| 105 | if ! ls $logfile >/dev/null 2>&1
|
|---|
| 106 | then
|
|---|
| 107 | echo $logfile
|
|---|
| 108 | `dirname $0`/RunGanymed.sh $source $dsfile
|
|---|
| 109 | numganymeds=`echo " $numganymeds + 1 " | bc -l`
|
|---|
| 110 | fi
|
|---|
| 111 | done
|
|---|
| 112 | # get list of new dataset files
|
|---|
| 113 | printprocesslog "INFO get list of dataset files for "$min"min"
|
|---|
| 114 | files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
|
|---|
| 115 | minold=$min
|
|---|
| 116 | done
|
|---|
| 117 | if [ $numganymeds -gt 0 ]
|
|---|
| 118 | then
|
|---|
| 119 | if ! ps aux | grep Step2b | grep -v grep >/dev/null 2>&1
|
|---|
| 120 | then
|
|---|
| 121 | `dirname $0`/Step2b.sh &
|
|---|
| 122 | fi
|
|---|
| 123 | if ! ps aux | grep Step3 | grep -v grep >/dev/null 2>&1
|
|---|
| 124 | then
|
|---|
| 125 | `dirname $0`/Step3.sh min &
|
|---|
| 126 | fi
|
|---|
| 127 | numganymeds=0
|
|---|
| 128 | fi
|
|---|
| 129 | done
|
|---|
| 130 |
|
|---|
| 131 | finish
|
|---|