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

Last change on this file since 7265 was 7265, checked in by Daniela Dorner, 19 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-2004
23#
24#
25# ========================================================================
26#
27#
28
29user=`whoami`
30source /home/$user/Mars/datacenter/scripts/sourcefile
31
32set -C
33
34cd $mars
35
36table=RunProcessStatus
37column=fDataCheckDone
38date=NULL
39datetime=`date +%F-%H-%M-%S`
40year=`date +%Y`
41
42todofile=$listpath/ToDo-$table-$column.txt
43getstatuslogpath=$logpath/getstatus/dodatacheck/$year
44getstatuslog=$getstatuslogpath/getstatus-dodatacheck-$datetime.log
45
46scriptlogpath=$logpath/run/dodatacheck/`date +%Y/%m`
47makedir $scriptlogpath
48
49scriptlog=$scriptlogpath/dodatacheck-$datetime.log
50
51date >> $scriptlog 2>&1
52
53makedir $getstatuslogpath >> $scriptlog 2>&1
54
55lockfile=$lockpath/lock-dodatacheck.txt
56date > $lockfile >> $scriptlog 2>&1
57checklock0=$?
58case $checklock0 in
59 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
60 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
61 echo "-> for datacheck is running -> exit" >> $scriptlog 2>&1
62 date >> $scriptlog 2>&1
63 exit;;
64 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
65esac
66
67
68echo "getting list..." >> $scriptlog 2>&1
69check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
70
71case $check0 in
72 1) echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1
73 ;;
74 *) echo "check0=$check0 -> ERROR -> no todofile -> exit " >> $scriptlog 2>&1
75 rm -v $lockfile >> $scriptlog 2>&1
76 date >> $scriptlog 2>&1
77 exit
78 ;;
79esac
80
81runs=(`cat $todofile`)
82
83if [ "$runs" = "" ]
84then
85 echo "nothing to do -> exit" >> $scriptlog 2>&1
86 rm -v $todofile >> $scriptlog 2>&1
87 rm -v $lockfile >> $scriptlog 2>&1
88 date >> $scriptlog 2>&1
89 exit
90fi
91
92echo "runs: "${runs[@]} >> $scriptlog 2>&1
93
94for run in ${runs[@]}
95do
96 date
97 echo "do datacheck for run "$run >> $scriptlog 2>&1
98 no=`printf %08d $run | cut -c 0-2`
99 no2=`printf %08d $run`
100 rawfile=`find /magic/data/rawfiles/ -name *${run}*.raw`
101 echo "rawfile: "$rawfile >> $scriptlog 2>&1
102 date=`find /magic/data/rawfiles/ -name *$run*.raw | cut -c 22-31`
103 echo "date: "$date >> $scriptlog 2>&1
104 date2=`echo $date | sed -e 's/\//-/g'`
105 echo "date2: "$date2 >> $scriptlog 2>&1
106
107 filldotrawpath=$logpath/filldotraw/$date
108 makedir $filldotrawpath >> $scriptlog 2>&1
109 filldotrawlogfile=$filldotrawpath/filldotraw-$no2.log
110
111 echo "doing filldotraw..." >> $scriptlog 2>&1
112 check1=`root -q -b $macrospath/filldotraw.C+\($run\,kFALSE\) | tee $filldotrawlogfile | grep int | sed -e 's/.*(int)//'`
113
114 case $check1 in
115 1) echo "check1=$check1 -> everything ok -> go on with datacheck..." >> $scriptlog 2>&1
116 ;;
117 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
118 continue;;
119 esac
120
121 sinopepath=$datapath/sinope/$date
122 makedir $sinopepath >> $scriptlog 2>&1
123
124 sins=( "-dat" "-cal")
125 echo ${sins[@]} >> $scriptlog 2>&1
126 for sin in ${sins[@]}
127 do
128 sinopefile=sinope$sin$no2
129 echo $sinopefile >> $scriptlog 2>&1
130
131 echo "running sinope $sin..." >> $scriptlog 2>&1
132 ./sinope -b -q -v4 -f $sin --outf=$sinopefile --log=$sinopefile.log --html=$sinopefile.html --out=$sinopepath --run=$run --date=$date2 2>> $scriptlog > /dev/null
133 check2=$?
134
135 case $check2 in
136 0) echo "check2=$check2 -> everything ok -> go on with datacheck..." >> $scriptlog 2>&1
137 ;;
138 *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
139 continue 2;;
140 esac
141 done
142
143 fillsinopepath=$logpath/fillsinope/$date
144 makedir $fillsinopepath >> $scriptlog 2>&1
145 fillsinopelogfile=$fillsinopepath/fillsinope-$no2.log
146
147 echo "doing filldotraw..." >> $scriptlog 2>&1
148 check3=`root -q -b $macrospath/fillsinope.C+\($run\,"\"$datapath\""\,kFALSE\) | tee $fillsinopelogfile | grep int | sed -e 's/.*(int)//'`
149
150 case $check3 in
151 1) echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
152 ;;
153 *) echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
154 continue;;
155 esac
156
157 echo "inserting the status for the datacheck for run $run into the db" >> $scriptlog 2>&1
158 setstatuslogpath=$logpath/setstatus/datacheck/$date
159 echo "setstatuslogpath: $setstatuslogpath" >> $scriptlog 2>&1
160 makedir $setstatuslogpath >> $scriptlog 2>&1
161 setstatuslog=$setstatuslogpath/setstatus-datacheck-$no2.log
162 echo "setstatuslogfile: $setstatuslog" >> $scriptlog 2>&1
163
164 check4=`root -q -b $macrospath/setstatus.C+\("\"$run\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
165 case $check4 in
166 1) echo "check4=$check4 -> everything ok, status has been set" >> $scriptlog 2>&1
167 ;;
168 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1
169 continue;;
170 esac
171
172 echo "resetting the status for fExclusions done for date $date2" >> $scriptlog 2>&1
173 resetlogpath=$logpath/resetexclusions/$date
174 echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
175 makedir $resetlogpath >> $scriptlog 2>&1
176 resetlog=$resetlogpath/reset-exclusions-$no2-$date2.log
177 echo "setstatuslogfile: $setstatuslog" >> $scriptlog 2>&1
178
179 check5=`root -q -b $macrospath/resetcolumn.C+\("\"fExclusionsDone\""\,"\"SequenceBuildStatus\""\,"\"$date2\""\,"\"$date2\""\,kFALSE\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
180 case $check5 in
181 1) echo "check5=$check5 -> everything ok, fExclusions have been reset " >> $scriptlog 2>&1
182 ;;
183 *) echo "check5=$check5 -> ERROR -> step could not be resetted -> repeat step " >> $scriptlog 2>&1
184 ;;
185 esac
186done
187
188rm -v $todofile >> $scriptlog 2>&1
189rm -v $lockfile >> $scriptlog 2>&1
190
191set +C
192
193date >> $scriptlog 2>&1
194
Note: See TracBrowser for help on using the repository browser.