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). "
|
---|
44 | echo "Please adapt it before using it."
|
---|
45 | exit
|
---|
46 |
|
---|
47 | program=datacheck
|
---|
48 | column=fDataCheckDone
|
---|
49 |
|
---|
50 | set -C
|
---|
51 |
|
---|
52 | scriptlog=$runlogpath/$program-$datetime.log
|
---|
53 | date >> $scriptlog 2>&1
|
---|
54 |
|
---|
55 | # get run #
|
---|
56 | gettodo >> $scriptlog 2>&1
|
---|
57 | run=$process
|
---|
58 |
|
---|
59 | # lock sequ
|
---|
60 | lockfile=$lockpath/lock-$table-$column-$run.txt
|
---|
61 | checklock >> $scriptlog 2>&1
|
---|
62 |
|
---|
63 | cd $mars
|
---|
64 |
|
---|
65 | echo "do $program for run "$run >> $scriptlog 2>&1
|
---|
66 | printprocesslog "INFO do $program for run $run"
|
---|
67 | no=`printf %08d $run | cut -c 0-2`
|
---|
68 | no2=`printf %08d $run`
|
---|
69 | query="SELECT DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%Y/%m/%d') FROM RunData where fRunNumber="$run
|
---|
70 | date=`sendquery`
|
---|
71 | rawfile=`find /magic/data/rawfiles/$date -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[DPCS]_*_E.raw.gz`
|
---|
72 | echo "rawfile: "$rawfile >> $scriptlog 2>&1
|
---|
73 | # for sinope the date is needed in the format YYYY-MM-DD
|
---|
74 | date2=`echo $date | sed -e 's/\//-/g'`
|
---|
75 |
|
---|
76 | primvar=$no2
|
---|
77 | setstatus "start" >> $scriptlog 2>&1
|
---|
78 |
|
---|
79 | # running filldotraw
|
---|
80 | echo "doing filldotraw..." >> $scriptlog 2>&1
|
---|
81 | filldotrawpath=$logpath/filldotraw/$date
|
---|
82 | makedir $filldotrawpath >> $scriptlog 2>&1
|
---|
83 | filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
|
---|
84 |
|
---|
85 | check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | intgrep`
|
---|
86 |
|
---|
87 | case $check1 in
|
---|
88 | 1) echo " check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
89 | printprocesslog "INFO finished filldotraw.C sucessfully for $rawfile"
|
---|
90 | ;;
|
---|
91 | 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
92 | printprocesslog "WARN connection to DB failed"
|
---|
93 | check="no"
|
---|
94 | setstatus "stop" >> $scriptlog 2>&1
|
---|
95 | continue ;;
|
---|
96 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
97 | printprocesslog "ERROR filldotraw.C failed for $rawfile"
|
---|
98 | com=$Ffillraw
|
---|
99 | check=$check1
|
---|
100 | setstatus "stop" >> $scriptlog 2>&1
|
---|
101 | continue ;;
|
---|
102 | esac
|
---|
103 |
|
---|
104 | # running sinope
|
---|
105 | printprocesslog "INFO running sinope for $run"
|
---|
106 | sinopepath=$datapath/sinope/$date
|
---|
107 | makedir $sinopepath >> $scriptlog 2>&1
|
---|
108 |
|
---|
109 | sins=( "-dat" "-cal")
|
---|
110 | for sin in ${sins[@]}
|
---|
111 | do
|
---|
112 | sinopefile=sinope$sin$no2
|
---|
113 |
|
---|
114 | echo "running sinope $sin..." >> $scriptlog 2>&1
|
---|
115 | ./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
|
---|
116 | check2=$?
|
---|
117 |
|
---|
118 | case $check2 in
|
---|
119 | 0) echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
|
---|
120 | ;;
|
---|
121 | *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
122 | printprocesslog "ERROR sinope $sin failed for $rawfile"
|
---|
123 | com=$Fsinope
|
---|
124 | # comadd=
|
---|
125 | check=$check2
|
---|
126 | setstatus "stop" >> $scriptlog 2>&1
|
---|
127 | continue 2;;
|
---|
128 | esac
|
---|
129 | check2=1
|
---|
130 | done
|
---|
131 |
|
---|
132 | # running fillsinope
|
---|
133 | fillsinopepath=$logpath/fillsinope/$date
|
---|
134 | makedir $fillsinopepath >> $scriptlog 2>&1
|
---|
135 | fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
|
---|
136 |
|
---|
137 | echo "doing fillsinope..." >> $scriptlog 2>&1
|
---|
138 | check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | intgrep`
|
---|
139 |
|
---|
140 | case $check3 in
|
---|
141 | 1) echo " check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
|
---|
142 | printprocesslog "INFO finished fillsinope.C sucessfully for run $run"
|
---|
143 | ;;
|
---|
144 | 0) echo " check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
145 | printprocesslog "WARN connection to DB failed"
|
---|
146 | check="no"
|
---|
147 | setstatus "stop" >> $scriptlog 2>&1
|
---|
148 | continue ;;
|
---|
149 | *) echo " check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
150 | printprocesslog "ERROR fillsinope.C failed for run $run"
|
---|
151 | com=$Ffillsinope
|
---|
152 | check=$check3
|
---|
153 | setstatus "stop" >> $scriptlog 2>&1
|
---|
154 | continue ;;
|
---|
155 | esac
|
---|
156 |
|
---|
157 | # resetting the status for exclusions
|
---|
158 | echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
|
---|
159 | printprocesslog "INFO resetting fExclusions done for $date2"
|
---|
160 | resetlogpath=$logpath/resetexclusions/$date
|
---|
161 | makedir $resetlogpath >> $scriptlog 2>&1
|
---|
162 | resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
|
---|
163 |
|
---|
164 | check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | intgrep`
|
---|
165 | case $check5 in
|
---|
166 | 1) echo " check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
|
---|
167 | printprocesslog "INFO resetted fExclusions done for $date2 successfully"
|
---|
168 | ;;
|
---|
169 | 0) echo " check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1
|
---|
170 | printprocesslog "WARN connection to DB failed"
|
---|
171 | check="no"
|
---|
172 | setstatus "stop" >> $scriptlog 2>&1
|
---|
173 | continue ;;
|
---|
174 | *) echo " check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
|
---|
175 | printprocesslog "ERROR resetcolumn.C failed for date $date2"
|
---|
176 | com=$Fresetexcl
|
---|
177 | comadd=`echo $date2 | sed -e 's/-//g'`
|
---|
178 | check=$check5
|
---|
179 | setstatus "stop" >> $scriptlog 2>&1
|
---|
180 | continue ;;
|
---|
181 | esac
|
---|
182 |
|
---|
183 | # set status
|
---|
184 | statustime="Now()"
|
---|
185 | failed="NULL"
|
---|
186 | starttime="NULL"
|
---|
187 | failedtime="NULL"
|
---|
188 | setstatus "stop" >> $scriptlog 2>&1
|
---|
189 |
|
---|
190 | finish >> $scriptlog 2>&1
|
---|
191 |
|
---|