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

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