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-2007
|
---|
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 | echo "This script has not been adapted to the new file structure (MAGIC II). "
|
---|
35 | echo "Please adapt it before using it."
|
---|
36 | exit
|
---|
37 |
|
---|
38 | program=compmux
|
---|
39 | column=fCompmux
|
---|
40 |
|
---|
41 | set -C
|
---|
42 |
|
---|
43 | scriptlog=/magic/datacenter/compmux/$program-$datetime.log
|
---|
44 | date >> $scriptlog 2>&1
|
---|
45 | todofile=$listpath/ToDo-$table-$column.txt
|
---|
46 |
|
---|
47 | if [ -e $todofile ]
|
---|
48 | then
|
---|
49 | echo "$program is already running -> exit" >> $scriptlog 2>&1
|
---|
50 | exit
|
---|
51 | fi
|
---|
52 |
|
---|
53 | #get todo list
|
---|
54 | getdolist >> $scriptlog 2>&1
|
---|
55 |
|
---|
56 | #retrieving runs from todo file
|
---|
57 | files=(`cat $listpath/ToDo-$table-$column.txt`)
|
---|
58 | if [ "$files" = "" ]
|
---|
59 | then
|
---|
60 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
61 | finish >> $scriptlog 2>&1
|
---|
62 | fi
|
---|
63 |
|
---|
64 | for file in ${files[@]}
|
---|
65 | do
|
---|
66 | echo -e "\ngetting path for run $file..." >> $scriptlog 2>&1
|
---|
67 | fullpath=`find $datapath/rawfiles/2007/0[2-9] -name *${file}_[DCPS]_*`
|
---|
68 |
|
---|
69 | lockfile=$lockpath/lock-$program-$file.txt
|
---|
70 |
|
---|
71 | #check lock file and stop for this run if already being processed
|
---|
72 | checklock continue >> $scriptlog 2>&1
|
---|
73 |
|
---|
74 | primvar=$file
|
---|
75 | setstatus "start" >> $scriptlog 2>&1
|
---|
76 |
|
---|
77 | cd $mars
|
---|
78 |
|
---|
79 | #cut the slices
|
---|
80 | gzip -cd $fullpath | $mars/datacenter/compmux | gzip -1c > /tmp/temp${file}.gz
|
---|
81 | check1=$?
|
---|
82 | touch -r $fullpath /tmp/temp${file}.gz
|
---|
83 |
|
---|
84 | #check success and insert information into the database
|
---|
85 | case $check1 in
|
---|
86 | 0) echo " check1=$check1 -> everything ok -> compmux succeeded, overwriting old file for run $file" >> $scriptlog 2>&1
|
---|
87 | mv -f /tmp/temp${file}.gz $fullpath >> $scriptlog 2>&1
|
---|
88 | check2=$?
|
---|
89 | chmod a=r $fullpath
|
---|
90 | case $check2 in
|
---|
91 | 0) echo " check2=$check2 -> everything ok -> mv done, setting db status for run $file" >> $scriptlog 2>&1
|
---|
92 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
93 | ;;
|
---|
94 | *) echo " check2=$check2 -> ERROR - moving of run $file failed -> continue" >> $scriptlog 2>&1
|
---|
95 | continue
|
---|
96 | ;;
|
---|
97 | esac
|
---|
98 | ;;
|
---|
99 | *) echo " check1=$check1 -> ERROR - $program failed for run $file" >> $scriptlog 2>&1
|
---|
100 | com=$FCompmux
|
---|
101 | check=$check1
|
---|
102 | ;;
|
---|
103 | esac
|
---|
104 |
|
---|
105 | setstatus "stop" >> $scriptlog 2>&1
|
---|
106 | done
|
---|