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

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