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-2006
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script launches the datacheck for all runs, which are not yet
|
---|
28 | # checked
|
---|
29 | #
|
---|
30 | # After checking, if the script is already running, the todolist is
|
---|
31 | # written by using the macro getdolist.C
|
---|
32 | # Then for each run the following steps are done:
|
---|
33 | # - filldotraw.C
|
---|
34 | # - sinope (once for data and once for calibration events)
|
---|
35 | # - fillsinope
|
---|
36 | # - reset ExclusionsDone, so that the result from the datacheck can be
|
---|
37 | # taken into account when doexclusions is running the next time
|
---|
38 | # If this was successful, the status is inserted into the database using
|
---|
39 | # the macro setstatus.C
|
---|
40 | #
|
---|
41 |
|
---|
42 | user=`whoami`
|
---|
43 | program=datacheck
|
---|
44 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
45 |
|
---|
46 | set -C
|
---|
47 |
|
---|
48 | cd $mars
|
---|
49 |
|
---|
50 | table=RunProcessStatus
|
---|
51 | column=fDataCheckDone
|
---|
52 |
|
---|
53 | todofile=$listpath/ToDo-$table-$column
|
---|
54 |
|
---|
55 | scriptlogpath=$logpath/run/$program/`date +%Y/%m`
|
---|
56 | makedir $scriptlogpath
|
---|
57 | scriptlog=$scriptlogpath/$program-$datetime.log
|
---|
58 |
|
---|
59 | date >> $scriptlog 2>&1
|
---|
60 |
|
---|
61 | # check if there are already todo files
|
---|
62 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
63 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
64 | then
|
---|
65 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
66 | echo " -> choose one file and start $program " >> $scriptlog 2>&1
|
---|
67 | else
|
---|
68 | date > $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
|
---|
69 | checklock0=$?
|
---|
70 | case $checklock0 in
|
---|
71 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
72 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
73 | echo "-> getting list for $program is running -> exit" >> $scriptlog 2>&1
|
---|
74 | date >> $scriptlog 2>&1
|
---|
75 | exit;;
|
---|
76 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
77 | esac
|
---|
78 |
|
---|
79 | # get todo list
|
---|
80 | getdolist >> $scriptlog 2>&1
|
---|
81 |
|
---|
82 | rm -v $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
|
---|
83 | fi
|
---|
84 |
|
---|
85 |
|
---|
86 | # finding a todo file
|
---|
87 | nr=bla
|
---|
88 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
89 | todofiles=`ls -r $listpath/ToDo-$table-$column-*`
|
---|
90 |
|
---|
91 | echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
|
---|
92 | for todofile in ${todofiles[@]}
|
---|
93 | do
|
---|
94 | if ! ls $todofile >> $scriptlog 2>&1
|
---|
95 | then
|
---|
96 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
97 | continue
|
---|
98 | fi
|
---|
99 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
---|
100 | date > $lockfile >> $scriptlog 2>&1
|
---|
101 | checklock=$?
|
---|
102 | case $checklock in
|
---|
103 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
104 | nr=${i}
|
---|
105 | break;;
|
---|
106 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
107 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
108 | esac
|
---|
109 | done
|
---|
110 |
|
---|
111 | case $nr in
|
---|
112 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
113 | date >> $scriptlog 2>&1
|
---|
114 | exit;;
|
---|
115 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
116 | esac
|
---|
117 |
|
---|
118 |
|
---|
119 | # get run(s) from todo file
|
---|
120 | runs=(`cat $todofile`)
|
---|
121 | if [ "$runs" = "" ]
|
---|
122 | then
|
---|
123 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
124 | finish >> $scriptlog 2>&1
|
---|
125 | fi
|
---|
126 |
|
---|
127 | # processing run(s)
|
---|
128 | echo "runs: "${runs[@]} >> $scriptlog 2>&1
|
---|
129 | for run in ${runs[@]}
|
---|
130 | do
|
---|
131 | echo "do $program for run "$run >> $scriptlog 2>&1
|
---|
132 | no=`printf %08d $run | cut -c 0-2`
|
---|
133 | no2=`printf %08d $run`
|
---|
134 | var1=$date
|
---|
135 | var2=$no2
|
---|
136 | rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw`
|
---|
137 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
---|
138 | date=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw | cut -c 22-31`
|
---|
139 | echo "date: "$date >> $scriptlog 2>&1
|
---|
140 | # for sinope the date is needed in the format YYYY-MM-DD
|
---|
141 | date2=`echo $date | sed -e 's/\//-/g'`
|
---|
142 | echo "date2: "$date2 >> $scriptlog 2>&1
|
---|
143 |
|
---|
144 | # running filldotraw
|
---|
145 | filldotrawpath=$logpath/filldotraw/$date
|
---|
146 | makedir $filldotrawpath >> $scriptlog 2>&1
|
---|
147 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
---|
148 |
|
---|
149 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
---|
150 | setstatus "start" >> $scriptlog 2>&1
|
---|
151 |
|
---|
152 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
|
---|
153 |
|
---|
154 | case $check1 in
|
---|
155 | 1) echo "check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
156 | ;;
|
---|
157 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
158 | com=$Ffillraw
|
---|
159 | check=$check1
|
---|
160 | setstatus "stop" >> $scriptlog 2>&1
|
---|
161 | continue ;;
|
---|
162 | esac
|
---|
163 |
|
---|
164 | # running sinope
|
---|
165 | sinopepath=$datapath/sinope/$date
|
---|
166 | makedir $sinopepath >> $scriptlog 2>&1
|
---|
167 |
|
---|
168 | sins=( "-dat" "-cal")
|
---|
169 | echo ${sins[@]} >> $scriptlog 2>&1
|
---|
170 | for sin in ${sins[@]}
|
---|
171 | do
|
---|
172 | sinopefile=sinope$sin$no2
|
---|
173 | echo $sinopefile >> $scriptlog 2>&1
|
---|
174 |
|
---|
175 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
---|
176 | ./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
|
---|
177 | check2=$?
|
---|
178 |
|
---|
179 | case $check2 in
|
---|
180 | 0) echo "check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
181 | ;;
|
---|
182 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
183 | com=$Fsinope
|
---|
184 | # comadd=
|
---|
185 | check=$check2
|
---|
186 | setstatus "stop" >> $scriptlog 2>&1
|
---|
187 | continue 2;;
|
---|
188 | esac
|
---|
189 | check2=1
|
---|
190 | done
|
---|
191 |
|
---|
192 | # running fillsinope
|
---|
193 | fillsinopepath=$logpath/fillsinope/$date
|
---|
194 | makedir $fillsinopepath >> $scriptlog 2>&1
|
---|
195 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
---|
196 |
|
---|
197 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
---|
198 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
|
---|
199 |
|
---|
200 | case $check3 in
|
---|
201 | 1) echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
|
---|
202 | ;;
|
---|
203 | *) echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
204 | com=$Ffillsinope
|
---|
205 | check=$check3
|
---|
206 | setstatus "stop" >> $scriptlog 2>&1
|
---|
207 | continue;;
|
---|
208 | esac
|
---|
209 |
|
---|
210 | # resetting the status for exclusions
|
---|
211 | echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
|
---|
212 | resetlogpath=$logpath/resetexclusions/$date
|
---|
213 | echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
|
---|
214 | makedir $resetlogpath >> $scriptlog 2>&1
|
---|
215 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
---|
216 |
|
---|
217 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | grep int | sed -e 's/(int)//'`
|
---|
218 | case $check5 in
|
---|
219 | 1) echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
---|
220 | ;;
|
---|
221 | *) echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
---|
222 | com=$Fresetexcl
|
---|
223 | comadd=`echo $date2 | sed -e 's/-//g'`
|
---|
224 | check=$check5
|
---|
225 | setstatus "stop" >> $scriptlog 2>&1
|
---|
226 | continue;;
|
---|
227 | esac
|
---|
228 |
|
---|
229 | # set status
|
---|
230 | echo "inserting the status for the $program for run $run into the db" >> $scriptlog 2>&1
|
---|
231 | statustime="Now()"
|
---|
232 | failed="NULL"
|
---|
233 | starttime="NULL"
|
---|
234 | failedtime="NULL"
|
---|
235 | var1=$date
|
---|
236 | var2=$no2
|
---|
237 | setstatus "stop" >> $scriptlog 2>&1
|
---|
238 | done
|
---|
239 |
|
---|
240 | finish >> $scriptlog 2>&1
|
---|
241 |
|
---|