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

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