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

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