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 | dspath=$anapath/$source/datasets_run/$datepath
|
---|
41 | makedir $dspath
|
---|
42 | for (( i=1 ; i<=${#files[@]} ; i++ ))
|
---|
43 | do
|
---|
44 | night=`basename ${files[$i-1]} | cut -d_ -f1`
|
---|
45 | echo "night: "$night
|
---|
46 | run=`basename ${files[$i-1]} | cut -d_ -f2`
|
---|
47 | echo "run: "$run
|
---|
48 | dsfile=$dspath"/dataset"$night"_"$run".txt"
|
---|
49 | echo $dsfile
|
---|
50 | printprocesslog "INFO writing dataset file "$dsfile
|
---|
51 | # write dataset only if merpp-log is available to make sure that star-file is complete
|
---|
52 | merpplog=`echo ${files[$i-1]} | sed -e 's/_I.root/-merpp.log/'`
|
---|
53 | stillrunning=`find $merpplog -mmin -1 2>/dev/null`
|
---|
54 | if [ -e $merpplog ] && [ "$stillrunning" == "" ]
|
---|
55 | then
|
---|
56 | echo `dirname ${files[$i-1]}`" "`basename ${files[$i-1]}` > $dsfile
|
---|
57 | else
|
---|
58 | echo "merpp still running - wait with file "${files[$i-1]}
|
---|
59 | continue
|
---|
60 | fi
|
---|
61 | # process only if ganymedlogfiles is not yet there
|
---|
62 | logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
|
---|
63 | if ! ls $logfile >/dev/null 2>&1
|
---|
64 | then
|
---|
65 | echo $logfile" "${files[$i-1]}
|
---|
66 | echo "`dirname $0`/RunGanymed.sh $source $dsfile"
|
---|
67 | `dirname $0`/RunGanymed.sh $source $dsfile
|
---|
68 | numganymeds=`echo " $numganymeds + 1 " | bc -l`
|
---|
69 | fi
|
---|
70 | done
|
---|
71 |
|
---|
72 | # # get list of 5min-dataset-files as starting point
|
---|
73 | # printprocesslog "INFO get list of dataset files for "$min"min"
|
---|
74 | # files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
|
---|
75 | # minold=5
|
---|
76 | # # loop over data set files
|
---|
77 | # # copy always 2 in one new file for double observation time
|
---|
78 | # while [ ${#files[@]} -gt 1 ]
|
---|
79 | # do
|
---|
80 | # # get double observation time and path for datasets
|
---|
81 | # min=`echo " $minold + $minold " | bc -l `
|
---|
82 | # dspathold=$dspath
|
---|
83 | # dspath=$anapath"/"$source"/datasets"`printf %03d $min`"min/"$datepath
|
---|
84 | # makedir $dspath
|
---|
85 | # # loop over already existing data set files
|
---|
86 | # for (( i=0 ; i<=${#files[@]} ; i++ ))
|
---|
87 | # do
|
---|
88 | # # number of 1st and 2nd old dataset file
|
---|
89 | # num1=`echo " $i + $i + 1" | bc -l `
|
---|
90 | # num2=`echo " $i + $i + 2 " | bc -l `
|
---|
91 | # # number of new dataset file
|
---|
92 | # dsnum=`echo " $i + 1 " | bc -l `
|
---|
93 | # # continue only if 2 dataset files are left
|
---|
94 | # if ! [ ${files[$num1]} ]
|
---|
95 | # then
|
---|
96 | # break
|
---|
97 | # fi
|
---|
98 | # ds1=$dspathold"/dataset"$num1".txt"
|
---|
99 | # ds2=$dspathold"/dataset"$num2".txt"
|
---|
100 | # dsfile=$dspath"/dataset"$dsnum".txt"
|
---|
101 | # if ! [ -e $ds1 ] || ! [ -e $ds2 ]
|
---|
102 | # then
|
---|
103 | # echo $ds1" or "$ds2" is still missing -> continue."
|
---|
104 | # continue
|
---|
105 | # fi
|
---|
106 | # # copy two old into one new dataset file
|
---|
107 | # printprocesslog "INFO writing dataset "$dsfile
|
---|
108 | # cat $ds1 > $dsfile
|
---|
109 | # cat $ds2 >> $dsfile
|
---|
110 | # # process only if ganymedlogfiles is not yet there
|
---|
111 | # logfile=`echo $dsfile | sed -e 's/datasets/ganymed/' -e 's/dataset//' -e 's/[.]txt/-ganymed[.]log/'`
|
---|
112 | # if ! ls $logfile >/dev/null 2>&1
|
---|
113 | # then
|
---|
114 | # echo $logfile
|
---|
115 | # `dirname $0`/RunGanymed.sh $source $dsfile
|
---|
116 | # numganymeds=`echo " $numganymeds + 1 " | bc -l`
|
---|
117 | # fi
|
---|
118 | # done
|
---|
119 | # # get list of new dataset files
|
---|
120 | # printprocesslog "INFO get list of dataset files for "$min"min"
|
---|
121 | # files=( `find $dspath -type f -name 'dataset*.txt' | sort` )
|
---|
122 | # minold=$min
|
---|
123 | # done
|
---|
124 |
|
---|
125 | echo "found "$numganymeds" ganymeds."
|
---|
126 | # if [ $numganymeds -gt 0 ]
|
---|
127 | # then
|
---|
128 | # if ! ps aux | grep Step2b | grep -v grep >/dev/null 2>&1
|
---|
129 | # then
|
---|
130 | # `dirname $0`/Step2b.sh &
|
---|
131 | # fi
|
---|
132 | # if ! ps aux | grep Step3 | grep -v grep >/dev/null 2>&1
|
---|
133 | # then
|
---|
134 | # `dirname $0`/Step3.sh min &
|
---|
135 | # fi
|
---|
136 | # numganymeds=0
|
---|
137 | # fi
|
---|
138 | done
|
---|
139 |
|
---|
140 | finish
|
---|