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

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