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): Stefan Ruegamer 12/2007 <mailto:snruegam@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2008
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script is removing the switching noise out of raw files.
|
---|
28 | # Corresponding information will be inserted into the database. The noise
|
---|
29 | # removal is being done by the script 'compmux'.
|
---|
30 | #
|
---|
31 |
|
---|
32 | source `dirname $0`/sourcefile
|
---|
33 | printprocesslog "INFO starting $0"
|
---|
34 | program=compmux
|
---|
35 | column=fCompmux
|
---|
36 |
|
---|
37 | set -C
|
---|
38 |
|
---|
39 | scriptlog=$runlogpath/run$program-$datetime.log
|
---|
40 | date >> $scriptlog 2>&1
|
---|
41 |
|
---|
42 | # query db 20 times for jobs
|
---|
43 | for ((j=0 ; j < 20 ; j++))
|
---|
44 | do
|
---|
45 | gettodo "1" >> $scriptlog 2>&1
|
---|
46 | runno=${primaries[0]}
|
---|
47 | tempfile=/data/tmp/temp${runno}.gz
|
---|
48 |
|
---|
49 | lockfile=$lockpath/lock-$table-$column-$runno.txt
|
---|
50 | checklock >> $scriptlog 2>&1
|
---|
51 |
|
---|
52 | setstatus "start" >> $scriptlog 2>&1
|
---|
53 |
|
---|
54 | # try to find the file; if impossible, continue with an error
|
---|
55 | echo "getting path for run $runno..." >> $scriptlog 2>&1
|
---|
56 | printprocesslog "INFO starting $program for run $runno"
|
---|
57 | fullname=`find $datapath/rawfiles/2007/0[2-9] -name 20070*${runno}_[DCPS]_*.raw.gz`
|
---|
58 | arraycheck=`echo $fullname | wc -w`
|
---|
59 | if [ "$fullname" == "" ] || ! [ $arraycheck == 1 ]
|
---|
60 | then
|
---|
61 | echo "ERROR file for run $runno not found or more than one file found... continue" >> $scriptlog 2>&1
|
---|
62 | printprocesslog "ERROR $program failed, file for run $runno not found or more than one file found"
|
---|
63 | rm -v $lockpath/lock-$table-$column-$runno.txt >> $scriptlog 2>&1
|
---|
64 | check=20
|
---|
65 | com=$FCompmux
|
---|
66 | setstatus "stop" >> $scriptlog 2>&1
|
---|
67 | echo "" >> $scriptlog 2>&1
|
---|
68 | continue
|
---|
69 | fi
|
---|
70 |
|
---|
71 | # cut the slices
|
---|
72 | check1=`ssh -nx phoenix 'cd /home/operator/compmux ; nice -n 19 gzip -cd' $fullname '| nice -n 19 ./compmux | nice -n 19 gzip -1c > /data/tmp/temp'${runno}.gz ' ; echo ${PIPESTATUS[1]}'`
|
---|
73 |
|
---|
74 | # check success and insert information into the database
|
---|
75 | case $check1 in
|
---|
76 | 0) echo " check1=$check1 -> everything ok -> compmux succeeded, overwriting old file for run $runno" >> $scriptlog 2>&1
|
---|
77 | ssh -nx phoenix nice -n 19 touch -r $fullname $tempfile
|
---|
78 | ssh -nx phoenix nice -n 19 mv -f $tempfile $fullname >> $scriptlog 2>&1
|
---|
79 | check2=$?
|
---|
80 | case $check2 in
|
---|
81 | 0) echo " check2=$check2 -> everything ok -> mv done, setting db status for run $runno" >> $scriptlog 2>&1
|
---|
82 | ssh -nx phoenix nice -n 19 chmod a=r $fullname
|
---|
83 | ;;
|
---|
84 | *) echo " check2=$check2 -> ERROR - moving of run $runno failed" >> $scriptlog 2>&1
|
---|
85 | printprocesslog "ERROR $program failed, moving of run $runno failed"
|
---|
86 | check=$check2
|
---|
87 | com=$FCompmux
|
---|
88 | ;;
|
---|
89 | esac
|
---|
90 | printprocesslog "INFO $program finished successfully for run $runno"
|
---|
91 | ;;
|
---|
92 | *) echo " check1=$check1 -> ERROR - $program failed for run $runno" >> $scriptlog 2>&1
|
---|
93 | printprocesslog "ERROR $program failed for run $runno"
|
---|
94 | rm -v $tempfile >> $scriptlog 2>&1
|
---|
95 | check=$check1
|
---|
96 | com=$FCompmux
|
---|
97 | ;;
|
---|
98 | esac
|
---|
99 |
|
---|
100 | rm -v $lockpath/lock-$table-$column-$runno.txt >> $scriptlog 2>&1
|
---|
101 | setstatus "stop" >> $scriptlog 2>&1
|
---|
102 | echo "" >> $scriptlog 2>&1
|
---|
103 | done
|
---|
104 |
|
---|
105 | finish >> $scriptlog 2>&1
|
---|