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-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script launches the datacheck for all runs, which are not yet
|
---|
28 | # checked
|
---|
29 | #
|
---|
30 | # Get todo file
|
---|
31 | # Then for each run the following steps are done:
|
---|
32 | # - filldotraw.C
|
---|
33 | # - sinope (once for data and once for calibration events)
|
---|
34 | # - fillsinope
|
---|
35 | # - reset ExclusionsDone, so that the result from the datacheck can be
|
---|
36 | # taken into account when doexclusions is running the next time
|
---|
37 | # If this was successful, the status is inserted into the database using
|
---|
38 | # the function setstatus.
|
---|
39 | #
|
---|
40 |
|
---|
41 | source `dirname $0`/sourcefile
|
---|
42 | printprocesslog "INFO starting $0"
|
---|
43 | echo "This script has not been adapted to the new file structure (MAGIC II) and new logging. "
|
---|
44 | echo "Only the usage of getodo has been adapted, but not tested."
|
---|
45 | echo "Please adapt it before using it."
|
---|
46 | exit
|
---|
47 |
|
---|
48 | program=datacheck
|
---|
49 | column=fDataCheckDone
|
---|
50 |
|
---|
51 | set -C
|
---|
52 |
|
---|
53 | scriptlog=$runlogpath/$program-$datetime.log
|
---|
54 | date >> $scriptlog 2>&1
|
---|
55 |
|
---|
56 | # get run #
|
---|
57 | gettodo "1" >> $scriptlog 2>&1
|
---|
58 | run=${primaries[0]}
|
---|
59 | telnum=${primaries[1]}
|
---|
60 | filenum=${primaries[2]}
|
---|
61 |
|
---|
62 | # lock sequ
|
---|
63 | lockfile=$lockpath/lock-$table-$column-$run.txt
|
---|
64 | checklock >> $scriptlog 2>&1
|
---|
65 |
|
---|
66 | cd $mars
|
---|
67 |
|
---|
68 | echo "do $program for run "$run >> $scriptlog 2>&1
|
---|
69 | printprocesslog "INFO do $program for run $run"
|
---|
70 | no=`printf %08d $run | cut -c 0-2`
|
---|
71 | no2=`printf %08d $run`
|
---|
72 | query="SELECT DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%Y/%m/%d') FROM RunData where fRunNumber="$run
|
---|
73 | date=`sendquery`
|
---|
74 | rawfile=`find /magic/data/rawfiles/$date -name *${run}_[D,P,C,S,N]_*.raw -o -name *${run}_[DPCSN]_*.raw.gz`
|
---|
75 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
---|
76 | # for sinope the date is needed in the format YYYY-MM-DD
|
---|
77 | date2=`echo $date | sed -e 's/\//-/g'`
|
---|
78 |
|
---|
79 | #primvar=$no2
|
---|
80 | setstatus "start" >> $scriptlog 2>&1
|
---|
81 |
|
---|
82 | # running filldotraw
|
---|
83 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
---|
84 | filldotrawpath=$logpath/filldotraw/$date
|
---|
85 | makedir $filldotrawpath >> $scriptlog 2>&1
|
---|
86 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
---|
87 |
|
---|
88 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | intgrep`
|
---|
89 |
|
---|
90 | case $check1 in
|
---|
91 | 1) echo " check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
92 | printprocesslog "INFO finished filldotraw.C sucessfully for $rawfile"
|
---|
93 | ;;
|
---|
94 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
95 | printprocesslog "WARN connection to DB failed"
|
---|
96 | check="no"
|
---|
97 | setstatus "stop" >> $scriptlog 2>&1
|
---|
98 | continue ;;
|
---|
99 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
100 | printprocesslog "ERROR filldotraw.C failed for $rawfile"
|
---|
101 | com=$Ffillraw
|
---|
102 | check=$check1
|
---|
103 | setstatus "stop" >> $scriptlog 2>&1
|
---|
104 | continue ;;
|
---|
105 | esac
|
---|
106 |
|
---|
107 | # running sinope
|
---|
108 | printprocesslog "INFO running sinope for $run"
|
---|
109 | sinopepath=$datapath/sinope/$date
|
---|
110 | makedir $sinopepath >> $scriptlog 2>&1
|
---|
111 |
|
---|
112 | sins=( "-dat" "-cal")
|
---|
113 | for sin in ${sins[@]}
|
---|
114 | do
|
---|
115 | sinopefile=sinope$sin$no2
|
---|
116 |
|
---|
117 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
---|
118 | ./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
|
---|
119 | check2=$?
|
---|
120 |
|
---|
121 | case $check2 in
|
---|
122 | 0) echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
123 | ;;
|
---|
124 | *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
125 | printprocesslog "ERROR sinope $sin failed for $rawfile"
|
---|
126 | com=$Fsinope
|
---|
127 | # comadd=
|
---|
128 | check=$check2
|
---|
129 | setstatus "stop" >> $scriptlog 2>&1
|
---|
130 | continue 2;;
|
---|
131 | esac
|
---|
132 | check2=1
|
---|
133 | done
|
---|
134 |
|
---|
135 | # running fillsinope
|
---|
136 | fillsinopepath=$logpath/fillsinope/$date
|
---|
137 | makedir $fillsinopepath >> $scriptlog 2>&1
|
---|
138 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
---|
139 |
|
---|
140 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
---|
141 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | intgrep`
|
---|
142 |
|
---|
143 | case $check3 in
|
---|
144 | 1) echo " check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
|
---|
145 | printprocesslog "INFO finished fillsinope.C sucessfully for run $run"
|
---|
146 | ;;
|
---|
147 | 0) echo " check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
148 | printprocesslog "WARN connection to DB failed"
|
---|
149 | check="no"
|
---|
150 | setstatus "stop" >> $scriptlog 2>&1
|
---|
151 | continue ;;
|
---|
152 | *) echo " check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
153 | printprocesslog "ERROR fillsinope.C failed for run $run"
|
---|
154 | com=$Ffillsinope
|
---|
155 | check=$check3
|
---|
156 | setstatus "stop" >> $scriptlog 2>&1
|
---|
157 | continue ;;
|
---|
158 | esac
|
---|
159 |
|
---|
160 | # resetting the status for exclusions
|
---|
161 | echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
|
---|
162 | printprocesslog "INFO resetting fExclusions done for $date2"
|
---|
163 | resetlogpath=$logpath/resetexclusions/$date
|
---|
164 | makedir $resetlogpath >> $scriptlog 2>&1
|
---|
165 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
---|
166 |
|
---|
167 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | intgrep`
|
---|
168 | case $check5 in
|
---|
169 | 1) echo " check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
---|
170 | printprocesslog "INFO resetted fExclusions done for $date2 successfully"
|
---|
171 | ;;
|
---|
172 | 0) echo " check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
173 | printprocesslog "WARN connection to DB failed"
|
---|
174 | check="no"
|
---|
175 | setstatus "stop" >> $scriptlog 2>&1
|
---|
176 | continue ;;
|
---|
177 | *) echo " check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
---|
178 | printprocesslog "ERROR resetcolumn.C failed for date $date2"
|
---|
179 | com=$Fresetexcl
|
---|
180 | comadd=`echo $date2 | sed -e 's/-//g'`
|
---|
181 | check=$check5
|
---|
182 | setstatus "stop" >> $scriptlog 2>&1
|
---|
183 | continue ;;
|
---|
184 | esac
|
---|
185 |
|
---|
186 | # set status
|
---|
187 | statustime="Now()"
|
---|
188 | failed="NULL"
|
---|
189 | starttime="NULL"
|
---|
190 | failedtime="NULL"
|
---|
191 | setstatus "stop" >> $scriptlog 2>&1
|
---|
192 |
|
---|
193 | finish >> $scriptlog 2>&1
|
---|
194 |
|
---|