source: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto@ 7284

Last change on this file since 7284 was 7284, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 9.4 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
34callistorcnew=$setuppath/callisto/callisto.rc
35callistorcmarapr05=$setuppath/callisto/callisto_MarApr05.rc
36
37table=SequenceProcessStatus
38column=fCallisto
39date=NULL
40datetime=`date +%F-%H-%M-%S`
41year=`date +%Y`
42#pno=500 # number of processes, i.e. number of todo-files
43
44todofile=$listpath/ToDo-$table-$column
45getstatuslogpath=$logpath/getstatus/callisto/$year
46getstatuslog=$getstatuslogpath/getstatus-callisto-$datetime.log
47
48scriptlogpath=$logpath/run/callisto/`date +%Y/%m/%d`
49makedir $scriptlogpath
50scriptlog=$scriptlogpath/runcallisto-$datetime.log
51
52date >> $scriptlog 2>&1
53
54makedir $getstatuslogpath >> $scriptlog 2>&1
55
56cd $mars
57
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 calibrating" >> $scriptlog 2>&1
63else
64 date > $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
65 checklock0=$?
66 case $checklock0 in
67 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
68 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
69 echo "-> getting list for callisto is running -> exit" >> $scriptlog 2>&1
70 date >> $scriptlog 2>&1
71 exit;;
72 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
73 esac
74
75 if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
76 then
77 echo "other file(s) on disk " >> $scriptlog 2>&1
78 echo " -> choose one file and start calibrating" >> $scriptlog 2>&1
79 else
80 echo "getting list..." >> $scriptlog 2>&1
81 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
82
83 case $check0 in
84 1) echo "check0=$check0 -> everything ok -> run callisto" >> $scriptlog 2>&1;;
85 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
86 esac
87 fi
88 rm -v $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
89fi
90
91
92nr=bla
93echo "finding the right todo-file" >> $scriptlog 2>&1
94todofiles=`ls -r $listpath/ToDo-$table-$column-*`
95
96echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
97
98for todofile in ${todofiles[@]}
99do
100 if ! ls $todofile >> $scriptlog 2>&1
101 then
102 echo "file is not on disk -> continue" >> $scriptlog 2>&1
103 continue
104 fi
105 lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
106 date > $lockfile >> $scriptlog 2>&1
107 checklock=$?
108 case $checklock in
109 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
110 nr=${i}
111 break;;
112 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
113 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
114 esac
115done
116
117case $nr in
118 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
119 date >> $scriptlog 2>&1
120 exit;;
121 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
122esac
123
124sequences=(`cat $todofile`)
125
126if [ "$sequences" = "" ]
127then
128 echo "nothing to do -> exit" >> $scriptlog 2>&1
129 rm -v $todofile >> $scriptlog 2>&1
130 rm -v $lockfile >> $scriptlog 2>&1
131 date >> $scriptlog 2>&1
132 exit
133fi
134
135echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
136
137for sequence in ${sequences[@]}
138do
139 no=`printf %08d $sequence | cut -c 0-4`
140 no2=`printf %08d $sequence`
141 outpath="$datapath/callisto/$no/$no2"
142 echo "outpath: "$outpath >> $scriptlog 2>&1
143 makedir $outpath >> $scriptlog 2>&1
144
145 sequfile="$sequpath/$no/sequence$no2.txt"
146 echo "sequfile: "$sequfile >> $scriptlog 2>&1
147
148 if [ -e $outpath/callisto.rc ]
149 then
150 echo "found callisto.rc in $outpath -> using this " >> $scriptlog 2>&1
151 callistorcseq=$outpath/callisto.rc
152 else
153 echo "no callisto.rc found in $outpath -> making link " >> $scriptlog 2>&1
154 if [ 49735 -lt $sequence ] && [ $sequence -lt 53516 ]
155 then
156 ln -vs $callistorcmarapr05 $outpath/callisto.rc >> $scriptlog 2>&1
157 else
158 ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
159 fi
160 callistorcseq=$outpath/callisto.rc
161 fi
162
163 echo "run callisto..." >> $scriptlog 2>&1
164 ./callisto -b -q -v4 -f -raw --log=$outpath/callisto$no2.log --html=$outpath/callisto$no2.html --out=$outpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
165 check1=$?
166
167 case $check1 in
168 0) echo "check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
169 echo "finding files to be updated" >> $scriptlog 2>&1
170 calfiles=`find $outpath -name *_Y_* `
171 echo "files to be updated: "$calfiles >> $scriptlog 2>&1
172 if [ "$calfiles" = "" ]
173 then
174 echo "no files found -> continue with next sequence" >> $scriptlog 2>&1
175 continue
176 fi
177
178 merpplogpath=$outpath"/merpplogs"
179 makedir $merpplogpath >> $scriptlog 2>&1
180
181 for calfile in ${calfiles[@]}
182 do
183 echo "calfile: "$calfile >> $scriptlog 2>&1
184 runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
185 ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
186 cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
187 echo "runno: "$runno >> $scriptlog 2>&1
188 echo "ccfile: "$ccfile >> $scriptlog 2>&1
189 if [ "$ccfile" = "" ]
190 then
191 echo "no ccfile found for run "$runno >> $scriptlog 2>&1
192 break
193 fi
194 echo "cacofile: "$cacofile >> $scriptlog 2>&1
195 if [ "$cacofile" = "" ]
196 then
197 echo "no cacofile found for run "$runno >> $scriptlog 2>&1
198 echo "finding cacofile..." >> $scriptlog 2>&1
199 for (( i = 0; i <= 10; i++ ))
200 do
201 newrun=`echo $runno - $i | bc`
202 # echo "$missingcacorun + $i = $newrun"
203 path=`dirname $ccfile`
204 path=`echo $path | sed -e 's/cc/caco/'`
205 echo "path: "$path >> $scriptlog 2>&1
206 cacofile=`find $path -name *$newrun*`
207 if [ "$cacofile" = "" ]
208 then
209 continue
210 else
211 break
212 echo "cacofile: "$cacofile >> $scriptlog 2>&1
213 fi
214 done
215 fi
216 ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --html=$merpplogpath/merppccupdate$runno.html --auto-time-stop --runfile=$runno $ccfile $calfile 2>> $scriptlog> /dev/null
217 check2=$?
218 case $check2 in
219 0) echo "check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1;;
220 *) echo "check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
221 continue 2 ;;
222 esac
223 ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null
224 check3=$?
225 case $check3 in
226 0) echo "check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1;;
227 *) echo "check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
228 continue 2 ;;
229 esac
230 done
231
232 echo "inserting the status for callisto for sequence $sequence into the db" >> $scriptlog 2>&1
233 setstatuslogpath=$logpath/setstatus/callisto/$no
234 makedir $setstatuslogpath >> $scriptlog 2>&1
235 setstatuslog=$setstatuslogpath/setstatus-callisto-$no2.log
236
237 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
238 case $check4 in
239 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1;;
240 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
241 esac
242 ;;
243 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
244 esac
245done
246
247rm -v $todofile >> $scriptlog 2>&1
248rm -v $lockfile >> $scriptlog 2>&1
249
250set +C
251
252date >> $scriptlog 2>&1
253
Note: See TracBrowser for help on using the repository browser.