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

Last change on this file since 7915 was 7915, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 7.1 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
87echo "runs: "${runs[@]} >> $scriptlog 2>&1
88rm -v $todofile >> $scriptlog 2>&
89
90cd $mars
91
92# processing run(s)
93for run in ${runs[@]}
94do
95 echo "do $program for run "$run >> $scriptlog 2>&1
96 no=`printf %08d $run | cut -c 0-2`
97 no2=`printf %08d $run`
98 var1=$date
99 var2=$no2
100 rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[D,P,C,S]_*_E.raw.gz`
101 echo "rawfile: "$rawfile >> $scriptlog 2>&1
102 date=`echo $rawfile | cut -c 22-31`
103 # for sinope the date is needed in the format YYYY-MM-DD
104 date2=`echo $date | sed -e 's/\//-/g'`
105
106 setstatus "start" >> $scriptlog 2>&1
107
108 # running filldotraw
109 echo "doing filldotraw..." >> $scriptlog 2>&1
110 filldotrawpath=$logpath/filldotraw/$date
111 makedir $filldotrawpath >> $scriptlog 2>&1
112 filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
113
114 check1=`root -q -b $macrospath/filldotraw.C+\("\"$rawfile\""\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
115
116 case $check1 in
117 1) echo " check1=$check1 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
118 ;;
119 0) echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1
120 check="no"
121 setstatus "stop" >> $scriptlog 2>&1
122 continue ;;
123 *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
124 com=$Ffillraw
125 check=$check1
126 setstatus "stop" >> $scriptlog 2>&1
127 continue ;;
128 esac
129
130 # running sinope
131 sinopepath=$datapath/sinope/$date
132 makedir $sinopepath >> $scriptlog 2>&1
133
134 sins=( "-dat" "-cal")
135 for sin in ${sins[@]}
136 do
137 sinopefile=sinope$sin$no2
138
139 echo "running sinope $sin..." >> $scriptlog 2>&1
140 ./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
141 check2=$?
142
143 case $check2 in
144 0) echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
145 ;;
146 *) echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
147 com=$Fsinope
148# comadd=
149 check=$check2
150 setstatus "stop" >> $scriptlog 2>&1
151 continue 2;;
152 esac
153 check2=1
154 done
155
156 # running fillsinope
157 fillsinopepath=$logpath/fillsinope/$date
158 makedir $fillsinopepath >> $scriptlog 2>&1
159 fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
160
161 echo "doing fillsinope..." >> $scriptlog 2>&1
162 check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
163
164 case $check3 in
165 1) echo " check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
166 ;;
167 0) echo " check3=$check3 -> no connection to db -> continue..." >> $scriptlog 2>&1
168 check="no"
169 setstatus "stop" >> $scriptlog 2>&1
170 continue ;;
171 *) echo " check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
172 com=$Ffillsinope
173 check=$check3
174 setstatus "stop" >> $scriptlog 2>&1
175 continue ;;
176 esac
177
178 # resetting the status for exclusions
179 echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
180 resetlogpath=$logpath/resetexclusions/$date
181 makedir $resetlogpath >> $scriptlog 2>&1
182 resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
183
184 check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $resetlog | grep int | sed -e 's/(int)//'`
185 case $check5 in
186 1) echo " check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
187 ;;
188 0) echo " check5=$check5 -> no connection to db -> continue..." >> $scriptlog 2>&1
189 check="no"
190 setstatus "stop" >> $scriptlog 2>&1
191 continue ;;
192 *) echo " check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
193 com=$Fresetexcl
194 comadd=`echo $date2 | sed -e 's/-//g'`
195 check=$check5
196 setstatus "stop" >> $scriptlog 2>&1
197 continue ;;
198 esac
199
200 # set status
201 statustime="Now()"
202 failed="NULL"
203 starttime="NULL"
204 failedtime="NULL"
205 var1=$date
206 var2=$no2
207 setstatus "stop" >> $scriptlog 2>&1
208done
209
210finish >> $scriptlog 2>&1
211
Note: See TracBrowser for help on using the repository browser.