1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2004
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | #
|
---|
28 |
|
---|
29 | user=`whoami`
|
---|
30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
31 |
|
---|
32 | set -C
|
---|
33 |
|
---|
34 | cd $mars
|
---|
35 |
|
---|
36 | table=RunProcessStatus
|
---|
37 | column=fDataCheckDone
|
---|
38 | date=NULL
|
---|
39 | datetime=`date +%F-%H-%M-%S`
|
---|
40 | year=`date +%Y`
|
---|
41 |
|
---|
42 | todofile=$listpath/ToDo-$table-$column
|
---|
43 | getstatuslogpath=$logpath/getstatus/dodatacheck/$year
|
---|
44 | getstatuslog=$getstatuslogpath/getstatus-dodatacheck-$datetime.log
|
---|
45 |
|
---|
46 | scriptlogpath=$logpath/run/dodatacheck/`date +%Y/%m`
|
---|
47 | makedir $scriptlogpath
|
---|
48 |
|
---|
49 | scriptlog=$scriptlogpath/dodatacheck-$datetime.log
|
---|
50 |
|
---|
51 | date >> $scriptlog 2>&1
|
---|
52 |
|
---|
53 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
54 |
|
---|
55 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
56 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
57 | then
|
---|
58 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
59 | echo " -> choose one file and start calibrating" >> $scriptlog 2>&1
|
---|
60 | else
|
---|
61 | date > $lockpath/lock-getting-dodatacheck-list.txt >> $scriptlog 2>&1
|
---|
62 | checklock0=$?
|
---|
63 | case $checklock0 in
|
---|
64 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
65 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
66 | echo "-> getting list for dodatacheck is running -> exit" >> $scriptlog 2>&1
|
---|
67 | date >> $scriptlog 2>&1
|
---|
68 | exit;;
|
---|
69 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
70 | esac
|
---|
71 |
|
---|
72 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
73 | then
|
---|
74 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
75 | echo " -> choose one file and start datacheck" >> $scriptlog 2>&1
|
---|
76 | else
|
---|
77 | echo "getting list..." >> $scriptlog 2>&1
|
---|
78 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
79 |
|
---|
80 | case $check0 in
|
---|
81 | 1) echo "check0=$check0 -> everything ok -> do datacheck" >> $scriptlog 2>&1;;
|
---|
82 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
83 | esac
|
---|
84 | fi
|
---|
85 | rm -v $lockpath/lock-getting-dodatacheck-list.txt >> $scriptlog 2>&1
|
---|
86 | fi
|
---|
87 |
|
---|
88 |
|
---|
89 | nr=bla
|
---|
90 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
91 | todofiles=`ls -r $listpath/ToDo-$table-$column-*`
|
---|
92 |
|
---|
93 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
---|
94 |
|
---|
95 | for todofile in ${todofiles[@]}
|
---|
96 | do
|
---|
97 | if ! ls $todofile >> $scriptlog 2>&1
|
---|
98 | then
|
---|
99 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
100 | continue
|
---|
101 | fi
|
---|
102 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
---|
103 | date > $lockfile >> $scriptlog 2>&1
|
---|
104 | checklock=$?
|
---|
105 | case $checklock in
|
---|
106 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
107 | nr=${i}
|
---|
108 | break;;
|
---|
109 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
110 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
111 | esac
|
---|
112 | done
|
---|
113 |
|
---|
114 | case $nr in
|
---|
115 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
116 | date >> $scriptlog 2>&1
|
---|
117 | exit;;
|
---|
118 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
119 | esac
|
---|
120 |
|
---|
121 |
|
---|
122 | runs=(`cat $todofile`)
|
---|
123 |
|
---|
124 | if [ "$runs" = "" ]
|
---|
125 | then
|
---|
126 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
127 | rm -v $todofile >> $scriptlog 2>&1
|
---|
128 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
129 | date >> $scriptlog 2>&1
|
---|
130 | exit
|
---|
131 | fi
|
---|
132 |
|
---|
133 | echo "runs: "${runs[@]} >> $scriptlog 2>&1
|
---|
134 |
|
---|
135 | for run in ${runs[@]}
|
---|
136 | do
|
---|
137 | date
|
---|
138 | echo "do datacheck for run "$run >> $scriptlog 2>&1
|
---|
139 | no=`printf %08d $run | cut -c 0-2`
|
---|
140 | no2=`printf %08d $run`
|
---|
141 | rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw`
|
---|
142 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
---|
143 | date=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw | cut -c 22-31`
|
---|
144 | echo "date: "$date >> $scriptlog 2>&1
|
---|
145 | date2=`echo $date | sed -e 's/\//-/g'`
|
---|
146 | echo "date2: "$date2 >> $scriptlog 2>&1
|
---|
147 |
|
---|
148 | filldotrawpath=$logpath/filldotraw/$date
|
---|
149 | makedir $filldotrawpath >> $scriptlog 2>&1
|
---|
150 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
---|
151 |
|
---|
152 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
---|
153 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
|
---|
154 |
|
---|
155 | case $check1 in
|
---|
156 | 1) echo "check1=$check1 -> everything ok -> go on with datacheck..." >> $scriptlog 2>&1
|
---|
157 | ;;
|
---|
158 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
159 | continue;;
|
---|
160 | esac
|
---|
161 |
|
---|
162 | sinopepath=$datapath/sinope/$date
|
---|
163 | makedir $sinopepath >> $scriptlog 2>&1
|
---|
164 |
|
---|
165 | sins=( "-dat" "-cal")
|
---|
166 | echo ${sins[@]} >> $scriptlog 2>&1
|
---|
167 | for sin in ${sins[@]}
|
---|
168 | do
|
---|
169 | sinopefile=sinope$sin$no2
|
---|
170 | echo $sinopefile >> $scriptlog 2>&1
|
---|
171 |
|
---|
172 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
---|
173 | ./sinope -b -q -v4 -f $sin --outf=$sinopefile --out=$sinopepath --log=$sinopepath/$sinopefile.log --html=$sinopepath/$sinopefile.html --run=$run --date=$date2 2>> $scriptlog > /dev/null
|
---|
174 | check2=$?
|
---|
175 |
|
---|
176 | case $check2 in
|
---|
177 | 0) echo "check2=$check2 -> everything ok -> go on with datacheck..." >> $scriptlog 2>&1
|
---|
178 | ;;
|
---|
179 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
180 | continue 2;;
|
---|
181 | esac
|
---|
182 | check2=1
|
---|
183 | done
|
---|
184 |
|
---|
185 | fillsinopepath=$logpath/fillsinope/$date
|
---|
186 | makedir $fillsinopepath >> $scriptlog 2>&1
|
---|
187 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
---|
188 |
|
---|
189 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
---|
190 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
|
---|
191 |
|
---|
192 | case $check3 in
|
---|
193 | 1) echo "check3=$check3 -> everything ok -> set exclusions..." >> $scriptlog 2>&1
|
---|
194 | ;;
|
---|
195 | *) echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
196 | continue;;
|
---|
197 | esac
|
---|
198 |
|
---|
199 | echo "resetting the status for fExclusions done for date $date2" >> $scriptlog 2>&1
|
---|
200 | resetlogpath=$logpath/resetexclusions/$date
|
---|
201 | echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
|
---|
202 | makedir $resetlogpath >> $scriptlog 2>&1
|
---|
203 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
---|
204 | echo "setstatuslogfile: $setstatuslog" >> $scriptlog 2>&1
|
---|
205 |
|
---|
206 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
207 | case $check5 in
|
---|
208 | 1) echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
---|
209 | ;;
|
---|
210 | *) echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
---|
211 | continue;;
|
---|
212 | esac
|
---|
213 |
|
---|
214 | echo "inserting the status for the datacheck for run $run into the db" >> $scriptlog 2>&1
|
---|
215 | setstatuslogpath=$logpath/setstatus/datacheck/$date
|
---|
216 | echo "setstatuslogpath: $setstatuslogpath" >> $scriptlog 2>&1
|
---|
217 | makedir $setstatuslogpath >> $scriptlog 2>&1
|
---|
218 | setstatuslog=$setstatuslogpath/setstatus-datacheck-$no2.log
|
---|
219 | echo "setstatuslogfile: $setstatuslog" >> $scriptlog 2>&1
|
---|
220 |
|
---|
221 | check4=`root -q -b $macrospath/setstatus.C+\("\"$run\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
222 | case $check4 in
|
---|
223 | 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1
|
---|
224 | ;;
|
---|
225 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1
|
---|
226 | ;;
|
---|
227 | esac
|
---|
228 | done
|
---|
229 |
|
---|
230 | rm -v $todofile >> $scriptlog 2>&1
|
---|
231 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
232 |
|
---|
233 | set +C
|
---|
234 |
|
---|
235 | date >> $scriptlog 2>&1
|
---|
236 |
|
---|