source: trunk/Mars/datacenter/scripts/dodatacheck@ 11169

Last change on this file since 11169 was 9355, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.8 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-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
41source `dirname $0`/sourcefile
42printprocesslog "INFO starting $0"
43echo "This script has not been adapted to the new file structure (MAGIC II) and new logging. "
44echo "Only the usage of getodo has been adapted, but not tested."
45echo "Please adapt it before using it."
46exit
47
48program=datacheck
49column=fDataCheckDone
50
51set -C
52
53scriptlog=$runlogpath/$program-$datetime.log
54date >> $scriptlog 2>&1
55
56# get run #
57gettodo "1" >> $scriptlog 2>&1
58run=${primaries[0]}
59telnum=${primaries[1]}
60filenum=${primaries[2]}
61
62# lock sequ
63lockfile=$lockpath/lock-$table-$column-$run.txt
64checklock >> $scriptlog 2>&1
65
66cd $mars
67
68echo "do $program for run "$run >> $scriptlog 2>&1
69printprocesslog "INFO do $program for run $run"
70no=`printf %08d $run | cut -c 0-2`
71no2=`printf %08d $run`
72query="SELECT DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%Y/%m/%d') FROM RunData where fRunNumber="$run
73date=`sendquery`
74rawfile=`find /magic/data/rawfiles/$date -name *${run}_[D,P,C,S,N]_*.raw -o -name *${run}_[DPCSN]_*.raw.gz`
75echo "rawfile: "$rawfile >> $scriptlog 2>&1
76# for sinope the date is needed in the format YYYY-MM-DD
77date2=`echo $date | sed -e 's/\//-/g'`
78
79#primvar=$no2
80setstatus "start" >> $scriptlog 2>&1
81
82# running filldotraw
83echo "doing filldotraw..." >> $scriptlog 2>&1
84filldotrawpath=$logpath/filldotraw/$date
85makedir $filldotrawpath >> $scriptlog 2>&1
86filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
87
88check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | intgrep`
89
90case $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 ;;
105esac
106
107# running sinope
108printprocesslog "INFO running sinope for $run"
109sinopepath=$datapath/sinope/$date
110makedir $sinopepath >> $scriptlog 2>&1
111
112sins=( "-dat" "-cal")
113for sin in ${sins[@]}
114do
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
133done
134
135# running fillsinope
136fillsinopepath=$logpath/fillsinope/$date
137makedir $fillsinopepath >> $scriptlog 2>&1
138fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
139
140echo "doing fillsinope..." >> $scriptlog 2>&1
141check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | intgrep`
142
143case $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 ;;
158esac
159
160# resetting the status for exclusions
161echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
162printprocesslog "INFO resetting fExclusions done for $date2"
163resetlogpath=$logpath/resetexclusions/$date
164makedir $resetlogpath >> $scriptlog 2>&1
165resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
166
167check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | intgrep`
168case $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 ;;
184esac
185
186# set status
187statustime="Now()"
188failed="NULL"
189starttime="NULL"
190failedtime="NULL"
191setstatus "stop" >> $scriptlog 2>&1
192
193finish >> $scriptlog 2>&1
194
Note: See TracBrowser for help on using the repository browser.