source: tags/Mars-V1.1/datacenter/scripts/dodatacheck

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