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 |
|
---|
29 | export ROOTSYS=/opt/root_v3.10.02
|
---|
30 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
---|
31 | export PATH=$PATH:$ROOTSYS/bin
|
---|
32 |
|
---|
33 | mars=/home/operator/Mars
|
---|
34 | macrospath=$mars/datacenter/macros
|
---|
35 |
|
---|
36 | table=RunProcessStatus
|
---|
37 | column=fTimingCorrection
|
---|
38 | date=NULL
|
---|
39 | datetime=`date +%F_%T`
|
---|
40 | year=`date +%Y`
|
---|
41 |
|
---|
42 | listdir=/magic/datacenter/lists
|
---|
43 | logpath=/magic/datacenter/autologs
|
---|
44 | getstatuslogpath=$logpath/getstatus/correct_raw_time/$year
|
---|
45 | getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
|
---|
46 |
|
---|
47 | if [ ! -d $getstatuslogpath ]
|
---|
48 | then
|
---|
49 | mkdir -pv $getstatuslogpath
|
---|
50 | if [ ! -d $getstatuslogpath ]
|
---|
51 | then
|
---|
52 | echo "could not make getstatuslogpath "$getstatuslogpath
|
---|
53 | exit
|
---|
54 | fi
|
---|
55 | fi
|
---|
56 |
|
---|
57 |
|
---|
58 | if [ -e $listdir/ToDo-$table-$column.txt ]
|
---|
59 | then
|
---|
60 | echo "correct_raw_time is already running -> exit"
|
---|
61 | exit
|
---|
62 | fi
|
---|
63 |
|
---|
64 | cd $mars
|
---|
65 |
|
---|
66 | echo "getting list..."
|
---|
67 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
68 |
|
---|
69 | case $check0 in
|
---|
70 | 1) echo "check0=$check0 -> everthing ok -> run correct_raw_time";;
|
---|
71 | *) echo "check0=$check0 -> ERROR -> step has to be repeated";;
|
---|
72 | esac
|
---|
73 |
|
---|
74 | runs=(`cat $listdir/ToDo-$table-$column.txt`)
|
---|
75 |
|
---|
76 | if [ "$runs" = "" ]
|
---|
77 | then
|
---|
78 | echo "nothing to do -> exit"
|
---|
79 | rm -v $listdir/ToDo-$table-$column.txt
|
---|
80 | exit
|
---|
81 | fi
|
---|
82 |
|
---|
83 | echo "runs: "${runs[@]}
|
---|
84 |
|
---|
85 | for run in ${runs[@]}
|
---|
86 | do
|
---|
87 | echo "getting path for run $run ... "
|
---|
88 | infile=`find /magic/data/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
|
---|
89 | echo "infile:"$infile
|
---|
90 | outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
|
---|
91 | echo "outfile:"$outfile
|
---|
92 | outpath=`dirname $outfile`
|
---|
93 | echo "outpath:"$outpath
|
---|
94 | if [ ! -d $outpath ]
|
---|
95 | then
|
---|
96 | mkdir -pv $outpath
|
---|
97 | if [ ! -d $outpath ]
|
---|
98 | then
|
---|
99 | echo "could not make outpath "$outpath
|
---|
100 | continue
|
---|
101 | fi
|
---|
102 | fi
|
---|
103 | timecorrpath=$outpath"/timecorrlogs"
|
---|
104 | echo "timecorrpath: "$timecorrpath
|
---|
105 | if [ ! -d $timecorrpath ]
|
---|
106 | then
|
---|
107 | mkdir -pv $timecorrpath
|
---|
108 | if [ ! -d $timecorrpath ]
|
---|
109 | then
|
---|
110 | echo "could not make timecorrpath "$timecorrpath
|
---|
111 | continue
|
---|
112 | fi
|
---|
113 | fi
|
---|
114 |
|
---|
115 | check1=0
|
---|
116 | echo "run correct_raw_time..."
|
---|
117 | /home/tape/MagicReadout/correct_raw_time $infile $outfile > $timecorrpath/correct_raw_time-$run.log
|
---|
118 | check1=$?
|
---|
119 |
|
---|
120 | case $check1 in
|
---|
121 | 1) echo "check1=$check1 -> everthing ok -> setting status..."
|
---|
122 | no=`printf %08d $run | cut -c 1-5`
|
---|
123 | setstatuspath=$logpath/setstatus/correct_raw_time/$no
|
---|
124 | echo "setstatuspath: "$setstatuspath
|
---|
125 | if [ ! -d $setstatuspath ]
|
---|
126 | then
|
---|
127 | mkdir -pv $setstatuspath
|
---|
128 | if [ ! -d $setstatuspath ]
|
---|
129 | then
|
---|
130 | echo "could not make setstatuspath $setstatuspath -> continue "
|
---|
131 | continue
|
---|
132 | fi
|
---|
133 | fi
|
---|
134 | check2=`root -q -b $macrospath/setstatus.C+\("\"$run\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuspath/setstatus-correct_raw_time-$run.log | grep int | sed -e 's/(int)//'`
|
---|
135 | case $check2 in
|
---|
136 | 0) echo "check2=0 -> ERROR -> step could not be set";;
|
---|
137 | 1) echo "check2=1 -> everthing ok, status has been set";;
|
---|
138 | esac
|
---|
139 | ;;
|
---|
140 | *) echo "check1=$check1 -> ERROR -> step has to be repeated";;
|
---|
141 | esac
|
---|
142 | done
|
---|
143 |
|
---|
144 | rm -v $listdir/ToDo-$table-$column.txt
|
---|
145 |
|
---|