source: trunk/MagicSoft/Mars/datacenter/scripts/correcttime@ 7141

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