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

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