source: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck@ 7471

Last change on this file since 7471 was 7471, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 8.9 KB
Line 
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
42user=`whoami`
43program=datacheck
44source /home/$user/Mars/datacenter/scripts/sourcefile
45
46set -C
47
48cd $mars
49
50table=RunProcessStatus
51column=fDataCheckDone
52date=NULL
53datetime=`date +%F-%H-%M-%S`
54year=`date +%Y`
55
56todofile=$listpath/ToDo-$table-$column
57getstatuslogpath=$logpath/getstatus/$program/$year
58getstatuslog=$getstatuslogpath/getstatus-$program-$datetime.log
59
60scriptlogpath=$logpath/run/$program/`date +%Y/%m`
61makedir $scriptlogpath
62scriptlog=$scriptlogpath/$program-$datetime.log
63
64date >> $scriptlog 2>&1
65
66makedir $getstatuslogpath >> $scriptlog 2>&1
67
68# check if there are already todo files
69echo "checking if other todo-files are there" >> $scriptlog 2>&1
70if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
71then
72 echo "other file(s) on disk " >> $scriptlog 2>&1
73 echo " -> choose one file and start $program " >> $scriptlog 2>&1
74else
75 date > $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
76 checklock0=$?
77 case $checklock0 in
78 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
79 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
80 echo "-> getting list for $program is running -> exit" >> $scriptlog 2>&1
81 date >> $scriptlog 2>&1
82 exit;;
83 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
84 esac
85
86 echo "getting list..." >> $scriptlog 2>&1
87 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
88
89 case $check0 in
90 1) echo "check0=$check0 -> everything ok -> do $program" >> $scriptlog 2>&1;;
91 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
92 esac
93 rm -v $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
94fi
95
96
97# finding a todo file
98nr=bla
99echo "finding the right todo-file" >> $scriptlog 2>&1
100todofiles=`ls -r $listpath/ToDo-$table-$column-*`
101
102echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
103for todofile in ${todofiles[@]}
104do
105 if ! ls $todofile >> $scriptlog 2>&1
106 then
107 echo "file is not on disk -> continue" >> $scriptlog 2>&1
108 continue
109 fi
110 lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
111 date > $lockfile >> $scriptlog 2>&1
112 checklock=$?
113 case $checklock in
114 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
115 nr=${i}
116 break;;
117 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
118 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
119 esac
120done
121
122case $nr in
123 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
124 date >> $scriptlog 2>&1
125 exit;;
126 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
127esac
128
129
130# get run(s) from todo file
131runs=(`cat $todofile`)
132if [ "$runs" = "" ]
133then
134 echo "nothing to do -> exit" >> $scriptlog 2>&1
135 rm -v $todofile >> $scriptlog 2>&1
136 rm -v $lockfile >> $scriptlog 2>&1
137 date >> $scriptlog 2>&1
138 exit
139fi
140
141# processing run(s)
142echo "runs: "${runs[@]} >> $scriptlog 2>&1
143for run in ${runs[@]}
144do
145 echo "do $program for run "$run >> $scriptlog 2>&1
146 no=`printf %08d $run | cut -c 0-2`
147 no2=`printf %08d $run`
148 var1=$date
149 var2=$no2
150 rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw`
151 echo "rawfile: "$rawfile >> $scriptlog 2>&1
152 date=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw | cut -c 22-31`
153 echo "date: "$date >> $scriptlog 2>&1
154 # for sinope the date is needed in the format YYYY-MM-DD
155 date2=`echo $date | sed -e 's/\//-/g'`
156 echo "date2: "$date2 >> $scriptlog 2>&1
157
158 # running filldotraw
159 filldotrawpath=$logpath/filldotraw/$date
160 makedir $filldotrawpath >> $scriptlog 2>&1
161 filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
162
163 echo "doing filldotraw..." >> $scriptlog 2>&1
164 setstatus "start" >> $scriptlog 2>&1
165
166 check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
167
168 case $check1 in
169 1) echo "check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
170 ;;
171 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
172 com="filldotraw for run $run failed"
173 check=$check1
174 setstatus "stop" >> $scriptlog 2>&1
175 continue ;;
176 esac
177
178 # running sinope
179 sinopepath=$datapath/sinope/$date
180 makedir $sinopepath >> $scriptlog 2>&1
181
182 sins=( "-dat" "-cal")
183 echo ${sins[@]} >> $scriptlog 2>&1
184 for sin in ${sins[@]}
185 do
186 sinopefile=sinope$sin$no2
187 echo $sinopefile >> $scriptlog 2>&1
188
189 echo "running sinope $sin..." >> $scriptlog 2>&1
190 ./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
191 check2=$?
192
193 case $check2 in
194 0) echo "check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
195 ;;
196 *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
197 com="sinope for run $run failed"
198 check=$check2
199 setstatus "stop" >> $scriptlog 2>&1
200 continue 2;;
201 esac
202 check2=1
203 done
204
205 # running fillsinope
206 fillsinopepath=$logpath/fillsinope/$date
207 makedir $fillsinopepath >> $scriptlog 2>&1
208 fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
209
210 echo "doing fillsinope..." >> $scriptlog 2>&1
211 check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
212
213 case $check3 in
214 1) echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
215 ;;
216 *) echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
217 com="fillsinope for run $run failed"
218 check=$check3
219 setstatus "stop" >> $scriptlog 2>&1
220 continue;;
221 esac
222
223 # resetting the status for exclusions
224 echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
225 resetlogpath=$logpath/resetexclusions/$date
226 echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
227 makedir $resetlogpath >> $scriptlog 2>&1
228 resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
229 echo "setstatuslogfile: $setstatuslog" >> $scriptlog 2>&1
230
231 check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
232 case $check5 in
233 1) echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
234 ;;
235 *) echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
236 com="reset status for fExclusionsDone for date $date2 failed"
237 check=$check5
238 setstatus "stop" >> $scriptlog 2>&1
239 continue;;
240 esac
241
242 # set status
243 echo "inserting the status for the $program for run $run into the db" >> $scriptlog 2>&1
244 statustime="Now()"
245 failed="NULL"
246 starttime="NULL"
247 failedtime="NULL"
248 var1=$date
249 var2=$no2
250 setstatus
251done
252
253rm -v $todofile >> $scriptlog 2>&1
254rm -v $lockfile >> $scriptlog 2>&1
255
256set +C
257
258date >> $scriptlog 2>&1
259
Note: See TracBrowser for help on using the repository browser.