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

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